This repository was archived by the owner on Feb 28, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
tests/Developer/Encryption Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,29 @@ public function testEncryptPayload_ShouldEncryptPrimitiveTypes_String() {
162162 self ::assertDecryptedPayloadEquals ('{"data": "string"} ' , $ encryptedPayload , $ config );
163163 }
164164
165+ public function testEncryptPayload_ShouldEncryptPrimitiveTypes_NumberAsString () {
166+
167+ // GIVEN
168+ $ payload = '{
169+ "data": "123",
170+ "encryptedData": {}
171+ } ' ;
172+ $ config = TestUtils::getTestFieldLevelEncryptionConfigBuilder ()
173+ ->withEncryptionPath ('data ' , 'encryptedData ' )
174+ ->withDecryptionPath ('encryptedData ' , 'data ' )
175+ ->withOaepPaddingDigestAlgorithm ('SHA-256 ' )
176+ ->build ();
177+
178+ // WHEN
179+ $ encryptedPayload = FieldLevelEncryption::encryptPayload ($ payload , $ config );
180+
181+ // THEN
182+ $ encryptedPayloadObject = json_decode ($ encryptedPayload );
183+ $ this ->assertFalse (property_exists ($ encryptedPayloadObject , 'data ' ));
184+ $ this ->assertNotEmpty ($ encryptedPayloadObject ->encryptedData );
185+ self ::assertDecryptedPayloadEquals ('{"data": 123} ' , $ encryptedPayload , $ config );
186+ }
187+
165188 public function testEncryptPayload_ShouldEncryptPrimitiveTypes_Integer () {
166189
167190 // GIVEN
You can’t perform that action at this time.
0 commit comments