-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_user.py
More file actions
34 lines (29 loc) · 906 Bytes
/
test_user.py
File metadata and controls
34 lines (29 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import assertpy
import pytest
from feast.permissions.user import User
@pytest.fixture(scope="module")
def users():
users = []
users.append(User("a", ["a1", "a2"]))
users.append(User("b", ["b1", "b2"]))
return dict([(u.username, u) for u in users])
@pytest.mark.parametrize(
"username, roles, result",
[
("c", [], False),
("a", ["b1"], False),
("a", ["a1", "b1"], True),
("a", ["a1"], True),
("a", ["a1", "a2"], True),
("a", ["a1", "a2", "a3"], True),
("b", ["a1", "a3"], False),
("b", ["a1", "b1"], True),
("b", ["b1", "b2"], True),
("b", ["b1", "b2", "b3"], True),
],
)
def test_user_has_matching_role(users, username, roles, result):
user = users.get(username, User(username, []))
assertpy.assert_that(user.has_matching_role(requested_roles=roles)).is_equal_to(
result
)