@@ -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 {
@@ -532,7 +545,7 @@ def test_authenticate_with_password(
532
545
assert request ["json" ]["user_agent" ] == user_agent
533
546
assert request ["json" ]["ip_address" ] == ip_address
534
547
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
535
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
548
+ assert request ["json" ]["client_secret" ] == "sk_test "
536
549
assert request ["json" ]["grant_type" ] == "password"
537
550
538
551
def test_authenticate_with_code (self , capture_and_mock_request , mock_auth_response ):
@@ -555,9 +568,24 @@ def test_authenticate_with_code(self, capture_and_mock_request, mock_auth_respon
555
568
assert request ["json" ]["user_agent" ] == user_agent
556
569
assert request ["json" ]["ip_address" ] == ip_address
557
570
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
558
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
571
+ assert request ["json" ]["client_secret" ] == "sk_test "
559
572
assert request ["json" ]["grant_type" ] == "authorization_code"
560
573
574
+ def test_authenticate_impersonator_with_code (self , capture_and_mock_request , mock_auth_response_with_impersonator ):
575
+ code = "test_code"
576
+
577
+ url , request = capture_and_mock_request ("post" , mock_auth_response_with_impersonator , 200 )
578
+
579
+ response = self .user_management .authenticate_with_code (
580
+ code = code ,
581
+ )
582
+
583
+ print (response )
584
+ assert url [0 ].endswith ("user_management/authenticate" )
585
+ assert response ["user" ]["id" ] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"
586
+ assert response [
"impersonator" ][
"email" ]
== "[email protected] "
587
+ assert response ["impersonator" ]["reason" ] == "Debugging an account issue."
588
+
561
589
def test_authenticate_with_magic_auth (
562
590
self , capture_and_mock_request , mock_auth_response
563
591
):
@@ -583,7 +611,7 @@ def test_authenticate_with_magic_auth(
583
611
assert request ["json" ]["email" ] == email
584
612
assert request ["json" ]["ip_address" ] == ip_address
585
613
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
586
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
614
+ assert request ["json" ]["client_secret" ] == "sk_test "
587
615
assert (
588
616
request ["json" ]["grant_type" ]
589
617
== "urn:workos:oauth:grant-type:magic-auth:code"
@@ -617,7 +645,7 @@ def test_authenticate_with_email_verification(
617
645
)
618
646
assert request ["json" ]["ip_address" ] == ip_address
619
647
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
620
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
648
+ assert request ["json" ]["client_secret" ] == "sk_test "
621
649
assert (
622
650
request ["json" ]["grant_type" ]
623
651
== "urn:workos:oauth:grant-type:email-verification:code"
@@ -655,7 +683,7 @@ def test_authenticate_with_totp(self, capture_and_mock_request, mock_auth_respon
655
683
)
656
684
assert request ["json" ]["ip_address" ] == ip_address
657
685
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
658
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
686
+ assert request ["json" ]["client_secret" ] == "sk_test "
659
687
assert request ["json" ]["grant_type" ] == "urn:workos:oauth:grant-type:mfa-totp"
660
688
661
689
def test_authenticate_with_organization_selection (
@@ -686,7 +714,7 @@ def test_authenticate_with_organization_selection(
686
714
)
687
715
assert request ["json" ]["ip_address" ] == ip_address
688
716
assert request ["json" ]["client_id" ] == "client_b27needthisforssotemxo"
689
- assert request ["json" ]["client_secret" ] == "sk_abdsomecharactersm284 "
717
+ assert request ["json" ]["client_secret" ] == "sk_test "
690
718
assert (
691
719
request ["json" ]["grant_type" ]
692
720
== "urn:workos:oauth:grant-type:organization-selection"
0 commit comments