@@ -1157,8 +1157,8 @@ def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
1157
1157
# it means MSAL Python is not affected by that.
1158
1158
1159
1159
1160
+ @unittest .skipUnless (broker_available , "AT POP feature is only supported by using broker" )
1160
1161
class PopTestCase (LabBasedTestCase ):
1161
- @unittest .skipUnless (broker_available , "AT POP feature is supported by using broker" )
1162
1162
def test_at_pop_should_contain_pop_scheme_content (self ):
1163
1163
auth_scheme = msal .PopAuthScheme (
1164
1164
http_method = msal .PopAuthScheme .HTTP_GET ,
@@ -1180,6 +1180,34 @@ def test_at_pop_should_contain_pop_scheme_content(self):
1180
1180
self .assertEqual (payload ["p" ], auth_scheme ._url .path )
1181
1181
self .assertEqual (payload ["nonce" ], auth_scheme ._nonce )
1182
1182
1183
+ def test_at_pop_via_testingsts_service (self ):
1184
+ """Based on https://testingsts.azurewebsites.net/ServerNonce"""
1185
+ auth_scheme = PopAuthScheme (
1186
+ http_method = "POST" ,
1187
+ url = "https://www.Contoso.com/Path1/Path2?queryParam1=a&queryParam2=b" ,
1188
+ nonce = requests .get (
1189
+ # TODO: Could use ".../missing" and then parse its WWW-Authenticate header
1190
+ "https://testingsts.azurewebsites.net/servernonce/get" ).text ,
1191
+ )
1192
+ config = self .get_lab_user (usertype = "cloud" )
1193
+ config ["password" ] = self .get_lab_user_secret (config ["lab_name" ])
1194
+ result = self ._test_username_password (auth_scheme = auth_scheme , ** config )
1195
+ self .assertEqual (result ["token_type" ], "pop" )
1196
+ shr = result ["access_token" ]
1197
+ payload = json .loads (decode_part (result ["access_token" ].split ("." )[1 ]))
1198
+ logger .debug ("AT POP payload = %s" , json .dumps (payload , indent = 2 ))
1199
+ self .assertEqual (payload ["m" ], auth_scheme ._http_method )
1200
+ self .assertEqual (payload ["u" ], auth_scheme ._url .netloc )
1201
+ self .assertEqual (payload ["p" ], auth_scheme ._url .path )
1202
+ self .assertEqual (payload ["nonce" ], auth_scheme ._nonce )
1203
+
1204
+ validation = requests .post (
1205
+ # TODO: This endpoint does not seem to validate the url
1206
+ "https://testingsts.azurewebsites.net/servernonce/validateshr" ,
1207
+ data = {"SHR" : shr },
1208
+ )
1209
+ self .assertEqual (validation .status_code , 200 )
1210
+
1183
1211
1184
1212
if __name__ == "__main__" :
1185
1213
unittest .main ()
0 commit comments