(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func 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 | |
| 190 | func TestGCPProviderCustomAudience(t *testing.T) { |
| 191 | mockClient := &http.Client{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…