Browse Source

Add tests for not requiring client cert

Maciek Sakrejda 10 years ago
parent
commit
ab9aeb580c
3 changed files with 16 additions and 8 deletions
  1. 8 4
      .travis.yml
  2. 7 3
      conn_test.go
  3. 1 1
      integration.sh

+ 8 - 4
.travis.yml

@@ -13,10 +13,14 @@ env:
   global:
     - GOMAXPROCS=2
   matrix:
-    - CASS=1.2.19 AUTH=false
-    - CASS=2.0.14 AUTH=false
-    - CASS=2.1.5  AUTH=false
-    - CASS=2.1.5  AUTH=true
+    - CASS=1.2.19 AUTH=false REQ_CLIENT_AUTH=true
+    - CASS=1.2.19 AUTH=false REQ_CLIENT_AUTH=false
+    - CASS=2.0.14 AUTH=false REQ_CLIENT_AUTH=true
+    - CASS=2.0.14 AUTH=false REQ_CLIENT_AUTH=false
+    - CASS=2.1.5  AUTH=false REQ_CLIENT_AUTH=true
+    - CASS=2.1.5  AUTH=true  REQ_CLIENT_AUTH=true
+    - CASS=2.1.5  AUTH=false REQ_CLIENT_AUTH=false
+    - CASS=2.1.5  AUTH=true  REQ_CLIENT_AUTH=false
 
 go:
   - 1.3

+ 7 - 3
conn_test.go

@@ -12,6 +12,7 @@ import (
 	"io"
 	"io/ioutil"
 	"net"
+	"os"
 	"strings"
 	"sync"
 	"sync/atomic"
@@ -70,12 +71,15 @@ func TestSSLSimple(t *testing.T) {
 
 func createTestSslCluster(hosts string, proto uint8) *ClusterConfig {
 	cluster := NewCluster(hosts)
-	cluster.SslOpts = &SslOptions{
-		CertPath:               "testdata/pki/gocql.crt",
-		KeyPath:                "testdata/pki/gocql.key",
+	sslOpts := &SslOptions{
 		CaPath:                 "testdata/pki/ca.crt",
 		EnableHostVerification: false,
 	}
+	if os.Getenv("REQ_CLIENT_AUTH") != "false" {
+		sslOpts.CertPath = "testdata/pki/gocql.crt"
+		sslOpts.KeyPath = "testdata/pki/gocql.key"
+	}
+	cluster.SslOpts = sslOpts
 	cluster.ProtoVersion = int(proto)
 	return cluster
 }

+ 1 - 1
integration.sh

@@ -17,7 +17,7 @@ function run_tests() {
 	    "client_encryption_options.enabled: true"
 	    "client_encryption_options.keystore: $keypath/.keystore"
 	    "client_encryption_options.keystore_password: cassandra"
-	    "client_encryption_options.require_client_auth: true"
+	    "client_encryption_options.require_client_auth: ${REQ_CLIENT_AUTH:-true}"
 	    "client_encryption_options.truststore: $keypath/.truststore"
 	    "client_encryption_options.truststore_password: cassandra"
 	    "concurrent_reads: 2"