Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions descope/management/tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def create(
self_provisioning_domains: Optional[List[str]] = None,
custom_attributes: Optional[dict] = None,
enforce_sso: Optional[bool] = False,
enforce_sso_exclusions: Optional[List[str]] = None,
federated_app_ids: Optional[List[str]] = None,
disabled: Optional[bool] = False,
) -> dict:
"""
Expand All @@ -30,6 +32,8 @@ def create(
Users authenticating from these domains will be associated with this tenant.
custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
enforce_sso (bool): Optional, login to the tenant is possible only using the configured sso
enforce_sso_exclusions (List[str]): Optional, list of user IDs excluded from SSO enforcement
federated_app_ids (List[str]): Optional, list of federated application IDs
disabled (bool): Optional, login to the tenant will be disabled

Return value (dict):
Expand All @@ -51,6 +55,8 @@ def create(
self_provisioning_domains,
custom_attributes,
enforce_sso,
enforce_sso_exclusions,
federated_app_ids,
disabled,
),
)
Expand All @@ -63,6 +69,8 @@ def update(
self_provisioning_domains: Optional[List[str]] = None,
custom_attributes: Optional[dict] = None,
enforce_sso: Optional[bool] = False,
enforce_sso_exclusions: Optional[List[str]] = None,
federated_app_ids: Optional[List[str]] = None,
disabled: Optional[bool] = False,
):
"""
Expand All @@ -76,6 +84,8 @@ def update(
Users authenticating from these domains will be associated with this tenant.
custom_attributes (dict): Optional, set the different custom attributes values of the keys that were previously configured in Descope console app
enforce_sso (bool): Optional, login to the tenant is possible only using the configured sso
enforce_sso_exclusions (List[str]): Optional, list of user IDs excluded from SSO enforcement
federated_app_ids (List[str]): Optional, list of federated application IDs
disabled (bool): Optional, login to the tenant will be disabled

Raise:
Expand All @@ -93,6 +103,8 @@ def update(
self_provisioning_domains,
custom_attributes,
enforce_sso,
enforce_sso_exclusions,
federated_app_ids,
disabled,
),
)
Expand All @@ -115,6 +127,9 @@ def update_settings(
inactivity_time_unit: Optional[SessionExpirationUnit] = None,
JITDisabled: Optional[bool] = None,
sso_setup_suite_settings: Optional[SSOSetupSuiteSettings] = None,
enforce_sso: Optional[bool] = None,
enforce_sso_exclusions: Optional[List[str]] = None,
federated_app_ids: Optional[List[str]] = None,
Comment on lines +130 to +132
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new parameters enforce_sso, enforce_sso_exclusions, and federated_app_ids added to the update_settings method lack test coverage. While tests exist for test_update_settings, they don't verify these newly added parameters. Consider adding a test case that calls update_settings with these parameters and verifies they are correctly included in the request body.

Copilot uses AI. Check for mistakes.
):
"""
Update an existing tenant's session settings.
Expand All @@ -136,6 +151,9 @@ def update_settings(
inactivity_time_unit (Optional[SessionExpirationUnit]): Unit for inactivity timeout.
JITDisabled (Optional[bool]): Whether JIT is disabled.
sso_setup_suite_settings (Optional[SSOSetupSuiteSettings]): SSO Setup Suite configuration.
enforce_sso (Optional[bool]): Whether to enforce SSO for the tenant.
enforce_sso_exclusions (Optional[List[str]]): List of user IDs excluded from SSO enforcement.
federated_app_ids (Optional[List[str]]): List of federated application IDs.

Raise:
AuthException: raised if update operation fails
Expand All @@ -159,6 +177,9 @@ def update_settings(
"ssoSetupSuiteSettings": (
sso_setup_suite_settings.to_dict() if sso_setup_suite_settings else None
),
"enforceSSO": enforce_sso,
"enforceSSOExclusions": enforce_sso_exclusions,
"federatedAppIds": federated_app_ids,
}

body = {k: v for k, v in body.items() if v is not None}
Expand Down Expand Up @@ -298,6 +319,8 @@ def _compose_create_update_body(
self_provisioning_domains: List[str],
custom_attributes: Optional[dict] = None,
enforce_sso: Optional[bool] = False,
enforce_sso_exclusions: Optional[List[str]] = None,
federated_app_ids: Optional[List[str]] = None,
disabled: Optional[bool] = False,
) -> dict:
body: dict[str, Any] = {
Expand All @@ -309,4 +332,8 @@ def _compose_create_update_body(
}
if custom_attributes is not None:
body["customAttributes"] = custom_attributes
if enforce_sso_exclusions is not None:
body["enforceSSOExclusions"] = enforce_sso_exclusions
if federated_app_ids is not None:
body["federatedAppIds"] = federated_app_ids
return body
8 changes: 8 additions & 0 deletions tests/management/test_tenant.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def test_create(self):
["domain.com"],
{"k1": "v1"},
enforce_sso=True,
enforce_sso_exclusions=["user1", "user2"],
federated_app_ids=["app1", "app2"],
disabled=True,
)
self.assertEqual(resp["id"], "t1")
Expand All @@ -102,6 +104,8 @@ def test_create(self):
"selfProvisioningDomains": ["domain.com"],
"customAttributes": {"k1": "v1"},
"enforceSSO": True,
"enforceSSOExclusions": ["user1", "user2"],
"federatedAppIds": ["app1", "app2"],
"disabled": True,
},
allow_redirects=False,
Expand Down Expand Up @@ -165,6 +169,8 @@ def test_update(self):
["domain.com"],
{"k1": "v1"},
enforce_sso=True,
enforce_sso_exclusions=["user1", "user2"],
federated_app_ids=["app1", "app2"],
disabled=True,
)
)
Expand All @@ -182,6 +188,8 @@ def test_update(self):
"selfProvisioningDomains": ["domain.com"],
"customAttributes": {"k1": "v1"},
"enforceSSO": True,
"enforceSSOExclusions": ["user1", "user2"],
"federatedAppIds": ["app1", "app2"],
"disabled": True,
},
allow_redirects=False,
Expand Down
Loading