Skip to content

Commit 0920f67

Browse files
committed
add tests
1 parent 6448005 commit 0920f67

6 files changed

+386
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '0'
13+
User-Agent:
14+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
15+
method: GET
16+
uri: https://vaultname.vault.azure.net/deletedcertificates?api-version=2016-10-01
17+
response:
18+
body:
19+
string: '{"error":{"code":"Unauthorized","message":"Request is missing a Bearer
20+
or PoP token."}}'
21+
headers:
22+
cache-control:
23+
- no-cache
24+
content-length:
25+
- '87'
26+
content-type:
27+
- application/json; charset=utf-8
28+
date:
29+
- Mon, 17 Aug 2020 19:36:32 GMT
30+
expires:
31+
- '-1'
32+
pragma:
33+
- no-cache
34+
strict-transport-security:
35+
- max-age=31536000;includeSubDomains
36+
www-authenticate:
37+
- Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
38+
resource="https://vault.azure.net"
39+
x-aspnet-version:
40+
- 4.0.30319
41+
x-content-type-options:
42+
- nosniff
43+
x-ms-keyvault-network-info:
44+
- conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
45+
x-ms-keyvault-region:
46+
- westus
47+
x-ms-keyvault-service-version:
48+
- 1.1.31.4
49+
x-powered-by:
50+
- ASP.NET
51+
status:
52+
code: 401
53+
message: Unauthorized
54+
- request:
55+
body: null
56+
headers:
57+
Accept:
58+
- application/json
59+
Accept-Encoding:
60+
- gzip, deflate
61+
Connection:
62+
- keep-alive
63+
User-Agent:
64+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
65+
method: GET
66+
uri: https://vaultname.vault.azure.net/deletedcertificates?api-version=2016-10-01
67+
response:
68+
body:
69+
string: '{"value":[],"nextLink":null}'
70+
headers:
71+
cache-control:
72+
- no-cache
73+
content-length:
74+
- '28'
75+
content-type:
76+
- application/json; charset=utf-8
77+
date:
78+
- Mon, 17 Aug 2020 19:36:32 GMT
79+
expires:
80+
- '-1'
81+
pragma:
82+
- no-cache
83+
strict-transport-security:
84+
- max-age=31536000;includeSubDomains
85+
x-aspnet-version:
86+
- 4.0.30319
87+
x-content-type-options:
88+
- nosniff
89+
x-ms-keyvault-network-info:
90+
- conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
91+
x-ms-keyvault-region:
92+
- westus
93+
x-ms-keyvault-service-version:
94+
- 1.1.31.4
95+
x-powered-by:
96+
- ASP.NET
97+
status:
98+
code: 200
99+
message: OK
100+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Accept-Encoding:
8+
- gzip, deflate
9+
Connection:
10+
- keep-alive
11+
Content-Length:
12+
- '0'
13+
User-Agent:
14+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
15+
method: GET
16+
uri: https://vaultname.vault.azure.net/certificates?api-version=2016-10-01
17+
response:
18+
body:
19+
string: '{"error":{"code":"Unauthorized","message":"Request is missing a Bearer
20+
or PoP token."}}'
21+
headers:
22+
cache-control:
23+
- no-cache
24+
content-length:
25+
- '87'
26+
content-type:
27+
- application/json; charset=utf-8
28+
date:
29+
- Mon, 17 Aug 2020 19:37:14 GMT
30+
expires:
31+
- '-1'
32+
pragma:
33+
- no-cache
34+
strict-transport-security:
35+
- max-age=31536000;includeSubDomains
36+
www-authenticate:
37+
- Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
38+
resource="https://vault.azure.net"
39+
x-aspnet-version:
40+
- 4.0.30319
41+
x-content-type-options:
42+
- nosniff
43+
x-ms-keyvault-network-info:
44+
- conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
45+
x-ms-keyvault-region:
46+
- westus
47+
x-ms-keyvault-service-version:
48+
- 1.1.31.4
49+
x-powered-by:
50+
- ASP.NET
51+
status:
52+
code: 401
53+
message: Unauthorized
54+
- request:
55+
body: null
56+
headers:
57+
Accept:
58+
- application/json
59+
Accept-Encoding:
60+
- gzip, deflate
61+
Connection:
62+
- keep-alive
63+
User-Agent:
64+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
65+
method: GET
66+
uri: https://vaultname.vault.azure.net/certificates?api-version=2016-10-01
67+
response:
68+
body:
69+
string: '{"value":[],"nextLink":null}'
70+
headers:
71+
cache-control:
72+
- no-cache
73+
content-length:
74+
- '28'
75+
content-type:
76+
- application/json; charset=utf-8
77+
date:
78+
- Mon, 17 Aug 2020 19:37:14 GMT
79+
expires:
80+
- '-1'
81+
pragma:
82+
- no-cache
83+
strict-transport-security:
84+
- max-age=31536000;includeSubDomains
85+
x-aspnet-version:
86+
- 4.0.30319
87+
x-content-type-options:
88+
- nosniff
89+
x-ms-keyvault-network-info:
90+
- conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
91+
x-ms-keyvault-region:
92+
- westus
93+
x-ms-keyvault-service-version:
94+
- 1.1.31.4
95+
x-powered-by:
96+
- ASP.NET
97+
status:
98+
code: 200
99+
message: OK
100+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Content-Length:
8+
- '0'
9+
User-Agent:
10+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
11+
method: GET
12+
uri: https://vaultname.vault.azure.net/deletedcertificates?api-version=2016-10-01
13+
response:
14+
body:
15+
string: '{"error":{"code":"Unauthorized","message":"Request is missing a Bearer
16+
or PoP token."}}'
17+
headers:
18+
cache-control: no-cache
19+
content-length: '87'
20+
content-type: application/json; charset=utf-8
21+
date: Mon, 17 Aug 2020 19:37:55 GMT
22+
expires: '-1'
23+
pragma: no-cache
24+
strict-transport-security: max-age=31536000;includeSubDomains
25+
www-authenticate: Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
26+
resource="https://vault.azure.net"
27+
x-aspnet-version: 4.0.30319
28+
x-content-type-options: nosniff
29+
x-ms-keyvault-network-info: conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
30+
x-ms-keyvault-region: westus
31+
x-ms-keyvault-service-version: 1.1.31.4
32+
x-powered-by: ASP.NET
33+
status:
34+
code: 401
35+
message: Unauthorized
36+
url: https://gtyp2gvo4xhgqxdbkjjn2mg3.vault.azure.net/deletedcertificates?api-version=2016-10-01
37+
- request:
38+
body: null
39+
headers:
40+
Accept:
41+
- application/json
42+
User-Agent:
43+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
44+
method: GET
45+
uri: https://vaultname.vault.azure.net/deletedcertificates?api-version=2016-10-01
46+
response:
47+
body:
48+
string: '{"value":[],"nextLink":null}'
49+
headers:
50+
cache-control: no-cache
51+
content-length: '28'
52+
content-type: application/json; charset=utf-8
53+
date: Mon, 17 Aug 2020 19:37:55 GMT
54+
expires: '-1'
55+
pragma: no-cache
56+
strict-transport-security: max-age=31536000;includeSubDomains
57+
x-aspnet-version: 4.0.30319
58+
x-content-type-options: nosniff
59+
x-ms-keyvault-network-info: conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
60+
x-ms-keyvault-region: westus
61+
x-ms-keyvault-service-version: 1.1.31.4
62+
x-powered-by: ASP.NET
63+
status:
64+
code: 200
65+
message: OK
66+
url: https://gtyp2gvo4xhgqxdbkjjn2mg3.vault.azure.net/deletedcertificates?api-version=2016-10-01
67+
version: 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers:
5+
Accept:
6+
- application/json
7+
Content-Length:
8+
- '0'
9+
User-Agent:
10+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
11+
method: GET
12+
uri: https://vaultname.vault.azure.net/certificates?api-version=2016-10-01
13+
response:
14+
body:
15+
string: '{"error":{"code":"Unauthorized","message":"Request is missing a Bearer
16+
or PoP token."}}'
17+
headers:
18+
cache-control: no-cache
19+
content-length: '87'
20+
content-type: application/json; charset=utf-8
21+
date: Mon, 17 Aug 2020 19:38:37 GMT
22+
expires: '-1'
23+
pragma: no-cache
24+
strict-transport-security: max-age=31536000;includeSubDomains
25+
www-authenticate: Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
26+
resource="https://vault.azure.net"
27+
x-aspnet-version: 4.0.30319
28+
x-content-type-options: nosniff
29+
x-ms-keyvault-network-info: conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
30+
x-ms-keyvault-region: westus
31+
x-ms-keyvault-service-version: 1.1.31.4
32+
x-powered-by: ASP.NET
33+
status:
34+
code: 401
35+
message: Unauthorized
36+
url: https://gyyvzoaguftghkx4oqftoyev.vault.azure.net/certificates?api-version=2016-10-01
37+
- request:
38+
body: null
39+
headers:
40+
Accept:
41+
- application/json
42+
User-Agent:
43+
- azsdk-python-keyvault-certificates/4.2.1 Python/3.8.5 (macOS-10.13.6-x86_64-i386-64bit)
44+
method: GET
45+
uri: https://vaultname.vault.azure.net/certificates?api-version=2016-10-01
46+
response:
47+
body:
48+
string: '{"value":[],"nextLink":null}'
49+
headers:
50+
cache-control: no-cache
51+
content-length: '28'
52+
content-type: application/json; charset=utf-8
53+
date: Mon, 17 Aug 2020 19:38:38 GMT
54+
expires: '-1'
55+
pragma: no-cache
56+
strict-transport-security: max-age=31536000;includeSubDomains
57+
x-aspnet-version: 4.0.30319
58+
x-content-type-options: nosniff
59+
x-ms-keyvault-network-info: conn_type=Ipv4;addr=73.135.72.237;act_addr_fam=InterNetwork;
60+
x-ms-keyvault-region: westus
61+
x-ms-keyvault-service-version: 1.1.31.4
62+
x-powered-by: ASP.NET
63+
status:
64+
code: 200
65+
message: OK
66+
url: https://gyyvzoaguftghkx4oqftoyev.vault.azure.net/certificates?api-version=2016-10-01
67+
version: 1

sdk/keyvault/azure-keyvault-certificates/tests/test_certificates_client.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import json
77
import logging
88
import time
9+
import pytest
910

1011
from azure_devtools.scenario_tests import RecordingProcessor, RequestUrlNormalizer
1112

@@ -676,23 +677,34 @@ def test_get_certificate_version(self, client, **kwargs):
676677
assert version_properties.version == cert.properties.version
677678
assert version_properties.x509_thumbprint == cert.properties.x509_thumbprint
678679

679-
class _CustomHookPolicy(object):
680-
pass
681-
682-
@ResourceGroupPreparer(random_name_enabled=True)
683-
@KeyVaultPreparer()
684-
@KeyVaultClientPreparer(client_kwargs={"custom_hook_policy": _CustomHookPolicy()})
685-
def test_custom_hook_policy(self, client, **kwargs):
686-
assert isinstance(client._client._config.custom_hook_policy, CertificateClientTests._CustomHookPolicy)
687-
688680
@ResourceGroupPreparer(random_name_enabled=True)
689681
@KeyVaultPreparer()
690682
@KeyVaultClientPreparer(client_kwargs={"api_version": ApiVersion.V2016_10_01})
691683
def test_list_properties_of_certificates_2016_10_01(self, client, **kwargs):
692-
client.list_properties_of_certificates()
684+
[_ for _ in client.list_properties_of_certificates()]
685+
686+
with pytest.raises(NotImplementedError) as excinfo:
687+
[_ for _ in client.list_properties_of_certificates(include_pending=True)]
688+
689+
assert "The 'include_pending' parameter to `list_properties_of_certificates` is only available for API versions v7.0 and up" in str(excinfo.value)
693690

694691
@ResourceGroupPreparer(random_name_enabled=True)
695692
@KeyVaultPreparer()
696693
@KeyVaultClientPreparer(client_kwargs={"api_version": ApiVersion.V2016_10_01})
697694
def test_list_deleted_certificates_2016_10_01(self, client, **kwargs):
698-
client.list_deleted_certificates()
695+
696+
[_ for _ in client.list_deleted_certificates()]
697+
698+
with pytest.raises(NotImplementedError) as excinfo:
699+
[_ for _ in client.list_deleted_certificates(include_pending=True)]
700+
701+
assert "The 'include_pending' parameter to `list_deleted_certificates` is only available for API versions v7.0 and up" in str(excinfo.value)
702+
703+
class _CustomHookPolicy(object):
704+
pass
705+
706+
@ResourceGroupPreparer(random_name_enabled=True)
707+
@KeyVaultPreparer()
708+
@KeyVaultClientPreparer(client_kwargs={"custom_hook_policy": _CustomHookPolicy()})
709+
def test_custom_hook_policy(self, client, **kwargs):
710+
assert isinstance(client._client._config.custom_hook_policy, CertificateClientTests._CustomHookPolicy)

0 commit comments

Comments
 (0)