9
9
10
10
from ..test_crypto import PRIVATE_KEY_PASSWORD , PRIVATE_KEY_PEM_BASE64 , PUBLIC_KEY
11
11
from 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
13
13
from apify ._crypto import public_encrypt
14
14
15
15
if TYPE_CHECKING :
@@ -79,9 +79,9 @@ async def test_get_input_with_encrypted_secrets(
79
79
secret_object = {'foo' : 'bar' , 'baz' : 'qux' }
80
80
secret_array = ['foo' , 'bar' , 'baz' ]
81
81
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.
85
85
86
86
encrypted_string_legacy = public_encrypt (secret_string_legacy , public_key = PUBLIC_KEY )
87
87
encrypted_string = public_encrypt (json_dumps (secret_string ), public_key = PUBLIC_KEY )
@@ -90,10 +90,26 @@ async def test_get_input_with_encrypted_secrets(
90
90
91
91
input_with_secret = {
92
92
'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
+ ),
97
113
}
98
114
99
115
await memory_storage_client .key_value_stores ().get_or_create (id = 'default' )
0 commit comments