Skip to content

Commit f1314eb

Browse files
Gkrumbach07claude
andauthored
fix(backend): fix ExtractServiceAccountFromAuth unit test (#910)
## 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 - [x] Verified all 407 backend unit tests pass locally with `go test -v -tags=test ./handlers` - [x] Confirmed the previously failing test now passes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4c40817 commit f1314eb

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

components/backend/handlers/middleware_test.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,9 @@ var _ = Describe("Middleware Handlers", Label(test_constants.LabelUnit, test_con
270270
It("Should extract service account from token review", func() {
271271
context := httpUtils.CreateTestGinContext("GET", "/api/projects/test-project/sessions", nil)
272272

273-
_, _, err := httpUtils.SetValidTestToken(
274-
k8sUtils,
275-
"test-project",
276-
[]string{"get", "list"},
277-
"agenticsessions",
278-
"test-sa",
279-
"test-agenticsessions-read-role",
280-
)
281-
Expect(err).NotTo(HaveOccurred())
273+
// ExtractServiceAccountFromAuth reads the X-Remote-User header
274+
// (set by OpenShift OAuth proxy) to identify service accounts
275+
context.Request.Header.Set("X-Remote-User", "system:serviceaccount:test-project:test-sa")
282276

283277
namespace, serviceAccount, found := ExtractServiceAccountFromAuth(context)
284278
Expect(found).To(BeTrue(), "Should find service account from token")

0 commit comments

Comments
 (0)