Skip to content

Commit

Permalink
Add new field auto_rotate_period on transit key management (#903)
Browse files Browse the repository at this point in the history
* Add new field `auto_rotate-period` on transit key management

* Add new field auto_rotate-period on transit key management

Signed-off-by: Sébastien GLON <sebastien.glon@ubble.ai>

* Apply suggestions from code review

---------

Signed-off-by: Sébastien GLON <sebastien.glon@ubble.ai>
Co-authored-by: Sébastien GLON <sebastien.glon@ubble.ai>
Co-authored-by: Brian Scholer <1260690+briantist@users.noreply.github.com>
  • Loading branch information
3 people committed Feb 19, 2023
1 parent d46c0b1 commit d7e9557
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions hvac/api/secrets_engines/transit.py
Expand Up @@ -22,6 +22,7 @@ def create_key(
allow_plaintext_backup=None,
key_type=None,
mount_point=DEFAULT_MOUNT_POINT,
auto_rotate_period=None,
):
"""Create a new named encryption key of the specified type.
Expand Down Expand Up @@ -59,6 +60,8 @@ def create_key(
:type key_type: str | unicode
:param mount_point: The "path" the method/backend was mounted on.
:type mount_point: str | unicode
:param auto_rotate_period: The period at which this key should be rotated automatically. Requires Vault 1.10.x or higher.
:type auto_rotate_period: str | unicode
:return: The response of the request.
:rtype: requests.Response
"""
Expand All @@ -81,6 +84,7 @@ def create_key(
"exportable": exportable,
"allow_plaintext_backup": allow_plaintext_backup,
"type": key_type,
"auto_rotate_period": auto_rotate_period,
}
)
api_path = utils.format_url(
Expand Down Expand Up @@ -171,6 +175,7 @@ def update_key_configuration(
exportable=None,
allow_plaintext_backup=None,
mount_point=DEFAULT_MOUNT_POINT,
auto_rotate_period=None,
):
"""Tune configuration values for a given key.
Expand Down Expand Up @@ -201,6 +206,8 @@ def update_key_configuration(
:type allow_plaintext_backup: bool
:param mount_point: The "path" the method/backend was mounted on.
:type mount_point: str | unicode
:param auto_rotate_period: The period at which this key should be rotated automatically. Requires Vault 1.10.x or higher.
:type auto_rotate_period: str | unicode
:return: The response of the request.
:rtype: requests.Response
"""
Expand All @@ -219,6 +226,7 @@ def update_key_configuration(
"deletion_allowed": deletion_allowed,
"exportable": exportable,
"allow_plaintext_backup": allow_plaintext_backup,
"auto_rotate_period": auto_rotate_period,
}
)
api_path = utils.format_url(
Expand Down
5 changes: 4 additions & 1 deletion tests/integration_tests/api/secrets_engines/test_transit.py
Expand Up @@ -28,9 +28,12 @@ def tearDown(self):
param(
"success",
),
param("auto rotate period field", auto_rotate_period="1h"),
]
)
def test_create_key(self, label, raises=False, exception_message=""):
def test_create_key(
self, label, raises=False, auto_rotate_period=None, exception_message=""
):
key_name = "testkey"
if raises:
with self.assertRaises(raises) as cm:
Expand Down

0 comments on commit d7e9557

Please sign in to comment.