Skip to content

fix(backend): fix ExtractServiceAccountFromAuth unit test#910

Merged
Gkrumbach07 merged 1 commit intomainfrom
bug/backend-unit-tests
Mar 13, 2026
Merged

fix(backend): fix ExtractServiceAccountFromAuth unit test#910
Gkrumbach07 merged 1 commit intomainfrom
bug/backend-unit-tests

Conversation

@Gkrumbach07
Copy link
Contributor

Summary

  • The ExtractServiceAccountFromAuth test was failing because it set an Authorization header via SetValidTestToken, but the function reads the X-Remote-User header (OpenShift OAuth proxy format system:serviceaccount:<ns>:<name>)
  • Fixed by setting the correct X-Remote-User header directly instead of using SetValidTestToken

Test plan

  • Verified all 407 backend unit tests pass locally with go test -v -tags=test ./handlers
  • Confirmed the previously failing test now passes

🤖 Generated with Claude Code

The test was setting an Authorization header via SetValidTestToken, but
ExtractServiceAccountFromAuth reads the X-Remote-User header (OpenShift
OAuth proxy format). Set the correct header so the test exercises the
actual code path.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 042bf37a-cd51-4db1-9939-aad6e410e71c

📥 Commits

Reviewing files that changed from the base of the PR and between dd0bc67 and 181dd03.

📒 Files selected for processing (1)
  • components/backend/handlers/middleware_test.go

Walkthrough

Test setup modification in ExtractServiceAccountFromAuth tests where token-based authentication setup is replaced with direct X-Remote-User header configuration to simulate service accounts. Other test cases for non-service accounts and malformed headers are preserved with existing error handling expectations.

Changes

Cohort / File(s) Summary
Test Setup Refactoring
components/backend/handlers/middleware_test.go
Simplified service account test initialization by replacing token review with direct X-Remote-User header assignment; preserves validation logic for non-service accounts and malformed inputs.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: fixing a failing unit test for ExtractServiceAccountFromAuth by correcting the header setup.
Description check ✅ Passed The description clearly explains why the test was failing and how it was fixed, providing relevant context about the header mismatch and verification steps.
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 docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/backend-unit-tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

@Gkrumbach07 Gkrumbach07 merged commit f1314eb into main Mar 13, 2026
33 checks passed
@Gkrumbach07 Gkrumbach07 deleted the bug/backend-unit-tests branch March 13, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant