Skip to content

Commit

Permalink
refactor(helm): remove unneeded apache httpclient dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa committed Jan 30, 2024
1 parent b7e1d6c commit e931b49
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
4 changes: 0 additions & 4 deletions jkube-kit/helm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jkube</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.net.PasswordAuthentication;
import java.net.URL;

import io.fabric8.kubernetes.client.http.StandardHttpHeaders;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHeaders;

public class HelmRepositoryConnectionUtils {

Expand Down Expand Up @@ -54,7 +54,7 @@ private static HttpURLConnection createConnection(HelmRepository repository, Str
final HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/gzip");
connection.setRequestProperty(StandardHttpHeaders.CONTENT_TYPE, "application/gzip");
verifyAndSetAuthentication(repository);
return connection;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import io.fabric8.kubernetes.client.utils.HttpClientUtils;
import io.fabric8.mockwebserver.DefaultMockServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.apache.http.HttpHeaders;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -113,7 +112,7 @@ void afterFailure_whenAuthCallFails_thenReturnFalse() {
.once();
String service = "localhost";
String wwwHeader = createWwwHeader(authUrl, service);
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader));
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap("WWW-Authenticate", Collections.singletonList(wwwHeader));
HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF);
HttpResponse<byte[]> response = new TestHttpResponse<byte[]>(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED);

Expand All @@ -133,7 +132,7 @@ void afterFailure_whenUnauthenticated_thenShouldAuthenticateWithGetAndFetchAcces
.once();
String service = "localhost";
String wwwHeader = createWwwHeader(authUrl, service);
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader));
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap("WWW-Authenticate", Collections.singletonList(wwwHeader));
HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF);
HttpResponse<byte[]> response = new TestHttpResponse<byte[]>(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED);

Expand All @@ -157,7 +156,7 @@ void afterFailure_whenGetNotAllowedAndPostAlsoFails_thenReturnFalse() {
.once();
String service = "localhost";
String wwwHeader = createWwwHeader(authUrl, service);
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader));
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap("WWW-Authenticate", Collections.singletonList(wwwHeader));
HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF);
HttpResponse<byte[]> response = new TestHttpResponse<byte[]>(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED);

Expand All @@ -181,7 +180,7 @@ void afterFailure_whenGetNotAllowed_thenShouldAuthenticateWithPostAndFetchAccess
.once();
String service = "localhost";
String wwwHeader = createWwwHeader(authUrl, service);
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap(HttpHeaders.WWW_AUTHENTICATE, Collections.singletonList(wwwHeader));
Map<String, List<String>> unAuthorizedResponseHeaders = Collections.singletonMap("WWW-Authenticate", Collections.singletonList(wwwHeader));
HttpRequest.Builder builder = mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF);
HttpResponse<byte[]> response = new TestHttpResponse<byte[]>(unAuthorizedResponseHeaders).withCode(HTTP_UNAUTHORIZED);

Expand Down

0 comments on commit e931b49

Please sign in to comment.