Skip to content

Commit a31db9b

Browse files
committed
Merge branch 'improve-tests' into dev
2 parents e74002b + c33bc11 commit a31db9b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

tests/test_e2e.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ def assertLoosely(self, response, assertion=None,
5858

5959
def assertCacheWorksForUser(
6060
self, result_from_wire, scope, username=None, data=None):
61+
logger.debug(
62+
"%s: cache = %s, id_token_claims = %s",
63+
self.id(),
64+
json.dumps(self.app.token_cache._cache, indent=4),
65+
json.dumps(result_from_wire.get("id_token_claims"), indent=4),
66+
)
6167
# You can filter by predefined username, or let end user to choose one
6268
accounts = self.app.get_accounts(username=username)
6369
self.assertNotEqual(0, len(accounts))
@@ -164,12 +170,6 @@ def _test_acquire_token_interactive(
164170
</ol></body></html>""".format(id=self.id(), username_uri=username_uri),
165171
data=data or {},
166172
)
167-
logger.debug(
168-
"%s: cache = %s, id_token_claims = %s",
169-
self.id(),
170-
json.dumps(self.app.token_cache._cache, indent=4),
171-
json.dumps(result.get("id_token_claims"), indent=4),
172-
)
173173
self.assertIn(
174174
"access_token", result,
175175
"{error}: {error_description}".format(
@@ -401,7 +401,10 @@ def tearDownClass(cls):
401401
def get_lab_app_object(cls, **query): # https://msidlab.com/swagger/index.html
402402
url = "https://msidlab.com/api/app"
403403
resp = cls.session.get(url, params=query)
404-
return resp.json()[0]
404+
result = resp.json()[0]
405+
result["scopes"] = [ # Raw data has extra space, such as "s1, s2"
406+
s.strip() for s in result["defaultScopes"].split(',')]
407+
return result
405408

406409
@classmethod
407410
def get_lab_user_secret(cls, lab_name="msidlab4"):
@@ -698,7 +701,7 @@ def test_b2c_acquire_token_by_auth_code(self):
698701
authority=self._build_b2c_authority("B2C_1_SignInPolicy"),
699702
client_id=config["appId"],
700703
port=3843, # Lab defines 4 of them: [3843, 4584, 4843, 60000]
701-
scope=config["defaultScopes"].split(','),
704+
scope=config["scopes"],
702705
)
703706

704707
@unittest.skipIf(os.getenv("TRAVIS"), "Browser automation is not yet implemented")
@@ -708,7 +711,7 @@ def test_b2c_acquire_token_by_auth_code_flow(self):
708711
authority=self._build_b2c_authority("B2C_1_SignInPolicy"),
709712
client_id=config["appId"],
710713
port=3843, # Lab defines 4 of them: [3843, 4584, 4843, 60000]
711-
scope=config["defaultScopes"].split(','),
714+
scope=config["scopes"],
712715
username_uri="https://msidlab.com/api/user?usertype=b2c&b2cprovider=local",
713716
)
714717

@@ -719,7 +722,7 @@ def test_b2c_acquire_token_by_ropc(self):
719722
client_id=config["appId"],
720723
username="[email protected]",
721724
password=self.get_lab_user_secret("msidlabb2c"),
722-
scope=config["defaultScopes"].split(','),
725+
scope=config["scopes"],
723726
)
724727

725728

0 commit comments

Comments
 (0)