You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2018/12/10 07:53:47 UTC
[3/3] ignite git commit: IGNITE-10189 Added SSL tests.
IGNITE-10189 Added SSL tests.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/c77e82e3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/c77e82e3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/c77e82e3
Branch: refs/heads/ignite-10189
Commit: c77e82e3705e2c76d055a3fc40822866c963bbdc
Parents: e5908dc
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Mon Dec 10 14:52:06 2018 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Mon Dec 10 14:52:06 2018 +0700
----------------------------------------------------------------------
.../ignite/util/GridCommandHandlerSslTest.java | 99 +++++++++++++++++---
1 file changed, 88 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/c77e82e3/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java
index 59155e5..9e84938 100644
--- a/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/util/GridCommandHandlerSslTest.java
@@ -17,28 +17,35 @@
package org.apache.ignite.util;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.configuration.ConnectorConfiguration;
import org.apache.ignite.configuration.DataStorageConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.commandline.CommandHandler;
+import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.ssl.SslContextFactory;
import org.apache.ignite.testframework.GridTestUtils;
import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.jetbrains.annotations.NotNull;
import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_CONNECTION_FAILED;
import static org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK;
/**
- * Command line handler test.
+ * Command line handler test with SSL.
*/
public class GridCommandHandlerSslTest extends GridCommonAbstractTest {
+ /** */
+ private volatile String[] cipherSuites;
+
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
cleanPersistenceDir();
stopAllGrids();
-
}
/** {@inheritDoc} */
@@ -46,7 +53,17 @@ public class GridCommandHandlerSslTest extends GridCommonAbstractTest {
stopAllGrids();
cleanPersistenceDir();
+ }
+ /**
+ * @return SSL factory.
+ */
+ @NotNull private SslContextFactory createSslFactory() {
+ SslContextFactory factory = (SslContextFactory)GridTestUtils.sslFactory();
+
+ factory.setCipherSuites(cipherSuites);
+
+ return factory;
}
/** {@inheritDoc} */
@@ -59,30 +76,90 @@ public class GridCommandHandlerSslTest extends GridCommonAbstractTest {
cfg.setConnectorConfiguration(new ConnectorConfiguration());
cfg.getConnectorConfiguration().setSslEnabled(true);
- cfg.setSslContextFactory(GridTestUtils.sslFactory());
+ cfg.setSslContextFactory(createSslFactory());
return cfg;
}
/**
- * Test activation works via control.sh
- *
+ * @param nodeCipherSuite Ciphers suites to set on node.
+ * @param utilityCipherSuite Ciphers suites to set on utility.
+ * @param expRes Expected result.
* @throws Exception If failed.
*/
- public void testActivate() throws Exception {
+ private void activate(String nodeCipherSuite, String utilityCipherSuite, int expRes) throws Exception {
+ cipherSuites = F.isEmpty(nodeCipherSuite) ? null : nodeCipherSuite.split(",");
+
Ignite ignite = startGrids(1);
assertFalse(ignite.cluster().active());
final CommandHandler cmd = new CommandHandler();
- assertEquals(EXIT_CODE_OK, cmd.execute(Arrays.asList(
- "--activate",
- "--keystore", GridTestUtils.keyStorePath("node01"),
- "--keystore-password", GridTestUtils.keyStorePassword())));
- assertTrue(ignite.cluster().active());
+ List<String> params = new ArrayList<>();
+ params.add("--activate");
+ params.add("--keystore");
+ params.add(GridTestUtils.keyStorePath("node01"));
+ params.add("--keystore-password");
+ params.add(GridTestUtils.keyStorePassword());
+
+ if (!F.isEmpty(utilityCipherSuite)) {
+ params.add("--ssl-cipher-suites");
+ params.add(utilityCipherSuite);
+ }
+
+ assertEquals(expRes, cmd.execute(params));
+
+ if (expRes == EXIT_CODE_OK)
+ assertTrue(ignite.cluster().active());
+ else
+ assertFalse(ignite.cluster().active());
assertEquals(EXIT_CODE_CONNECTION_FAILED, cmd.execute(Arrays.asList("--deactivate", "--yes")));
}
+ /**
+ * @throws Exception If test failed.
+ */
+ public void testDefaultCipherSuite() throws Exception {
+ cipherSuites = null;
+
+ activate(null, null, EXIT_CODE_OK);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testSameCipherSuite() throws Exception {
+ String ciphers = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," +
+ "TLS_RSA_WITH_AES_128_GCM_SHA256," +
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
+
+ activate(ciphers, ciphers, EXIT_CODE_OK);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testOneCommonCipherSuite() throws Exception {
+ String nodeCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256," +
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
+
+ String utilityCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," +
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
+
+ activate(nodeCipherSuites, utilityCipherSuites, EXIT_CODE_OK);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testNoCommonCipherSuite() throws Exception {
+ String nodeCipherSuites = "TLS_RSA_WITH_AES_128_GCM_SHA256";
+
+ String utilityCipherSuites = "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256," +
+ "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256";
+
+ activate(nodeCipherSuites, utilityCipherSuites, EXIT_CODE_CONNECTION_FAILED);
+ }
}