From 578da9a615072231593daca1a01caaa21a03856e Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Mon, 17 Oct 2016 01:14:57 +0200 Subject: [PATCH] Enable test for lookups on python 3 Since passlib algo sometime takes a bytes, and sometime not, depending on a internal variable, we have to convert bnased on it, or it fail with "TypeError: salt must be bytes, not str" (or unicode instead of bytes) However, that's not great to use internal structure for that. --- lib/ansible/utils/encrypt.py | 4 +++- test/utils/shippable/python3-test-tag-blacklist.txt | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/encrypt.py b/lib/ansible/utils/encrypt.py index 1ef6e29c48..c88387050d 100644 --- a/lib/ansible/utils/encrypt.py +++ b/lib/ansible/utils/encrypt.py @@ -67,7 +67,7 @@ except ImportError: from ansible import constants as C from ansible.errors import AnsibleError -from ansible.module_utils._text import to_text +from ansible.module_utils._text import to_text, to_native __all__ = ['do_encrypt'] @@ -84,6 +84,8 @@ def do_encrypt(result, encrypt, salt_size=None, salt=None): if salt_size: result = crypt.encrypt(result, salt_size=salt_size) elif salt: + if not crypt._salt_is_bytes: + salt = to_native(salt) result = crypt.encrypt(result, salt=salt) else: result = crypt.encrypt(result) diff --git a/test/utils/shippable/python3-test-tag-blacklist.txt b/test/utils/shippable/python3-test-tag-blacklist.txt index e749c6bb28..f4874eaafe 100644 --- a/test/utils/shippable/python3-test-tag-blacklist.txt +++ b/test/utils/shippable/python3-test-tag-blacklist.txt @@ -1,7 +1,6 @@ test_filters test_git test_hg -test_lookups test_pip test_service test_uri