kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 7379e42ec8fa71d077e34bae9ac6d0637d78658a9eea71babfb7d5fc7008a36e |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-16 13:42 -06:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-16 13:42 -06:00 |
| Parents | c0be9f8b8e05, 02fbe0add6d2 |
4 files changed
modified driver-core/src/test/java/com/datastax/driver/core/SSLAuthenticatedEncryptionTest.java +2 −11
| @@ -15,21 +15,12 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import org.testng.annotations.DataProvider; | |
| 19 | 18 | import org.testng.annotations.Test; |
| 20 | 19 | |
| 21 | 20 | import com.datastax.driver.core.exceptions.NoHostAvailableException; |
| 22 | 21 | |
| 23 | -import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK; | |
| 24 | -import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL; | |
| 25 | - | |
| 26 | 22 | public class SSLAuthenticatedEncryptionTest extends SSLTestBase { |
| 27 | 23 | |
| 28 | - @DataProvider(name="sslImplementation") | |
| 29 | - public static Object[][] sslImplementation() { | |
| 30 | - return new Object[][]{ { JDK }, { NETTY_OPENSSL } }; | |
| 31 | - } | |
| 32 | - | |
| 33 | 24 | public SSLAuthenticatedEncryptionTest() { |
| 34 | 25 | super(true); |
| 35 | 26 | } |
| @@ -44,7 +35,7 @@ | ||
| 44 | 35 | * @test_category connection:ssl, authentication |
| 45 | 36 | * @expected_result Connection can be established to a cassandra node using SSL that requires client auth. |
| 46 | 37 | */ |
| 47 | - @Test(groups="short", dataProvider = "sslImplementation") | |
| 38 | + @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class) | |
| 48 | 39 | public void should_connect_with_ssl_with_client_auth_and_node_requires_auth(SslImplementation sslImplementation) throws Exception { |
| 49 | 40 | connectWithSSLOptions(getSSLOptions(sslImplementation, true, true)); |
| 50 | 41 | } |
| @@ -59,7 +50,7 @@ | ||
| 59 | 50 | * @test_category connection:ssl, authentication |
| 60 | 51 | * @expected_result Connection is not established. |
| 61 | 52 | */ |
| 62 | - @Test(groups="short", dataProvider = "sslImplementation", expectedExceptions={NoHostAvailableException.class}) | |
| 53 | + @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class, expectedExceptions={NoHostAvailableException.class}) | |
| 63 | 54 | public void should_not_connect_without_client_auth_but_node_requires_auth(SslImplementation sslImplementation) throws Exception { |
| 64 | 55 | connectWithSSLOptions(getSSLOptions(sslImplementation, false, true)); |
| 65 | 56 | } |
modified driver-core/src/test/java/com/datastax/driver/core/SSLEncryptionTest.java +3 −11
| @@ -17,22 +17,14 @@ | ||
| 17 | 17 | |
| 18 | 18 | import java.util.concurrent.TimeUnit; |
| 19 | 19 | |
| 20 | -import org.testng.annotations.DataProvider; | |
| 21 | 20 | import org.testng.annotations.Test; |
| 22 | 21 | |
| 23 | 22 | import com.datastax.driver.core.exceptions.NoHostAvailableException; |
| 24 | 23 | |
| 25 | 24 | import static com.datastax.driver.core.Assertions.assertThat; |
| 26 | -import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK; | |
| 27 | -import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL; | |
| 28 | 25 | |
| 29 | 26 | public class SSLEncryptionTest extends SSLTestBase { |
| 30 | 27 | |
| 31 | - @DataProvider(name="sslImplementation") | |
| 32 | - public static Object[][] sslImplementation() { | |
| 33 | - return new Object[][]{ { JDK }, { NETTY_OPENSSL } }; | |
| 34 | - } | |
| 35 | - | |
| 36 | 28 | public SSLEncryptionTest() { |
| 37 | 29 | super(false); |
| 38 | 30 | } |
| @@ -46,7 +38,7 @@ | ||
| 46 | 38 | * @test_category connection:ssl |
| 47 | 39 | * @expected_result Connection can be established to a cassandra node using SSL. |
| 48 | 40 | */ |
| 49 | - @Test(groups="short", dataProvider = "sslImplementation") | |
| 41 | + @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class) | |
| 50 | 42 | public void should_connect_with_ssl_without_client_auth_and_node_doesnt_require_auth(SslImplementation sslImplementation) throws Exception { |
| 51 | 43 | connectWithSSLOptions(getSSLOptions(sslImplementation, false, true)); |
| 52 | 44 | } |
| @@ -60,7 +52,7 @@ | ||
| 60 | 52 | * @test_category connection:ssl |
| 61 | 53 | * @expected_result Connection can not be established to a cassandra node using SSL with an untrusted cert. |
| 62 | 54 | */ |
| 63 | - @Test(groups="short", dataProvider = "sslImplementation", expectedExceptions={NoHostAvailableException.class}) | |
| 55 | + @Test(groups="short", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class, expectedExceptions={NoHostAvailableException.class}) | |
| 64 | 56 | public void should_not_connect_with_ssl_without_trusting_server_cert(SslImplementation sslImplementation) throws Exception { |
| 65 | 57 | connectWithSSLOptions(getSSLOptions(sslImplementation, false, false)); |
| 66 | 58 | } |
| @@ -103,7 +95,7 @@ | ||
| 103 | 95 | * @test_category connection:ssl |
| 104 | 96 | * @expected_result Connection is re-established within a sufficient amount of time after a node comes back online. |
| 105 | 97 | */ |
| 106 | - @Test(groups="long", dataProvider = "sslImplementation") | |
| 98 | + @Test(groups="long", dataProvider = "sslImplementation", dataProviderClass = SSLTestBase.class) | |
| 107 | 99 | public void should_reconnect_with_ssl_on_node_up(SslImplementation sslImplementation) throws Exception { |
| 108 | 100 | Cluster cluster = null; |
| 109 | 101 | try { |
modified driver-core/src/test/java/com/datastax/driver/core/SSLTestBase.java +14 −0
| @@ -24,10 +24,13 @@ | ||
| 24 | 24 | import javax.net.ssl.TrustManagerFactory; |
| 25 | 25 | import org.testng.annotations.AfterClass; |
| 26 | 26 | import org.testng.annotations.BeforeClass; |
| 27 | +import org.testng.annotations.DataProvider; | |
| 27 | 28 | |
| 28 | 29 | import static io.netty.handler.ssl.SslProvider.OPENSSL; |
| 29 | 30 | import static org.assertj.core.api.Assertions.fail; |
| 30 | 31 | |
| 32 | +import static com.datastax.driver.core.SSLTestBase.SslImplementation.JDK; | |
| 33 | +import static com.datastax.driver.core.SSLTestBase.SslImplementation.NETTY_OPENSSL; | |
| 31 | 34 | |
| 32 | 35 | public abstract class SSLTestBase { |
| 33 | 36 | |
| @@ -39,6 +42,17 @@ | ||
| 39 | 42 | this.requireClientAuth = requireClientAuth; |
| 40 | 43 | } |
| 41 | 44 | |
| 45 | + @DataProvider(name="sslImplementation") | |
| 46 | + public static Object[][] sslImplementation() { | |
| 47 | + // Bypass Netty SSL if on JDK 1.6 since it only works on 1.7+. | |
| 48 | + String javaVersion = System.getProperty("java.version"); | |
| 49 | + if(javaVersion.startsWith("1.6")) { | |
| 50 | + return new Object[][]{ { JDK } }; | |
| 51 | + } else { | |
| 52 | + return new Object[][]{ { JDK }, { NETTY_OPENSSL } }; | |
| 53 | + } | |
| 54 | + } | |
| 55 | + | |
| 42 | 56 | @BeforeClass(groups={"isolated", "short", "long"}) |
| 43 | 57 | public void beforeClass() { |
| 44 | 58 | ccm = CCMBridge.builder("test") |
modified features/ssl/README.md +2 −0
| @@ -149,6 +149,8 @@ | ||
| 149 | 149 | [these instructions](http://netty.io/wiki/forked-tomcat-native.html) to |
| 150 | 150 | add it to your dependencies. |
| 151 | 151 | |
| 152 | +Note that using netty-tcnative requires JDK 1.7 or above. | |
| 153 | + | |
| 152 | 154 | ##### Configuring the context |
| 153 | 155 | |
| 154 | 156 | Use the following Java code to configure OpenSSL with your certificates: |