test(oauth): add unit tests for storage backends and auth middleware#19
Merged
test(oauth): add unit tests for storage backends and auth middleware#19
Conversation
Add comprehensive unit tests to improve OAuth code coverage: - MemoryStorageBackend: 70 tests covering session CRUD, device flows, auth codes, cleanup, and export/import functionality (30% -> 99%) - FileStorageBackend: 43 tests covering persistence, atomic writes, recovery scenarios, and file operations (4% -> 97%) - OAuth auth middleware: 21 tests covering token validation, refresh, error handling, and optional auth mode (11% -> 100%) Total: 134 new tests added (1178 -> 1312 tests passing)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit tests to improve code coverage for OAuth functionality, specifically targeting storage backends and authentication middleware. The tests achieve near-complete coverage (97-100%) for the targeted components.
Changes:
- Added 70 unit tests for MemoryStorageBackend covering CRUD operations, cleanup, and data export/import
- Added 43 unit tests for FileStorageBackend covering persistence, atomic writes, and recovery scenarios
- Added 21 unit tests for OAuth authentication middleware covering token validation, refresh, and error handling
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/unit/oauth/storage/memory.test.ts | Comprehensive tests for in-memory storage backend including session management, device flows, auth codes, cleanup operations, and import/export functionality |
| tests/unit/oauth/storage/file.test.ts | Tests for file-based storage backend including persistence verification, atomic writes, corruption handling, and various edge cases |
| tests/unit/middleware/oauth-auth.test.ts | Tests for OAuth authentication middleware covering token validation, session management, GitLab token refresh, and both required and optional authentication flows |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
polaz
added a commit
that referenced
this pull request
Jan 19, 2026
README FIXES: - Clarify migration guide heading: "v5.0" → "v5.x → v6.0" - Update summary heading: "Consolidated Tools in v5.0" → "CQRS Tools Introduced in v6.0" - Fix Core/Projects count: "8 tools → CQRS" → "13 tools → 5 CQRS tools" TEST IMPROVEMENTS (coverage 90.35% → 92.1%): - Add test for create draft note with in_reply_to_discussion_id - Add test for update MR with array parameters (assignee_ids, reviewer_ids) - Statements: 92.1%, Branches: 86.84%, Functions: 100%, Lines: 99.01% Note: Copilot review incorrectly flagged Files/Core CQRS tools as non-existent, but they DO exist from previous PRs (#12, #19, #20).
sw-release-bot bot
pushed a commit
that referenced
this pull request
Jan 19, 2026
## [6.1.0](v6.0.0...v6.1.0) (2026-01-19) ### ⚠ BREAKING CHANGES * **mrs:** Individual MR tools replaced with action-based CQRS tools ### Features * **mrs:** consolidate 20 MR tools into 5 CQRS tools ([#15](#15)) ([ec06fae](ec06fae)) ### Bug Fixes * **mrs:** address PR [#23](#23) review comments and increase coverage ([0e6410b](0e6410b)), closes [#12](#12) [#19](#19) [#20](#20) * **mrs:** address PR review comments from Copilot ([#23](#23)) ([1905ac4](1905ac4))
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
Coverage Improvements
src/oauth/storage/memory.tssrc/oauth/storage/file.tssrc/middleware/oauth-auth.tsTests Added
Test plan
Related to #12