(t *testing.T)
| 91 | } |
| 92 | |
| 93 | func TestTokenAuthInterceptor_ValidToken(t *testing.T) { |
| 94 | logger := zap.NewNop() |
| 95 | auth := NewTokenAuthInterceptor("secret123", logger) |
| 96 | |
| 97 | md := metadata.New(map[string]string{"authorization": "Bearer secret123"}) |
| 98 | ctx := metadata.NewIncomingContext(context.Background(), md) |
| 99 | newCtx, err := auth.authorize(ctx, "/chatcli.v1.ChatCLIService/SendPrompt") |
| 100 | |
| 101 | assert.NoError(t, err) |
| 102 | // Legacy token gets admin role |
| 103 | user := UserFromContext(newCtx) |
| 104 | assert.NotNil(t, user) |
| 105 | assert.Equal(t, RoleAdmin, user.Role) |
| 106 | } |
| 107 | |
| 108 | func TestTokenAuthInterceptor_ConstantTimeComparison(t *testing.T) { |
| 109 | logger := zap.NewNop() |
nothing calls this directly
no test coverage detected