(t *testing.T)
| 405 | } |
| 406 | |
| 407 | func TestServeHTTP_StripCoderToken(t *testing.T) { |
| 408 | t.Parallel() |
| 409 | |
| 410 | cases := []struct { |
| 411 | name string |
| 412 | reqHeaders map[string]string |
| 413 | expectPresent map[string]string // header → expected value |
| 414 | expectAbsent []string // headers that must be gone |
| 415 | }{ |
| 416 | { |
| 417 | // Centralized: the client sets Authorization and X-Api-Key, |
| 418 | // but does not include HeaderCoderToken. |
| 419 | // All auth headers are stripped. |
| 420 | name: "centralized", |
| 421 | reqHeaders: map[string]string{ |
| 422 | "Authorization": "Bearer coder-token", |
| 423 | "X-Api-Key": "sk-ant-api03-user-key", |
| 424 | }, |
| 425 | expectAbsent: []string{ |
| 426 | "Authorization", |
| 427 | "X-Api-Key", |
| 428 | agplaibridge.HeaderCoderToken, |
| 429 | }, |
| 430 | }, |
| 431 | { |
| 432 | // BYOK with access token: Coder token in BYOK header, |
| 433 | // user's access token in Authorization. Only the |
| 434 | // BYOK header is stripped. |
| 435 | name: "byok bearer token", |
| 436 | reqHeaders: map[string]string{ |
| 437 | agplaibridge.HeaderCoderToken: "coder-token", |
| 438 | "Authorization": "Bearer sk-ant-oat01-user-oauth-token", |
| 439 | }, |
| 440 | expectPresent: map[string]string{ |
| 441 | "Authorization": "Bearer sk-ant-oat01-user-oauth-token", |
| 442 | }, |
| 443 | expectAbsent: []string{ |
| 444 | agplaibridge.HeaderCoderToken, |
| 445 | }, |
| 446 | }, |
| 447 | { |
| 448 | // BYOK with personal API key: Coder token in BYOK header, |
| 449 | // user's API key in X-Api-Key. Only the BYOK header is |
| 450 | // stripped. |
| 451 | name: "byok api key", |
| 452 | reqHeaders: map[string]string{ |
| 453 | agplaibridge.HeaderCoderToken: "coder-token", |
| 454 | "X-Api-Key": "sk-ant-api03-user-key", |
| 455 | }, |
| 456 | expectPresent: map[string]string{ |
| 457 | "X-Api-Key": "sk-ant-api03-user-key", |
| 458 | }, |
| 459 | expectAbsent: []string{ |
| 460 | agplaibridge.HeaderCoderToken, |
| 461 | }, |
| 462 | }, |
| 463 | } |
| 464 |
nothing calls this directly
no test coverage detected