Skip to content

Commit

Permalink
Fix address already in use
Browse files Browse the repository at this point in the history
  • Loading branch information
Raul committed Sep 4, 2024
1 parent 13bf663 commit 8b9111c
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.Map;
import java.util.Optional;
import javax.inject.Inject;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -71,6 +72,11 @@ public void setup() throws IOException {
Guice.createInjector().injectMembers(this);
}

@After
public void tearDown() throws IOException {
ajpTestServer.stop();
}

@Test
public void detect_weakCredentialsExists_returnsWeakCredentials() throws Exception {
ajpTestServer.setResponseForCredential(
Expand All @@ -92,7 +98,6 @@ public void detect_weakCredentialsExists_returnsWeakCredentials() throws Excepti

assertThat(tester.testValidCredentials(targetNetworkService, ImmutableList.of(WEAK_CRED_1)))
.containsExactly(WEAK_CRED_1);
ajpTestServer.stop();
}

@Test
Expand Down Expand Up @@ -122,7 +127,6 @@ public void detect_weakCredentialsExist_returnsAllWeakCredentials() throws Excep
tester.testValidCredentials(
targetNetworkService, ImmutableList.of(WEAK_CRED_1, WEAK_CRED_2)))
.containsExactly(WEAK_CRED_1, WEAK_CRED_2);
ajpTestServer.stop();
}

@Test
Expand All @@ -143,7 +147,6 @@ public void detect_noWeakCredentials_returnsNoCredentials() throws Exception {

assertThat(tester.testValidCredentials(targetNetworkService, ImmutableList.of(WRONG_CRED_1)))
.isEmpty();
ajpTestServer.stop();
}

private static byte[] createAjpUnauthorizedResponse() {
Expand All @@ -156,7 +159,7 @@ private static byte[] createAjpUnauthorizedResponse() {
private static class AjpTestServer {
private ServerSocket serverSocket;
private boolean running = false;
private final int port = 8909;
private final int port = 8009;
private final String host = "localhost";
private final Map<String, byte[]> credentialResponses = new HashMap<>();

Expand Down

0 comments on commit 8b9111c

Please sign in to comment.