summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2023-03-27 10:22:18 -0400
committerGitHub <noreply@github.com>2023-03-27 10:22:18 -0400
commit0fd88717c953b92ed8a50495d55e630eb5d59166 (patch)
tree8db74aeaf3a4df0b25244c3d5a95d7a9dc587ab8 /test
parent016b7f71b10539c90ddbb3246f19f9cbf0e65428 (diff)
downloadansible-0fd88717c953b92ed8a50495d55e630eb5d59166.tar.gz
password lookup, handle ident properly when saved (#80251)
* password lookup, handle ident properly when saved Currently we format and save ident when present but we didn't account for this when reading the saved file Also added some more robust error handling.
Diffstat (limited to 'test')
-rw-r--r--test/units/plugins/lookup/test_password.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/units/plugins/lookup/test_password.py b/test/units/plugins/lookup/test_password.py
index 39aa8b9a7b..1caec33e56 100644
--- a/test/units/plugins/lookup/test_password.py
+++ b/test/units/plugins/lookup/test_password.py
@@ -330,23 +330,34 @@ class TestRandomPassword(unittest.TestCase):
class TestParseContent(unittest.TestCase):
def test_empty_password_file(self):
- plaintext_password, salt = password._parse_content(u'')
+ plaintext_password, salt, ident = password._parse_content(u'')
self.assertEqual(plaintext_password, u'')
self.assertEqual(salt, None)
+ self.assertEqual(ident, None)
def test(self):
expected_content = u'12345678'
file_content = expected_content
- plaintext_password, salt = password._parse_content(file_content)
+ plaintext_password, salt, ident = password._parse_content(file_content)
self.assertEqual(plaintext_password, expected_content)
self.assertEqual(salt, None)
+ self.assertEqual(ident, None)
def test_with_salt(self):
expected_content = u'12345678 salt=87654321'
file_content = expected_content
- plaintext_password, salt = password._parse_content(file_content)
+ plaintext_password, salt, ident = password._parse_content(file_content)
self.assertEqual(plaintext_password, u'12345678')
self.assertEqual(salt, u'87654321')
+ self.assertEqual(ident, None)
+
+ def test_with_salt_and_ident(self):
+ expected_content = u'12345678 salt=87654321 ident=2a'
+ file_content = expected_content
+ plaintext_password, salt, ident = password._parse_content(file_content)
+ self.assertEqual(plaintext_password, u'12345678')
+ self.assertEqual(salt, u'87654321')
+ self.assertEqual(ident, u'2a')
class TestFormatContent(unittest.TestCase):