mirror of
https://github.com/ansible/awx.git
synced 2026-02-17 19:20:05 -03:30
Fix an issue where smtplib can't handle unicode strings
We probably do get this value as unicode originally but when we store it, due to a recently fixed bug it will come out as *not* unicode. So things were accidentally working because py2 smtplib uses hmac which won't accept unicode. This change adds a flag to encrypt_field that forces it to skip the utf8 fixup from before for narrow use cases.
This commit is contained in:
@@ -29,6 +29,14 @@ def test_encrypt_field_with_unicode_string():
|
||||
assert common.decrypt_field(field, 'value') == value
|
||||
|
||||
|
||||
def test_encrypt_field_force_disable_unicode():
|
||||
value = u"NothingSpecial"
|
||||
field = Setting(value=value)
|
||||
encrypted = field.value = common.encrypt_field(field, 'value', skip_utf8=True)
|
||||
assert "UTF8" not in encrypted
|
||||
assert common.decrypt_field(field, 'value') == value
|
||||
|
||||
|
||||
def test_encrypt_subfield():
|
||||
field = Setting(value={'name': 'ANSIBLE'})
|
||||
encrypted = field.value = common.encrypt_field(field, 'value', subfield='name')
|
||||
|
||||
Reference in New Issue
Block a user