(t *testing.T)
| 199 | } |
| 200 | |
| 201 | func TestOpenAI_CreateInterceptor(t *testing.T) { |
| 202 | t.Parallel() |
| 203 | |
| 204 | tests := []struct { |
| 205 | name string |
| 206 | route string |
| 207 | requestBody string |
| 208 | responseBody string |
| 209 | setHeaders map[string]string |
| 210 | wantAuthorization string |
| 211 | wantCredentialKind intercept.CredentialKind |
| 212 | wantCredentialHint string |
| 213 | }{ |
| 214 | { |
| 215 | name: "ChatCompletions_BYOK", |
| 216 | route: routeChatCompletions, |
| 217 | requestBody: `{"model": "gpt-4", "messages": [{"role": "user", "content": "hello"}], "stream": false}`, |
| 218 | responseBody: chatCompletionResponse, |
| 219 | setHeaders: map[string]string{"Authorization": "Bearer user-token"}, |
| 220 | wantAuthorization: "Bearer user-token", |
| 221 | wantCredentialKind: intercept.CredentialKindBYOK, |
| 222 | wantCredentialHint: "us...en", |
| 223 | }, |
| 224 | { |
| 225 | name: "ChatCompletions_Centralized", |
| 226 | route: routeChatCompletions, |
| 227 | requestBody: `{"model": "gpt-4", "messages": [{"role": "user", "content": "hello"}], "stream": false}`, |
| 228 | responseBody: chatCompletionResponse, |
| 229 | setHeaders: map[string]string{}, |
| 230 | wantAuthorization: "Bearer centralized-key", |
| 231 | wantCredentialKind: intercept.CredentialKindCentralized, |
| 232 | // Centralized hint is empty at CreateInterceptor; set |
| 233 | // by the key failover loop during ProcessRequest. |
| 234 | wantCredentialHint: "", |
| 235 | }, |
| 236 | { |
| 237 | name: "Responses_BYOK", |
| 238 | route: routeResponses, |
| 239 | requestBody: `{"model": "gpt-5", "input": "hello", "stream": false}`, |
| 240 | responseBody: responsesAPIResponse, |
| 241 | setHeaders: map[string]string{"Authorization": "Bearer user-token"}, |
| 242 | wantAuthorization: "Bearer user-token", |
| 243 | wantCredentialKind: intercept.CredentialKindBYOK, |
| 244 | wantCredentialHint: "us...en", |
| 245 | }, |
| 246 | { |
| 247 | name: "Responses_Centralized", |
| 248 | route: routeResponses, |
| 249 | requestBody: `{"model": "gpt-5", "input": "hello", "stream": false}`, |
| 250 | responseBody: responsesAPIResponse, |
| 251 | setHeaders: map[string]string{}, |
| 252 | wantAuthorization: "Bearer centralized-key", |
| 253 | wantCredentialKind: intercept.CredentialKindCentralized, |
| 254 | // Centralized hint is empty at CreateInterceptor; set |
| 255 | // by the key failover loop during ProcessRequest. |
| 256 | wantCredentialHint: "", |
| 257 | }, |
| 258 | // X-Api-Key should not appear in production since clients use Authorization, |
nothing calls this directly
no test coverage detected