Skip to content

Commit cbfc4d3

Browse files
committed
Add per-engine grants request logging to duplicate grant tests
Show the actual PATCH requests to the permissions endpoint for each engine, making the differences visible (e.g. direct sends ALL_PRIVILEGES in both Add and Remove, terraform sends clean requests). Co-authored-by: Isaac
1 parent 8660651 commit cbfc4d3

File tree

12 files changed

+148
-3
lines changed

12 files changed

+148
-3
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"method": "PATCH",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
4+
"body": {
5+
"changes": [
6+
{
7+
"add": [
8+
"ALL_PRIVILEGES"
9+
],
10+
"principal": "deco-test-user@databricks.com",
11+
"remove": [
12+
"ALL_PRIVILEGES"
13+
]
14+
}
15+
]
16+
}
17+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"method": "GET",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
4+
}
5+
{
6+
"method": "PATCH",
7+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
8+
"body": {
9+
"changes": [
10+
{
11+
"add": [
12+
"ALL_PRIVILEGES"
13+
],
14+
"principal": "deco-test-user@databricks.com"
15+
}
16+
]
17+
}
18+
}
19+
{
20+
"method": "GET",
21+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
22+
}
23+
{
24+
"method": "GET",
25+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
26+
}

acceptance/bundle/resources/grants/schemas/all_privileges/script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ envsubst < databricks.yml.tmpl > databricks.yml
22

33
cleanup() {
44
trace $CLI bundle destroy --auto-approve
5+
rm -f out.requests.txt
56
}
67
trap cleanup EXIT
78

89
# The direct engine puts ALL_PRIVILEGES in both the Add and Remove lists in the PATCH request,
910
# which the backend rejects with "Duplicate privileges to add and delete".
1011
$CLI bundle deploy > out.deploy.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1 || true
12+
print_requests.py --get //permissions --keep > out.requests.$DATABRICKS_BUNDLE_ENGINE.txt
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Badness = "direct engine fails: applyGrants() puts ALL_PRIVILEGES in both Add and Remove lists"
2-
RecordRequests = false
2+
RecordRequests = true
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"method": "PATCH",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
4+
"body": {
5+
"changes": [
6+
{
7+
"add": [
8+
"CREATE_TABLE"
9+
],
10+
"principal": "deco-test-user@databricks.com",
11+
"remove": [
12+
"ALL_PRIVILEGES"
13+
]
14+
},
15+
{
16+
"add": [
17+
"CREATE_TABLE"
18+
],
19+
"principal": "deco-test-user@databricks.com",
20+
"remove": [
21+
"ALL_PRIVILEGES"
22+
]
23+
}
24+
]
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"method": "GET",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
4+
}
5+
{
6+
"method": "PATCH",
7+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
8+
"body": {
9+
"changes": [
10+
{
11+
"add": [
12+
"CREATE_TABLE"
13+
],
14+
"principal": "deco-test-user@databricks.com"
15+
}
16+
]
17+
}
18+
}
19+
{
20+
"method": "GET",
21+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
22+
}
23+
{
24+
"method": "GET",
25+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
26+
}

acceptance/bundle/resources/grants/schemas/duplicate_principals/script

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ envsubst < databricks.yml.tmpl > databricks.yml
22

33
cleanup() {
44
trace $CLI bundle destroy --auto-approve
5+
rm -f out.requests.txt
56
}
67
trap cleanup EXIT
78

89
# Same principal listed twice with the same privilege.
910
trace $CLI bundle deploy
11+
print_requests.py --get //permissions --keep > out.requests.$DATABRICKS_BUNDLE_ENGINE.txt
1012
trace $CLI bundle plan > out.plan.$DATABRICKS_BUNDLE_ENGINE.txt 2>&1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Badness = "direct engine shows drift after deploy when same principal is listed twice with same privilege"
2-
RecordRequests = false
2+
RecordRequests = true
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"method": "PATCH",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
4+
"body": {
5+
"changes": [
6+
{
7+
"add": [
8+
"CREATE_TABLE",
9+
"CREATE_TABLE"
10+
],
11+
"principal": "deco-test-user@databricks.com",
12+
"remove": [
13+
"ALL_PRIVILEGES"
14+
]
15+
}
16+
]
17+
}
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"method": "GET",
3+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
4+
}
5+
{
6+
"method": "PATCH",
7+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]",
8+
"body": {
9+
"changes": [
10+
{
11+
"add": [
12+
"CREATE_TABLE"
13+
],
14+
"principal": "deco-test-user@databricks.com"
15+
}
16+
]
17+
}
18+
}
19+
{
20+
"method": "GET",
21+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
22+
}
23+
{
24+
"method": "GET",
25+
"path": "/api/2.1/unity-catalog/permissions/schema/main.schema_dup_grants_[UNIQUE_NAME]"
26+
}

0 commit comments

Comments
 (0)