Skip to content

Commit bc62a62

Browse files
committed
update test
Signed-off-by: Huabing Zhao <[email protected]>
1 parent f3196ca commit bc62a62

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

internal/mcpproxy/authorization_test.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,37 @@ func TestAuthorizeRequest(t *testing.T) {
175175
toolName: "tool1",
176176
expectAllowed: true,
177177
},
178+
{
179+
name: "no rules falls back to default deny",
180+
auth: &filterapi.MCPRouteAuthorization{
181+
DefaultAction: ptr.To(filterapi.AuthorizationActionDeny),
182+
},
183+
header: "",
184+
backendName: "backend1",
185+
toolName: "tool1",
186+
expectAllowed: false,
187+
},
188+
{
189+
name: "no bearer token not allowed when rules exist",
190+
auth: &filterapi.MCPRouteAuthorization{
191+
DefaultAction: ptr.To(filterapi.AuthorizationActionAllow),
192+
Rules: []filterapi.MCPRouteAuthorizationRule{
193+
{
194+
Source: filterapi.MCPAuthorizationSource{
195+
JWTSource: filterapi.JWTSource{Scopes: []string{"read"}},
196+
},
197+
Target: filterapi.MCPAuthorizationTarget{
198+
Tools: []filterapi.ToolCall{{BackendName: "backend1", ToolName: "tool1"}},
199+
},
200+
Action: filterapi.AuthorizationActionDeny,
201+
},
202+
},
203+
},
204+
header: "",
205+
backendName: "backend1",
206+
toolName: "tool1",
207+
expectAllowed: false,
208+
},
178209
{
179210
name: "multiple rules, first match applied - denied",
180211
auth: &filterapi.MCPRouteAuthorization{

0 commit comments

Comments
 (0)