Skip to content
This repository was archived by the owner on Feb 28, 2024. It is now read-only.

Commit 3b2fa76

Browse files
committed
Added missing test
1 parent ec18622 commit 3b2fa76

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/Developer/Encryption/FieldLevelEncryptionTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)