Skip to content

Commit a9b401a

Browse files
committed
fix(gateway): 修复 ACL 测试中 allow map 键未归一化导致大小写不匹配
TestNetworkServerSessionAssetACLIndependent 直接用 sessionAssetReadMethod/ sessionAssetDeleteMethod(混合大小写)作为 allow map 键,但 IsAllowed 查找时 用 strings.ToLower 归一化,导致键不匹配返回 403。改用 normalizedMethodSet() 构造内层 map,与生产代码 NewStrictControlPlaneACL 保持一致。
1 parent be64f2c commit a9b401a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

internal/gateway/network_server_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ func TestNetworkServerSessionAssetACLIndependent(t *testing.T) {
753753
t.Run("read allowed delete denied", func(t *testing.T) {
754754
readOnlyACL := &ControlPlaneACL{
755755
mode: ACLModeStrict,
756-
allow: map[RequestSource]map[string]struct{}{RequestSourceHTTP: {sessionAssetReadMethod: {}}},
756+
allow: map[RequestSource]map[string]struct{}{RequestSourceHTTP: normalizedMethodSet(sessionAssetReadMethod)},
757757
enabled: true,
758758
}
759759
runtimePort := &runtimePortEventStub{
@@ -797,7 +797,7 @@ func TestNetworkServerSessionAssetACLIndependent(t *testing.T) {
797797
t.Run("delete allowed read denied", func(t *testing.T) {
798798
deleteOnlyACL := &ControlPlaneACL{
799799
mode: ACLModeStrict,
800-
allow: map[RequestSource]map[string]struct{}{RequestSourceHTTP: {sessionAssetDeleteMethod: {}}},
800+
allow: map[RequestSource]map[string]struct{}{RequestSourceHTTP: normalizedMethodSet(sessionAssetDeleteMethod)},
801801
enabled: true,
802802
}
803803
runtimePort := &runtimePortEventStub{

0 commit comments

Comments
 (0)