Skip to content

Commit

Permalink
adding unit test to address comments
Browse files Browse the repository at this point in the history
Signed-off-by: Dhrubo Saha <dhrubo@amazon.com>
  • Loading branch information
dhrubo-os committed Oct 16, 2024
1 parent 7723c35 commit 15c19fa
Showing 1 changed file with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
Expand Down Expand Up @@ -104,6 +105,30 @@ private static String maskSensitiveInfo(String input) {
return input.replaceAll(regex, "\"credential\": \"***\"");
}

@Test
public void testMaskSensitiveInfo_withCredential() {
String input = "{\"credential\":{\"username\":\"admin\",\"password\":\"secret\"}}";
String expectedOutput = "{\"credential\": \"***\"}";
String actualOutput = maskSensitiveInfo(input);
assertEquals(expectedOutput, actualOutput);
}

@Test
public void testMaskSensitiveInfo_noCredential() {
String input = "{\"otherInfo\":\"someValue\"}";
String expectedOutput = "{\"otherInfo\":\"someValue\"}";
String actualOutput = maskSensitiveInfo(input);
assertEquals(expectedOutput, actualOutput);
}

@Test
public void testMaskSensitiveInfo_emptyInput() {
String input = "";
String expectedOutput = "";
String actualOutput = maskSensitiveInfo(input);
assertEquals(expectedOutput, actualOutput);
}

public void testSearchConnectors_beforeCreation() throws IOException {
String searchEntity = "{\n" + " \"query\": {\n" + " \"match_all\": {}\n" + " },\n" + " \"size\": 1000\n" + "}";
Response response = TestHelper
Expand Down

0 comments on commit 15c19fa

Please sign in to comment.