Skip to content

Commit 337a9fe

Browse files
committed
Simplified test
1 parent 55503fb commit 337a9fe

File tree

2 files changed

+8
-41
lines changed

2 files changed

+8
-41
lines changed

src/test/java/com/mastercard/developer/encryption/FieldLevelEncryptionWithDefaultJsonEngineTest.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import javax.crypto.spec.IvParameterSpec;
1515
import javax.crypto.spec.SecretKeySpec;
1616
import java.security.InvalidKeyException;
17-
import java.security.PrivateKey;
1817

1918
import static com.mastercard.developer.encryption.FieldLevelEncryptionConfig.FieldValueEncoding;
2019
import static com.mastercard.developer.encryption.FieldLevelEncryptionParams.SYMMETRIC_KEY_TYPE;
@@ -1070,29 +1069,25 @@ public void testDecryptPayload_ShouldOverwriteInputObject_WhenOutPathSameAsInPat
10701069
// GIVEN
10711070
String encryptedPayload = "{" +
10721071
" \"data\": {" +
1073-
" \"encryptedData\": {" +
1074-
" \"encryptedValue\": \"Qiw1g87OCwa5/IXPC5nIJw==\"," +
1075-
" \"iv\": \"OZt7FRV644fEFbb75VNdjA==\"," +
1076-
" \"encryptedKey\": \"AyI8R1/ziGTZ6Uhy2JGsy+PYf+KXcrzn5v56tP3WnuFM2Qt24T9t4WXE+B1cqiDjo1LQIEgXJWZ5XX/fbYh/Y1qmycit/QmPVEjGqoKLNSB1Js00Cghyt7lChuSUIWRnYbNAa0q6EgPS5vyDrXDVZH0vkTM6egc7d76O9Sw+rXGzv9d9wiQlhxFXkb+GH/BCiswb064w53LcXdoBcup1sEEn6UIuORtiCGeQcNqS6yvkR3HWc0lrAJpCikJoTCMQli7MJYAVj+w4LZCUZMcwWMuiMhLQQdjTAhCCK9+fKItwA5xSDaXictspUALTi/drdcj2zXbxX3E2t+q1PgWPUg==\"," +
1077-
" \"publicKeyFingerprint\": \"29f8a7cea970886829226864c79195088ee464a89d8bc835d392c1f6666326c6\"," +
1078-
" \"oaepPaddingDigestAlgorithm\": \"SHA256\"" +
1079-
" }" +
1072+
" \"encryptedValue\": \"e2d6a3a76ea6e605e55b400e5a4eba11\"," +
1073+
" \"iv\": \"3ce861359fa1630c7a794901ee14bf41\"," +
1074+
" \"encryptedKey\": \"02bb8d5c7d113ef271f199c09f0d76db2b6d5d2d209ad1a20dbc4dd0d04576a92ceb917eea5f403ccf64c3c39dda564046909af96c82fad62f89c3cbbec880ea3105a0a171af904cd3b86ea68991202a2795dca07050ca58252701b7ecea06055fd43e96f4beee48b6275e86af93c88c21994ff46f0610171bd388a2c0a1f518ffc8346f7f513f3283feae5b102c8596ddcb2aea5e62ceb17222e646c599f258463405d28ac012bfd4cc431f94111ee07d79e660948485e38c13cdb8bba8e1df3f7dba0f4c77696f71930533c955f3a430658edaa03b0b0c393934d60f5ac3ea5c06ed64bf969fc01942eac432b8e0c56f7538659a72859d445d150c169ae690\"," +
1075+
" \"encryptionCertificateFingerprint\": \"80810fc13a8319fcf0e2ec322c82a4c304b782cc3ce671176343cfe8160c2279\"," +
1076+
" \"encryptionKeyFingerprint\": \"761b003c1eade3a5490e5000d37887baa5e6ec0e226c07706e599451fc032a79\"," +
1077+
" \"oaepHashingAlgorithm\": \"SHA256\"" +
10801078
" }" +
10811079
"}";
10821080

1083-
PrivateKey decryptionKey = EncryptionUtils.loadDecryptionKey("./src/test/resources/keys/pkcs8/github-issue#3.pem");
10841081
FieldLevelEncryptionConfig config = getTestFieldLevelEncryptionConfigBuilder()
1085-
.withDecryptionKey(decryptionKey)
1086-
.withDecryptionPath("$.data.encryptedData", "$.data.encryptedData")
1087-
.withFieldValueEncoding(FieldValueEncoding.BASE64)
1082+
.withDecryptionPath("$.data", "$.data")
10881083
.build();
10891084

10901085
// WHEN
10911086
String payload = FieldLevelEncryption.decryptPayload(encryptedPayload, config);
10921087

10931088
// THEN
10941089
JsonObject payloadObject = new Gson().fromJson(payload, JsonObject.class);
1095-
assertEquals("India", payloadObject.get("data").getAsJsonObject().get("encryptedData").getAsString());
1090+
assertEquals("string", payloadObject.get("data").getAsString());
10961091
}
10971092

10981093
@Test

src/test/resources/keys/pkcs8/github-issue#3.pem

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)