Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.elasticsearch.xpack.security.transport.ssl;

import org.apache.lucene.util.Constants;
import org.elasticsearch.client.transport.NoNodeAvailableException;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.network.NetworkAddress;
Expand Down Expand Up @@ -39,14 +40,24 @@

public class SslMultiPortTests extends SecurityIntegTestCase {

private static final int NUMBER_OF_CLIENT_PORTS = Constants.WINDOWS ? 300 : 100;

private static int randomClientPort;
private static String randomClientPortRange;
private static int randomNoClientAuthPort;
private static String randomNoClientAuthPortRange;
private static InetAddress localAddress;

@BeforeClass
public static void getRandomPort() {
randomClientPort = randomIntBetween(49000, 65500); // ephemeral port
randomNoClientAuthPort = randomIntBetween(49000, 65500);
randomClientPort = randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS);
randomClientPortRange = randomClientPort + "-" + (randomClientPort + NUMBER_OF_CLIENT_PORTS);

randomNoClientAuthPort = randomValueOtherThanMany(
port -> port >= randomClientPort - NUMBER_OF_CLIENT_PORTS && port <= randomClientPort + NUMBER_OF_CLIENT_PORTS,
() -> randomIntBetween(49152, 65535 - NUMBER_OF_CLIENT_PORTS)
);
randomNoClientAuthPortRange = randomNoClientAuthPort + "-" + (randomNoClientAuthPort + NUMBER_OF_CLIENT_PORTS);
localAddress = InetAddress.getLoopbackAddress();
}

Expand All @@ -60,9 +71,6 @@ public static void getRandomPort() {
*/
@Override
protected Settings nodeSettings(int nodeOrdinal, Settings otherSettings) {
String randomClientPortRange = randomClientPort + "-" + (randomClientPort + 100);
String randomNoClientAuthPortRange = randomNoClientAuthPort + "-" + (randomNoClientAuthPort + 100);

Path trustCert;
try {
trustCert = getDataPath("/org/elasticsearch/xpack/security/transport/ssl/certs/simple/testclient-client-profile.crt");
Expand Down