Skip to content

Commit

Permalink
add create_token action test
Browse files Browse the repository at this point in the history
  • Loading branch information
cognifloyd committed Jan 27, 2021
1 parent f4e05cf commit 9fb8ab5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_action_create_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
class CreateTokenActionTestCase(VaultActionTestCase):
action_cls = VaultCreateTokenAction

# Use None here to avoid this error:
# "expiring root tokens cannot create non-expiring root tokens"
default_token_lease = None

def test_method(self):
action = self.get_action_instance(config=self.dummy_pack_config)
result = action.run(
Expand All @@ -19,3 +23,4 @@ def test_method(self):
# orphan=False,
# wrap_ttl=None,
)
assert result["auth"]["client_token"]
3 changes: 2 additions & 1 deletion tests/vault_action_tests_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class VaultActionTestCase(HvacIntegrationTestCase, BaseActionTestCase):
dummy_pack_config = None
secret_v1 = False
secret_v2 = False
default_token_lease = "1h"

# in setUp() and tearDown(), explicitly handle super()-like calls.
# - HvacIntegrationTestCase does not call super().
Expand Down Expand Up @@ -56,7 +57,7 @@ def build_dummy_pack_config(self, url="https://localhost:8200"):
# based on create_client() in hvac/tests/utils/__init__.py
server_cert_path = get_config_file_path("server-cert.pem")

token_result = self.client.create_token(lease="1h")
token_result = self.client.create_token(lease=self.default_token_lease)
token = token_result["auth"]["client_token"]

dummy_pack_config = {
Expand Down

0 comments on commit 9fb8ab5

Please sign in to comment.