From 060001b08d98969217156b2b696613ade44eb8c5 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Tue, 23 Jan 2018 19:02:09 +0100 Subject: [PATCH] Remove deprecated code (#34828) * Remove compat code for to_unicode, to_str and to_bytes Code was marked as deprecated and to be removed after 2.4 * Remove is_encrypted and is_encrypted_file Code was marked as deprecated after 2.4 release. --- lib/ansible/parsing/vault/__init__.py | 20 --------------- lib/ansible/utils/unicode.py | 35 ++------------------------ test/units/parsing/vault/test_vault.py | 5 ---- 3 files changed, 2 insertions(+), 58 deletions(-) diff --git a/lib/ansible/parsing/vault/__init__.py b/lib/ansible/parsing/vault/__init__.py index c9a54ae3e7..cca3164763 100644 --- a/lib/ansible/parsing/vault/__init__.py +++ b/lib/ansible/parsing/vault/__init__.py @@ -600,26 +600,6 @@ class VaultLib: self.cipher_name = None self.b_version = b'1.2' - @staticmethod - def is_encrypted(data): - """ Test if this is vault encrypted data - - :arg data: a byte or text string or a python3 to test for whether it is - recognized as vault encrypted data - :returns: True if it is recognized. Otherwise, False. - """ - - # This could in the future, check to see if the data is a vault blob and - # is encrypted with a key associated with this vault - # instead of just checking the format. - display.deprecated(u'vault.VaultLib.is_encrypted is deprecated. Use vault.is_encrypted instead', version='2.4') - return is_encrypted(data) - - @staticmethod - def is_encrypted_file(file_obj): - display.deprecated(u'vault.VaultLib.is_encrypted_file is deprecated. Use vault.is_encrypted_file instead', version='2.4') - return is_encrypted_file(file_obj) - def encrypt(self, plaintext, secret=None, vault_id=None): """Vault encrypt a piece of data. diff --git a/lib/ansible/utils/unicode.py b/lib/ansible/utils/unicode.py index dbd3ec1e7c..29a52237a6 100644 --- a/lib/ansible/utils/unicode.py +++ b/lib/ansible/utils/unicode.py @@ -19,41 +19,10 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -from ansible.module_utils._text import to_bytes as _to_bytes, to_text, to_native - -try: - from __main__ import display -except ImportError: - from ansible.utils.display import Display - display = Display() +from ansible.module_utils._text import to_text -__all__ = ('to_bytes', 'to_unicode', 'to_str', 'unicode_wrap') - - -# Backwards compat - -def to_bytes(*args, **kwargs): - display.deprecated(u'ansible.utils.unicode.to_bytes is deprecated. Use ansible.module_utils._text.to_bytes instead', version=u'2.4') - if 'errors' not in kwargs: - kwargs['errors'] = 'replace' - return _to_bytes(*args, **kwargs) - - -def to_unicode(*args, **kwargs): - display.deprecated(u'ansible.utils.unicode.to_unicode is deprecated. Use ansible.module_utils._text.to_text instead', version=u'2.4') - if 'errors' not in kwargs: - kwargs['errors'] = 'replace' - return to_text(*args, **kwargs) - - -def to_str(*args, **kwargs): - display.deprecated(u'ansible.utils.unicode.to_str is deprecated. Use ansible.module_utils._text.to_native instead', version=u'2.4') - if 'errors' not in kwargs: - kwargs['errors'] = 'replace' - return to_native(*args, **kwargs) - -# End Backwards compat +__all__ = ('unicode_wrap') def unicode_wrap(func, *args, **kwargs): diff --git a/test/units/parsing/vault/test_vault.py b/test/units/parsing/vault/test_vault.py index efbc5527f9..5d06aaa516 100644 --- a/test/units/parsing/vault/test_vault.py +++ b/test/units/parsing/vault/test_vault.py @@ -708,11 +708,6 @@ class TestVaultLib(unittest.TestCase): v.encrypt, plaintext) - def test_is_encrypted(self): - self.assertFalse(self.v.is_encrypted(b"foobar"), msg="encryption check on plaintext yielded false positive") - b_data = b"$ANSIBLE_VAULT;9.9;TEST\n%s" % hexlify(b"ansible") - self.assertTrue(self.v.is_encrypted(b_data), msg="encryption check on headered text failed") - def test_format_vaulttext_envelope(self): cipher_name = "TEST" b_ciphertext = b"ansible"