-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…5072 Updates for CVE-2023-51074 and CVE-2023-5072
- Loading branch information
Showing
5 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/test/java/com/mastercard/developer/encryption/JsonParserTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.mastercard.developer.encryption; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.JsonObject; | ||
import com.jayway.jsonpath.DocumentContext; | ||
import com.jayway.jsonpath.JsonPath; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class JsonParserTest { | ||
|
||
@Test | ||
public void testDeleteIfExists_shouldDeleteIfElementExists() { | ||
final String key = "dummyKey"; | ||
JsonObject dummyObject = new JsonObject(); | ||
dummyObject.addProperty(key, "dummyValue"); | ||
|
||
DocumentContext context = JsonPath.parse(new Gson().toJson(dummyObject), JsonParser.jsonPathConfig); | ||
|
||
JsonParser.deleteIfExists(context, key); | ||
|
||
Object value = context.read(key); | ||
|
||
assertNull(value); | ||
} | ||
|
||
@Test | ||
public void testDeleteIfExists_doNothingIfElementDoesNotExist() { | ||
final String key = "dummyKey"; | ||
JsonObject dummyObject = new JsonObject(); | ||
dummyObject.addProperty(key, "dummyValue"); | ||
|
||
DocumentContext context = JsonPath.parse(new Gson().toJson(dummyObject), JsonParser.jsonPathConfig); | ||
|
||
JsonParser.deleteIfExists(context, "keyWhichDoesNotExist"); | ||
|
||
Object value = context.read(key); | ||
assertNotNull(value); | ||
} | ||
} |