Skip to content
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

[ACR] Fixing credential_scopes kwarg #19664

Merged
merged 7 commits into from
Jul 6, 2021

Conversation

seankane-msft
Copy link
Member

No description provided.

@seankane-msft
Copy link
Member Author

/azp run python - containerregistry - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@seankane-msft seankane-msft requested a review from benbp as a code owner July 6, 2021 13:40
@seankane-msft
Copy link
Member Author

/azp run python - containerregistry - tests-weekly

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@seankane-msft
Copy link
Member Author

/azp run python - containerregistry - tests-weekly

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@@ -139,6 +169,9 @@ def test_update_repository_properties(self, containerregistry_anonregistry_endpo

@acr_preparer()
def test_update_tag_properties(self, containerregistry_anonregistry_endpoint):
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can do a pytest.mark.skipif instead, even though you're looking at a self parameter

Copy link
Member Author

Choose a reason for hiding this comment

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

I get a NameError: name 'self' is not defined if I do this, also the parameter is passed in by the preparer so it wouldn't be available either.

@@ -43,13 +43,12 @@ def __init__(self, endpoint, credential, **kwargs):
if not endpoint.startswith("https://") and not endpoint.startswith("http://"):
endpoint = "https://" + endpoint
self._endpoint = endpoint
self.credential_scope = kwargs.get("authentication_scope", "https://management.core.windows.net/.default")
self.credential_scopes = kwargs.get("credential_scopes", ["https://management.core.windows.net/.default"])
Copy link
Member

Choose a reason for hiding this comment

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

should this be a private attr?

Copy link
Member Author

Choose a reason for hiding this comment

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

It probably should, but the ExchangeClient models are not exposed publicly

@@ -74,7 +73,7 @@ def get_refresh_token(self, service, **kwargs):
def exchange_aad_token_for_refresh_token(self, service=None, **kwargs):
# type: (str, Dict[str, Any]) -> str
refresh_token = self._client.authentication.exchange_aad_access_token_for_acr_refresh_token(
service=service, access_token=self._credential.get_token(self.credential_scope).token, **kwargs
service=service, access_token=self._credential.get_token(*self.credential_scopes).token, **kwargs
Copy link
Member

Choose a reason for hiding this comment

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

Is credential_scopes an iterable (the name implies that it is)? If so, does the keyword paramtype need to be updated from str to something like List[str]?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it should be a List[str].

Copy link
Member

@swathipil swathipil left a comment

Choose a reason for hiding this comment

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

lgtm

@seankane-msft seankane-msft merged commit 43b7b8c into Azure:main Jul 6, 2021
@seankane-msft seankane-msft deleted the acr-credscope branch July 6, 2021 21:36
rakshith91 pushed a commit to rakshith91/azure-sdk-for-python that referenced this pull request Jul 16, 2021
* renaming kwarg and passing through

* fixing pylint issue

* removing unnecessary cred scopes kwarg pops

* adding tests for sovereign cloud

* fixing kwarg

* fixing invalid cred scope test

* mccoys comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants