From a502e1beb9fa252e756afec28da62447102f970b Mon Sep 17 00:00:00 2001 From: Debjani Banerjee <56744681+debjanibnrj@users.noreply.github.com> Date: Wed, 3 Mar 2021 14:13:56 -0800 Subject: [PATCH] Correcting setupSslOnlyMode to use AbstractSecurityUnitTest.hasCustomTransportSettings() (#1057) (cherry picked from commit 70a4f700518c06fb24cac1b01a22dad33d6fad8e) --- .../security/test/AbstractSecurityUnitTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/amazon/opendistroforelasticsearch/security/test/AbstractSecurityUnitTest.java b/src/test/java/com/amazon/opendistroforelasticsearch/security/test/AbstractSecurityUnitTest.java index 0edf7de93e..7bd2a5613e 100644 --- a/src/test/java/com/amazon/opendistroforelasticsearch/security/test/AbstractSecurityUnitTest.java +++ b/src/test/java/com/amazon/opendistroforelasticsearch/security/test/AbstractSecurityUnitTest.java @@ -219,7 +219,7 @@ protected void initialize(ClusterInfo info, Settings initTransportClientSettings } } - protected Settings.Builder minimumSecuritySettingsBuilder(int node, boolean sslOnly, boolean hasCustomTransportSettings) { + protected Settings.Builder minimumSecuritySettingsBuilder(int node, boolean sslOnly, Settings other) { final String prefix = getResourceFolder()==null?"":getResourceFolder()+"/"; @@ -228,7 +228,7 @@ protected Settings.Builder minimumSecuritySettingsBuilder(int node, boolean sslO .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_ENABLE_OPENSSL_IF_AVAILABLE, allowOpenSSL); // If custom transport settings are not defined use defaults - if (!hasCustomTransportSettings) { + if (!hasCustomTransportSettings(other)) { builder.put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_KEYSTORE_ALIAS, "node-0") .put(SSLConfigConstants.OPENDISTRO_SECURITY_SSL_TRANSPORT_KEYSTORE_FILEPATH, FileHelper.getAbsoluteFilePathFromClassPath(prefix+"node-0-keystore.jks")) @@ -241,6 +241,8 @@ protected Settings.Builder minimumSecuritySettingsBuilder(int node, boolean sslO builder.put(ConfigConstants.OPENDISTRO_SECURITY_BACKGROUND_INIT_IF_SECURITYINDEX_NOT_EXIST, false); } + builder.put(other); + return builder; } @@ -248,7 +250,7 @@ protected NodeSettingsSupplier minimumSecuritySettings(Settings other) { return new NodeSettingsSupplier() { @Override public Settings get(int i) { - return minimumSecuritySettingsBuilder(i, false, hasCustomTransportSettings(other)).put(other).build(); + return minimumSecuritySettingsBuilder(i, false, other).build(); } }; } @@ -258,7 +260,7 @@ protected NodeSettingsSupplier minimumSecuritySettingsSslOnly(Settings other) { return new NodeSettingsSupplier() { @Override public Settings get(int i) { - return minimumSecuritySettingsBuilder(i, true, false).put(other).build(); + return minimumSecuritySettingsBuilder(i, true, other).build(); } }; } @@ -271,7 +273,7 @@ public Settings get(int i) { if (i == nonSSLNodeNum) { return Settings.builder().build(); } - return minimumSecuritySettingsBuilder(i, true, false).put(other).build(); + return minimumSecuritySettingsBuilder(i, true, other).build(); } }; }