-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for newly added file_mode option.
- Loading branch information
1 parent
bbdb3ec
commit 18a6b92
Showing
5 changed files
with
38 additions
and
0 deletions.
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
1 change: 1 addition & 0 deletions
1
tests/conjur_variable/test_cases/retrieve-variable-into-file/env
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 @@ | ||
export CONJUR_CERT_FILE=./conjur.pem |
14 changes: 14 additions & 0 deletions
14
tests/conjur_variable/test_cases/retrieve-variable-into-file/playbook.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,14 @@ | ||
--- | ||
- name: Retrieve Conjur variable into file | ||
hosts: localhost | ||
connection: local | ||
tasks: | ||
- name: Clean artifact path | ||
file: | ||
state: absent | ||
path: /conjur_secret_path.txt | ||
|
||
- name: Retrieve Conjur variable into file using file_mode option | ||
vars: | ||
secret_path: "{{lookup('conjur_variable', 'ansible/test-secret-in-file', file_mode=True)}}" | ||
shell: echo "{{secret_path}}" > /conjur_secret_path.txt |
21 changes: 21 additions & 0 deletions
21
tests/conjur_variable/test_cases/retrieve-variable-into-file/tests/test_default.py
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,21 @@ | ||
from __future__ import (absolute_import, division, print_function) | ||
|
||
__metaclass__ = type | ||
|
||
import os | ||
import testinfra.utils.ansible_runner | ||
|
||
testinfra_hosts = [os.environ['COMPOSE_PROJECT_NAME'] + '_ansible_1'] | ||
|
||
|
||
def test_retrieved_secret(host): | ||
secret_path_file = host.file('/conjur_secret_path.txt') | ||
assert secret_path_file.exists | ||
|
||
secret_path = host.check_output("cat /conjur_secret_path.txt", shell=True) | ||
secret_file = host.file(secret_path) | ||
assert secret_file.exists | ||
assert secret_file.mode == 0o600 | ||
|
||
secret = host.check_output("cat {0}".format(secret_path), shell=True) | ||
assert secret == "test_secret_in_file_password" |