MCPcopy Index your code
hub / github.com/coder/coder / TestAIBridgeAllowBYOK

Function TestAIBridgeAllowBYOK

enterprise/coderd/aibridge_test.go:2516–2609  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2514}
2515
2516func 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{

Callers

nothing calls this directly

Calls 15

DeploymentValuesFunction · 0.92
NewWithAPIFunction · 0.92
ContextFunction · 0.92
RunMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65
WriteHeaderMethod · 0.45
StringMethod · 0.45
SessionTokenMethod · 0.45

Tested by

no test coverage detected