Skip to content

Commit c456ce4

Browse files
committed
Merge branch 'update-ssh-cert-test-case' into dev
2 parents 4bac5a8 + 259ecb1 commit c456ce4

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/test_e2e.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ def test_username_password(self):
153153
self.skipUnlessWithConfig(["client_id", "username", "password", "scope"])
154154
self._test_username_password(**self.config)
155155

156-
def _get_app_and_auth_code(self, **kwargs):
156+
def _get_app_and_auth_code(self, scopes=None, **kwargs):
157157
return _get_app_and_auth_code(
158158
self.config["client_id"],
159159
client_secret=self.config.get("client_secret"),
160160
authority=self.config.get("authority"),
161161
port=self.config.get("listen_port", 44331),
162-
scopes=self.config["scope"],
162+
scopes=scopes or self.config["scope"],
163163
**kwargs)
164164

165165
def _test_auth_code(self, auth_kwargs, token_kwargs):
@@ -202,27 +202,31 @@ def test_ssh_cert(self):
202202
"sshcrt": "true",
203203
}
204204

205-
(self.app, ac, redirect_uri) = self._get_app_and_auth_code()
205+
scopes = [ # Only this scope would result in an SSH-Cert
206+
"https://pas.windows.net/CheckMyAccess/Linux/user_impersonation"]
207+
(self.app, ac, redirect_uri) = self._get_app_and_auth_code(scopes=scopes)
206208

207209
result = self.app.acquire_token_by_authorization_code(
208-
ac, self.config["scope"], redirect_uri=redirect_uri, data=data1,
210+
ac, scopes, redirect_uri=redirect_uri, data=data1,
209211
params=ssh_test_slice)
212+
self.assertIsNotNone(result.get("access_token"), "Encountered {}: {}".format(
213+
result.get("error"), result.get("error_description")))
210214
self.assertEqual("ssh-cert", result["token_type"])
211215
logger.debug("%s.cache = %s",
212216
self.id(), json.dumps(self.app.token_cache._cache, indent=4))
213217

214218
# acquire_token_silent() needs to be passed the same key to work
215219
account = self.app.get_accounts()[0]
216220
result_from_cache = self.app.acquire_token_silent(
217-
self.config["scope"], account=account, data=data1)
221+
scopes, account=account, data=data1)
218222
self.assertIsNotNone(result_from_cache)
219223
self.assertEqual(
220224
result['access_token'], result_from_cache['access_token'],
221225
"We should get the cached SSH-cert")
222226

223227
# refresh_token grant can fetch an ssh-cert bound to a different key
224228
refreshed_ssh_cert = self.app.acquire_token_silent(
225-
self.config["scope"], account=account, params=ssh_test_slice,
229+
scopes, account=account, params=ssh_test_slice,
226230
data={"token_type": "ssh-cert", "key_id": "key2", "req_cnf": JWK2})
227231
self.assertIsNotNone(refreshed_ssh_cert)
228232
self.assertEqual(refreshed_ssh_cert["token_type"], "ssh-cert")

0 commit comments

Comments
 (0)