Ensure version "*" is passed instead of "" for all authz checks (#116937)

* ensure version * is passed instead of  for all authz checks

* unexport match function

* remove allversion constant
This commit is contained in:
Sheng Zhan
2023-04-26 00:06:18 +08:00
committed by GitHub
parent c471f03ea3
commit 892ebf2d25
4 changed files with 42 additions and 6 deletions

View File

@@ -133,6 +133,35 @@ func TestAuthorizationAttributesFrom(t *testing.T) {
ResourceRequest: true,
},
},
{
name: "resource with no version",
args: args{
spec: authorizationapi.SubjectAccessReviewSpec{
User: "bob",
ResourceAttributes: &authorizationapi.ResourceAttributes{
Namespace: "myns",
Verb: "create",
Group: "extensions",
Resource: "deployments",
Subresource: "scale",
Name: "mydeployment",
},
},
},
want: authorizer.AttributesRecord{
User: &user.DefaultInfo{
Name: "bob",
},
APIGroup: "extensions",
APIVersion: "*",
Namespace: "myns",
Verb: "create",
Resource: "deployments",
Subresource: "scale",
Name: "mydeployment",
ResourceRequest: true,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {