-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Core] Add 2020-09-01-hybrid API profile for AzureStack #15096
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
43c4cec
Adding 2020-09-01-hybrid API profile for AzureStack
abbhar 41e0fb8
fixing Data_private_Keyvault & MGMT_resource_template loading issue
abbhar 5cc0e05
Fixing the CIfailure issue
abbhar f4fb50d
adding disk access version
abbhar fac8420
added gallary & resource feature versions
abbhar 1030401
adding storage,IOT & KV tests suppresion
abbhar 3a19f0c
fixing code integrity failure
abbhar 86b0873
reverting KV to older version
abbhar 187dc3c
vm kv, sa, testcase fixes
abbhar 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
4 changes: 4 additions & 0 deletions
4
src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/__init__.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,4 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- |
80 changes: 80 additions & 0 deletions
80
src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/_test_utils.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,80 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from os.path import exists | ||
abbhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import os | ||
| from OpenSSL import crypto | ||
|
|
||
|
|
||
| def _create_test_cert(cert_file, key_file, subject, valid_days, serial_number): | ||
| # create a key pair | ||
| k = crypto.PKey() | ||
| k.generate_key(crypto.TYPE_RSA, 2046) | ||
|
|
||
| # create a self-signed cert with some basic constraints | ||
| cert = crypto.X509() | ||
| cert.get_subject().CN = subject | ||
| cert.gmtime_adj_notBefore(-1 * 24 * 60 * 60) | ||
| cert.gmtime_adj_notAfter(valid_days * 24 * 60 * 60) | ||
| cert.set_version(2) | ||
| cert.set_serial_number(serial_number) | ||
| cert.add_extensions([ | ||
| crypto.X509Extension(b"basicConstraints", True, b"CA:TRUE, pathlen:1"), | ||
| crypto.X509Extension(b"subjectKeyIdentifier", False, b"hash", | ||
| subject=cert), | ||
| ]) | ||
| cert.add_extensions([ | ||
| crypto.X509Extension(b"authorityKeyIdentifier", False, b"keyid:always", | ||
| issuer=cert) | ||
| ]) | ||
| cert.set_issuer(cert.get_subject()) | ||
| cert.set_pubkey(k) | ||
| cert.sign(k, 'sha256') | ||
|
|
||
| cert_str = crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode('ascii') | ||
| key_str = crypto.dump_privatekey(crypto.FILETYPE_PEM, k).decode('ascii') | ||
|
|
||
| open(cert_file, 'w').write(cert_str) | ||
| open(key_file, 'w').write(key_str) | ||
|
|
||
|
|
||
| def _delete_test_cert(cert_file, key_file, verification_file): | ||
| if exists(cert_file) and exists(key_file): | ||
| os.remove(cert_file) | ||
| os.remove(key_file) | ||
|
|
||
| if exists(verification_file): | ||
| os.remove(verification_file) | ||
|
|
||
|
|
||
| def _create_verification_cert(cert_file, key_file, verification_file, nonce, valid_days, serial_number): | ||
| if exists(cert_file) and exists(key_file): | ||
| # create a key pair | ||
| public_key = crypto.PKey() | ||
| public_key.generate_key(crypto.TYPE_RSA, 2046) | ||
|
|
||
| # open the root cert and key | ||
| signing_cert = crypto.load_certificate(crypto.FILETYPE_PEM, open(cert_file).read()) | ||
| k = crypto.load_privatekey(crypto.FILETYPE_PEM, open(key_file).read()) | ||
|
|
||
| # create a cert signed by the root | ||
| verification_cert = crypto.X509() | ||
| verification_cert.get_subject().CN = nonce | ||
| verification_cert.gmtime_adj_notBefore(-1 * 24 * 60 * 60) | ||
| verification_cert.gmtime_adj_notAfter(valid_days * 24 * 60 * 60) | ||
| verification_cert.set_version(2) | ||
| verification_cert.set_serial_number(serial_number) | ||
|
|
||
| verification_cert.set_pubkey(public_key) | ||
| verification_cert.set_issuer(signing_cert.get_subject()) | ||
| verification_cert.add_extensions([ | ||
| crypto.X509Extension(b"authorityKeyIdentifier", False, b"keyid:always", | ||
| issuer=signing_cert) | ||
| ]) | ||
| verification_cert.sign(k, 'sha256') | ||
|
|
||
| verification_cert_str = crypto.dump_certificate(crypto.FILETYPE_PEM, verification_cert).decode('ascii') | ||
|
|
||
| open(verification_file, 'w').write(verification_cert_str) | ||
46 changes: 46 additions & 0 deletions
46
src/azure-cli/azure/cli/command_modules/iot/tests/hybrid_2020_09_01/recording_processors.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,46 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from azure_devtools.scenario_tests import RecordingProcessor | ||
| from azure_devtools.scenario_tests.utilities import is_text_payload | ||
|
|
||
| MOCK_KEY = 'mock_key' | ||
|
|
||
|
|
||
| class KeyReplacer(RecordingProcessor): | ||
abbhar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def process_request(self, request): | ||
| if is_text_payload(request) and isinstance(request.body, bytes): | ||
| request.body = self._replace_byte_keys(request.body) | ||
| elif is_text_payload(request) and isinstance(request.body, str): | ||
| request.body = self._replace_string_keys(request.body) | ||
| return request | ||
|
|
||
| def process_response(self, response): | ||
| if is_text_payload(response) and response['body']['string']: | ||
| response['body']['string'] = self._replace_string_keys(response['body']['string']) | ||
| return response | ||
|
|
||
| # pylint: disable=no-self-use | ||
| def _replace_string_keys(self, val): | ||
| import re | ||
| if 'primaryKey' in val: | ||
| val = re.sub(r'"primaryKey":( ?)"([^"]+)"', r'"primaryKey":"{}"' | ||
| .format(MOCK_KEY), val, flags=re.IGNORECASE) | ||
| if 'secondaryKey' in val: | ||
| val = re.sub(r'"secondaryKey":( ?)"([^"]+)"', r'"secondaryKey":"{}"' | ||
| .format(MOCK_KEY), val, flags=re.IGNORECASE) | ||
| return val | ||
|
|
||
| # pylint: disable=no-self-use | ||
| def _replace_byte_keys(self, val): | ||
| import re | ||
| if b'primaryKey' in val: | ||
| val = re.sub(b'"primaryKey":( ?)"([^"]+)"', '"primaryKey":"{}"' | ||
| .format(MOCK_KEY).encode(), val, flags=re.IGNORECASE) | ||
| if b'secondaryKey' in val: | ||
| val = re.sub(b'"secondaryKey":( ?)"([^"]+)"', '"secondaryKey":"{}"' | ||
| .format(MOCK_KEY).encode(), val, flags=re.IGNORECASE) | ||
| return val | ||
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.