summaryrefslogtreecommitdiff
path: root/test/units/plugins/lookup/test_password.py
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2023-04-17 12:56:37 -0400
committerGitHub <noreply@github.com>2023-04-17 11:56:37 -0500
commitba487253bb91f42b6385c0194ee2ccc387d3c499 (patch)
treef69cc1e7563cf35d6710eec7a11e2754791e18cc /test/units/plugins/lookup/test_password.py
parentd5a36b8734077de524c1bb090d6179278c1187d6 (diff)
downloadansible-ba487253bb91f42b6385c0194ee2ccc387d3c499.tar.gz
password lookup, handle ident properly when saved (#80251) (#80310)
* 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. (cherry picked from commit 0fd88717c953b92ed8a50495d55e630eb5d59166) * fix try block indent# https://chris.beams.io/posts/git-commit/ * clog (cherry picked from commit 97c8da77838e93b416c5e700abafa89a8383e950) * fix bad merge indentation
Diffstat (limited to 'test/units/plugins/lookup/test_password.py')
-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 15207b2f39..318bc10ba6 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):