mirror of
https://github.com/ansible/awx.git
synced 2026-03-19 01:47:31 -02:30
Merge pull request #609 from AlanCoding/more_encryption_tests
encryption tests around the contract with survey functionality
This commit is contained in:
@@ -51,3 +51,24 @@ def test_encrypt_field_with_ask():
|
|||||||
def test_encrypt_field_with_empty_value():
|
def test_encrypt_field_with_empty_value():
|
||||||
encrypted = encryption.encrypt_field(Setting(value=None), 'value')
|
encrypted = encryption.encrypt_field(Setting(value=None), 'value')
|
||||||
assert encrypted is None
|
assert encrypted is None
|
||||||
|
|
||||||
|
|
||||||
|
class TestSurveyReversibilityValue:
|
||||||
|
'''
|
||||||
|
Tests to enforce the contract with survey password question encrypted values
|
||||||
|
'''
|
||||||
|
_key = encryption.get_encryption_key('value', None)
|
||||||
|
|
||||||
|
def test_encrypt_empty_string(self):
|
||||||
|
assert encryption.encrypt_value('') == ''
|
||||||
|
# the reverse, decryption, does not work
|
||||||
|
|
||||||
|
def test_encrypt_encryption_key(self):
|
||||||
|
assert encryption.encrypt_value('$encrypted$') == '$encrypted$'
|
||||||
|
# the reverse, decryption, does not work
|
||||||
|
|
||||||
|
def test_encrypt_empty_string_twice(self):
|
||||||
|
# Encryption is idempotent
|
||||||
|
val = encryption.encrypt_value('foobar')
|
||||||
|
val2 = encryption.encrypt_value(val)
|
||||||
|
assert encryption.decrypt_value(self._key, val2) == 'foobar'
|
||||||
|
|||||||
Reference in New Issue
Block a user