-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Changes from all commits
d6a321c
4d94b42
95971ef
b10679f
67ffbdf
9f86091
eb9f20d
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 |
---|---|---|
|
@@ -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"]) | ||
self._client = ContainerRegistry( | ||
credential=credential, | ||
url=endpoint, | ||
sdk_moniker=USER_AGENT, | ||
authentication_policy=ExchangeClientAuthenticationPolicy(), | ||
credential_scopes=self.credential_scope, | ||
**kwargs | ||
) | ||
self._credential = credential | ||
|
@@ -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 | ||
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. Is 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. Yes, it should be a |
||
) | ||
return refresh_token.refresh_token | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,9 @@ | |
class TestContainerRegistryClient(ContainerRegistryTestClass): | ||
@acr_preparer() | ||
def test_list_repository_names(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -40,6 +43,9 @@ def test_list_repository_names(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_list_repository_names_by_page(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -63,6 +69,9 @@ def test_list_repository_names_by_page(self, containerregistry_anonregistry_endp | |
|
||
@acr_preparer() | ||
def test_get_repository_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -73,6 +82,9 @@ def test_get_repository_properties(self, containerregistry_anonregistry_endpoint | |
|
||
@acr_preparer() | ||
def test_list_manifest_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -84,6 +96,9 @@ def test_list_manifest_properties(self, containerregistry_anonregistry_endpoint) | |
|
||
@acr_preparer() | ||
def test_get_manifest_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -95,6 +110,9 @@ def test_get_manifest_properties(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_list_tag_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -106,6 +124,9 @@ def test_list_tag_properties(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_delete_repository(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -114,6 +135,9 @@ def test_delete_repository(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_delete_tag(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -122,6 +146,9 @@ def test_delete_tag(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_delete_manifest(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
assert client._credential is None | ||
|
||
|
@@ -130,6 +157,9 @@ def test_delete_manifest(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_update_repository_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
|
||
properties = client.get_repository_properties(HELLO_WORLD) | ||
|
@@ -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): | ||
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. I think you can do a 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. I get a |
||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
|
||
properties = client.get_tag_properties(HELLO_WORLD, "latest") | ||
|
@@ -148,9 +181,12 @@ def test_update_tag_properties(self, containerregistry_anonregistry_endpoint): | |
|
||
@acr_preparer() | ||
def test_update_manifest_properties(self, containerregistry_anonregistry_endpoint): | ||
if not self.is_public_endpoint(containerregistry_anonregistry_endpoint): | ||
pytest.skip("Not a public endpoint") | ||
|
||
client = self.create_anon_client(containerregistry_anonregistry_endpoint) | ||
|
||
properties = client.get_manifest_properties(HELLO_WORLD, "latest") | ||
|
||
with pytest.raises(ClientAuthenticationError): | ||
client.update_manifest_properties(HELLO_WORLD, "latest", properties, can_delete=True) | ||
client.update_manifest_properties(HELLO_WORLD, "latest", properties, can_delete=True) |
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.
should this be a private attr?
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.
It probably should, but the
ExchangeClient
models are not exposed publicly