-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Spring] certificate - Add argument --auto-sync and new command update
#6728
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
Merged
zhoxing-ms
merged 16 commits into
Azure:main
from
domainname:jeffhuang/certificate-auto-sync
Sep 12, 2023
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a4ce3f4
feat(certificate): Add argument `--auto-sync` in `az spring certifica…
domainname 420e9c7
Add new command `az spring certificate update` to update a certificate
domainname db206ff
update
domainname b1d4e62
update
domainname 35fecca
rename to --enable-auto-sync
domainname 22164de
add help
domainname 6a6abae
add UT
domainname b55720c
add UT
domainname df74187
update
domainname a106a44
fix UTs
domainname b5f413b
Merge branch 'main' into jeffhuang/certificate-auto-sync
domainname 302d072
Change type of autoSync
domainname 58c5309
update version
domainname 15c9fba
fix UT
domainname 80631cb
remove redundant options_list
domainname c9ddb7b
revert version
domainname File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
76 changes: 76 additions & 0 deletions
76
src/spring/azext_spring/tests/latest/test_asa_certificate.py
This file contains hidden or 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,76 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
| import unittest | ||
| import os | ||
| from ...vendored_sdks.appplatform.v2023_09_01_preview import models | ||
| from ..._utils import _get_sku_name | ||
| from ...custom import (certificate_add, certificate_update) | ||
| try: | ||
| import unittest.mock as mock | ||
| except ImportError: | ||
| from unittest import mock | ||
|
|
||
| from azure.cli.core.mock import DummyCli | ||
| from azure.cli.core import AzCommandsLoader | ||
| from azure.cli.core.commands import AzCliCommand | ||
|
|
||
| from knack.log import get_logger | ||
|
|
||
| logger = get_logger(__name__) | ||
| TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) | ||
|
|
||
| def _get_test_cmd(): | ||
| cli_ctx = DummyCli() | ||
| cli_ctx.data['subscription_id'] = '00000000-0000-0000-0000-000000000000' | ||
| loader = AzCommandsLoader(cli_ctx, resource_type='Microsoft.AppPlatform') | ||
| cmd = AzCliCommand(loader, 'test', None) | ||
| cmd.command_kwargs = {'resource_type': 'Microsoft.AppPlatform'} | ||
| cmd.cli_ctx = cli_ctx | ||
| return cmd | ||
|
|
||
|
|
||
| class BasicTest(unittest.TestCase): | ||
| def _get_basic_mock_client(self, sku='Standard'): | ||
| client = mock.MagicMock() | ||
| client.services.get.return_value = models.ServiceResource( | ||
| sku=models.Sku( | ||
| tier=sku, | ||
| name=_get_sku_name(sku) | ||
| ) | ||
| ) | ||
| return client | ||
|
|
||
|
|
||
| class CertificateTests(BasicTest): | ||
|
|
||
| def test_create_certificate(self): | ||
| client = self._get_basic_mock_client() | ||
| certificate_add(_get_test_cmd(), client, 'rg', 'asc', 'my-cert', | ||
| False, "vault-uri", "kv-cert-name") | ||
| args = client.certificates.begin_create_or_update.call_args_list | ||
| self.assertEqual(1, len(args)) | ||
| self.assertEqual(4, len(args[0][0])) | ||
| self.assertEqual(('rg', 'asc', 'my-cert'), args[0][0][0:3]) | ||
| resource = args[0][0][3] | ||
| self.assertEqual('vault-uri', resource.properties.vault_uri) | ||
| self.assertEqual('kv-cert-name', resource.properties.key_vault_cert_name) | ||
|
|
||
| def test_update_certificate(self): | ||
| client = self._get_basic_mock_client() | ||
| client.certificates.get.return_value = models.CertificateResource( | ||
| properties=models.KeyVaultCertificateProperties( | ||
| type="KeyVaultCertificate", | ||
| vault_uri="vault-uri", | ||
| key_vault_cert_name="kv-cert-name", | ||
| exclude_private_key=False, | ||
| auto_sync="Disabled") | ||
| ) | ||
| certificate_update(_get_test_cmd(), client, 'rg', 'asc', 'my-cert', True) | ||
| args = client.certificates.begin_create_or_update.call_args_list | ||
| self.assertEqual(1, len(args)) | ||
| self.assertEqual(4, len(args[0][0])) | ||
| self.assertEqual(('rg', 'asc', 'my-cert'), args[0][0][0:3]) | ||
| resource = args[0][0][3] | ||
| self.assertEqual("Enabled", resource.properties.auto_sync) |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.