WEB-840: Implement Unit Test Suite for AuthenticationInterceptor
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!
-
[X] If you have multiple commits please combine them into one commit by squashing them.
-
[X] Read and understood the contribution guidelines at
web-app/.github/CONTRIBUTING.md.
Summary by CodeRabbit
- Tests
- Added comprehensive unit tests for the authentication interceptor covering internal vs external request handling and tenant header logic.
- Verified authorization header behavior with OAuth on/off, token prefixing, and header cleanup.
- Included two-factor authentication token handling and end-to-end HTTP request checks to ensure consistent runtime behavior.
[!NOTE]
.coderabbit.yamlhas unrecognized propertiesCodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'⚙️ Configuration instructions
- Please see the configuration documentation for more information.
- You can also validate your configuration using the online YAML validator.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: fb131b16-7a77-427e-b1ca-b42b1eb8f2c1
📥 Commits
Reviewing files that changed from the base of the PR and between b2b0eb64bae34e4085fb13399235d32c4300a298 and a49a93f11ff3ce6d4bcc116c2c2e71e790658f80.
📒 Files selected for processing (1)
src/app/core/authentication/authentication.interceptor.spec.ts
Walkthrough
Adds a comprehensive unit test suite for AuthenticationInterceptor validating header injection/removal, tenant selection, OAuth authorization prefixing, two-factor token handling, and behavior differences between internal and external HTTP requests using HttpClientTestingModule and a mocked SettingsService.
Changes
| 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.
@IOhacker @shubhamkumar9199 Happy to make changes if any!
This pull request seems to be stale. Are you still planning to work on it? We will automatically close it in 30 days.