Skip to content

Commit 2734c6f

Browse files
committed
Test: remove hardcoded list of unconfigured ciphers (#30367)
This commit removes the hardcoded list of unconfigured ciphers in the SslIntegrationTests. This list may include ciphers that are not supported on certain JVMs. This list is replaced with code that dynamically computes the set of ciphers that are not configured for use by default.
1 parent 485af9e commit 2734c6f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/transport/ssl/SslIntegrationTests.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@
2222
import org.elasticsearch.common.network.NetworkModule;
2323
import org.elasticsearch.common.settings.Settings;
2424
import org.elasticsearch.common.transport.TransportAddress;
25+
import org.elasticsearch.common.util.set.Sets;
2526
import org.elasticsearch.http.HttpServerTransport;
2627
import org.elasticsearch.test.SecurityIntegTestCase;
2728
import org.elasticsearch.transport.Transport;
2829
import org.elasticsearch.xpack.core.TestXPackTransportClient;
30+
import org.elasticsearch.xpack.core.XPackSettings;
2931
import org.elasticsearch.xpack.core.common.socket.SocketAccess;
32+
import org.elasticsearch.xpack.core.ssl.SSLConfigurationSettings;
3033
import org.elasticsearch.xpack.core.ssl.SSLService;
3134
import org.elasticsearch.xpack.security.LocalStateSecurity;
3235

@@ -39,7 +42,12 @@
3942
import java.nio.charset.StandardCharsets;
4043
import java.security.KeyStore;
4144
import java.security.SecureRandom;
45+
import java.util.ArrayList;
46+
import java.util.Collections;
47+
import java.util.HashSet;
48+
import java.util.List;
4249
import java.util.Locale;
50+
import java.util.Set;
4351

4452
import static org.elasticsearch.test.SecuritySettingsSource.addSSLSettingsForStore;
4553
import static org.hamcrest.CoreMatchers.is;
@@ -60,12 +68,18 @@ protected boolean transportSSLEnabled() {
6068
}
6169

6270
// no SSL exception as this is the exception is returned when connecting
63-
public void testThatUnconfiguredCiphersAreRejected() {
71+
public void testThatUnconfiguredCiphersAreRejected() throws Exception {
72+
Set<String> supportedCiphers = Sets.newHashSet(SSLContext.getDefault().getSupportedSSLParameters().getCipherSuites());
73+
Set<String> defaultXPackCiphers = Sets.newHashSet(XPackSettings.DEFAULT_CIPHERS);
74+
final List<String> unconfiguredCiphers = new ArrayList<>(Sets.difference(supportedCiphers, defaultXPackCiphers));
75+
Collections.shuffle(unconfiguredCiphers, random());
76+
assumeFalse("the unconfigured ciphers list is empty", unconfiguredCiphers.isEmpty());
77+
6478
try (TransportClient transportClient = new TestXPackTransportClient(Settings.builder()
6579
.put(transportClientSettings())
6680
.put("node.name", "programmatic_transport_client")
6781
.put("cluster.name", internalCluster().getClusterName())
68-
.putList("xpack.ssl.cipher_suites", "TLS_ECDH_anon_WITH_RC4_128_SHA", "SSL_RSA_WITH_3DES_EDE_CBC_SHA")
82+
.putList("xpack.ssl.cipher_suites", unconfiguredCiphers)
6983
.build(), LocalStateSecurity.class)) {
7084

7185
TransportAddress transportAddress = randomFrom(internalCluster().getInstance(Transport.class).boundAddress().boundAddresses());

0 commit comments

Comments
 (0)