Python3 (#416)
* Fixing issue where decrypted credentials were not returning valid strings.
This commit is contained in:
parent
2d7a6ccf3c
commit
7e6278684c
|
@ -328,8 +328,8 @@ def test_create_certificate(issuer_plugin, authority, logged_in_admin):
|
|||
def test_create_csr():
|
||||
from lemur.certificates.service import create_csr
|
||||
|
||||
csr, private_key = create_csr(common_name='ACommonName', organization='test', organizational_unit='Meters', country='US',
|
||||
state='CA', location='Here', owner='joe@example.com')
|
||||
csr, private_key = create_csr(owner='joe@example.com', common_name='ACommonName', organization='test', organizational_unit='Meters', country='US',
|
||||
state='CA', location='Here')
|
||||
assert csr
|
||||
assert private_key
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ class Vault(types.TypeDecorator):
|
|||
|
||||
# we only support strings and they should be of type bytes for Fernet
|
||||
if not isinstance(value, six.string_types):
|
||||
return None
|
||||
return
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
value = bytes(value, 'utf8')
|
||||
|
@ -122,10 +122,12 @@ class Vault(types.TypeDecorator):
|
|||
|
||||
# if the value is not a string we aren't going to try to decrypt
|
||||
# it. this is for the case where the column is null
|
||||
if not isinstance(value, six.string_types):
|
||||
return None
|
||||
|
||||
# TODO this may raise an InvalidToken exception in certain
|
||||
# cases. Should we handle that?
|
||||
# https://cryptography.io/en/latest/fernet/#cryptography.fernet.Fernet.decrypt
|
||||
if not sys.version_info >= (3, 0):
|
||||
if not isinstance(value, six.string_types):
|
||||
return
|
||||
return MultiFernet(self.keys).decrypt(value)
|
||||
else:
|
||||
if not value:
|
||||
return
|
||||
return str(MultiFernet(self.keys).decrypt(value), 'utf8')
|
||||
|
|
Loading…
Reference in New Issue