Skip to content

Commit

Permalink
Validate Privs for Create/Update
Browse files Browse the repository at this point in the history
  • Loading branch information
ledbutter committed Feb 22, 2024
1 parent 207dda6 commit 49e2d1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions catalog/resource_grants.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ func ResourceGrants() common.Resource {
var grants PermissionsList
common.DataToStructPointer(d, s, &grants)
securable, name := mapping.kv(d)
err = mapping.validate(d, grants)
if err != nil {
return err
}
unityCatalogPermissionsAPI := permissions.NewUnityCatalogPermissionsAPI(ctx, c)
err = replaceAllPermissions(unityCatalogPermissionsAPI, securable, name, grants.toSdkPermissionsList())
if err != nil {
Expand Down Expand Up @@ -373,6 +377,10 @@ func ResourceGrants() common.Resource {
}
var grants PermissionsList
common.DataToStructPointer(d, s, &grants)
err = mapping.validate(d, grants)
if err != nil {
return err
}
unityCatalogPermissionsAPI := permissions.NewUnityCatalogPermissionsAPI(ctx, c)
return replaceAllPermissions(unityCatalogPermissionsAPI, securable, name, grants.toSdkPermissionsList())
},
Expand Down
2 changes: 1 addition & 1 deletion catalog/resource_grants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func TestPermissionsCornerCases(t *testing.T) {
qa.ResourceCornerCases(t, ResourceGrants(), qa.CornerCaseID("schema/sandbox"))
qa.ResourceCornerCases(t, ResourceGrants(), qa.CornerCaseSkipCRUD("Validation prevents CRUD"))
}

func TestGrantCreate(t *testing.T) {
Expand Down

0 comments on commit 49e2d1e

Please sign in to comment.