@@ -140,6 +140,19 @@ def mock_auth_response(self):
140
140
141
141
return {"user" : user , "organization_id" : "org_12345" }
142
142
143
+ @pytest .fixture
144
+ def mock_auth_response_with_impersonator (self ):
145
+ user = MockUser ("user_01H7ZGXFP5C6BBQY6Z7277ZCT0" ).to_dict ()
146
+
147
+ return {
148
+ "user" : user ,
149
+ "organization_id" : "org_12345" ,
150
+ "impersonator" : {
151
+
152
+ "reason" : "Debugging an account issue." ,
153
+ },
154
+ }
155
+
143
156
@pytest .fixture
144
157
def mock_magic_auth_challenge_response (self ):
145
158
return {
@@ -546,7 +559,7 @@ def test_authenticate_with_password(
546
559
assert request ["json" ]["user_agent" ] == user_agent
547
560
assert request ["json" ]["ip_address" ] == ip_address
548
561
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
549
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
562
+ assert request ["json" ]["client_secret" ] == "sk_test "
550
563
assert request ["json" ]["grant_type" ] == "password"
551
564
552
565
def test_authenticate_with_code (self , capture_and_mock_request , mock_auth_response ):
@@ -569,9 +582,28 @@ def test_authenticate_with_code(self, capture_and_mock_request, mock_auth_respon
569
582
assert request ["json" ]["user_agent" ] == user_agent
570
583
assert request ["json" ]["ip_address" ] == ip_address
571
584
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
572
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
585
+ assert request ["json" ]["client_secret" ] == "sk_test "
573
586
assert request ["json" ]["grant_type" ] == "authorization_code"
574
587
588
+ def test_authenticate_impersonator_with_code (
589
+ self , capture_and_mock_request , mock_auth_response_with_impersonator
590
+ ):
591
+ code = "test_code"
592
+
593
+ url , request = capture_and_mock_request (
594
+ "post" , mock_auth_response_with_impersonator , 200
595
+ )
596
+
597
+ response = self .user_management .authenticate_with_code (
598
+ code = code ,
599
+ )
600
+
601
+ print (response )
602
+ assert url [0 ].endswith ("user_management/authenticate" )
603
+ assert response ["user" ]["id" ] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"
604
+ assert response [
"impersonator" ][
"email" ]
== "[email protected] "
605
+ assert response ["impersonator" ]["reason" ] == "Debugging an account issue."
606
+
575
607
def test_authenticate_with_magic_auth (
576
608
self , capture_and_mock_request , mock_auth_response
577
609
):
@@ -597,7 +629,7 @@ def test_authenticate_with_magic_auth(
597
629
assert request ["json" ]["email" ] == email
598
630
assert request ["json" ]["ip_address" ] == ip_address
599
631
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
600
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
632
+ assert request ["json" ]["client_secret" ] == "sk_test "
601
633
assert (
602
634
request ["json" ]["grant_type" ]
603
635
== "urn:workos:oauth:grant-type:magic-auth:code"
@@ -631,7 +663,7 @@ def test_authenticate_with_email_verification(
631
663
)
632
664
assert request ["json" ]["ip_address" ] == ip_address
633
665
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
634
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
666
+ assert request ["json" ]["client_secret" ] == "sk_test "
635
667
assert (
636
668
request ["json" ]["grant_type" ]
637
669
== "urn:workos:oauth:grant-type:email-verification:code"
@@ -669,7 +701,7 @@ def test_authenticate_with_totp(self, capture_and_mock_request, mock_auth_respon
669
701
)
670
702
assert request ["json" ]["ip_address" ] == ip_address
671
703
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
672
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
704
+ assert request ["json" ]["client_secret" ] == "sk_test "
673
705
assert request ["json" ]["grant_type" ] == "urn:workos:oauth:grant-type:mfa-totp"
674
706
675
707
def test_authenticate_with_organization_selection (
@@ -700,7 +732,7 @@ def test_authenticate_with_organization_selection(
700
732
)
701
733
assert request ["json" ]["ip_address" ] == ip_address
702
734
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
703
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
735
+ assert request ["json" ]["client_secret" ] == "sk_test "
704
736
assert (
705
737
request ["json" ]["grant_type" ]
706
738
== "urn:workos:oauth:grant-type:organization-selection"
0 commit comments