@@ -19,7 +19,6 @@ import (
19
19
yaml "gopkg.in/yaml.v3"
20
20
21
21
"github.com/jaegertracing/jaeger/internal/metricstest"
22
- "github.com/jaegertracing/jaeger/pkg/config/tlscfg"
23
22
"github.com/jaegertracing/jaeger/pkg/discovery"
24
23
"github.com/jaegertracing/jaeger/pkg/metrics"
25
24
"github.com/jaegertracing/jaeger/proto-gen/api_v2"
@@ -201,7 +200,7 @@ func TestProxyClientTLS(t *testing.T) {
201
200
tests := []struct {
202
201
name string
203
202
clientTLS * configtls.ClientConfig
204
- serverTLS tlscfg. Options
203
+ serverTLS configtls. ServerConfig
205
204
expectError bool
206
205
}{
207
206
{
@@ -215,10 +214,11 @@ func TestProxyClientTLS(t *testing.T) {
215
214
},
216
215
{
217
216
name : "should fail with TLS client to untrusted TLS server" ,
218
- serverTLS : tlscfg.Options {
219
- Enabled : true ,
220
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
221
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
217
+ serverTLS : configtls.ServerConfig {
218
+ Config : configtls.Config {
219
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
220
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
221
+ },
222
222
},
223
223
clientTLS : & configtls.ClientConfig {
224
224
ServerName : "example.com" ,
@@ -227,10 +227,11 @@ func TestProxyClientTLS(t *testing.T) {
227
227
},
228
228
{
229
229
name : "should fail with TLS client to trusted TLS server with incorrect hostname" ,
230
- serverTLS : tlscfg.Options {
231
- Enabled : true ,
232
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
233
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
230
+ serverTLS : configtls.ServerConfig {
231
+ Config : configtls.Config {
232
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
233
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
234
+ },
234
235
},
235
236
clientTLS : & configtls.ClientConfig {
236
237
Config : configtls.Config {
@@ -241,10 +242,11 @@ func TestProxyClientTLS(t *testing.T) {
241
242
},
242
243
{
243
244
name : "should pass with TLS client to trusted TLS server with correct hostname" ,
244
- serverTLS : tlscfg.Options {
245
- Enabled : true ,
246
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
247
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
245
+ serverTLS : configtls.ServerConfig {
246
+ Config : configtls.Config {
247
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
248
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
249
+ },
248
250
},
249
251
clientTLS : & configtls.ClientConfig {
250
252
Config : configtls.Config {
@@ -256,11 +258,12 @@ func TestProxyClientTLS(t *testing.T) {
256
258
},
257
259
{
258
260
name : "should fail with TLS client without cert to trusted TLS server requiring cert" ,
259
- serverTLS : tlscfg.Options {
260
- Enabled : true ,
261
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
262
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
263
- ClientCAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
261
+ serverTLS : configtls.ServerConfig {
262
+ ClientCAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
263
+ Config : configtls.Config {
264
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
265
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
266
+ },
264
267
},
265
268
clientTLS : & configtls.ClientConfig {
266
269
Config : configtls.Config {
@@ -272,11 +275,12 @@ func TestProxyClientTLS(t *testing.T) {
272
275
},
273
276
{
274
277
name : "should fail with TLS client without cert to trusted TLS server requiring cert from a different CA" ,
275
- serverTLS : tlscfg.Options {
276
- Enabled : true ,
277
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
278
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
279
- ClientCAPath : testCertKeyLocation + "/wrong-CA-cert.pem" , // NB: wrong CA
278
+ serverTLS : configtls.ServerConfig {
279
+ ClientCAFile : testCertKeyLocation + "/wrong-CA-cert.pem" , // NB: wrong CA
280
+ Config : configtls.Config {
281
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
282
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
283
+ },
280
284
},
281
285
clientTLS : & configtls.ClientConfig {
282
286
Config : configtls.Config {
@@ -290,11 +294,12 @@ func TestProxyClientTLS(t *testing.T) {
290
294
},
291
295
{
292
296
name : "should pass with TLS client with cert to trusted TLS server requiring cert" ,
293
- serverTLS : tlscfg.Options {
294
- Enabled : true ,
295
- CertPath : testCertKeyLocation + "/example-server-cert.pem" ,
296
- KeyPath : testCertKeyLocation + "/example-server-key.pem" ,
297
- ClientCAPath : testCertKeyLocation + "/example-CA-cert.pem" ,
297
+ serverTLS : configtls.ServerConfig {
298
+ ClientCAFile : testCertKeyLocation + "/example-CA-cert.pem" ,
299
+ Config : configtls.Config {
300
+ CertFile : testCertKeyLocation + "/example-server-cert.pem" ,
301
+ KeyFile : testCertKeyLocation + "/example-server-key.pem" ,
302
+ },
298
303
},
299
304
clientTLS : & configtls.ClientConfig {
300
305
Config : configtls.Config {
@@ -314,11 +319,13 @@ func TestProxyClientTLS(t *testing.T) {
314
319
ctx , cancel := context .WithCancel (context .Background ())
315
320
defer cancel ()
316
321
var opts []grpc.ServerOption
317
- if test .serverTLS .Enabled {
318
- tlsCfg , err := test .serverTLS .ToOtelServerConfig ().LoadTLSConfig (ctx )
322
+
323
+ if test .serverTLS .CertFile != "" && test .serverTLS .KeyFile != "" {
324
+ tlsCfg , err := test .serverTLS .LoadTLSConfig (ctx )
319
325
require .NoError (t , err )
320
326
opts = []grpc.ServerOption {grpc .Creds (credentials .NewTLS (tlsCfg ))}
321
327
}
328
+
322
329
spanHandler := & mockSpanHandler {}
323
330
s , addr := initializeGRPCTestServer (t , func (s * grpc.Server ) {
324
331
api_v2 .RegisterCollectorServiceServer (s , spanHandler )
0 commit comments