@@ -59,6 +59,108 @@ func TestGrantCreate(t *testing.T) {
5959 },
6060 },
6161 },
62+ {
63+ Method : "GET" ,
64+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
65+ Response : PermissionsList {
66+ Assignments : []PrivilegeAssignment {
67+ {
68+ Principal : "me" ,
69+ Privileges : []string {"MODIFY" },
70+ },
71+ },
72+ },
73+ },
74+ },
75+ Resource : ResourceGrants (),
76+ Create : true ,
77+ HCL : `
78+ table = "foo.bar.baz"
79+
80+ grant {
81+ principal = "me"
82+ privileges = ["MODIFY"]
83+ }` ,
84+ }.ApplyNoError (t )
85+ }
86+
87+ func TestWaitUntilReady (t * testing.T ) {
88+ qa.ResourceFixture {
89+ Fixtures : []qa.HTTPFixture {
90+ {
91+ Method : "GET" ,
92+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
93+ Response : PermissionsList {
94+ Assignments : []PrivilegeAssignment {
95+ {
96+ Principal : "me" ,
97+ Privileges : []string {"SELECT" },
98+ },
99+ {
100+ Principal : "someone-else" ,
101+ Privileges : []string {"MODIFY" , "SELECT" },
102+ },
103+ },
104+ },
105+ },
106+ {
107+ Method : "PATCH" ,
108+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
109+ ExpectedRequest : permissionsDiff {
110+ Changes : []permissionsChange {
111+ {
112+ Principal : "me" ,
113+ Add : []string {"MODIFY" },
114+ Remove : []string {"SELECT" },
115+ },
116+ {
117+ Principal : "someone-else" ,
118+ Remove : []string {"MODIFY" , "SELECT" },
119+ },
120+ },
121+ },
122+ },
123+ // This one is still the first one, to simulate a delay on updating the permissions
124+ {
125+ Method : "GET" ,
126+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
127+ Response : PermissionsList {
128+ Assignments : []PrivilegeAssignment {
129+ {
130+ Principal : "me" ,
131+ Privileges : []string {"SELECT" },
132+ },
133+ {
134+ Principal : "someone-else" ,
135+ Privileges : []string {"MODIFY" , "SELECT" },
136+ },
137+ },
138+ },
139+ },
140+ {
141+ Method : "GET" ,
142+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
143+ Response : PermissionsList {
144+ Assignments : []PrivilegeAssignment {
145+ {
146+ Principal : "me" ,
147+ Privileges : []string {"MODIFY" },
148+ },
149+ },
150+ },
151+ },
152+ {
153+ Method : "GET" ,
154+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
155+ Response : PermissionsList {
156+ Assignments : []PrivilegeAssignment {
157+ {
158+ Principal : "me" ,
159+ Privileges : []string {"MODIFY" },
160+ },
161+ },
162+ },
163+ },
62164 },
63165 Resource : ResourceGrants (),
64166 Create : true ,
@@ -106,6 +208,18 @@ func TestGrantUpdate(t *testing.T) {
106208 },
107209 },
108210 },
211+ {
212+ Method : "GET" ,
213+ Resource : "/api/2.1/unity-catalog/permissions/table/foo.bar.baz" ,
214+ Response : PermissionsList {
215+ Assignments : []PrivilegeAssignment {
216+ {
217+ Principal : "me" ,
218+ Privileges : []string {"MODIFY" , "SELECT" },
219+ },
220+ },
221+ },
222+ },
109223 },
110224 Resource : ResourceGrants (),
111225 Update : true ,
@@ -275,6 +389,18 @@ func TestShareGrantCreate(t *testing.T) {
275389 },
276390 },
277391 },
392+ {
393+ Method : "GET" ,
394+ Resource : "/api/2.1/unity-catalog/shares/myshare/permissions" ,
395+ Response : PermissionsList {
396+ Assignments : []PrivilegeAssignment {
397+ {
398+ Principal : "me" ,
399+ Privileges : []string {"SELECT" },
400+ },
401+ },
402+ },
403+ },
278404 },
279405 Resource : ResourceGrants (),
280406 Create : true ,
@@ -331,6 +457,18 @@ func TestShareGrantUpdate(t *testing.T) {
331457 },
332458 },
333459 },
460+ {
461+ Method : "GET" ,
462+ Resource : "/api/2.1/unity-catalog/shares/myshare/permissions" ,
463+ Response : PermissionsList {
464+ Assignments : []PrivilegeAssignment {
465+ {
466+ Principal : "you" ,
467+ Privileges : []string {"SELECT" },
468+ },
469+ },
470+ },
471+ },
334472 },
335473 Resource : ResourceGrants (),
336474 Update : true ,
@@ -406,6 +544,18 @@ func TestConnectionGrantCreate(t *testing.T) {
406544 },
407545 },
408546 },
547+ {
548+ Method : "GET" ,
549+ Resource : "/api/2.1/unity-catalog/permissions/connection/myconn" ,
550+ Response : PermissionsList {
551+ Assignments : []PrivilegeAssignment {
552+ {
553+ Principal : "me" ,
554+ Privileges : []string {"USE_CONNECTION" },
555+ },
556+ },
557+ },
558+ },
409559 },
410560 Resource : ResourceGrants (),
411561 Create : true ,
0 commit comments