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

Function TestAzureProviderCustomResource

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

Source from the content-addressed store, hash-verified

162}
163
164func TestAzureProviderCustomResource(t *testing.T) {
165 mockClient := &http.Client{
166 Transport: roundTripFunc(func(req *http.Request) (*http.Response, error) {
167 if !strings.Contains(req.URL.RawQuery, "resource=https%3A%2F%2Fcustom.openai.com") {
168 t.Fatalf("Expected custom resource in URL, got %q", req.URL.RawQuery)
169 }
170 return &http.Response{
171 StatusCode: http.StatusOK,
172 Body: io.NopCloser(strings.NewReader(`{"access_token":"azure-custom-token"}`)),
173 Header: make(http.Header),
174 }, nil
175 }),
176 }
177
178 provider := auth.AzureManagedIdentityTokenProvider(&auth.AzureManagedIdentityTokenProviderConfig{
179 Resource: "https://custom.openai.com",
180 })
181 token, err := provider.GetToken(context.Background(), mockClient)
182 if err != nil {
183 t.Fatalf("GetToken() error = %v", err)
184 }
185 if token != "azure-custom-token" {
186 t.Errorf("GetToken() = %q, want %q", token, "azure-custom-token")
187 }
188}
189
190func TestGCPProviderCustomAudience(t *testing.T) {
191 mockClient := &http.Client{

Callers

nothing calls this directly

Calls 4

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…