Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: idp resource (#13271)

Danny Xu0f299b5486bc
diff --git a/backend/api/v1/acl.go b/backend/api/v1/acl.go
index 3afec4a661..7ac071e7da 100644
--- a/backend/api/v1/acl.go
+++ b/backend/api/v1/acl.go
@@ -366,7 +366,8 @@ func getResourceFromSingleRequest(mr protoreflect.Message, shortMethod string) *
isCreate := strings.HasPrefix(shortMethod, "Create")
isUpdate := strings.HasPrefix(shortMethod, "Update")
isRemove := strings.HasPrefix(shortMethod, "Remove")
- if !isCreate && !isUpdate && !isRemove {
+ isTest := strings.HasPrefix(shortMethod, "Test")
+ if !isCreate && !isUpdate && !isRemove && !isTest {
return nil
}
var resourceName string
@@ -380,6 +381,9 @@ func getResourceFromSingleRequest(mr protoreflect.Message, shortMethod string) *
if isRemove {
resourceName = strings.TrimPrefix(shortMethod, "Remove")
}
+ if isTest {
+ resourceName = strings.TrimPrefix(shortMethod, "Test")
+ }
resourceName = toSnakeCase(resourceName)
resourceDesc := mr.Descriptor().Fields().ByName(protoreflect.Name(resourceName))
if resourceDesc == nil {
diff --git a/backend/api/v1/acl_test.go b/backend/api/v1/acl_test.go
index f6403eec1c..c45c45869c 100644
--- a/backend/api/v1/acl_test.go
+++ b/backend/api/v1/acl_test.go
@@ -103,6 +103,17 @@ func TestGetResourceFromRequest(t *testing.T) {
{Name: "idps/hello"},
},
},
+ {
+ request: &v1pb.TestIdentityProviderRequest{
+ IdentityProvider: &v1pb.IdentityProvider{
+ Name: "idps/hello",
+ },
+ },
+ method: "/bytebase.v1.IdentityProviderService/TestIdentityProvider",
+ want: []*common.Resource{
+ {Name: "idps/hello"},
+ },
+ },
{
request: &v1pb.ListReviewConfigsRequest{},
method: "/bytebase.v1.ReviewConfigService/ListReviewConfigs",