@@ -1041,8 +1041,8 @@ def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
1041
1041
# it means MSAL Python is not affected by that.
1042
1042
1043
1043
1044
+ @unittest .skipUnless (broker_available , "AT POP feature is only supported by using broker" )
1044
1045
class PopTestCase (LabBasedTestCase ):
1045
- @unittest .skipUnless (broker_available , "AT POP feature is supported by using broker" )
1046
1046
def test_at_pop_should_contain_pop_scheme_content (self ):
1047
1047
auth_scheme = PopAuthScheme (
1048
1048
http_method = "GET" ,
@@ -1060,6 +1060,34 @@ def test_at_pop_should_contain_pop_scheme_content(self):
1060
1060
self .assertEqual (payload ["p" ], auth_scheme ._url .path )
1061
1061
self .assertEqual (payload ["nonce" ], auth_scheme ._nonce )
1062
1062
1063
+ def test_at_pop_via_testingsts_service (self ):
1064
+ """Based on https://testingsts.azurewebsites.net/ServerNonce"""
1065
+ auth_scheme = PopAuthScheme (
1066
+ http_method = "POST" ,
1067
+ url = "https://www.Contoso.com/Path1/Path2?queryParam1=a&queryParam2=b" ,
1068
+ nonce = requests .get (
1069
+ # TODO: Could use ".../missing" and then parse its WWW-Authenticate header
1070
+ "https://testingsts.azurewebsites.net/servernonce/get" ).text ,
1071
+ )
1072
+ config = self .get_lab_user (usertype = "cloud" )
1073
+ config ["password" ] = self .get_lab_user_secret (config ["lab_name" ])
1074
+ result = self ._test_username_password (auth_scheme = auth_scheme , ** config )
1075
+ self .assertEqual (result ["token_type" ], "pop" )
1076
+ shr = result ["access_token" ]
1077
+ payload = json .loads (decode_part (result ["access_token" ].split ("." )[1 ]))
1078
+ logger .debug ("AT POP payload = %s" , json .dumps (payload , indent = 2 ))
1079
+ self .assertEqual (payload ["m" ], auth_scheme ._http_method )
1080
+ self .assertEqual (payload ["u" ], auth_scheme ._url .netloc )
1081
+ self .assertEqual (payload ["p" ], auth_scheme ._url .path )
1082
+ self .assertEqual (payload ["nonce" ], auth_scheme ._nonce )
1083
+
1084
+ validation = requests .post (
1085
+ # TODO: This endpoint does not seem to validate the url
1086
+ "https://testingsts.azurewebsites.net/servernonce/validateshr" ,
1087
+ data = {"SHR" : shr },
1088
+ )
1089
+ self .assertEqual (validation .status_code , 200 )
1090
+
1063
1091
1064
1092
if __name__ == "__main__" :
1065
1093
unittest .main ()
0 commit comments