Skip to content

Commit 4550037

Browse files
TPT-4397: Refactor of integration tests for IAM RBAC (#680)
* Add support for account and entity permissions endpoints * Skip tests early if response is empty * Fail tests if resources are not found * Refactor test_set_user_role_permissions to not be skipped by default * Linter fixes --------- Co-authored-by: Dawid Dzhafarov <ddzhafar@akamai.com>
1 parent a8b6c4e commit 4550037

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

test/integration/models/iam/iam_test.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,28 @@ def test_get_user_role_permissions(test_linode_client):
2424
assert isinstance(user_permissions["account_access"], list)
2525

2626

27-
@pytest.mark.skip(
28-
reason="Updating IAM role permissions may require elevated privileges."
29-
)
30-
def test_set_user_role_permissions(test_linode_client):
27+
def test_set_user_role_permissions(test_linode_client, test_firewall):
3128
client = test_linode_client
32-
iam = client.iam
29+
firewall_id = test_firewall.id
3330

3431
username = client.profile().username
35-
entity_access = [EntityAccess(id=1, type="linode", roles=["read_only"])]
36-
37-
updated = iam.role_permissions_user_set(
32+
user_permissions = client.iam.role_permissions_user_get(username)[
33+
"account_access"
34+
]
35+
entity_access = EntityAccess(
36+
id=firewall_id, type="firewall", roles=["firewall_admin"]
37+
).dict
38+
39+
updated_perms = client.iam.role_permissions_user_set(
3840
username,
39-
account_access=["read_only"],
40-
entity_access=entity_access,
41+
account_access=user_permissions,
42+
entity_access=[entity_access],
4143
)
4244

43-
assert "account_access" in updated
44-
assert "entity_access" in updated
45+
assert "account_access" in updated_perms
46+
assert updated_perms["entity_access"][0]["id"] == firewall_id
47+
assert updated_perms["entity_access"][0]["roles"] == ["firewall_admin"]
48+
assert updated_perms["entity_access"][0]["type"] == "firewall"
4549

4650

4751
def test_list_entities(test_linode_client):

0 commit comments

Comments
 (0)