Skip to content

Commit

Permalink
Switch to apache http 4 and compileable
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Sep 20, 2023
1 parent abe0421 commit 253465b
Show file tree
Hide file tree
Showing 14 changed files with 131 additions and 337 deletions.
13 changes: 13 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ configurations {
force "com.github.luben:zstd-jni:${versions.zstd}"
force "org.xerial.snappy:snappy-java:1.1.10.3"
force "com.google.guava:guava:${guava_version}"

// TODO: Seems like this should be removable
force "org.apache.httpcomponents:httpclient-cache:4.5.13"
force "org.apache.httpcomponents:httpclient:4.5.13"
force "org.apache.httpcomponents:fluent-hc:4.5.13"
force "org.apache.httpcomponents:httpcore:4.4.16"
force "org.apache.httpcomponents:httpcore-nio:4.4.16"
force "org.apache.httpcomponents:httpasyncclient:4.1.5"
}
}

Expand Down Expand Up @@ -639,6 +647,11 @@ dependencies {
exclude(group: 'org.hamcrest', module: 'hamcrest')
}
integrationTestImplementation 'com.unboundid:unboundid-ldapsdk:4.0.14'
integrationTestImplementation "org.apache.httpcomponents:httpclient-cache:4.5.13"
integrationTestImplementation "org.apache.httpcomponents:httpclient:4.5.13"
integrationTestImplementation "org.apache.httpcomponents:fluent-hc:4.5.13"
integrationTestImplementation "org.apache.httpcomponents:httpcore:4.4.13"
integrationTestImplementation "org.apache.httpcomponents:httpasyncclient:4.1.5"

