Skip to content

Conversation

@Juliehzl
Copy link
Contributor

@Juliehzl Juliehzl commented Jul 2, 2020

Description

Testing Guide

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.


This checklist is used to make sure that common guidelines for a pull request are followed.

@Juliehzl Juliehzl requested a review from jsntcy July 3, 2020 05:49

@mock.patch('azure.cli.core._profile._load_tokens_from_file', autospec=True)
@mock.patch('msrestazure.azure_active_directory.MSIAuthentication', autospec=True)
@mock.patch('azure.cli.core._profile.MSIAuthenticationWrapper', autospec=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary? Won't it be nice to have MSIAuthenticationWrapper also tested?

Copy link
Member

@jiasli jiasli Jul 6, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mock.patch by default will create a MagicMock instance which can't be inherited, maybe using new=MSIAuthentication may work? Haven't tested.

Comment on lines 24 to 25
from azure.core.credentials import AccessToken
from msrestazure.azure_active_directory import MSIAuthentication
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delay these imports as they will cause significant latency on client-side commands.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about extracting MSIAuthenticationWrapper to src/azure-cli-core/azure/cli/core/adal_authentication.py and import it conditionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

try:
return AccessToken(token, int(full_token['expiresIn'] + time.time()))
except KeyError:
return AccessToken(token, int(full_token['expires_on']))
Copy link
Member

@jsntcy jsntcy Jul 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is for cloud shell? If yes, can we add comments so that others can understand the purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@yonzhan yonzhan added this to the S172 milestone Jul 3, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Jul 3, 2020

add to S172

@jiasli
Copy link
Member

jiasli commented Jul 6, 2020

Please specify what "login credentials issue" is.

is_windows, is_wsl
from azure.cli.core.cloud import get_active_cloud, set_cloud_subscription

from .adal_authentication import MSIAuthenticationWrapper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another problem with mock.patch is for this form of import, it won't work. After importing MSIAuthenticationWrapper, it becomes a local reference azure.cli.core._profile.MSIAuthenticationWrapper. See Where to patch.

@Juliehzl Juliehzl changed the title [Core] Fix login credentials issue for track 2 SDK [Core] Fix msi and cloud shell login credentials issue for track 2 SDK related commands Jul 9, 2020
@Juliehzl Juliehzl requested review from jiasli and jsntcy July 9, 2020 10:58
@Juliehzl Juliehzl changed the title [Core] Fix msi and cloud shell login credentials issue for track 2 SDK related commands [Core] Fix get_token() issue in msi login and expiresIn key error in cloud shell login credentials for track 2 SDK related commands Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants