Skip to content

Commit dc71044

Browse files
Add intent_options_sso_bookmark_slug parameter on Portal.generate_link() method
1 parent 2521bcb commit dc71044

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

tests/test_portal.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,26 @@ def setup(self, sync_http_client_for_test):
1313
def mock_portal_link(self):
1414
return {"link": "https://id.workos.com/portal/launch?secret=secret"}
1515

16-
def test_generate_link_sso(self, mock_portal_link, mock_http_client_with_response):
17-
mock_http_client_with_response(self.http_client, mock_portal_link, 201)
16+
def test_generate_link_sso(
17+
self, mock_portal_link, capture_and_mock_http_client_request
18+
):
19+
request_kwargs = capture_and_mock_http_client_request(
20+
self.http_client, mock_portal_link, 201
21+
)
1822

1923
response = self.portal.generate_link(
20-
intent="sso", organization_id="org_01EHQMYV6MBK39QC5PZXHY59C3"
24+
intent="sso",
25+
organization_id="org_01EHQMYV6MBK39QC5PZXHY59C3",
26+
intent_options_sso_bookmark_slug="my_app",
2127
)
2228

29+
assert request_kwargs["url"].endswith("/portal/generate_link")
30+
assert request_kwargs["method"] == "post"
31+
assert request_kwargs["json"] == {
32+
"intent": "sso",
33+
"organization": "org_01EHQMYV6MBK39QC5PZXHY59C3",
34+
"intent_options": {"sso": {"bookmark_slug": "my_app"}},
35+
}
2336
assert response.link == "https://id.workos.com/portal/launch?secret=secret"
2437

2538
def test_generate_link_domain_verification(

workos/portal.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,22 @@ def generate_link(
4747
organization_id: str,
4848
return_url: Optional[str] = None,
4949
success_url: Optional[str] = None,
50+
intent_options_sso_bookmark_slug: Optional[str] = None,
5051
) -> PortalLink:
5152
json = {
5253
"intent": intent,
5354
"organization": organization_id,
5455
"return_url": return_url,
5556
"success_url": success_url,
5657
}
58+
59+
if intent_options_sso_bookmark_slug:
60+
json["intent_options"] = {
61+
"sso": {
62+
"bookmark_slug": intent_options_sso_bookmark_slug,
63+
}
64+
}
65+
5766
response = self._http_client.request(
5867
PORTAL_GENERATE_PATH, method=REQUEST_METHOD_POST, json=json
5968
)

0 commit comments

Comments
 (0)