-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
158 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
tests/integration/targets/auth_approle/tasks/approle_test_revocation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
- name: "Test block" | ||
module_defaults: | ||
community.hashi_vault.vault_read: | ||
url: '{{ ansible_hashi_vault_url }}' | ||
auth_method: 'approle' | ||
mount_point: '{{ this_path }}' | ||
role_id: '{{ role_id_cmd.result.data.role_id | default(omit) }}' | ||
secret_id: "{{ secret_id_cmd.result.data.secret_id | default(omit) }}" | ||
block: | ||
- name: 'Fetch the RoleID of the AppRole' | ||
vault_ci_read: | ||
path: 'auth/{{ this_path }}/role/{{ approle_name }}/role-id' | ||
register: role_id_cmd | ||
|
||
- name: 'Get a SecretID issued against the AppRole' | ||
vault_ci_write: | ||
path: 'auth/{{ this_path }}/role/{{ approle_name }}/secret-id' | ||
data: {} | ||
register: secret_id_cmd | ||
|
||
- name: Read token information using plugin | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
revoke_ephemeral_token: "{{ revoke_token }}" | ||
register: token_info | ||
|
||
- name: Check if token can still be used | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
token: '{{ token_info.data.data.id }}' | ||
auth_method: token | ||
ignore_errors: true | ||
register: token_check | ||
|
||
- assert: | ||
fail_msg: "A token from vault_read was unexpectedly (un-)usable" | ||
that: | ||
- token_check is failed or not revoke_token | ||
- token_check is not failed or revoke_token | ||
|
||
- name: Read token information using lookup | ||
set_fact: | ||
token: "{{ lookup('community.hashi_vault.vault_read', 'auth/token/lookup-self', auth_method='approle', mount_point=this_path, url=ansible_hashi_vault_url, role_id=role_id_cmd.result.data.role_id, secret_id=secret_id_cmd.result.data.secret_id, revoke_ephemeral_token=revoke_token) }}" | ||
|
||
- name: Check if token can still be used | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
token: '{{ token.data.id }}' | ||
auth_method: token | ||
ignore_errors: true | ||
register: token_check | ||
|
||
- assert: | ||
fail_msg: "A token from vault_read was unexpectedly (un-)usable" | ||
that: | ||
- token_check is failed or not revoke_token | ||
- token_check is not failed or revoke_token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
tests/integration/targets/auth_token/tasks/token_test_revocation.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
- name: "Test block" | ||
module_defaults: | ||
community.hashi_vault.vault_read: | ||
url: '{{ ansible_hashi_vault_url }}' | ||
auth_method: token | ||
vars: | ||
user_token: '{{ user_token_cmd.result.auth.client_token }}' | ||
block: | ||
# the token auth method never has ephemeral tokens, so we expect all tokens | ||
# to continue to be usable even if `revoke_ephemeral_token` is set to true. | ||
- name: Read token information using plugin | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
token: "{{ user_token }}" | ||
revoke_ephemeral_token: "{{ revoke_token }}" | ||
register: token_info | ||
|
||
- name: Check if token can still be used | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
# note: we cannot use token_info.data.data.id here, because that is | ||
# identical to the `token` parameter, which is no log, so it is | ||
# replaced with the verbatim string | ||
# `VALUE_SPECIFIED_IN_NO_LOG_PARAMETER` (for better or worse). | ||
token: '{{ user_token }}' | ||
auth_method: token | ||
|
||
- name: Read token information using lookup | ||
set_fact: | ||
_: "{{ lookup('community.hashi_vault.vault_read', 'auth/token/lookup-self', auth_method='token', token=user_token, url=ansible_hashi_vault_url, revoke_ephemeral_token=revoke_token) }}" | ||
|
||
- name: Check if token can still be used | ||
community.hashi_vault.vault_read: | ||
path: "auth/token/lookup-self" | ||
token: '{{ user_token }}' | ||
auth_method: token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters