Add DELETE /users/$USER/tokens #7787
Open
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.
Description
Adds an API v1 endpoint, DELETE /users/$USER/tokens which allows users to delete tokens by SHA1.
I am deliberately requiring SHA1, so that only those holding said secret are capable of deleting them via the API.
Link to the issue: #7788
Checklist
Test plan
I would love to add automated tests to this, however I didn't see any for the other API calls, and I am unfamiliar with go's testing ecosystem (and go in general). Any hints here would be most appreciated if I am missing something.
Dev setup
Requires that a PR to go-gogs-client merges first, as it is reliant on an input type defined there (as appears customary).
Currently you can test that it works by cloning my branch of go-gogs-client, or picking the following commit:
https://github.com/teodesian/go-gogs-client/
commit/4488fbb10902b695e7df8c76fa5d6edf5394e0eb
and running:
and finally going back in to this repo to do:
Companion PRs:
gogs/go-gogs-client#126
gogs/docs-api#39