diff --git a/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java b/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java index 456d1ebada..4aa6005beb 100644 --- a/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java +++ b/src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java @@ -12,6 +12,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.stream.Collectors; @@ -462,8 +463,9 @@ public void shouldPerformCatIndices_positive() throws IOException { Request getIndicesRequest = new Request("GET", "/_cat/indices"); // High level client doesn't support _cat/_indices API Response getIndicesResponse = restHighLevelClient.getLowLevelClient().performRequest(getIndicesRequest); - List indexes = new BufferedReader(new InputStreamReader(getIndicesResponse.getEntity().getContent())).lines() - .collect(Collectors.toList()); + List indexes = new BufferedReader( + new InputStreamReader(getIndicesResponse.getEntity().getContent(), StandardCharsets.UTF_8) + ).lines().collect(Collectors.toList()); assertThat(indexes.size(), equalTo(1)); assertThat(indexes.get(0), containsString("marvelous_songs")); @@ -476,8 +478,9 @@ public void shouldPerformCatAliases_positive() throws IOException { try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(LIMITED_USER)) { Request getAliasesRequest = new Request("GET", "/_cat/aliases"); Response getAliasesResponse = restHighLevelClient.getLowLevelClient().performRequest(getAliasesRequest); - List aliases = new BufferedReader(new InputStreamReader(getAliasesResponse.getEntity().getContent())).lines() - .collect(Collectors.toList()); + List aliases = new BufferedReader( + new InputStreamReader(getAliasesResponse.getEntity().getContent(), StandardCharsets.UTF_8) + ).lines().collect(Collectors.toList()); // Does not fail on forbidden, but alias response only contains index which user has access to assertThat(getAliasesResponse.getStatusLine().getStatusCode(), equalTo(200)); @@ -490,8 +493,9 @@ public void shouldPerformCatAliases_positive() throws IOException { try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) { Request getAliasesRequest = new Request("GET", "/_cat/aliases"); Response getAliasesResponse = restHighLevelClient.getLowLevelClient().performRequest(getAliasesRequest); - List aliases = new BufferedReader(new InputStreamReader(getAliasesResponse.getEntity().getContent())).lines() - .collect(Collectors.toList()); + List aliases = new BufferedReader( + new InputStreamReader(getAliasesResponse.getEntity().getContent(), StandardCharsets.UTF_8) + ).lines().collect(Collectors.toList()); // Admin has access to all assertThat(getAliasesResponse.getStatusLine().getStatusCode(), equalTo(200)); diff --git a/src/test/java/org/opensearch/security/support/SafeSerializationUtilsTest.java b/src/test/java/org/opensearch/security/support/SafeSerializationUtilsTest.java index f69d4e0291..187fd8b372 100644 --- a/src/test/java/org/opensearch/security/support/SafeSerializationUtilsTest.java +++ b/src/test/java/org/opensearch/security/support/SafeSerializationUtilsTest.java @@ -17,6 +17,7 @@ import java.util.HashMap; import java.util.regex.Pattern; +import org.junit.After; import org.junit.Test; import org.opensearch.security.auth.UserInjector; @@ -35,6 +36,11 @@ public class SafeSerializationUtilsTest { + @After + public void clearCache() { + SafeSerializationUtils.safeClassCache.clear(); + } + @Test public void testSafeClasses() { assertTrue(SafeSerializationUtils.isSafeClass(String.class));