Skip to content

Commit 2b12c6a

Browse files
committed
Add another cloud shell test case for non ssh cert
Refine unittest
1 parent 579eb5f commit 2b12c6a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/test_e2e.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def test_ssh_cert_for_user(self):
258258

259259
@unittest.skipUnless(
260260
msal.application._is_running_in_cloud_shell(),
261-
"Manually run this by python -m unittest tests.test_e2e.SshCertTestCase")
261+
"Manually run this test case from inside Cloud Shell")
262262
def test_ssh_cert_for_user_silent_inside_cloud_shell(self):
263263
app = msal.PublicClientApplication("client_id_wont_matter")
264264
accounts = app.get_accounts()
@@ -270,6 +270,23 @@ def test_ssh_cert_for_user_silent_inside_cloud_shell(self):
270270
self.assertIsNotNone(result.get("access_token"))
271271

272272

273+
@unittest.skipUnless(
274+
msal.application._is_running_in_cloud_shell(),
275+
"Manually run this test case from inside Cloud Shell")
276+
class CloudShellTestCase(E2eTestCase):
277+
app = msal.PublicClientApplication("client_id_wont_matter")
278+
# Scopes came from https://msazure.visualstudio.com/One/_git/compute-CloudShell?path=/src/images/agent/env/envconfig.PROD.json&version=GBmaster&_a=contents
279+
scope_that_requires_no_managed_device = "https://management.core.windows.net/"
280+
def test_access_token_should_be_obtained_for_a_supported_scope(self):
281+
accounts = self.app.get_accounts()
282+
self.assertNotEqual([], accounts)
283+
result = self.app.acquire_token_silent_with_error(
284+
[self.scope_that_requires_no_managed_device], account=accounts[0])
285+
self.assertEqual(
286+
"Bearer", result.get("token_type"), "Unexpected result: %s" % result)
287+
self.assertIsNotNone(result.get("access_token"))
288+
289+
273290
THIS_FOLDER = os.path.dirname(__file__)
274291
CONFIG = os.path.join(THIS_FOLDER, "config.json")
275292
@unittest.skipUnless(os.path.exists(CONFIG), "Optional %s not found" % CONFIG)

0 commit comments

Comments
 (0)