Skip to content

Commit

Permalink
[Key Vault] Target multiple API versions with tests (certificates) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyp authored Apr 8, 2021
1 parent 8fe589d commit 58a1c0d
Show file tree
Hide file tree
Showing 167 changed files with 96,915 additions and 19,727 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
-e ../../identity/azure-identity
-e ../azure-mgmt-keyvault
../azure-keyvault-nspkg
aiohttp>=3.0; python_version >= '3.5'
aiohttp>=3.0; python_version >= '3.5'
parameterized>=0.7.3
35 changes: 35 additions & 0 deletions sdk/keyvault/azure-keyvault-certificates/tests/_test_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from azure.keyvault.certificates._shared import HttpChallengeCache
from azure.keyvault.certificates._shared.client_base import DEFAULT_VERSION
from devtools_testutils import AzureTestCase
from parameterized import parameterized
import pytest


def suffixed_test_name(testcase_func, param_num, param):
return "{}_{}".format(testcase_func.__name__, parameterized.to_safe_name(param.kwargs.get("api_version")))


class CertificatesTestCase(AzureTestCase):
def tearDown(self):
HttpChallengeCache.clear()
assert len(HttpChallengeCache._cache) == 0
super(CertificatesTestCase, self).tearDown()

def create_client(self, vault_uri, **kwargs):
if kwargs.pop("is_async", False):
from azure.keyvault.certificates.aio import CertificateClient
credential = self.get_credential(CertificateClient, is_async=True)
else:
from azure.keyvault.certificates import CertificateClient
credential = self.get_credential(CertificateClient)
return self.create_client_from_credential(
CertificateClient, credential=credential, vault_url=vault_uri, **kwargs
)

def _skip_if_not_configured(self, api_version, **kwargs):
if self.is_live and api_version != DEFAULT_VERSION:
pytest.skip("This test only uses the default API version for live tests")

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
Content-Type:
- application/json
User-Agent:
- azsdk-python-keyvault-certificates/4.3.0b1 Python/3.5.3 (Windows-10-10.0.19041-SP0)
method: PUT
uri: https://vaultname.vault.azure.net/certificates/contacts?api-version=2016-10-01
response:
body:
string: '{"error":{"code":"Unauthorized","message":"Request is missing a Bearer
or PoP token."}}'
headers:
cache-control:
- no-cache
content-length:
- '87'
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Mar 2021 21:27:04 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000;includeSubDomains
www-authenticate:
- Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
resource="https://vault.azure.net"
x-content-type-options:
- nosniff
x-ms-keyvault-network-info:
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
x-ms-keyvault-region:
- eastus2
x-ms-keyvault-service-version:
- 1.2.205.0
x-powered-by:
- ASP.NET
status:
code: 401
message: Unauthorized
- request:
body: '{"contacts": [{"phone": "1111111111", "name": "John Doe", "email": "[email protected]"},
{"phone": "2222222222", "name": "John Doe2", "email": "[email protected]"}]}'
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '166'
Content-Type:
- application/json
User-Agent:
- azsdk-python-keyvault-certificates/4.3.0b1 Python/3.5.3 (Windows-10-10.0.19041-SP0)
method: PUT
uri: https://vaultname.vault.azure.net/certificates/contacts?api-version=2016-10-01
response:
body:
string: '{"id":"https://vaultname.vault.azure.net/certificates/contacts","contacts":[{"email":"[email protected]","name":"John
Doe","phone":"1111111111"},{"email":"[email protected]","name":"John Doe2","phone":"2222222222"}]}'
headers:
cache-control:
- no-cache
content-length:
- '220'
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Mar 2021 21:27:04 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000;includeSubDomains
x-content-type-options:
- nosniff
x-ms-keyvault-network-info:
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
x-ms-keyvault-region:
- eastus2
x-ms-keyvault-service-version:
- 1.2.205.0
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-keyvault-certificates/4.3.0b1 Python/3.5.3 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://vaultname.vault.azure.net/certificates/contacts?api-version=2016-10-01
response:
body:
string: '{"id":"https://vaultname.vault.azure.net/certificates/contacts","contacts":[{"email":"[email protected]","name":"John
Doe","phone":"1111111111"},{"email":"[email protected]","name":"John Doe2","phone":"2222222222"}]}'
headers:
cache-control:
- no-cache
content-length:
- '220'
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Mar 2021 21:27:04 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000;includeSubDomains
x-content-type-options:
- nosniff
x-ms-keyvault-network-info:
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
x-ms-keyvault-region:
- eastus2
x-ms-keyvault-service-version:
- 1.2.205.0
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
User-Agent:
- azsdk-python-keyvault-certificates/4.3.0b1 Python/3.5.3 (Windows-10-10.0.19041-SP0)
method: DELETE
uri: https://vaultname.vault.azure.net/certificates/contacts?api-version=2016-10-01
response:
body:
string: '{"id":"https://vaultname.vault.azure.net/certificates/contacts","contacts":[{"email":"[email protected]","name":"John
Doe","phone":"1111111111"},{"email":"[email protected]","name":"John Doe2","phone":"2222222222"}]}'
headers:
cache-control:
- no-cache
content-length:
- '220'
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Mar 2021 21:27:05 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000;includeSubDomains
x-content-type-options:
- nosniff
x-ms-keyvault-network-info:
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
x-ms-keyvault-region:
- eastus2
x-ms-keyvault-service-version:
- 1.2.205.0
x-powered-by:
- ASP.NET
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- azsdk-python-keyvault-certificates/4.3.0b1 Python/3.5.3 (Windows-10-10.0.19041-SP0)
method: GET
uri: https://vaultname.vault.azure.net/certificates/contacts?api-version=2016-10-01
response:
body:
string: '{"error":{"code":"ContactsNotFound","message":"Contacts not found"}}'
headers:
cache-control:
- no-cache
content-length:
- '68'
content-type:
- application/json; charset=utf-8
date:
- Mon, 22 Mar 2021 21:27:05 GMT
expires:
- '-1'
pragma:
- no-cache
strict-transport-security:
- max-age=31536000;includeSubDomains
x-content-type-options:
- nosniff
x-ms-keyvault-network-info:
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
x-ms-keyvault-region:
- eastus2
x-ms-keyvault-service-version:
- 1.2.205.0
x-powered-by:
- ASP.NET
status:
code: 404
message: Not Found
version: 1
Loading

0 comments on commit 58a1c0d

Please sign in to comment.