-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Key Vault] Test keys library against a shared vault #16474
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 7 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6ae6485
Add test resource creation scripts and gitignore
mccoyp f041790
Add synchronous test resource cleanup script
mccoyp 0a1fc8f
Add functionality to shared test case classes
mccoyp c84d934
Refactor test_key_client.py to work with PowerShellPreparer
mccoyp 02e4717
Remove MHSM URL fetching for this PR
mccoyp d8c7872
Update tests.yml to run resource creation script
mccoyp d9de9fc
Set hsm=True since KV SKU is premium
mccoyp 8c7b238
Target async KeyClient in test_case_async.py
mccoyp 0bce125
Refactor tests_keys_async.py
mccoyp 78e80d8
Move client creation out of KeyVaultTestCase
mccoyp bbe8be7
Call load_dotenv in test-resources-cleanup.py
mccoyp de9ba74
Refactor crypto client tests
mccoyp f3918c9
Refactor crypto example tests
mccoyp dca8d65
Refactor sample tests
mccoyp 8fcb360
Add test recordings
mccoyp a1d32eb
Refactor test_parse_id.py
mccoyp 03b4bb5
create_client -> create_key_client in test_crypto_*.py
mccoyp 07935a6
Show KeyType enum in test_samples_*.py
mccoyp 184da0c
Remove cryptic test comment
mccoyp 117fb78
create_client -> create_key_client in example tests
mccoyp 5f21866
Clear HttpChallengeCache in test_crypto_client.py
mccoyp 130c4c6
wip
mccoyp 82c8d3e
Re-record to fix weird URL breaking
mccoyp 70fefd4
Re-record all tests
mccoyp 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| *.cer | ||
| *.key | ||
| *.pfx |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import os | ||
mccoyp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| from azure.identity import ClientSecretCredential | ||
| from azure.keyvault.certificates import CertificateClient | ||
| from azure.keyvault.keys import KeyClient | ||
| from azure.keyvault.secrets import SecretClient | ||
|
|
||
mccoyp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if "AZURE_KEYVAULT_URL" not in os.environ: | ||
| raise EnvironmentError("Missing a Key Vault URL") | ||
| if "KEYVAULT_TENANT_ID" not in os.environ: | ||
| raise EnvironmentError("Missing a tenant ID for Key Vault") | ||
| if "KEYVAULT_CLIENT_ID" not in os.environ: | ||
| raise EnvironmentError("Missing a client ID for Key Vault") | ||
| if "KEYVAULT_CLIENT_SECRET" not in os.environ: | ||
| raise EnvironmentError("Missing a client secret for Key Vault") | ||
|
|
||
| credential = ClientSecretCredential( | ||
| tenant_id=os.environ.get("KEYVAULT_TENANT_ID"), | ||
| client_id=os.environ.get("KEYVAULT_CLIENT_ID"), | ||
| client_secret=os.environ.get("KEYVAULT_CLIENT_SECRET") | ||
mccoyp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| if "AZURE_KEYVAULT_URL" in os.environ: | ||
mccoyp marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| cert_client = CertificateClient(os.environ.get("AZURE_KEYVAULT_URL"), credential) | ||
| key_client = KeyClient(os.environ.get("AZURE_KEYVAULT_URL"), credential) | ||
| secret_client = SecretClient(os.environ.get("AZURE_KEYVAULT_URL"), credential) | ||
|
|
||
| test_certificates = [c for c in cert_client.list_properties_of_certificates() if c.name.startswith("livekvtest")] | ||
| for certificate in test_certificates: | ||
| cert_client.begin_delete_certificate(certificate.name).wait() | ||
| deleted_test_certificates = [c for c in cert_client.list_deleted_certificates() if c.name.startswith("livekvtest")] | ||
| for certificate in deleted_test_certificates: | ||
| cert_client.purge_deleted_certificate(certificate.name) | ||
|
|
||
| test_keys = [k for k in key_client.list_properties_of_keys() if k.name.startswith("livekvtest")] | ||
| for key in test_keys: | ||
| key_client.begin_delete_key(key.name).wait() | ||
| deleted_test_keys = [k for k in key_client.list_deleted_keys() if k.name.startswith("livekvtest")] | ||
| for key in deleted_test_keys: | ||
| key_client.purge_deleted_key(key.name) | ||
|
|
||
| test_secrets = [s for s in secret_client.list_properties_of_secrets() if s.name.startswith("livekvtest")] | ||
| for secret in test_secrets: | ||
| secret_client.begin_delete_secret(secret.name).wait() | ||
| deleted_test_secrets = [s for s in secret_client.list_deleted_secrets() if s.name.startswith("livekvtest")] | ||
| for secret in deleted_test_secrets: | ||
| secret_client.purge_deleted_secret(secret.name) | ||
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.