@@ -238,10 +238,7 @@ def diverse_item():
238
238
_reserved_attributes = set ([attr .value for attr in ReservedAttributes ])
239
239
240
240
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 ):
245
242
# Verify that all expected attributes are present
246
243
ciphertext_attributes = set (ciphertext_item .keys ())
247
244
plaintext_attributes = set (plaintext_item .keys ())
@@ -256,12 +253,19 @@ def cycle_item_check(plaintext_item, crypto_config):
256
253
continue
257
254
258
255
# 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 :
260
257
assert isinstance (value , Binary )
261
258
assert value != plaintext_item [name ]
262
259
# Otherwise, verify that it is the same as the original
263
260
else :
264
261
assert value == plaintext_item [name ]
265
262
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
+
266
270
cycled_item = decrypt_python_item (ciphertext_item , crypto_config )
267
271
assert cycled_item == plaintext_item
0 commit comments