@@ -268,6 +268,20 @@ func TestVirtualMCPServerEnsureRBACResources(t *testing.T) {
268268 assert .Equal (t , vmcpServiceAccountName (vmcp .Name ), role .Name )
269269 assert .NotEmpty (t , role .Rules )
270270
271+ // Verify Role includes required ToolHive resources (mcpgroups, mcpservers, mcpremoteproxies, mcpexternalauthconfigs)
272+ var toolhiveRule * rbacv1.PolicyRule
273+ for i := range role .Rules {
274+ if len (role .Rules [i ].APIGroups ) > 0 && role .Rules [i ].APIGroups [0 ] == "toolhive.stacklok.dev" {
275+ toolhiveRule = & role .Rules [i ]
276+ break
277+ }
278+ }
279+ require .NotNil (t , toolhiveRule , "Role should have a rule for toolhive.stacklok.dev API group" )
280+ assert .Contains (t , toolhiveRule .Resources , "mcpgroups" , "Role should allow listing mcpgroups" )
281+ assert .Contains (t , toolhiveRule .Resources , "mcpservers" , "Role should allow listing mcpservers" )
282+ assert .Contains (t , toolhiveRule .Resources , "mcpremoteproxies" , "Role should allow listing mcpremoteproxies" )
283+ assert .Contains (t , toolhiveRule .Resources , "mcpexternalauthconfigs" , "Role should allow listing mcpexternalauthconfigs" )
284+
271285 // Verify RoleBinding was created
272286 rb := & rbacv1.RoleBinding {}
273287 err = fakeClient .Get (context .Background (), types.NamespacedName {
0 commit comments