(t *testing.T)
| 2514 | } |
| 2515 | |
| 2516 | func TestAIBridgeAllowBYOK(t *testing.T) { |
| 2517 | t.Parallel() |
| 2518 | |
| 2519 | cases := []struct { |
| 2520 | name string |
| 2521 | allowBYOK bool |
| 2522 | reqHeaders map[string]string |
| 2523 | expectedStatus int |
| 2524 | }{ |
| 2525 | { |
| 2526 | name: "byok_enabled/centralized_request", |
| 2527 | allowBYOK: true, |
| 2528 | reqHeaders: map[string]string{ |
| 2529 | "Authorization": "Bearer coder-token", |
| 2530 | }, |
| 2531 | expectedStatus: http.StatusOK, |
| 2532 | }, |
| 2533 | { |
| 2534 | name: "byok_enabled/byok_request", |
| 2535 | allowBYOK: true, |
| 2536 | reqHeaders: map[string]string{ |
| 2537 | agplaibridge.HeaderCoderToken: "coder-token", |
| 2538 | "Authorization": "Bearer user-llm-key", |
| 2539 | }, |
| 2540 | expectedStatus: http.StatusOK, |
| 2541 | }, |
| 2542 | { |
| 2543 | name: "byok_disabled/centralized_request", |
| 2544 | allowBYOK: false, |
| 2545 | reqHeaders: map[string]string{ |
| 2546 | "Authorization": "Bearer coder-token", |
| 2547 | }, |
| 2548 | expectedStatus: http.StatusOK, |
| 2549 | }, |
| 2550 | { |
| 2551 | name: "byok_disabled/byok_request", |
| 2552 | allowBYOK: false, |
| 2553 | reqHeaders: map[string]string{ |
| 2554 | agplaibridge.HeaderCoderToken: "coder-token", |
| 2555 | "Authorization": "Bearer user-llm-key", |
| 2556 | }, |
| 2557 | expectedStatus: http.StatusForbidden, |
| 2558 | }, |
| 2559 | } |
| 2560 | |
| 2561 | for _, tc := range cases { |
| 2562 | t.Run(tc.name, func(t *testing.T) { |
| 2563 | t.Parallel() |
| 2564 | |
| 2565 | dv := coderdtest.DeploymentValues(t) |
| 2566 | dv.AI.BridgeConfig.Enabled = serpent.Bool(true) |
| 2567 | dv.AI.BridgeConfig.AllowBYOK = serpent.Bool(tc.allowBYOK) |
| 2568 | |
| 2569 | client, closer, api, _ := coderdenttest.NewWithAPI(t, &coderdenttest.Options{ |
| 2570 | Options: &coderdtest.Options{ |
| 2571 | DeploymentValues: dv, |
| 2572 | }, |
| 2573 | LicenseOptions: &coderdenttest.LicenseOptions{ |
nothing calls this directly
no test coverage detected