forked from ansible-collections/community.general
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
passwordstore: Add some real gopass integration tests (ansible-collec…
…tions#5030) * passwordstore: Add some real go tests This is work in progress. * passwordstore: Fix gopass init * Init gopass store in explicit path in integration test * passwordstore: Show versions of tools in integration test * passwordstore: Install gopass from different location on Debian Part of integration tests * passwordstore: Add changelog fragment for ansible-collections#5030 * passwordstore: Address review feedback
- Loading branch information
Showing
7 changed files
with
182 additions
and
148 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
125 changes: 125 additions & 0 deletions
125
tests/integration/targets/lookup_passwordstore/tasks/password_tests.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,125 @@ | ||
- name: Create a password ({{ backend }}) | ||
set_fact: | ||
newpass: "{{ lookup('community.general.passwordstore', 'test-pass length=8 create=yes', backend=backend) }}" | ||
|
||
- name: Fetch password from an existing file ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ lookup('community.general.passwordstore', 'test-pass', backend=backend) }}" | ||
|
||
- name: Verify password ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == newpass | ||
|
||
- name: Create a password with equal sign ({{ backend }}) | ||
set_fact: | ||
newpass: "{{ lookup('community.general.passwordstore', 'test-pass-equal userpass=SimpleSample= create=yes', backend=backend) }}" | ||
|
||
- name: Fetch a password with equal sign ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ lookup('community.general.passwordstore', 'test-pass-equal', backend=backend) }}" | ||
|
||
- name: Verify password ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == newpass | ||
|
||
- name: Create a password using missing=create ({{ backend }}) | ||
set_fact: | ||
newpass: "{{ lookup('community.general.passwordstore', 'test-missing-create missing=create length=8', backend=backend) }}" | ||
|
||
- name: Fetch password from an existing file ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ lookup('community.general.passwordstore', 'test-missing-create', backend=backend) }}" | ||
|
||
- name: Verify password ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == newpass | ||
|
||
- name: Fetch password from existing file using missing=empty ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ lookup('community.general.passwordstore', 'test-missing-create missing=empty', backend=backend) }}" | ||
|
||
- name: Verify password ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == newpass | ||
|
||
- name: Fetch password from non-existing file using missing=empty ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ query('community.general.passwordstore', 'test-missing-pass missing=empty', backend=backend) }}" | ||
|
||
- name: Verify password ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == [ none ] | ||
|
||
- name: Create the YAML password ({{ backend }}) | ||
command: "{{ backend }} insert -m -f test-yaml-pass" | ||
args: | ||
stdin: | | ||
testpassword | ||
key: | | ||
multi | ||
line | ||
- name: Fetch a password with YAML subkey ({{ backend }}) | ||
set_fact: | ||
readyamlpass: "{{ lookup('community.general.passwordstore', 'test-yaml-pass subkey=key', backend=backend) }}" | ||
|
||
- name: Read a yaml subkey ({{ backend }}) | ||
assert: | ||
that: | ||
- readyamlpass == 'multi\nline\n' | ||
|
||
- name: Create a non-YAML multiline file ({{ backend }}) | ||
command: "{{ backend }} insert -m -f test-multiline-pass" | ||
args: | ||
stdin: | | ||
testpassword | ||
random additional line | ||
- name: Fetch password from multiline file ({{ backend }}) | ||
set_fact: | ||
readyamlpass: "{{ lookup('community.general.passwordstore', 'test-multiline-pass', backend=backend) }}" | ||
|
||
- name: Multiline pass only returns first line ({{ backend }}) | ||
assert: | ||
that: | ||
- readyamlpass == 'testpassword' | ||
|
||
- name: Fetch all from multiline file ({{ backend }}) | ||
set_fact: | ||
readyamlpass: "{{ lookup('community.general.passwordstore', 'test-multiline-pass returnall=yes', backend=backend) }}" | ||
|
||
- name: Multiline pass returnall returns everything in the file ({{ backend }}) | ||
assert: | ||
that: | ||
- readyamlpass == 'testpassword\nrandom additional line\n' | ||
|
||
- name: Create a password in a folder ({{ backend }}) | ||
set_fact: | ||
newpass: "{{ lookup('community.general.passwordstore', 'folder/test-pass length=8 create=yes', backend=backend) }}" | ||
|
||
- name: Fetch password from folder ({{ backend }}) | ||
set_fact: | ||
readpass: "{{ lookup('community.general.passwordstore', 'folder/test-pass', backend=backend) }}" | ||
|
||
- name: Verify password from folder ({{ backend }}) | ||
assert: | ||
that: | ||
- readpass == newpass | ||
|
||
- name: Try to read folder as passname ({{ backend }}) | ||
set_fact: | ||
newpass: "{{ lookup('community.general.passwordstore', 'folder', backend=backend) }}" | ||
ignore_errors: true | ||
register: eval_error | ||
|
||
- name: Make sure reading folder as passname failed ({{ backend }}) | ||
assert: | ||
that: | ||
- eval_error is failed | ||
- '"passname folder not found" in eval_error.msg' | ||
when: backend != "gopass" # Remove this line once gopass backend can handle this |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
passwordstore_packages: | ||
- gopass | ||
- pass |
1 change: 1 addition & 0 deletions
1
tests/integration/targets/lookup_passwordstore/vars/Archlinux.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
passwordstore_packages: | ||
- gopass | ||
- pass |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
passwordstore_packages: | ||
- gopass | ||
- pass |
Oops, something went wrong.