//Checkstyle
checkstyle 'com.puppycrawl.tools:checkstyle:10.12.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public void listPitSegments_positive() throws IOException {
try (TestRestClient restClient = cluster.getRestClient(LIMITED_POINT_IN_TIME_USER)) {
String existingPitId = createPitForIndices(FIRST_SONG_INDEX);
String body = String.format("{\"pit_id\":[\"%s\"]}", existingPitId);
HttpResponse response = restClient.getWithJsonBody("/_cat/pit_segments", body);
HttpResponse response = restClient.putJson("/_cat/pit_segments", body);

response.assertStatusCode(OK.getStatus());
}
Expand All @@ -347,7 +347,7 @@ public void listPitSegmentsCreatedWithIndexAlias_positive() throws IOException {
try (TestRestClient restClient = cluster.getRestClient(POINT_IN_TIME_USER)) {
String existingPitId = createPitForIndices(FIRST_INDEX_ALIAS);
String body = String.format("{\"pit_id\":[\"%s\"]}", existingPitId);
HttpResponse response = restClient.getWithJsonBody("/_cat/pit_segments", body);
HttpResponse response = restClient.putJson("/_cat/pit_segments", body);

response.assertStatusCode(OK.getStatus());
}
Expand All @@ -358,7 +358,7 @@ public void listPitSegments_negative() throws IOException {
try (TestRestClient restClient = cluster.getRestClient(LIMITED_POINT_IN_TIME_USER)) {
String existingPitId = createPitForIndices(SECOND_SONG_INDEX);
String body = String.format("{\"pit_id\":[\"%s\"]}", existingPitId);
HttpResponse response = restClient.getWithJsonBody("/_cat/pit_segments", body);
HttpResponse response = restClient.putJson("/_cat/pit_segments", body);

response.assertStatusCode(FORBIDDEN.getStatus());
}
Expand All @@ -369,7 +369,7 @@ public void listPitSegmentsCreatedWithIndexAlias_negative() throws IOException {
try (TestRestClient restClient = cluster.getRestClient(LIMITED_POINT_IN_TIME_USER)) {
String existingPitId = createPitForIndices(SECOND_INDEX_ALIAS);
String body = String.format("{\"pit_id\":[\"%s\"]}", existingPitId);
HttpResponse response = restClient.getWithJsonBody("/_cat/pit_segments", body);
HttpResponse response = restClient.putJson("/_cat/pit_segments", body);

response.assertStatusCode(FORBIDDEN.getStatus());
}
Expand Down
12 changes: 6 additions & 6 deletions src/integrationTest/java/org/opensearch/security/TlsTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
import javax.net.ssl.SSLHandshakeException;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.classic.HttpClients;
import org.apache.hc.core5.http.NoHttpResponseException;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.NoHttpResponseException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -89,7 +89,7 @@ public void shouldSupportClientCipherSuite_positive() throws IOException {

try (CloseableHttpResponse response = client.execute(httpGet)) {

int responseStatusCode = response.getCode();
int responseStatusCode = response.getStatusLine().getStatusCode();
assertThat(responseStatusCode, equalTo(200));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.security.Keys;
import org.apache.http.header.BasicHeader;
import org.apache.http.Header;
import org.apache.http.message.BasicHeader;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import com.google.common.collect.ImmutableMap;
import io.jsonwebtoken.Jwts;
import org.apache.commons.lang3.StringUtils;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.Header;
import org.apache.http.message.BasicHeader;

import static io.jsonwebtoken.SignatureAlgorithm.RS256;
import static java.util.Objects.requireNonNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.Map;

import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope;
import org.apache.hc.core5.http.message.BasicHeader;
import org.apache.http.message.BasicHeader;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Rule;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;

import org.opensearch.script.mustache.MustacheModulePlugin;
import org.opensearch.script.mustache.MustachePlugin;
import org.opensearch.test.framework.TestSecurityConfig;
import org.opensearch.test.framework.TestSecurityConfig.Role;
import org.opensearch.test.framework.cluster.ClusterManager;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class PrivilegesEvaluatorTest {
public static LocalCluster cluster = new LocalCluster.Builder().clusterManager(ClusterManager.THREE_CLUSTER_MANAGERS)
.authc(AUTHC_HTTPBASIC_INTERNAL)
.users(NEGATIVE_LOOKAHEAD, NEGATED_REGEX, SEARCH_TEMPLATE, TestSecurityConfig.User.USER_ADMIN)
.plugin(MustacheModulePlugin.class)
.plugin(MustachePlugin.class)
.build();

@Test
Expand Down Expand Up @@ -90,7 +90,7 @@ public void testSearchTemplateRequestSuccess() {

try (TestRestClient client = cluster.getRestClient(SEARCH_TEMPLATE)) {
final String searchTemplateOnServicesIndex = "services/_search/template";
final TestRestClient.HttpResponse searchTemplateOnAuthorizedIndexResponse = client.getWithJsonBody(
final TestRestClient.HttpResponse searchTemplateOnAuthorizedIndexResponse = client.postJson(
searchTemplateOnServicesIndex,
TEST_QUERY
);
Expand All @@ -102,7 +102,7 @@ public void testSearchTemplateRequestSuccess() {
public void testSearchTemplateRequestUnauthorizedIndex() {
try (TestRestClient client = cluster.getRestClient(SEARCH_TEMPLATE)) {
final String searchTemplateOnMoviesIndex = "movies/_search/template";
final TestRestClient.HttpResponse searchTemplateOnUnauthorizedIndexResponse = client.getWithJsonBody(
final TestRestClient.HttpResponse searchTemplateOnUnauthorizedIndexResponse = client.postJson(
searchTemplateOnMoviesIndex,
TEST_QUERY
);
Expand All @@ -114,7 +114,7 @@ public void testSearchTemplateRequestUnauthorizedIndex() {
public void testSearchTemplateRequestUnauthorizedAllIndices() {
try (TestRestClient client = cluster.getRestClient(SEARCH_TEMPLATE)) {
final String searchTemplateOnAllIndices = "_search/template";
final TestRestClient.HttpResponse searchOnAllIndicesResponse = client.getWithJsonBody(searchTemplateOnAllIndices, TEST_QUERY);
final TestRestClient.HttpResponse searchOnAllIndicesResponse = client.postJson(searchTemplateOnAllIndices, TEST_QUERY);
assertThat(searchOnAllIndicesResponse.getStatusCode(), equalTo(HttpStatus.SC_FORBIDDEN));
}
}
Expand Down
Loading

0 comments on commit 253465b

Please sign in to comment.