-
Notifications
You must be signed in to change notification settings - Fork 11
Add test coverage for the api-keys lifecycle and prefix deletion #83
Copy link
Copy link
Labels
GRANTFOX OSSGrantFox open-source campaign taskGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueOfficial GrantFox campaign issuearea:api-keysapi keysapi keyspriority:mediumMedium priorityMedium prioritystack:expressstack:expressstack:expressstack:nodejsNode.jsNode.jsstack:typescriptTypeScriptTypeScripttype:testTest coverage workTest coverage work
Description
Metadata
Metadata
Assignees
Labels
GRANTFOX OSSGrantFox open-source campaign taskGrantFox open-source campaign taskMAYBE REWARDEDMay be rewarded under the GrantFox campaignMay be rewarded under the GrantFox campaignOFFICIAL CAMPAIGNOfficial GrantFox campaign issueOfficial GrantFox campaign issuearea:api-keysapi keysapi keyspriority:mediumMedium priorityMedium prioritystack:expressstack:expressstack:expressstack:nodejsNode.jsNode.jsstack:typescriptTypeScriptTypeScripttype:testTest coverage workTest coverage work
Type
Fields
Give feedbackNo fields configured for Feature.
Test the API-key create, list, and delete lifecycle
Description
The api-key endpoints in
src/index.ts—POST /api/v1/api-keys,GET /api/v1/api-keys, andDELETE /api/v1/api-keys/:prefix— have no tests. Thesrk_key format, the 1–64 charlabelvalidation, the list projection that returns only the 8-charprefix(never the raw key), and the prefix-match deletion (including the 404 path) are all uncovered. This issue adds end-to-end lifecycle coverage.Requirements and context
POSTreturns201with akeystartingsrk_and the echoedlabel.POSTrejects an empty label and a label over 64 chars with400 invalid_requestandrequestId.GETreturns items containingprefix,label,createdAtand never the fullkey.DELETE /api/v1/api-keys/:prefixremoves the key (204) using the 8-char prefix, and that an unknown prefix returns404 not_found.Suggested execution
git checkout -b test/api-keys-35-lifecyclesrc/__tests__/apiKeys.test.ts.Test and commit
npm run build,npm run lint, andnpm test.npm testoutput and a coverage summary in the PR.Example commit message
test(api-keys): cover create/list/delete lifecycle and prefix matchGuidelines
Community & contribution rewards