feat(backend): implement comprehensive test suite for auth service#542
Open
Robinsonchiziterem wants to merge 1 commit into
Open
feat(backend): implement comprehensive test suite for auth service#542Robinsonchiziterem wants to merge 1 commit into
Robinsonchiziterem wants to merge 1 commit into
Conversation
|
@Robinsonchiziterem is attempting to deploy a commit to the Ayomide Adeniran's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Robinsonchiziterem Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
name: Pull Request
about: Submit changes to Soroban Playground
title: 'feat(backend): implement comprehensive test suite for auth service'
labels: 'backend, testing'
assignees: ''
What does this PR do?
This PR implements a comprehensive Jest unit and integration test suite for the
ApiKeyService(Auth Service) located atbackend/tests/authService.test.js.The test suite covers 16 detailed test cases representing all public API methods, edge cases, and time-sensitive triggers:
generateKey: Verifies generation of secure key prefixes/hashes, access tiers, and audit log generation.validateKey: Validates active keys, usage count increments, last-used updates, automatic revocation of expired keys, and invalid formats.getKeyById: Tests key details retrieval and associated tier limits.listKeys: Tests descending created-at ordering, pagination limits, status filtering, and offset offsets.revokeKey: Confirms status updates, updated_at modifications, and revocation auditing.trackUsage: Validates request tracking, conflict-handling on identical window boundaries, and request count incrementation.logAudit: Verifies structured logs are stored correctly in theaudit_logtable.getUsageStats: Validates daily aggregated request stats, endpoint distribution, and rate-limit violations.To prevent write operations on developer local sqlite databases, the connection service is mocked using Jest ESM module hooks. The in-memory database (
:memory:) is populated with the repository's production schema fromschema.sqlon test setup, providing a completely isolated testing environment.Related Issue
Closes #474
Type of Change
🗂️ Affected Area(s)
How Has This Been Tested?
The test suite was verified locally inside the environment:
npm testequivalents) to verify no regressions were introduced. Since our changes are entirely confined to a brand new filebackend/tests/authService.test.js, existing modules are untouched.npm test)Screenshots / Demo (if applicable)
Not applicable (Backend/Infrastructure changes only).
Checklist
Related Issues or References
None.
Additional Context
trackUsage()conflicts on overlapping SQLite windows without dependency on machine speed,global.Datewas temporarily stubbed to freeze time boundaries during consecutive increments.idx_rate_limit_usage_unique_test) onrate_limit_usageduring test database setups to guaranteeON CONFLICTtrigger compliance across SQLite testing.Closes #474