Skip to content

Commit 3b390a4

Browse files
committed
working on ansible and tests
1 parent 485c402 commit 3b390a4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/test_cases/ansible.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import click
2+
import os
3+
import random
4+
import string
5+
6+
from click.testing import CliRunner
7+
from click_types.ansible import AnsibleVaultParamType as vault
8+
9+
10+
sec_env = 'TEST_VAULT_PASSPHRASE'
11+
key_path = 'key.subkey.subsubkey'
12+
vault_file = '/tmp/xyz.yml'
13+
os.environ[sec_env] = ''.join(random.SystemRandom().choice(string.ascii_letters + string.digits) for _ in range(10))
14+
15+
runner = CliRunner()
16+
17+
18+
@click.command()
19+
def vault_wrapper():
20+
click.prompt('value please', type=vault(vault_file, sec_env, key_path))
21+
22+
23+
def test_create_value():
24+
response = runner.invoke(vault_wrapper, input='initial value')
25+
assert response.exit_code == 0
26+
27+
28+
def test_update_value():
29+
response = runner.invoke(vault_wrapper, input='updated value')
30+
assert response.exit_code == 0
31+
32+
33+
if __name__ == "__main__":
34+
vault_wrapper()

0 commit comments

Comments
 (0)