Skip to content

Commit 75ddd51

Browse files
committed
separating encrypted item check from cycle item check
1 parent 2ee8800 commit 75ddd51

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

test/functional/functional_test_utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,7 @@ def diverse_item():
238238
_reserved_attributes = set([attr.value for attr in ReservedAttributes])
239239

240240

241-
def cycle_item_check(plaintext_item, crypto_config):
242-
"""Common logic for cycled item (plaintext->encrypted->decrypted) tests: used by many test suites."""
243-
ciphertext_item = encrypt_python_item(plaintext_item, crypto_config)
244-
241+
def check_encrypted_item(plaintext_item, ciphertext_item, attribute_actions):
245242
# Verify that all expected attributes are present
246243
ciphertext_attributes = set(ciphertext_item.keys())
247244
plaintext_attributes = set(plaintext_item.keys())
@@ -256,12 +253,19 @@ def cycle_item_check(plaintext_item, crypto_config):
256253
continue
257254

258255
# If the attribute should have been encrypted, verify that it is Binary and different from the original
259-
if crypto_config.attribute_actions.action(name) is ItemAction.ENCRYPT_AND_SIGN:
256+
if attribute_actions.action(name) is ItemAction.ENCRYPT_AND_SIGN:
260257
assert isinstance(value, Binary)
261258
assert value != plaintext_item[name]
262259
# Otherwise, verify that it is the same as the original
263260
else:
264261
assert value == plaintext_item[name]
265262

263+
264+
def cycle_item_check(plaintext_item, crypto_config):
265+
"""Common logic for cycled item (plaintext->encrypted->decrypted) tests: used by many test suites."""
266+
ciphertext_item = encrypt_python_item(plaintext_item, crypto_config)
267+
268+
check_encrypted_item(plaintext_item, ciphertext_item, crypto_config.attribute_actions)
269+
266270
cycled_item = decrypt_python_item(ciphertext_item, crypto_config)
267271
assert cycled_item == plaintext_item

0 commit comments

Comments
 (0)