Skip to content

Commit

Permalink
Fix two thread leaks on the RestAuthentication IT
Browse files Browse the repository at this point in the history
  • Loading branch information
tristantarrant committed May 23, 2023
1 parent 45dd016 commit d80d210
Showing 1 changed file with 20 additions and 21 deletions.
@@ -1,23 +1,5 @@
package org.infinispan.server.security.authentication;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.infinispan.commons.util.Util.toHexString;
import static org.infinispan.server.test.core.Common.HTTP_MECHS;
import static org.infinispan.server.test.core.Common.HTTP_PROTOCOLS;
import static org.infinispan.server.test.core.Common.sync;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import static org.wildfly.security.mechanism._private.ElytronMessages.httpDigest;

import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import org.infinispan.client.rest.RestClient;
import org.infinispan.client.rest.RestResponse;
import org.infinispan.client.rest.configuration.Protocol;
Expand All @@ -36,6 +18,24 @@
import org.junit.runners.Parameterized;
import org.wildfly.security.mechanism.digest.DigestUtil;

import java.net.InetSocketAddress;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.infinispan.commons.util.Util.toHexString;
import static org.infinispan.server.test.core.Common.HTTP_MECHS;
import static org.infinispan.server.test.core.Common.HTTP_PROTOCOLS;
import static org.infinispan.server.test.core.Common.sync;
import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import static org.wildfly.security.mechanism._private.ElytronMessages.httpDigest;

/**
* @author Tristan Tarrant <tristan@infinispan.org>
* @since 10.0
Expand Down Expand Up @@ -77,8 +77,7 @@ public void testStaticResourcesAnonymously() {
InetSocketAddress serverAddress = serverDriver.getServerSocket(0, 11222);
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder().followRedirects(false);
builder.addServer().host(serverAddress.getHostString()).port(serverAddress.getPort());

RestClient restClient = RestClient.forConfiguration(builder.build());
RestClient restClient = SERVER_TEST.rest().withClientConfiguration(builder).get();

RestResponse response = sync(restClient.raw().get("/"));
assertEquals(307, response.getStatus()); // The root resource redirects to the console
Expand All @@ -93,7 +92,7 @@ public void testMalformedDigestHeader() throws Exception {
RestClientConfigurationBuilder builder = new RestClientConfigurationBuilder().followRedirects(false);
builder.addServer().host(serverAddress.getHostString()).port(serverAddress.getPort());

RestClient restClient = RestClient.forConfiguration(builder.build());
RestClient restClient = SERVER_TEST.rest().withClientConfiguration(builder).get();
RestResponse response = sync(restClient.raw().get("/rest/v2/caches"));
assertEquals(401, response.getStatus());
String auth = response.headers().get("Www-Authenticate").stream().filter(h -> h.startsWith("Digest")).findFirst().get();
Expand Down

0 comments on commit d80d210

Please sign in to comment.