From ed4230f1fc30ef81d077b801c7c5172d0a6e2f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Tis=C3=A4ter?= Date: Tue, 27 May 2014 00:47:47 +0200 Subject: [PATCH] Fix tests on Go 1.3 and greater Go 1.3 and greater require ServerName or InsecureSkipVerify to be set. https://codereview.appspot.com/67010043/ --- consul/client_test.go | 15 ++++++--------- consul/config.go | 2 ++ consul/server_test.go | 17 ++++++++--------- test/ca/certindex | 1 + test/ca/serialfile | 2 +- test/key/ourdomain.cer | 34 +++++++++++++++++----------------- test/key/ourdomain.csr | 20 ++++++++++---------- test/key/ourdomain.key | 26 +++++++++++++------------- 8 files changed, 58 insertions(+), 59 deletions(-) diff --git a/consul/client_test.go b/consul/client_test.go index 10ab0fde7f..93ab88bc3e 100644 --- a/consul/client_test.go +++ b/consul/client_test.go @@ -10,18 +10,15 @@ import ( "time" ) -func testClientConfig(t *testing.T) (string, *Config) { +func testClientConfig(t *testing.T, NodeName string) (string, *Config) { dir := tmpDir(t) config := DefaultConfig() config.Datacenter = "dc1" config.DataDir = dir - - // Adjust the ports - p := getPort() - config.NodeName = fmt.Sprintf("Node %d", p) + config.NodeName = NodeName config.RPCAddr = &net.TCPAddr{ IP: []byte{127, 0, 0, 1}, - Port: p, + Port: getPort(), } config.SerfLANConfig.MemberlistConfig.BindAddr = "127.0.0.1" config.SerfLANConfig.MemberlistConfig.BindPort = getPort() @@ -37,7 +34,7 @@ func testClient(t *testing.T) (string, *Client) { } func testClientDC(t *testing.T, dc string) (string, *Client) { - dir, config := testClientConfig(t) + dir, config := testClientConfig(t, "testco.internal") config.Datacenter = dc client, err := NewClient(config) @@ -130,7 +127,7 @@ func TestClient_RPC(t *testing.T) { } func TestClient_RPC_TLS(t *testing.T) { - dir1, conf1 := testServerConfig(t) + dir1, conf1 := testServerConfig(t, "a.testco.internal") conf1.VerifyIncoming = true conf1.VerifyOutgoing = true configureTLS(conf1) @@ -141,7 +138,7 @@ func TestClient_RPC_TLS(t *testing.T) { defer os.RemoveAll(dir1) defer s1.Shutdown() - dir2, conf2 := testClientConfig(t) + dir2, conf2 := testClientConfig(t, "b.testco.internal") conf2.VerifyOutgoing = true configureTLS(conf2) c1, err := NewClient(conf2) diff --git a/consul/config.go b/consul/config.go index e848c3b011..ab4bb3d36d 100644 --- a/consul/config.go +++ b/consul/config.go @@ -173,6 +173,7 @@ func (c *Config) KeyPair() (*tls.Certificate, error) { func (c *Config) OutgoingTLSConfig() (*tls.Config, error) { // Create the tlsConfig tlsConfig := &tls.Config{ + ServerName: c.NodeName, RootCAs: x509.NewCertPool(), InsecureSkipVerify: !c.VerifyOutgoing, } @@ -205,6 +206,7 @@ func (c *Config) OutgoingTLSConfig() (*tls.Config, error) { func (c *Config) IncomingTLSConfig() (*tls.Config, error) { // Create the tlsConfig tlsConfig := &tls.Config{ + ServerName: c.NodeName, ClientCAs: x509.NewCertPool(), ClientAuth: tls.NoClientCert, } diff --git a/consul/server_test.go b/consul/server_test.go index dc984ba35a..e2ea363c13 100644 --- a/consul/server_test.go +++ b/consul/server_test.go @@ -33,19 +33,17 @@ func configureTLS(config *Config) { config.KeyFile = "../test/key/ourdomain.key" } -func testServerConfig(t *testing.T) (string, *Config) { +func testServerConfig(t *testing.T, NodeName string) (string, *Config) { dir := tmpDir(t) config := DefaultConfig() + + config.NodeName = NodeName config.Bootstrap = true config.Datacenter = "dc1" config.DataDir = dir - - // Adjust the ports - p := getPort() - config.NodeName = fmt.Sprintf("Node %d", p) config.RPCAddr = &net.TCPAddr{ IP: []byte{127, 0, 0, 1}, - Port: p, + Port: getPort(), } config.SerfLANConfig.MemberlistConfig.BindAddr = "127.0.0.1" config.SerfLANConfig.MemberlistConfig.BindPort = getPort() @@ -77,7 +75,8 @@ func testServerDC(t *testing.T, dc string) (string, *Server) { } func testServerDCBootstrap(t *testing.T, dc string, bootstrap bool) (string, *Server) { - dir, config := testServerConfig(t) + name := fmt.Sprintf("Node %d", getPort()) + dir, config := testServerConfig(t, name) config.Datacenter = dc config.Bootstrap = bootstrap server, err := NewServer(config) @@ -248,7 +247,7 @@ func TestServer_RPC(t *testing.T) { } func TestServer_JoinLAN_TLS(t *testing.T) { - dir1, conf1 := testServerConfig(t) + dir1, conf1 := testServerConfig(t, "a.testco.internal") conf1.VerifyIncoming = true conf1.VerifyOutgoing = true configureTLS(conf1) @@ -259,7 +258,7 @@ func TestServer_JoinLAN_TLS(t *testing.T) { defer os.RemoveAll(dir1) defer s1.Shutdown() - dir2, conf2 := testServerConfig(t) + dir2, conf2 := testServerConfig(t, "b.testco.internal") conf2.Bootstrap = false conf2.VerifyIncoming = true conf2.VerifyOutgoing = true diff --git a/test/ca/certindex b/test/ca/certindex index 976623958e..f24bb0886f 100644 --- a/test/ca/certindex +++ b/test/ca/certindex @@ -1,2 +1,3 @@ V 150407190456Z 0A unknown /CN=testco.internal/ST=California/C=US/emailAddress=test@testco.com/O=TestCo/OU=Beta V 150407194146Z 0B unknown /CN=testco.internal/ST=California/C=US/emailAddress=test@testco.com/O=TestCo/OU=Beta +V 150526223338Z 0C unknown /CN=*.testco.internal/ST=California/C=US/emailAddress=test@testco.com/O=TestCo/OU=Beta diff --git a/test/ca/serialfile b/test/ca/serialfile index d73cdef37a..8af8809acf 100644 --- a/test/ca/serialfile +++ b/test/ca/serialfile @@ -1 +1 @@ -0C +0D diff --git a/test/key/ourdomain.cer b/test/key/ourdomain.cer index e795f20562..c3a8946df5 100644 --- a/test/key/ourdomain.cer +++ b/test/key/ourdomain.cer @@ -1,22 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIDtTCCAp2gAwIBAgIBCzANBgkqhkiG9w0BAQUFADCBmDELMAkGA1UEBhMCVVMx +MIIDtzCCAp+gAwIBAgIBDDANBgkqhkiG9w0BAQUFADCBmDELMAkGA1UEBhMCVVMx CzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRwwGgYDVQQKExNI YXNoaUNvcnAgVGVzdCBDZXJ0MQwwCgYDVQQL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Dp1yIeRw== -----END CERTIFICATE----- diff --git a/test/key/ourdomain.csr b/test/key/ourdomain.csr index 40e7e8cd8d..e68015de7c 100644 --- a/test/key/ourdomain.csr +++ b/test/key/ourdomain.csr @@ -1,12 +1,12 @@ -----BEGIN CERTIFICATE REQUEST----- -MIIB1TCCAT4CAQAwgZQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlh -MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMQ8wDQYDVQQKEwZUZXN0Q28xDTALBgNV -BAsTBEJldGExGDAWBgNVBAMTD3Rlc3Rjby5pbnRlcm5hbDEeMBwGCSqGSIb3DQEJ -ARYPdGVzdEB0ZXN0Y28uY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC1 -zVG6lVI7LKTB4eOjwd+5COqys2ZUrMmgWFrEtfbXa8EvN50l2SZWjAFTy0f00fm9 -T/Nc8WQ/JvGZkNmyu9DaObrBZHZW6MFSwCDMkiEJmRdbUy124gipXYsBI5DlmtcS -sCWrqDNFyp1pBZixg8SAJfOA2Wi4JjY9rf6vHfpWgwIDAQABoAAwDQYJKoZIhvcN -AQEFBQADgYEAG7SdzgaTcJ1sMJ+pH+42J9Fyp2SY+WGEP3dA7f1/Lwc1dFHeKLPL -X0Gv6DgNkxUwWOe/yncq+dkuUkDGx3M1FRvpKCKFAywp+j0NxIll7821/2Jvf5/f -BVHPmgUIzZEYz0d6vcCQl2RKd83wLWcR77JTrD2S1JqAEkrMw/xUa/s= +MIIBvjCCAScCAQAwfjELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWEx +DzANBgNVBAoTBlRlc3RDbzENMAsGA1UECxMEQmV0YTEaMBgGA1UEAxQRKi50ZXN0 +Y28uaW50ZXJuYWwxHjAcBgkqhkiG9w0BCQEWD3Rlc3RAdGVzdGNvLmNvbTCBnzAN +BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA4x6514o05YIcqeurGljZ4GUfN1QxLZpa +k3HakL/u0nTiOvp17huaIjLShXz2ue2OhjtSc3XOAyTEiaqN2eKQ+NOh/JjEfprR +W1uUazA62zfTrJIcN/+cns9w6THPqgly3vrIcc1nQlCqi2afjpzwvb+sTENybT1q +qpWo7CiwPKMCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4GBADYNANLRORU5zO5qCTZ5 +m8jXfkVX2fDbiG5rdVbd9V4cYQ8/eulPmX/TZzY5qNuoT2zJZcOwrJWGtMofZra6 +4kb5qNCNWHEUfVBM6WXi9rFO55DD83T9NsBxbi09QltqUNja6ueeLkJHgphpxXuU +1CJ8IOFdH/a1zETHO917GHii -----END CERTIFICATE REQUEST----- diff --git a/test/key/ourdomain.key b/test/key/ourdomain.key index 18d52ba1c2..10d61d1301 100644 --- a/test/key/ourdomain.key +++ b/test/key/ourdomain.key @@ -1,15 +1,15 @@ -----BEGIN RSA PRIVATE KEY----- -MIICWwIBAAKBgQC1zVG6lVI7LKTB4eOjwd+5COqys2ZUrMmgWFrEtfbXa8EvN50l -2SZWjAFTy0f00fm9T/Nc8WQ/JvGZkNmyu9DaObrBZHZW6MFSwCDMkiEJmRdbUy12 -4gipXYsBI5DlmtcSsCWrqDNFyp1pBZixg8SAJfOA2Wi4JjY9rf6vHfpWgwIDAQAB -AoGAQNOSxg6CwPj9UulCa90w8mD8l3YjEiR+zP9UdnpQJ6aTv0t8bMeOxSOtQXzm -DqVlAR1mMQkebuprEhA1oGcaZGx5hYIfhad8k5e18nkfogMG2J23fjyw/Zvcsbpi -AebEHGwrPnGplG2AZ2knRVpQ0EkKLUZ3sHGQjCuh/srw5QECQQDb5vKCz181/wnE -0CVIAg61ibwyWNR2s3i2Xhsp0UmhbTSknP2mQzdUqegMB5Y5mbruXy46EHuia5H7 -LnFXfx6BAkEA06VF154NirTBU6MCPtj0ynUkTFSYu7oJG7U+rMA7Bx4itLjAy76g -wniz6HWHMqgQP1G8mhkHYb6fmkBQY1V7AwJANjP07t1ioJKeu856ggdPz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