Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a single shared set of CA, client & server keys/certs for testing #2343

Merged
merged 1 commit into from
Jul 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 35 additions & 33 deletions cmd/agent/app/reporter/grpc/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ collectorHostPorts:
- 127.0.0.1:14269
`

var testCertKeyLocation = "../../../../../pkg/config/tlscfg/testdata/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: trailing / not needed


type noopNotifier struct{}

func (noopNotifier) Register(chan<- []string) {}
Expand Down Expand Up @@ -151,7 +153,7 @@ func TestProxyBuilder(t *testing.T) {
CollectorHostPorts: []string{"localhost:0000"},
TLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/not/valid",
CAPath: testCertKeyLocation + "/not/valid",
},
},
expectError: true,
Expand All @@ -162,9 +164,9 @@ func TestProxyBuilder(t *testing.T) {
CollectorHostPorts: []string{"localhost:0000"},
TLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/testCA.pem",
CertPath: "testdata/client.jaeger.io-client.pem",
KeyPath: "testdata/client.jaeger.io-client-key.pem",
CAPath: testCertKeyLocation + "/wrong-CA-cert.pem",
CertPath: testCertKeyLocation + "/example-client-cert.pem",
KeyPath: testCertKeyLocation + "/example-client-key.pem",
},
},
expectError: false,
Expand Down Expand Up @@ -210,88 +212,88 @@ func TestProxyClientTLS(t *testing.T) {
name: "should fail with TLS client to untrusted TLS server",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
},
clientTLS: tlscfg.Options{
Enabled: true,
ServerName: "server.jaeger.io",
ServerName: "example.com",
},
expectError: true,
},
{
name: "should fail with TLS client to trusted TLS server with incorrect hostname",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
},
clientTLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/rootCA.pem",
CAPath: testCertKeyLocation + "/example-CA-cert.pem",
},
expectError: true,
},
{
name: "should pass with TLS client to trusted TLS server with correct hostname",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
},
clientTLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/rootCA.pem",
ServerName: "server.jaeger.io",
CAPath: testCertKeyLocation + "/example-CA-cert.pem",
ServerName: "example.com",
},
expectError: false,
},
{
name: "should fail with TLS client without cert to trusted TLS server requiring cert",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
ClientCAPath: "testdata/rootCA.pem",
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
ClientCAPath: testCertKeyLocation + "/example-CA-cert.pem",
},
clientTLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/rootCA.pem",
ServerName: "server.jaeger.io",
CAPath: testCertKeyLocation + "/example-CA-cert.pem",
ServerName: "example.com",
},
expectError: true,
},
{
name: "should fail with TLS client without cert to trusted TLS server requiring cert from a different CA",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
ClientCAPath: "testdata/testCA.pem", // NB: wrong CA
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
ClientCAPath: testCertKeyLocation + "/wrong-CA-cert.pem", // NB: wrong CA
},
clientTLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/rootCA.pem",
ServerName: "server.jaeger.io",
CertPath: "testdata/client.jaeger.io-client.pem",
KeyPath: "testdata/client.jaeger.io-client-key.pem",
CAPath: testCertKeyLocation + "/example-CA-cert.pem",
ServerName: "example.com",
CertPath: testCertKeyLocation + "/example-client-cert.pem",
KeyPath: testCertKeyLocation + "/example-client-key.pem",
},
expectError: true,
},
{
name: "should pass with TLS client with cert to trusted TLS server requiring cert",
serverTLS: tlscfg.Options{
Enabled: true,
CertPath: "testdata/server.jaeger.io.pem",
KeyPath: "testdata/server.jaeger.io-key.pem",
ClientCAPath: "testdata/rootCA.pem",
CertPath: testCertKeyLocation + "/example-server-cert.pem",
KeyPath: testCertKeyLocation + "/example-server-key.pem",
ClientCAPath: testCertKeyLocation + "/example-CA-cert.pem",
},
clientTLS: tlscfg.Options{
Enabled: true,
CAPath: "testdata/rootCA.pem",
ServerName: "server.jaeger.io",
CertPath: "testdata/client.jaeger.io-client.pem",
KeyPath: "testdata/client.jaeger.io-client-key.pem",
CAPath: testCertKeyLocation + "/example-CA-cert.pem",
ServerName: "example.com",
CertPath: testCertKeyLocation + "/example-client-cert.pem",
KeyPath: testCertKeyLocation + "/example-client-key.pem",
},
expectError: false,
},
Expand Down

This file was deleted.

25 changes: 0 additions & 25 deletions cmd/agent/app/reporter/grpc/testdata/client.jaeger.io-client.pem

This file was deleted.

40 changes: 0 additions & 40 deletions cmd/agent/app/reporter/grpc/testdata/rootCA-key.pem

This file was deleted.

27 changes: 0 additions & 27 deletions cmd/agent/app/reporter/grpc/testdata/rootCA.pem

This file was deleted.

28 changes: 0 additions & 28 deletions cmd/agent/app/reporter/grpc/testdata/server.jaeger.io-key.pem

This file was deleted.

25 changes: 0 additions & 25 deletions cmd/agent/app/reporter/grpc/testdata/server.jaeger.io.pem

This file was deleted.

13 changes: 0 additions & 13 deletions cmd/agent/app/reporter/grpc/testdata/testCA.pem

This file was deleted.

Loading