@@ -39,9 +39,9 @@ const (
39
39
TLSCAChainPath = "testdata/tls-ca-chain.pem"
40
40
ServerCertificatePath = "testdata/server.crt"
41
41
ServerKeyPath = "testdata/server.key"
42
- BarneyCertificatePath = "testdata/barney .crt"
43
- BarneyKeyNoPassPath = "testdata/barney -no-pass.key"
44
- InvalidCA = "testdata/barney -no-pass.key"
42
+ ClientCertificatePath = "testdata/client .crt"
43
+ ClientKeyNoPassPath = "testdata/client -no-pass.key"
44
+ InvalidCA = "testdata/client -no-pass.key"
45
45
WrongClientCertPath = "testdata/self-signed-client.crt"
46
46
WrongClientKeyPath = "testdata/self-signed-client.key"
47
47
EmptyFile = "testdata/empty"
@@ -113,8 +113,8 @@ func TestNewClientFromConfig(t *testing.T) {
113
113
clientConfig : HTTPClientConfig {
114
114
TLSConfig : TLSConfig {
115
115
CAFile : "" ,
116
- CertFile : BarneyCertificatePath ,
117
- KeyFile : BarneyKeyNoPassPath ,
116
+ CertFile : ClientCertificatePath ,
117
+ KeyFile : ClientKeyNoPassPath ,
118
118
ServerName : "" ,
119
119
InsecureSkipVerify : true },
120
120
},
@@ -125,8 +125,8 @@ func TestNewClientFromConfig(t *testing.T) {
125
125
clientConfig : HTTPClientConfig {
126
126
TLSConfig : TLSConfig {
127
127
CAFile : TLSCAChainPath ,
128
- CertFile : BarneyCertificatePath ,
129
- KeyFile : BarneyKeyNoPassPath ,
128
+ CertFile : ClientCertificatePath ,
129
+ KeyFile : ClientKeyNoPassPath ,
130
130
ServerName : "" ,
131
131
InsecureSkipVerify : false },
132
132
},
@@ -138,8 +138,8 @@ func TestNewClientFromConfig(t *testing.T) {
138
138
BearerToken : BearerToken ,
139
139
TLSConfig : TLSConfig {
140
140
CAFile : TLSCAChainPath ,
141
- CertFile : BarneyCertificatePath ,
142
- KeyFile : BarneyKeyNoPassPath ,
141
+ CertFile : ClientCertificatePath ,
142
+ KeyFile : ClientKeyNoPassPath ,
143
143
ServerName : "" ,
144
144
InsecureSkipVerify : false },
145
145
},
@@ -157,8 +157,8 @@ func TestNewClientFromConfig(t *testing.T) {
157
157
BearerTokenFile : BearerTokenFile ,
158
158
TLSConfig : TLSConfig {
159
159
CAFile : TLSCAChainPath ,
160
- CertFile : BarneyCertificatePath ,
161
- KeyFile : BarneyKeyNoPassPath ,
160
+ CertFile : ClientCertificatePath ,
161
+ KeyFile : ClientKeyNoPassPath ,
162
162
ServerName : "" ,
163
163
InsecureSkipVerify : false },
164
164
},
@@ -179,8 +179,8 @@ func TestNewClientFromConfig(t *testing.T) {
179
179
},
180
180
TLSConfig : TLSConfig {
181
181
CAFile : TLSCAChainPath ,
182
- CertFile : BarneyCertificatePath ,
183
- KeyFile : BarneyKeyNoPassPath ,
182
+ CertFile : ClientCertificatePath ,
183
+ KeyFile : ClientKeyNoPassPath ,
184
184
ServerName : "" ,
185
185
InsecureSkipVerify : false },
186
186
},
@@ -274,8 +274,8 @@ func TestMissingBearerAuthFile(t *testing.T) {
274
274
BearerTokenFile : MissingBearerTokenFile ,
275
275
TLSConfig : TLSConfig {
276
276
CAFile : TLSCAChainPath ,
277
- CertFile : BarneyCertificatePath ,
278
- KeyFile : BarneyKeyNoPassPath ,
277
+ CertFile : ClientCertificatePath ,
278
+ KeyFile : ClientKeyNoPassPath ,
279
279
ServerName : "" ,
280
280
InsecureSkipVerify : false },
281
281
}
@@ -361,8 +361,8 @@ func TestBearerAuthFileRoundTripper(t *testing.T) {
361
361
func TestTLSConfig (t * testing.T ) {
362
362
configTLSConfig := TLSConfig {
363
363
CAFile : TLSCAChainPath ,
364
- CertFile : BarneyCertificatePath ,
365
- KeyFile : BarneyKeyNoPassPath ,
364
+ CertFile : ClientCertificatePath ,
365
+ KeyFile : ClientKeyNoPassPath ,
366
366
ServerName : "localhost" ,
367
367
InsecureSkipVerify : false }
368
368
@@ -384,17 +384,17 @@ func TestTLSConfig(t *testing.T) {
384
384
t .Fatalf ("Can't create a new TLS Config from a configuration (%s)." , err )
385
385
}
386
386
387
- barneyCertificate , err := tls .LoadX509KeyPair (BarneyCertificatePath , BarneyKeyNoPassPath )
387
+ clientCertificate , err := tls .LoadX509KeyPair (ClientCertificatePath , ClientKeyNoPassPath )
388
388
if err != nil {
389
389
t .Fatalf ("Can't load the client key pair ('%s' and '%s'). Reason: %s" ,
390
- BarneyCertificatePath , BarneyKeyNoPassPath , err )
390
+ ClientCertificatePath , ClientKeyNoPassPath , err )
391
391
}
392
392
cert , err := tlsConfig .GetClientCertificate (nil )
393
393
if err != nil {
394
394
t .Fatalf ("unexpected error returned by tlsConfig.GetClientCertificate(): %s" , err )
395
395
}
396
- if ! reflect .DeepEqual (cert , & barneyCertificate ) {
397
- t .Fatalf ("Unexpected client certificate result: \n \n %+v\n expected\n \n %+v" , cert , barneyCertificate )
396
+ if ! reflect .DeepEqual (cert , & clientCertificate ) {
397
+ t .Fatalf ("Unexpected client certificate result: \n \n %+v\n expected\n \n %+v" , cert , clientCertificate )
398
398
}
399
399
400
400
// non-nil functions are never equal.
@@ -440,18 +440,18 @@ func TestTLSConfigInvalidCA(t *testing.T) {
440
440
configTLSConfig : TLSConfig {
441
441
CAFile : "" ,
442
442
CertFile : MissingCert ,
443
- KeyFile : BarneyKeyNoPassPath ,
443
+ KeyFile : ClientKeyNoPassPath ,
444
444
ServerName : "" ,
445
445
InsecureSkipVerify : false },
446
- errorMessage : fmt .Sprintf ("unable to use specified client cert (%s) & key (%s):" , MissingCert , BarneyKeyNoPassPath ),
446
+ errorMessage : fmt .Sprintf ("unable to use specified client cert (%s) & key (%s):" , MissingCert , ClientKeyNoPassPath ),
447
447
}, {
448
448
configTLSConfig : TLSConfig {
449
449
CAFile : "" ,
450
- CertFile : BarneyCertificatePath ,
450
+ CertFile : ClientCertificatePath ,
451
451
KeyFile : MissingKey ,
452
452
ServerName : "" ,
453
453
InsecureSkipVerify : false },
454
- errorMessage : fmt .Sprintf ("unable to use specified client cert (%s) & key (%s):" , BarneyCertificatePath , MissingKey ),
454
+ errorMessage : fmt .Sprintf ("unable to use specified client cert (%s) & key (%s):" , ClientCertificatePath , MissingKey ),
455
455
},
456
456
}
457
457
@@ -548,8 +548,8 @@ func TestBasicAuthPasswordFile(t *testing.T) {
548
548
func getCertificateBlobs (t * testing.T ) map [string ][]byte {
549
549
files := []string {
550
550
TLSCAChainPath ,
551
- BarneyCertificatePath ,
552
- BarneyKeyNoPassPath ,
551
+ ClientCertificatePath ,
552
+ ClientKeyNoPassPath ,
553
553
ServerCertificatePath ,
554
554
ServerKeyPath ,
555
555
WrongClientCertPath ,
@@ -608,14 +608,14 @@ func TestTLSRoundTripper(t *testing.T) {
608
608
{
609
609
// Valid certs.
610
610
ca : TLSCAChainPath ,
611
- cert : BarneyCertificatePath ,
612
- key : BarneyKeyNoPassPath ,
611
+ cert : ClientCertificatePath ,
612
+ key : ClientKeyNoPassPath ,
613
613
},
614
614
{
615
615
// CA not matching.
616
- ca : BarneyCertificatePath ,
617
- cert : BarneyCertificatePath ,
618
- key : BarneyKeyNoPassPath ,
616
+ ca : ClientCertificatePath ,
617
+ cert : ClientCertificatePath ,
618
+ key : ClientKeyNoPassPath ,
619
619
620
620
errMsg : "certificate signed by unknown authority" ,
621
621
},
@@ -630,32 +630,32 @@ func TestTLSRoundTripper(t *testing.T) {
630
630
{
631
631
// CA file empty
632
632
ca : EmptyFile ,
633
- cert : BarneyCertificatePath ,
634
- key : BarneyKeyNoPassPath ,
633
+ cert : ClientCertificatePath ,
634
+ key : ClientKeyNoPassPath ,
635
635
636
636
errMsg : "unable to use specified CA cert" ,
637
637
},
638
638
{
639
639
// cert file empty
640
640
ca : TLSCAChainPath ,
641
641
cert : EmptyFile ,
642
- key : BarneyKeyNoPassPath ,
642
+ key : ClientKeyNoPassPath ,
643
643
644
644
errMsg : "failed to find any PEM data in certificate input" ,
645
645
},
646
646
{
647
647
// key file empty
648
648
ca : TLSCAChainPath ,
649
- cert : BarneyCertificatePath ,
649
+ cert : ClientCertificatePath ,
650
650
key : EmptyFile ,
651
651
652
652
errMsg : "failed to find any PEM data in key input" ,
653
653
},
654
654
{
655
655
// Valid certs again.
656
656
ca : TLSCAChainPath ,
657
- cert : BarneyCertificatePath ,
658
- key : BarneyKeyNoPassPath ,
657
+ cert : ClientCertificatePath ,
658
+ key : ClientKeyNoPassPath ,
659
659
},
660
660
}
661
661
@@ -745,8 +745,8 @@ func TestTLSRoundTripperRaces(t *testing.T) {
745
745
746
746
var c * http.Client
747
747
writeCertificate (bs , TLSCAChainPath , ca )
748
- writeCertificate (bs , BarneyCertificatePath , cert )
749
- writeCertificate (bs , BarneyKeyNoPassPath , key )
748
+ writeCertificate (bs , ClientCertificatePath , cert )
749
+ writeCertificate (bs , ClientKeyNoPassPath , key )
750
750
c , err = NewClientFromConfig (cfg , "test" )
751
751
if err != nil {
752
752
t .Fatalf ("Error creating HTTP Client: %v" , err )
@@ -785,7 +785,7 @@ func TestTLSRoundTripperRaces(t *testing.T) {
785
785
tick := time .NewTicker (10 * time .Millisecond )
786
786
<- tick .C
787
787
if i % 2 == 0 {
788
- writeCertificate (bs , BarneyCertificatePath , ca )
788
+ writeCertificate (bs , ClientCertificatePath , ca )
789
789
} else {
790
790
writeCertificate (bs , TLSCAChainPath , ca )
791
791
}
0 commit comments