MCPcopy Create free account
hub / github.com/diillson/chatcli / TestTokenAuthInterceptor_MissingAuthHeader

Function TestTokenAuthInterceptor_MissingAuthHeader

server/auth_test.go:50–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestTokenAuthInterceptor_MissingAuthHeader(t *testing.T) {
51 logger := zap.NewNop()
52 auth := NewTokenAuthInterceptor("secret123", logger)
53
54 md := metadata.New(map[string]string{"other-key": "value"})
55 ctx := metadata.NewIncomingContext(context.Background(), md)
56 _, err := auth.authorize(ctx, "/chatcli.v1.ChatCLIService/SendPrompt")
57
58 assert.Error(t, err)
59 s, ok := status.FromError(err)
60 assert.True(t, ok)
61 assert.Equal(t, codes.Unauthenticated, s.Code())
62}
63
64func TestTokenAuthInterceptor_InvalidFormat(t *testing.T) {
65 logger := zap.NewNop()

Callers

nothing calls this directly

Calls 4

authorizeMethod · 0.95
NewTokenAuthInterceptorFunction · 0.85
EqualMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected