Skip to content

Commit 8a96b2c

Browse files
committed
Add tests, fix up methods
1 parent 54e477b commit 8a96b2c

9 files changed

+822
-10
lines changed

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ._shared import KeyVaultClientBase
99
from ._shared.exceptions import error_map as _error_map
1010
from ._shared._polling import DeleteRecoverPollingMethod, KeyVaultOperationPoller
11-
from ._models import DeletedKey, KeyVaultKey, KeyProperties, KeyRotationLifetimeAction, KeyRotationPolicy, RandomBytes, ReleaseKeyResult
11+
from ._models import DeletedKey, KeyVaultKey, KeyProperties, KeyRotationPolicy, RandomBytes, ReleaseKeyResult
1212

1313
try:
1414
from typing import TYPE_CHECKING
@@ -729,7 +729,7 @@ def get_random_bytes(self, count, **kwargs):
729729
return RandomBytes(value=result.value)
730730

731731
@distributed_trace
732-
async def get_key_rotation_policy(self, name, **kwargs):
732+
def get_key_rotation_policy(self, name, **kwargs):
733733
# type: (str, **Any) -> Optional[KeyRotationPolicy]
734734
"""Get the rotation policy of a Key Vault key.
735735
@@ -781,15 +781,15 @@ def update_key_rotation_policy(self, name, **kwargs):
781781
if lifetime_actions:
782782
lifetime_actions = [
783783
self._models.LifetimeActions(
784-
action=action.action,
784+
action=self._models.LifetimeActionsType(type=action.action),
785785
trigger=self._models.LifetimeActionsTrigger(
786786
time_after_create=action.time_after_create, time_before_expiry=action.time_before_expiry
787787
),
788788
)
789789
for action in lifetime_actions
790790
]
791791

792-
attributes = self._models.KeyRotationPolicyAttributes(expiry_time=kwargs.pop("exires_in", None))
792+
attributes = self._models.KeyRotationPolicyAttributes(expiry_time=kwargs.pop("expires_in", None))
793793
policy = self._models.KeyRotationPolicy(lifetime_actions=lifetime_actions, attributes=attributes)
794794
result = self._client.update_key_rotation_policy(
795795
vault_base_url=self._vault_url, key_name=name, key_rotation_policy=policy

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def _from_generated(cls, lifetime_action):
311311
class KeyRotationPolicy(object):
312312
"""The key rotation policy that belongs to a key.
313313
314-
:ivar str policy_id: The identifier of the key rotation policy.
314+
:ivar str id: The identifier of the key rotation policy.
315315
:ivar lifetime_actions: Actions that will be performed by Key Vault over the lifetime of a key.
316316
:type lifetime_actions: list[~azure.keyvault.keys.KeyRotationLifetimeAction]
317317
:ivar str expires_in: The expiry time of the policy that will be applied on new key versions, defined as an ISO

sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/_client.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
DeletedKey,
1616
JsonWebKey,
1717
KeyProperties,
18-
KeyRotationLifetimeAction,
1918
KeyRotationPolicy,
2019
KeyVaultKey,
2120
RandomBytes,
@@ -763,15 +762,15 @@ async def update_key_rotation_policy(self, name: str, **kwargs: "Any") -> KeyRot
763762
if lifetime_actions:
764763
lifetime_actions = [
765764
self._models.LifetimeActions(
766-
action=action.action,
765+
action=self._models.LifetimeActionsType(type=action.action),
767766
trigger=self._models.LifetimeActionsTrigger(
768767
time_after_create=action.time_after_create, time_before_expiry=action.time_before_expiry
769768
),
770769
)
771770
for action in lifetime_actions
772771
]
773772

774-
attributes = self._models.KeyRotationPolicyAttributes(expiry_time=kwargs.pop("exires_in", None))
773+
attributes = self._models.KeyRotationPolicyAttributes(expiry_time=kwargs.pop("expires_in", None))
775774
policy = self._models.KeyRotationPolicy(lifetime_actions=lifetime_actions, attributes=attributes)
776775
result = await self._client.update_key_rotation_policy(
777776
vault_base_url=self._vault_url, key_name=name, key_rotation_policy=policy
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
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+
Content-Type:
14+
- application/json
15+
User-Agent:
16+
- azsdk-python-keyvault-keys/4.5.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0)
17+
method: POST
18+
uri: https://vaultname.vault.azure.net/keys/livekvtestrotation-key1cff14c0/create?api-version=7.3-preview
19+
response:
20+
body:
21+
string: '{"error":{"code":"Unauthorized","message":"AKV10000: Request is missing
22+
a Bearer or PoP token."}}'
23+
headers:
24+
cache-control:
25+
- no-cache
26+
content-length:
27+
- '97'
28+
content-type:
29+
- application/json; charset=utf-8
30+
date:
31+
- Tue, 28 Sep 2021 00:38:10 GMT
32+
expires:
33+
- '-1'
34+
pragma:
35+
- no-cache
36+
strict-transport-security:
37+
- max-age=31536000;includeSubDomains
38+
www-authenticate:
39+
- Bearer authorization="https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47",
40+
resource="https://vault.azure.net"
41+
x-content-type-options:
42+
- nosniff
43+
x-ms-keyvault-network-info:
44+
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
45+
x-ms-keyvault-region:
46+
- westus
47+
x-ms-keyvault-service-version:
48+
- 1.9.79.2
49+
x-powered-by:
50+
- ASP.NET
51+
status:
52+
code: 401
53+
message: Unauthorized
54+
- request:
55+
body: '{"kty": "RSA"}'
56+
headers:
57+
Accept:
58+
- application/json
59+
Accept-Encoding:
60+
- gzip, deflate
61+
Connection:
62+
- keep-alive
63+
Content-Length:
64+
- '14'
65+
Content-Type:
66+
- application/json
67+
User-Agent:
68+
- azsdk-python-keyvault-keys/4.5.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0)
69+
method: POST
70+
uri: https://vaultname.vault.azure.net/keys/livekvtestrotation-key1cff14c0/create?api-version=7.3-preview
71+
response:
72+
body:
73+
string: '{"key":{"kid":"https://vaultname.vault.azure.net/keys/livekvtestrotation-key1cff14c0/8d038a3884a24dc997ef9d529debf31a","kty":"RSA","key_ops":["encrypt","decrypt","sign","verify","wrapKey","unwrapKey"],"n":"1aJXI-PznJu_7RfGmgUSvqRptbKTYSWOpEDJQShmUHOy8ri9TlC0r6vZ0Ek21dj6gpWpnxu91-0-IVOaLn4RRBl74OlcRiSGzzbXdVaRwTS9-GAbq7DfXKVP0ZSm37fexkPtrqk94uOqsybGbjUgJ2CF645b7yJAfcpqiQmx4i7NTriie1rH4CzXq5YaecOPw9fwZEh4Wqup6gl2mdAGAjZW72LCWsIvAccJLp2DQ4ZBJ-qMltWwKnMcDPMDRtOemo6FaZW41BKqCQy-e0fdHIWhyWp0GkqylJ3OumWAg50P3PjevWT_rltPovwcvOy4upvS4IEkKDJHVJFujE32fQ","e":"AQAB"},"attributes":{"enabled":true,"created":1632789491,"updated":1632789491,"recoveryLevel":"Recoverable+Purgeable","recoverableDays":90}}'
74+
headers:
75+
cache-control:
76+
- no-cache
77+
content-length:
78+
- '698'
79+
content-type:
80+
- application/json; charset=utf-8
81+
date:
82+
- Tue, 28 Sep 2021 00:38:10 GMT
83+
expires:
84+
- '-1'
85+
pragma:
86+
- no-cache
87+
strict-transport-security:
88+
- max-age=31536000;includeSubDomains
89+
x-content-type-options:
90+
- nosniff
91+
x-ms-keyvault-network-info:
92+
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
93+
x-ms-keyvault-region:
94+
- westus
95+
x-ms-keyvault-service-version:
96+
- 1.9.79.2
97+
x-powered-by:
98+
- ASP.NET
99+
status:
100+
code: 200
101+
message: OK
102+
- request:
103+
body: null
104+
headers:
105+
Accept:
106+
- application/json
107+
Accept-Encoding:
108+
- gzip, deflate
109+
Connection:
110+
- keep-alive
111+
Content-Length:
112+
- '0'
113+
User-Agent:
114+
- azsdk-python-keyvault-keys/4.5.0b4 Python/3.9.0 (Windows-10-10.0.19041-SP0)
115+
method: POST
116+
uri: https://vaultname.vault.azure.net/keys/livekvtestrotation-key1cff14c0/rotate?api-version=7.3-preview
117+
response:
118+
body:
119+
string: '{"key":{"kid":"https://vaultname.vault.azure.net/keys/livekvtestrotation-key1cff14c0/7d2cb7c5012d41bd87ff36c5fa845cfc","kty":"RSA","key_ops":["encrypt","decrypt","sign","verify","wrapKey","unwrapKey"],"n":"wB5MHXYWo2l-8yOrk4bjheXi95VicMvJpSDInALbtMd6V9IzanKUKHoFD7sUrx5vBeApR07Vww9WPPWr-wAMQ8d6z7-qby7xF5SCWCZNWCXmKotUI9WH-ExRmZGzWCkbvsDE4fEh-uDLqh55-tGZSJMJRkc9DDl97_kdJyPILbwoQjQrAHghQJSC9JonWOS70GfTBKoIdgJrxKimHi61OnGDEIqnCuUbQmv9C3P_bNYMpV53F8M4Yxtcjmv_epiEh33rWtPXm-0S_kLbO3Ln0EoM09CaW1h5d3OdR9qy7r1YycpIaBHJHoF9LAbCUUTO8zUEDCKJglkfCmtRrZnL9Q","e":"AQAB"},"attributes":{"enabled":true,"created":1632789491,"updated":1632789491,"recoveryLevel":"Recoverable+Purgeable","recoverableDays":90}}'
120+
headers:
121+
cache-control:
122+
- no-cache
123+
content-length:
124+
- '698'
125+
content-type:
126+
- application/json; charset=utf-8
127+
date:
128+
- Tue, 28 Sep 2021 00:38:11 GMT
129+
expires:
130+
- '-1'
131+
pragma:
132+
- no-cache
133+
strict-transport-security:
134+
- max-age=31536000;includeSubDomains
135+
x-content-type-options:
136+
- nosniff
137+
x-ms-keyvault-network-info:
138+
- conn_type=Ipv4;addr=172.92.159.124;act_addr_fam=InterNetwork;
139+
x-ms-keyvault-region:
140+
- westus
141+
x-ms-keyvault-service-version:
142+
- 1.9.79.2
143+
x-powered-by:
144+
- ASP.NET
145+
status:
146+
code: 200
147+
message: OK
148+
version: 1

0 commit comments

Comments
 (0)