MCPcopy
hub / github.com/openai/openai-go / TestK8sProviderFileReading

Function TestK8sProviderFileReading

auth/subjecttokenprovider_test.go:14–42  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestK8sProviderFileReading(t *testing.T) {
15 tmpFile, err := os.CreateTemp("", "k8s-token-*")
16 if err != nil {
17 t.Fatalf("Failed to create temp file: %v", err)
18 }
19 defer os.Remove(tmpFile.Name())
20
21 tokenContent := " test-jwt-token-123 \n"
22 if _, err := tmpFile.WriteString(tokenContent); err != nil {
23 t.Fatalf("Failed to write to temp file: %v", err)
24 }
25 tmpFile.Close()
26
27 provider := auth.K8sServiceAccountTokenProvider(tmpFile.Name())
28
29 token, err := provider.GetToken(context.Background(), nil)
30 if err != nil {
31 t.Fatalf("GetToken() error = %v", err)
32 }
33
34 expectedToken := "test-jwt-token-123"
35 if token != expectedToken {
36 t.Errorf("GetToken() = %q, want %q", token, expectedToken)
37 }
38
39 if provider.TokenType() != auth.SubjectTokenTypeJWT {
40 t.Errorf("TokenType() = %v, want %v", provider.TokenType(), auth.SubjectTokenTypeJWT)
41 }
42}
43
44func TestK8sProviderDefaultPath(t *testing.T) {
45 provider := auth.K8sServiceAccountTokenProvider("")

Callers

nothing calls this directly

Calls 4

CloseMethod · 0.65
GetTokenMethod · 0.65
TokenTypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…