-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[Identity] CAE b1 #17070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Identity] CAE b1 #17070
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -298,7 +298,7 @@ def from_json(cls, json_str): | |
| 'AzureCloud', | ||
| endpoints=CloudEndpoints( | ||
| management='https://management.core.windows.net/', | ||
| resource_manager='https://management.azure.com/', | ||
| resource_manager='https://eastus2euap.management.azure.com/', | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using canary ARM endpoint causes CI failure: This can't be fixed because
|
||
| sql_management='https://management.core.windows.net:8443/', | ||
| batch_resource_id='https://batch.core.windows.net/', | ||
| gallery='https://gallery.azure.com/', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -214,6 +214,8 @@ def __init__(self, method_name): | |
| self.kwargs = {} | ||
| self.test_resources_count = 0 | ||
|
|
||
| patch_main_exception_handler(self) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Do the same for |
||
|
|
||
| def cmd(self, command, checks=None, expect_failure=False): | ||
| command = self._apply_kwargs(command) | ||
| return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from time import sleep | ||
|
|
||
| import jwt | ||
| from azure.cli.core.azclierror import AuthenticationError | ||
| from azure.cli.testsdk import LiveScenarioTest | ||
| from msrestazure.azure_exceptions import CloudError | ||
|
|
||
| ARM_URL = "https://eastus2euap.management.azure.com/" # ARM canary | ||
| ARM_RETRY_INTERVAL = 10 | ||
|
|
||
|
|
||
| class CAEScenarioTest(LiveScenarioTest): | ||
|
|
||
| def test_client_capabilities(self): | ||
| self.cmd('login') | ||
|
|
||
| # Verify the access token has CAE enabled | ||
| out = self.cmd('account get-access-token').get_output_in_json() | ||
| access_token = out['accessToken'] | ||
| decoded = jwt.decode(access_token, verify=False, algorithms=['RS256']) | ||
| self.assertEqual(decoded['xms_cc'], ['CP1']) # xms_cc: extension microsoft client capabilities | ||
| self.assertEqual(decoded['xms_ssm'], '1') # xms_ssm: extension microsoft smart session management | ||
|
|
||
| def _test_revoke_session(self, command, expected_error, checks=None): | ||
| self.test_client_capabilities() | ||
|
|
||
| # Test access token is working | ||
| self.cmd(command) | ||
|
|
||
| self._revoke_sign_in_sessions() | ||
|
|
||
| # CAE is currently only available in canary endpoint | ||
| # with mock.patch.object(self.cli_ctx.cloud.endpoints, "resource_manager", ARM_URL): | ||
| exit_code = 0 | ||
| with self.assertRaises(expected_error) as ex: | ||
| while exit_code == 0: | ||
| exit_code = self.cmd(command).exit_code | ||
| sleep(ARM_RETRY_INTERVAL) | ||
| if checks: | ||
| checks(ex.exception) | ||
|
|
||
| def test_revoke_session_track2(self): | ||
| def check_aad_error_code(ex): | ||
| self.assertIn('AADSTS50173', str(ex)) | ||
|
|
||
| self._test_revoke_session("storage account list", AuthenticationError, check_aad_error_code) | ||
|
|
||
| def test_revoke_session_track1(self): | ||
| def check_arm_error(ex): | ||
| self.assertEqual(ex.status_code, 401) | ||
| self.assertIsNotNone(ex.response.headers["WWW-Authenticate"]) | ||
|
|
||
| self._test_revoke_session('group list', CloudError, check_arm_error) | ||
|
|
||
| def _revoke_sign_in_sessions(self): | ||
| # Manually revoke sign in sessions | ||
| self.cmd('rest -m POST -u https://graph.microsoft.com/v1.0/me/revokeSignInSessions') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is continuous access evaluation just makes revoke happen before AT is expired. The statement can be "blocked by access policy" or "not meet the criteria to access this resource"