Skip to content

Commit 4a3fc6f

Browse files
committed
increase code coverage
1 parent 9de4470 commit 4a3fc6f

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

tests/unit/workspace_access/test_tacl.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ def test_tacl_crawler_multiple_permissions():
4444
("[email protected]", "SELECT", "catalog_a", "database_b", "table_c", None, False, False),
4545
# duplicate
4646
("[email protected]", "SELECT", "catalog_a", "database_b", "table_c", None, False, False),
47+
# view
48+
("[email protected]", "SELECT", "catalog_a", "database_b", None, "view_c", False, False),
49+
# database
50+
("[email protected]", "SELECT", "catalog_a", "database_b", None, None, False, False),
51+
# catalog
52+
("[email protected]", "SELECT", "catalog_a", None, None, None, False, False),
53+
# any file
54+
("[email protected]", "SELECT", None, None, None, None, True, False),
55+
# function
56+
("[email protected]", "SELECT", None, None, None, None, False, True),
4757
]
4858
}
4959
)
@@ -98,6 +108,81 @@ def test_tacl_crawler_multiple_permissions():
98108
anonymous_function=False,
99109
) == Grant(**json.loads(permissions.raw))
100110

111+
permissions = next(crawler_tasks)()
112+
113+
assert "VIEW" == permissions.object_type
114+
assert "catalog_a.database_b.view_c" == permissions.object_id
115+
assert Grant(
116+
principal="[email protected]",
117+
action_type="SELECT",
118+
catalog="catalog_a",
119+
database="database_b",
120+
table=None,
121+
view="view_c",
122+
any_file=False,
123+
anonymous_function=False,
124+
) == Grant(**json.loads(permissions.raw))
125+
126+
permissions = next(crawler_tasks)()
127+
128+
assert "DATABASE" == permissions.object_type
129+
assert "catalog_a.database_b" == permissions.object_id
130+
assert Grant(
131+
principal="[email protected]",
132+
action_type="SELECT",
133+
catalog="catalog_a",
134+
database="database_b",
135+
table=None,
136+
view=None,
137+
any_file=False,
138+
anonymous_function=False,
139+
) == Grant(**json.loads(permissions.raw))
140+
141+
permissions = next(crawler_tasks)()
142+
143+
assert "CATALOG" == permissions.object_type
144+
assert "catalog_a" == permissions.object_id
145+
assert Grant(
146+
principal="[email protected]",
147+
action_type="SELECT",
148+
catalog="catalog_a",
149+
database=None,
150+
table=None,
151+
view=None,
152+
any_file=False,
153+
anonymous_function=False,
154+
) == Grant(**json.loads(permissions.raw))
155+
156+
permissions = next(crawler_tasks)()
157+
158+
assert "ANY FILE" == permissions.object_type
159+
assert permissions.object_id == ""
160+
assert Grant(
161+
principal="[email protected]",
162+
action_type="SELECT",
163+
catalog="",
164+
database=None,
165+
table=None,
166+
view=None,
167+
any_file=True,
168+
anonymous_function=False,
169+
) == Grant(**json.loads(permissions.raw))
170+
171+
permissions = next(crawler_tasks)()
172+
173+
assert "ANONYMOUS FUNCTION" == permissions.object_type
174+
assert permissions.object_id == ""
175+
assert Grant(
176+
principal="[email protected]",
177+
action_type="SELECT",
178+
catalog="",
179+
database=None,
180+
table=None,
181+
view=None,
182+
any_file=False,
183+
anonymous_function=True,
184+
) == Grant(**json.loads(permissions.raw))
185+
101186

102187
def test_tacl_applier(mocker):
103188
sql_backend = MockBackend()

0 commit comments

Comments
 (0)