99
1010from ..test_crypto import PRIVATE_KEY_PASSWORD , PRIVATE_KEY_PEM_BASE64 , PUBLIC_KEY
1111from apify import Actor
12- from apify ._consts import ENCRYPTED_STRING_VALUE_PREFIX , ENCRYPTED_JSON_VALUE_PREFIX
12+ from apify ._consts import ENCRYPTED_JSON_VALUE_PREFIX , ENCRYPTED_STRING_VALUE_PREFIX
1313from apify ._crypto import public_encrypt
1414
1515if TYPE_CHECKING :
@@ -79,9 +79,9 @@ async def test_get_input_with_encrypted_secrets(
7979 secret_object = {'foo' : 'bar' , 'baz' : 'qux' }
8080 secret_array = ['foo' , 'bar' , 'baz' ]
8181
82- # The legacy encryption format uses ENCRYPTED_STRING_VALUE_PREFIX prefix, value in raw string and does not include schemahash.
83- # The new format uses ENCRYPTED_JSON_VALUE_PREFIX prefix, value in JSON format and includes schemahash.
84- # We are testing both formats to ensure backward compatibility.
82+ # The legacy encryption format uses ENCRYPTED_STRING_VALUE_PREFIX prefix, value in raw string and does
83+ # not include schemahash. The new format uses ENCRYPTED_JSON_VALUE_PREFIX prefix, value in JSON format
84+ # and includes schemahash. We are testing both formats to ensure backward compatibility.
8585
8686 encrypted_string_legacy = public_encrypt (secret_string_legacy , public_key = PUBLIC_KEY )
8787 encrypted_string = public_encrypt (json_dumps (secret_string ), public_key = PUBLIC_KEY )
@@ -90,10 +90,26 @@ async def test_get_input_with_encrypted_secrets(
9090
9191 input_with_secret = {
9292 'foo' : 'bar' ,
93- 'secret_string_legacy' : f'{ ENCRYPTED_STRING_VALUE_PREFIX } :{ encrypted_string_legacy ["encrypted_password" ]} :{ encrypted_string_legacy ["encrypted_value" ]} ' ,
94- 'secret_string' : f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:{ encrypted_string ["encrypted_password" ]} :{ encrypted_string ["encrypted_value" ]} ' ,
95- 'secret_object' : f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:{ encrypted_object ["encrypted_password" ]} :{ encrypted_object ["encrypted_value" ]} ' ,
96- 'secret_array' : f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:{ encrypted_array ["encrypted_password" ]} :{ encrypted_array ["encrypted_value" ]} ' ,
93+ 'secret_string_legacy' : (
94+ f'{ ENCRYPTED_STRING_VALUE_PREFIX } :'
95+ f'{ encrypted_string_legacy ["encrypted_password" ]} :'
96+ f'{ encrypted_string_legacy ["encrypted_value" ]} '
97+ ),
98+ 'secret_string' : (
99+ f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:'
100+ f'{ encrypted_string ["encrypted_password" ]} :'
101+ f'{ encrypted_string ["encrypted_value" ]} '
102+ ),
103+ 'secret_object' : (
104+ f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:'
105+ f'{ encrypted_object ["encrypted_password" ]} :'
106+ f'{ encrypted_object ["encrypted_value" ]} '
107+ ),
108+ 'secret_array' : (
109+ f'{ ENCRYPTED_JSON_VALUE_PREFIX } :schemahash:'
110+ f'{ encrypted_array ["encrypted_password" ]} :'
111+ f'{ encrypted_array ["encrypted_value" ]} '
112+ ),
97113 }
98114
99115 await memory_storage_client .key_value_stores ().get_or_create (id = 'default' )
0 commit comments