Skip to content

Commit 899bf17

Browse files
Update middleware/token_test.go
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent cb9d620 commit 899bf17

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

middleware/token_test.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,9 @@ func TestStoreWebToken_WithFakeBearerToken(t *testing.T) {
1515
authHeader := "Bearer " + token
1616

1717
nextHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
18-
// Token parsing may fail due to signature validation, which is expected in tests
19-
// The middleware should handle this gracefully
2018
_, err := context.GetWebTokenFromContext(r.Context())
21-
// In a real scenario with proper JWT validation, this might fail
22-
// For test purposes, we just verify the middleware doesn't crash
23-
if err != nil {
24-
// This is expected behavior when token validation fails
25-
assert.Error(t, err)
26-
}
19+
// Presence of a Bearer header must result in a stored token.
20+
assert.NoError(t, err)
2721

2822
w.WriteHeader(http.StatusOK)
2923
})

0 commit comments

Comments
 (0)