mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
password lookup plugin, with working tests and documentation
This commit is contained in:
@@ -172,20 +172,20 @@ class TestPlaybook(unittest.TestCase):
|
||||
print utils.jsonify(actual, format=True)
|
||||
expected = {
|
||||
"localhost": {
|
||||
"changed": 9,
|
||||
"changed": 16,
|
||||
"failures": 0,
|
||||
"ok": 14,
|
||||
"ok": 21,
|
||||
"skipped": 1,
|
||||
"unreachable": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print "**EXPECTED**"
|
||||
print utils.jsonify(expected, format=True)
|
||||
|
||||
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
|
||||
|
||||
print "len(EVENTS) = %d" % len(EVENTS)
|
||||
assert len(EVENTS) == 60
|
||||
assert len(EVENTS) == 74
|
||||
|
||||
def test_includes(self):
|
||||
pb = os.path.join(self.test_dir, 'playbook-includer.yml')
|
||||
@@ -201,14 +201,14 @@ class TestPlaybook(unittest.TestCase):
|
||||
"ok": 10,
|
||||
"skipped": 0,
|
||||
"unreachable": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
print "**EXPECTED**"
|
||||
print utils.jsonify(expected, format=True)
|
||||
|
||||
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
|
||||
|
||||
def test_playbook_vars(self):
|
||||
def test_playbook_vars(self):
|
||||
test_callbacks = TestCallbacks()
|
||||
playbook = ansible.playbook.PlayBook(
|
||||
playbook=os.path.join(self.test_dir, 'test_playbook_vars', 'playbook.yml'),
|
||||
|
||||
@@ -55,3 +55,25 @@
|
||||
action: copy src=sample.j2 dest=/tmp/ansible-test-with_lines-data
|
||||
- name: cleanup test file
|
||||
action: file path=/tmp/ansible-test-with_lines-data state=absent
|
||||
|
||||
# password lookup plugin
|
||||
- name: ensure test file doesn't exist
|
||||
# command because file will return differently
|
||||
action: command rm -f /tmp/ansible-test-with_password
|
||||
- name: test LOOKUP and PASSWORD with non existing password file
|
||||
action: command test "$LOOKUP(password, /tmp/ansible-test-with_password)" = "$PASSWORD(/tmp/ansible-test-with_password)"
|
||||
- name: test LOOKUP and PASSWORD with existing password file
|
||||
action: command test "$LOOKUP(password, /tmp/ansible-test-with_password)" = "$PASSWORD(/tmp/ansible-test-with_password)"
|
||||
- name: now test existing password via $item and with_password
|
||||
action: command test "$PASSWORD(/tmp/ansible-test-with_password)" = "$item"
|
||||
with_password:
|
||||
- /tmp/ansible-test-with_password
|
||||
- name: cleanup test file
|
||||
action: file path=/tmp/ansible-test-with_password state=absent
|
||||
- name: now test a password of non-default length (default=20, but here length=8)
|
||||
action: command test "$PASSWORD(/tmp/ansible-test-with_password length=8)" = "$LOOKUP(password, /tmp/ansible-test-with_password)"
|
||||
# - name: did we really create a password of length=8?
|
||||
# action: command test "`expr length $PASSWORD(/tmp/ansible-test-with_password)`" = "8"
|
||||
- name: cleanup test file, again
|
||||
action: file path=/tmp/ansible-test-with_password state=absent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user