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

Function TestResolveAuthProvider_StoreAPIKey

auth/resolver_test.go:89–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

87}
88
89func TestResolveAuthProvider_StoreAPIKey(t *testing.T) {
90 withTempStore(t)
91 cred := &AuthProfileCredential{
92 CredType: CredentialAPIKey,
93 Provider: ProviderOpenAI,
94 Key: "sk-test",
95 Email: "u@example.com",
96 }
97 if err := UpsertProfile("openai:test", cred, zap.NewNop()); err != nil {
98 t.Fatalf("UpsertProfile: %v", err)
99 }
100
101 tp, err := ResolveAuthProvider(context.Background(), ProviderOpenAI, zap.NewNop())
102 if err != nil {
103 t.Fatalf("ResolveAuthProvider: %v", err)
104 }
105 defer tp.Close()
106 if tp.Mode() != AuthModeAPIKey {
107 t.Errorf("mode = %q, want api-key", tp.Mode())
108 }
109 if tp.Email() != "u@example.com" {
110 t.Errorf("email = %q, want u@example.com", tp.Email())
111 }
112 tok, _ := tp.Token(context.Background())
113 if tok != "sk-test" {
114 t.Errorf("token = %q, want sk-test", tok)
115 }
116}
117
118func TestResolveAuthProvider_StoreToken(t *testing.T) {
119 withTempStore(t)

Callers

nothing calls this directly

Calls 8

withTempStoreFunction · 0.85
UpsertProfileFunction · 0.85
ResolveAuthProviderFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.65
ModeMethod · 0.65
EmailMethod · 0.65
TokenMethod · 0.65

Tested by

no test coverage detected