B5: gh-compat /subscription endpoints over WatchLevel#318
Merged
Conversation
aaf751d to
8d8833f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Note: Rebased onto trunk after #PR landing watching.go shipped
/subscriptionendpoints with the server-native{level, explicit}shape. This PR retrofits the same endpoints to use the gh-compat{subscribed, ignored}body + response, per the B5 audit decision.Replaces the
{level, explicit}request/response shape onGET/PUT /api/v1/repos/{owner}/{repo}/subscriptionwith the gh-compat pair soshithub api -X PUT .../subscription -F subscribed=trueand other gh-style clients work without translation.subscriberslist endpoint unchanged.Mapping (handler-side translation onto WatchLevel):
subscribed=true, ignored=false→ SetWatch(all)subscribed=false, ignored=true→ SetWatch(ignore)participating)Scopes unchanged: GET =
repo:read, PUT/DELETE =user:write.Test plan
Tests updated to match the new shape:
TestWatching_GetNoExplicitReturns404TestWatching_PutSubscribedThenGetReflectsStateTestWatching_PutIgnoredFlipsLevelTestWatching_PutBothTrueIs422TestWatching_PutBothFalseClearsTestWatching_DeleteIsIdempotentTestWatching_SubscribersList— gh-compat PUT writes a row visible in subscribers listTestWatching_IgnoreExcludedFromSubscribers— ignore-level filter still appliesTestWatching_PutRequiresUserWriteScope— 403 on repo-read-only tokenTestWatching_GetRequiresRepoRead— 403 on user-read-only tokengolangci-lint run— 0 issuesshithub api -X PUT /repos/.../subscription -F subscribed=trueagainstshithub.shreturns 200 + gh shapeCloses audit finding B5.