Skip to content

Commit de56894

Browse files
authored
default role (#588)
1 parent d0357d3 commit de56894

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

descope/management/role.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ def create(
1111
description: Optional[str] = None,
1212
permission_names: Optional[List[str]] = None,
1313
tenant_id: Optional[str] = None,
14+
default: Optional[bool] = None,
1415
):
1516
"""
1617
Create a new role.
@@ -19,6 +20,8 @@ def create(
1920
name (str): role name.
2021
description (str): Optional description to briefly explain what this role allows.
2122
permission_names (List[str]): Optional list of names of permissions this role grants.
23+
tenant_id (str): Optional tenant ID to create the role in.
24+
default (bool): Optional marks this role as default role.
2225
2326
Raise:
2427
AuthException: raised if creation operation fails
@@ -32,6 +35,7 @@ def create(
3235
"description": description,
3336
"permissionNames": permission_names,
3437
"tenantId": tenant_id,
38+
"default": default,
3539
},
3640
pswd=self._auth.management_key,
3741
)
@@ -43,6 +47,7 @@ def update(
4347
description: Optional[str] = None,
4448
permission_names: Optional[List[str]] = None,
4549
tenant_id: Optional[str] = None,
50+
default: Optional[bool] = None,
4651
):
4752
"""
4853
Update an existing role with the given various fields. IMPORTANT: All parameters are used as overrides
@@ -53,6 +58,8 @@ def update(
5358
new_name (str): role updated name.
5459
description (str): Optional description to briefly explain what this role allows.
5560
permission_names (List[str]): Optional list of names of permissions this role grants.
61+
tenant_id (str): Optional tenant ID to update the role in.
62+
default (bool): Optional marks this role as default role.
5663
5764
Raise:
5865
AuthException: raised if update operation fails
@@ -66,6 +73,7 @@ def update(
6673
"description": description,
6774
"permissionNames": permission_names,
6875
"tenantId": tenant_id,
76+
"default": default,
6977
},
7078
pswd=self._auth.management_key,
7179
)

tests/management/test_role.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_create(self):
4444
# Test success flow
4545
with patch("requests.post") as mock_post:
4646
mock_post.return_value.ok = True
47-
self.assertIsNone(client.mgmt.role.create("R1", "Something", ["P1"], "t1"))
47+
self.assertIsNone(client.mgmt.role.create("R1", "Something", ["P1"], "t1", True))
4848
mock_post.assert_called_with(
4949
f"{common.DEFAULT_BASE_URL}{MgmtV1.role_create_path}",
5050
headers={
@@ -58,6 +58,7 @@ def test_create(self):
5858
"description": "Something",
5959
"permissionNames": ["P1"],
6060
"tenantId": "t1",
61+
"default": True,
6162
},
6263
allow_redirects=False,
6364
verify=True,
@@ -92,6 +93,7 @@ def test_update(self):
9293
"new-description",
9394
["P1", "P2"],
9495
"t1",
96+
True,
9597
)
9698
)
9799
mock_post.assert_called_with(
@@ -108,6 +110,7 @@ def test_update(self):
108110
"description": "new-description",
109111
"permissionNames": ["P1", "P2"],
110112
"tenantId": "t1",
113+
"default": True,
111114
},
112115
allow_redirects=False,
113116
verify=True,

0 commit comments

Comments
 (0)