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

Function TestGCPProviderCustomAudience

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

Source from the content-addressed store, hash-verified

188}
189
190func TestGCPProviderCustomAudience(t *testing.T) {
191 mockClient := &http.Client{
192 Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
193 if !strings.Contains(req.URL.RawQuery, "audience=https%3A%2F%2Fcustom.openai.com") {
194 t.Fatalf("Expected custom audience in URL, got %q", req.URL.RawQuery)
195 }
196 return &http.Response{
197 StatusCode: http.StatusOK,
198 Body: io.NopCloser(strings.NewReader("gcp-custom-token-jwt")),
199 Header: make(http.Header),
200 }, nil
201 }),
202 }
203
204 provider := auth.GCPIDTokenProvider(&auth.GCPIDTokenProviderConfig{
205 Audience: "https://custom.openai.com",
206 })
207 token, err := provider.GetToken(context.Background(), mockClient)
208 if err != nil {
209 t.Fatalf("GetToken() error = %v", err)
210 }
211 if token != "gcp-custom-token-jwt" {
212 t.Errorf("GetToken() = %q, want %q", token, "gcp-custom-token-jwt")
213 }
214}
215
216func TestAzureProviderNilConfigBackwardCompatibility(t *testing.T) {
217 mockClient := &http.Client{

Callers

nothing calls this directly

Calls 4

GCPIDTokenProviderFunction · 0.92
ContainsMethod · 0.80
roundTripFuncFuncType · 0.70
GetTokenMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…