Skip to content

Commit

Permalink
spotless:apply on modified files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe authored and manusa committed Jul 22, 2022
1 parent 2c90779 commit 0dc1242
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public void before(BasicBuilder headerBuilder, HttpHeaders headers) {
}
}


@Override
public CompletableFuture<Boolean> afterFailure(BasicBuilder headerBuilder, HttpResponse<?> response) {
if (response.code() == HttpURLConnection.HTTP_UNAUTHORIZED) {
Expand All @@ -70,7 +69,7 @@ private CompletableFuture<Boolean> refreshToken(BasicBuilder headerBuilder) {
Config newestConfig = Config.autoConfigure(currentContextName);
if (newestConfig.getAuthProvider() != null && newestConfig.getAuthProvider().getName().equalsIgnoreCase("oidc")) {
newAccessToken = OpenIDConnectionUtils.resolveOIDCTokenFromAuthConfig(newestConfig.getAuthProvider().getConfig(),
factory.newBuilder());
factory.newBuilder());
} else {
newAccessToken = CompletableFuture.completedFuture(newestConfig.getOauthToken());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
import io.fabric8.kubernetes.client.http.HttpClient;
import io.fabric8.kubernetes.client.http.HttpRequest;
import io.fabric8.kubernetes.client.http.TestHttpResponse;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Objects;

import static io.fabric8.kubernetes.client.Config.KUBERNETES_AUTH_SERVICEACCOUNT_TOKEN_FILE_SYSTEM_PROPERTY;
Expand Down Expand Up @@ -68,7 +68,7 @@ void shouldAutoconfigureAfter1Minute() throws Exception {
// Prepare kubeconfig for autoconfiguration
File tempFile = Files.createTempFile("test", "kubeconfig").toFile();
Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/token-refresh-interceptor/kubeconfig")),
Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING);
Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING);
System.setProperty(KUBERNETES_KUBECONFIG_FILE, tempFile.getAbsolutePath());

HttpRequest.Builder builder = Mockito.mock(HttpRequest.Builder.class, Mockito.RETURNS_SELF);
Expand All @@ -77,7 +77,7 @@ void shouldAutoconfigureAfter1Minute() throws Exception {
TokenRefreshInterceptor tokenRefreshInterceptor = new TokenRefreshInterceptor(Config.autoConfigure(null), null);
// Replace kubeconfig file
Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("/token-refresh-interceptor/kubeconfig.new")),
Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING);
Paths.get(tempFile.getPath()), StandardCopyOption.REPLACE_EXISTING);
tokenRefreshInterceptor.setLastRefresh(Instant.now().minus(61, ChronoUnit.SECONDS));
tokenRefreshInterceptor.before(builder, null);
Mockito.verify(builder).setHeader("Authorization", "Bearer new token");
Expand All @@ -87,8 +87,6 @@ void shouldAutoconfigureAfter1Minute() throws Exception {
}
}



@Test
void shouldReloadInClusterServiceAccount() throws Exception {
try {
Expand Down

0 comments on commit 0dc1242

Please sign in to comment.