diff --git a/pkg/agent/server_ai_tokens.go b/pkg/agent/server_ai_tokens.go index 403f62b4b5..f5628cb998 100644 --- a/pkg/agent/server_ai_tokens.go +++ b/pkg/agent/server_ai_tokens.go @@ -24,7 +24,10 @@ func (s *Server) getClaudeInfo() *protocol.ClaudeInfo { providerNames = append(providerNames, p.DisplayName) } - sessionIn, sessionOut, todayIn, todayOut := s.tokens.GetUsage() + var sessionIn, sessionOut, todayIn, todayOut int + if s.tokens != nil { + sessionIn, sessionOut, todayIn, todayOut = s.tokens.GetUsage() + } return &protocol.ClaudeInfo{ Installed: true, diff --git a/pkg/api/handlers/mcp/drasi_proxy_test.go b/pkg/api/handlers/mcp/drasi_proxy_test.go index 5cf00f7c2a..8df2a35815 100644 --- a/pkg/api/handlers/mcp/drasi_proxy_test.go +++ b/pkg/api/handlers/mcp/drasi_proxy_test.go @@ -43,6 +43,12 @@ func TestProxyDrasi_Server(t *testing.T) { }) defer func() { drasiProxyClient.Transport = oldTransport }() + // Auth middleware to inject test user ID for RBAC checks + env.App.Use(func(c *fiber.Ctx) error { + c.Locals("userID", testAdminUserID) + return c.Next() + }) + env.App.All("/api/drasi/proxy/*", h.ProxyDrasi) req := httptest.NewRequest("GET", "/api/drasi/proxy/api/v1/sources?target=server&url=http://drasi-server&foo=bar", nil) diff --git a/pkg/api/handlers/stellar/auth_test.go b/pkg/api/handlers/stellar/auth_test.go index f557329bca..8f6df1f39d 100644 --- a/pkg/api/handlers/stellar/auth_test.go +++ b/pkg/api/handlers/stellar/auth_test.go @@ -21,7 +21,7 @@ func TestRequireUser(t *testing.T) { }{ { name: "valid user ID", - userID: "user-123", + userID: "00000000-0000-0000-0000-000000000001", wantError: false, }, { @@ -39,7 +39,11 @@ func TestRequireUser(t *testing.T) { app := fiber.New() app.Get("/test", func(c *fiber.Ctx) error { if tt.userID != "" { - c.Locals("stellarUserID", tt.userID) + // resolveStellarUserID checks middleware.GetUserID which reads from "userID" Locals + parsedID, err := uuid.Parse(tt.userID) + if err == nil { + c.Locals("userID", parsedID) + } } userID, err := handler.requireUser(c) if tt.wantError {