Skip to content

Commit f36991a

Browse files
committed
WIP: An e2e test case but not really validating SHR
1 parent 4661fc7 commit f36991a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

tests/test_e2e.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,8 @@ def test_acquire_token_silent_with_an_empty_cache_should_return_none(self):
10411041
# it means MSAL Python is not affected by that.
10421042

10431043

1044+
@unittest.skipUnless(broker_available, "AT POP feature is only supported by using broker")
10441045
class PopTestCase(LabBasedTestCase):
1045-
@unittest.skipUnless(broker_available, "AT POP feature is supported by using broker")
10461046
def test_at_pop_should_contain_pop_scheme_content(self):
10471047
auth_scheme = PopAuthScheme(
10481048
http_method="GET",
@@ -1060,6 +1060,34 @@ def test_at_pop_should_contain_pop_scheme_content(self):
10601060
self.assertEqual(payload["p"], auth_scheme._url.path)
10611061
self.assertEqual(payload["nonce"], auth_scheme._nonce)
10621062

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+
10631091

10641092
if __name__ == "__main__":
10651093
unittest.main()

0 commit comments

Comments
 (0)