WEB-840: Implement Unit Test Suite for AuthenticationInterceptor#3362
WEB-840: Implement Unit Test Suite for AuthenticationInterceptor#3362DeathGun44 wants to merge 1 commit intoopenMF:devfrom
Conversation
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
AuthenticationInterceptor Test Suite src/app/core/authentication/authentication.interceptor.spec.ts |
New unit tests exercising interceptor behavior: internal vs external URL handling, tenant header injection and custom tenant selection, authorization header propagation and OAuth prefix logic, Fineract-Platform-TFA-Token set/remove, and helper removal methods; uses TestBed, HttpClientTestingController, and mocked SettingsService. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'WEB-840: Implement Unit Test Suite for AuthenticationInterceptor' is clear, concise, and directly summarizes the main change - adding a comprehensive unit test suite for the AuthenticationInterceptor class. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
📝 Coding Plan
- Generate coding plan for human review comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Tip
CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.
Add a .trivyignore file to your project to customize which findings Trivy reports.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/app/core/authentication/authentication.interceptor.spec.ts (1)
71-79: External URL test covers only https:// protocol.The test verifies that
https://URLs bypass Fineract headers, but the interceptor implementation (per context snippet 1) also checks forhttp://URLs. Consider adding a test case forhttp://external URLs for complete coverage of the bypass logic.💡 Optional: Add http:// external URL test
it('should pass http external URLs through without Fineract headers', async () => { const resultPromise = firstValueFrom(http.get('http://api.external.com/data')); const req = httpMock.expectOne((r) => r.url === 'http://api.external.com/data' && r.method === 'GET'); expect(req.request.headers.has('Fineract-Platform-TenantId')).toBe(false); req.flush({}); await resultPromise; });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/app/core/authentication/authentication.interceptor.spec.ts` around lines 71 - 79, Add a parallel test to the existing external URL spec to cover the http protocol: create an it block similar to the https test that uses firstValueFrom(http.get('http://api.external.com/data')), assert httpMock.expectOne matches url 'http://api.external.com/data' and method 'GET', verify the request.headers does not have 'Fineract-Platform-TenantId', flush an empty response and await the promise; reference the same helpers used in the file (firstValueFrom, http, httpMock) to mirror the https test's structure.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/app/core/authentication/authentication.interceptor.spec.ts`:
- Around line 71-79: Add a parallel test to the existing external URL spec to
cover the http protocol: create an it block similar to the https test that uses
firstValueFrom(http.get('http://api.external.com/data')), assert
httpMock.expectOne matches url 'http://api.external.com/data' and method 'GET',
verify the request.headers does not have 'Fineract-Platform-TenantId', flush an
empty response and await the promise; reference the same helpers used in the
file (firstValueFrom, http, httpMock) to mirror the https test's structure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 112b8a8d-0928-4567-b62c-8b1f42173342
📒 Files selected for processing (1)
src/app/core/authentication/authentication.interceptor.spec.ts
IOhacker
left a comment
There was a problem hiding this comment.
@shubhamkumar9199 please take a look
|
@IOhacker @shubhamkumar9199 Happy to make changes if any! |
b2b0eb6 to
a49a93f
Compare
Description
Adds the interceptor unit test suite for the codebase. Covers all 6 public methods of [AuthenticationInterceptor] with 10 test cases across 4 describe blocks - tenant header injection, Basic/Bearer auth token switching, two-factor authentication headers, and header cleanup methods.
Related issues and discussion
#WEB-840
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
If you have multiple commits please combine them into one commit by squashing them.
Read and understood the contribution guidelines at
web-app/.github/CONTRIBUTING.md.Summary by CodeRabbit