|
13 | 13 | from tests.utils.fixtures.mock_user import MockUser |
14 | 14 | from workos.user_management import UserManagement |
15 | 15 | from workos.utils.um_provider_types import UserManagementProviderType |
| 16 | +from workos.utils.um_screen_hint_types import UserManagementScreenHintType |
16 | 17 | from workos.utils.request import RESPONSE_TYPE_CODE |
17 | 18 |
|
18 | 19 |
|
@@ -508,6 +509,49 @@ def test_authorization_url_throws_value_error_with_incorrect_provider_type( |
508 | 509 | redirect_uri=redirect_uri, |
509 | 510 | ) |
510 | 511 |
|
| 512 | + @pytest.mark.parametrize( |
| 513 | + "invalid_screen_hint", |
| 514 | + [ |
| 515 | + 123, |
| 516 | + UserManagementScreenHintType, |
| 517 | + True, |
| 518 | + False, |
| 519 | + {"screen_hint": "Something"}, |
| 520 | + ["Something"], |
| 521 | + ], |
| 522 | + ) |
| 523 | + def test_authorization_url_throws_value_error_with_incorrect_screen_hint_type( |
| 524 | + self, invalid_screen_hint |
| 525 | + ): |
| 526 | + with pytest.raises( |
| 527 | + ValueError, match="'screen_hint' must be of type UserManagementScreenHintType" |
| 528 | + ): |
| 529 | + redirect_uri = "https://localhost/auth/callback" |
| 530 | + self.user_management.get_authorization_url( |
| 531 | + screen_hint=invalid_screen_hint, |
| 532 | + redirect_uri=redirect_uri, |
| 533 | + provider=UserManagementProviderType.AuthKit |
| 534 | + ) |
| 535 | + |
| 536 | + def test_authorization_url_has_expected_query_params_with_screen_hint(self): |
| 537 | + screen_hint = UserManagementScreenHintType.SignUp |
| 538 | + redirect_uri = "https://localhost/auth/callback" |
| 539 | + authorization_url = self.user_management.get_authorization_url( |
| 540 | + screen_hint=screen_hint, |
| 541 | + redirect_uri=redirect_uri, |
| 542 | + provider=UserManagementProviderType.AuthKit |
| 543 | + ) |
| 544 | + |
| 545 | + parsed_url = urlparse(authorization_url) |
| 546 | + |
| 547 | + assert dict(parse_qsl(parsed_url.query)) == { |
| 548 | + "screen_hint": screen_hint.value, |
| 549 | + "client_id": workos.client_id, |
| 550 | + "redirect_uri": redirect_uri, |
| 551 | + "response_type": RESPONSE_TYPE_CODE, |
| 552 | + "provider": UserManagementProviderType.AuthKit.value |
| 553 | + } |
| 554 | + |
511 | 555 | def test_authorization_url_has_expected_query_params_with_connection_id(self): |
512 | 556 | connection_id = "connection_123" |
513 | 557 | redirect_uri = "https://localhost/auth/callback" |
|
0 commit comments