summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Likins <alikins@redhat.com>2017-01-04 12:17:19 -0500
committerBrian Coca <brian.coca+git@gmail.com>2017-01-04 12:17:38 -0500
commit22f7ca8c979677fac043f021fb98f06eb4299f73 (patch)
tree260d58a86aa8cafb3d8ab28acd86af5bb4a936fc /test
parenta0a2392c879c4e940c08fd1b448f32406e4aab7d (diff)
downloadansible-22f7ca8c979677fac043f021fb98f06eb4299f73.tar.gz
Add a encode() to AnsibleVaultEncryptedUnicode (#19840)
* Add a encode() to AnsibleVaultEncryptedUnicode Without it, calling encode() on it results in a bytestring of the encrypted !vault-encrypted string. ssh connection plugin triggers this if ansible_password is from a var using !vault-encrypted. That path ends up calling .encode() instead of using the __str__. Fixes #19795 * Fix str.encode() errors on py2.6 py2.6 str.encode() does not take keyword arguments. (cherry picked from commit c771ab34c7fd1c3b66c3d2fff2124c668679644e)
Diffstat (limited to 'test')
-rw-r--r--test/units/parsing/yaml/test_objects.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/units/parsing/yaml/test_objects.py b/test/units/parsing/yaml/test_objects.py
index a7af0a19bc..3ef72a3b44 100644
--- a/test/units/parsing/yaml/test_objects.py
+++ b/test/units/parsing/yaml/test_objects.py
@@ -121,6 +121,15 @@ class TestAnsibleVaultEncryptedUnicode(unittest.TestCase, YamlTestUtils):
avu = self._from_plaintext(seq)
self.assert_values(avu,seq)
+ def test_unicode_from_plaintext_encode(self):
+ seq = u'some text here'
+ avu = self._from_plaintext(seq)
+ b_avu = avu.encode('utf-8', 'strict')
+ self.assertIsInstance(avu, objects.AnsibleVaultEncryptedUnicode)
+ self.assertEquals(b_avu, seq.encode('utf-8', 'strict'))
+ self.assertTrue(avu.vault is self.vault)
+ self.assertIsInstance(avu.vault, vault.VaultLib)
+
# TODO/FIXME: make sure bad password fails differently than 'thats not encrypted'
def test_empty_string_wrong_password(self):
seq = ''