-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ACR]
az acr create
: Add validation for registry name to support do…
…main name label (#30404)
- Loading branch information
1 parent
d978740
commit 3fb76a9
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_validators.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for license information. | ||
# -------------------------------------------------------------------------------------------- | ||
|
||
import unittest | ||
from types import SimpleNamespace | ||
from unittest.mock import Mock | ||
from azure.cli.core.cloud import HARD_CODED_CLOUD_LIST | ||
from azure.cli.command_modules.acr._validators import validate_registry_name | ||
|
||
class AcrValidatorsTests(unittest.TestCase): | ||
def test_registry_name_with_dnl_suffix(self): | ||
acr_supported_clouds = [cloud for cloud in HARD_CODED_CLOUD_LIST if cloud.name != 'AzureGermanCloud'] | ||
for hard_coded_cloud in acr_supported_clouds: | ||
namespace = SimpleNamespace( | ||
**{ | ||
"registry_name": "myacr-dnlhash123", | ||
} | ||
) | ||
cmd = Mock(cli_ctx=Mock(cloud=hard_coded_cloud)) | ||
validate_registry_name(cmd, namespace) | ||
self.assertEqual(namespace.registry_name, 'myacr') | ||
|
||
def test_registry_name_with_dnl_suffix_loginserver(self): | ||
namespace = SimpleNamespace( | ||
**{ | ||
"registry_name": "myacr-dnlhash123.azurecr.io", | ||
} | ||
) | ||
azure_public_cloud = HARD_CODED_CLOUD_LIST[0] | ||
cmd = Mock(cli_ctx=Mock(cloud=azure_public_cloud)) | ||
validate_registry_name(cmd, namespace) | ||
self.assertEqual(namespace.registry_name, 'myacr') | ||
|