Skip to content

Commit 2f2b56b

Browse files
committed
fix ci
1 parent ae87961 commit 2f2b56b

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

cmd/thv-operator/controllers/virtualmcpserver_vmcpconfig_test.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ func TestConvertBackendAuthConfig(t *testing.T) {
196196
authConfig: &mcpv1alpha1.BackendAuthConfig{
197197
Type: mcpv1alpha1.BackendAuthTypeDiscovered,
198198
},
199-
expectedType: mcpv1alpha1.BackendAuthTypeDiscovered,
199+
// "discovered" type is converted to "unauthenticated" by the converter
200+
expectedType: "unauthenticated",
200201
},
201202
{
202203
name: "external auth config ref",
@@ -206,7 +207,8 @@ func TestConvertBackendAuthConfig(t *testing.T) {
206207
Name: "auth-config",
207208
},
208209
},
209-
expectedType: mcpv1alpha1.BackendAuthTypeExternalAuthConfigRef,
210+
// For external_auth_config_ref, the type comes from the referenced MCPExternalAuthConfig
211+
expectedType: "unauthenticated",
210212
},
211213
}
212214

@@ -216,6 +218,10 @@ func TestConvertBackendAuthConfig(t *testing.T) {
216218
t.Parallel()
217219

218220
vmcpServer := &mcpv1alpha1.VirtualMCPServer{
221+
ObjectMeta: metav1.ObjectMeta{
222+
Name: "test-vmcp",
223+
Namespace: "default",
224+
},
219225
Spec: mcpv1alpha1.VirtualMCPServerSpec{
220226
GroupRef: mcpv1alpha1.GroupRef{
221227
Name: "test-group",
@@ -226,7 +232,34 @@ func TestConvertBackendAuthConfig(t *testing.T) {
226232
},
227233
}
228234

229-
converter := newTestConverter(t, newNoOpMockResolver(t))
235+
// For external_auth_config_ref test, create the referenced MCPExternalAuthConfig
236+
var converter *vmcpconfig.Converter
237+
if tt.authConfig.Type == mcpv1alpha1.BackendAuthTypeExternalAuthConfigRef {
238+
// Create a fake MCPExternalAuthConfig
239+
externalAuthConfig := &mcpv1alpha1.MCPExternalAuthConfig{
240+
ObjectMeta: metav1.ObjectMeta{
241+
Name: "auth-config",
242+
Namespace: "default",
243+
},
244+
Spec: mcpv1alpha1.MCPExternalAuthConfigSpec{
245+
Type: mcpv1alpha1.ExternalAuthTypeUnauthenticated,
246+
},
247+
}
248+
249+
// Create converter with fake client that has the external auth config
250+
scheme := runtime.NewScheme()
251+
_ = mcpv1alpha1.AddToScheme(scheme)
252+
fakeClient := fake.NewClientBuilder().
253+
WithScheme(scheme).
254+
WithObjects(externalAuthConfig).
255+
Build()
256+
var err error
257+
converter, err = vmcpconfig.NewConverter(newNoOpMockResolver(t), fakeClient)
258+
require.NoError(t, err)
259+
} else {
260+
converter = newTestConverter(t, newNoOpMockResolver(t))
261+
}
262+
230263
config, err := converter.Convert(context.Background(), vmcpServer)
231264
require.NoError(t, err)
232265

0 commit comments

Comments
 (0)