6
6
package authentication
7
7
8
8
import (
9
+ "testing"
10
+
9
11
"github.com/nginxinc/kubernetes-nginx-ingress/internal/certification"
10
12
"github.com/nginxinc/kubernetes-nginx-ingress/internal/configuration"
11
- "testing "
13
+ "github.com/nginxinc/kubernetes-nginx-ingress/internal/core "
12
14
)
13
15
14
16
const (
@@ -53,7 +55,7 @@ func TestTlsFactory_UnspecifiedModeDefaultsToNoTls(t *testing.T) {
53
55
}
54
56
55
57
func TestTlsFactory_SelfSignedTlsMode (t * testing.T ) {
56
- certificates := make (map [string ]map [string ][] byte )
58
+ certificates := make (map [string ]map [string ]core. SecretBytes )
57
59
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
58
60
59
61
settings := configuration.Settings {
@@ -88,7 +90,7 @@ func TestTlsFactory_SelfSignedTlsMode(t *testing.T) {
88
90
}
89
91
90
92
func TestTlsFactory_SelfSignedTlsModeCertPoolError (t * testing.T ) {
91
- certificates := make (map [string ]map [string ][] byte )
93
+ certificates := make (map [string ]map [string ]core. SecretBytes )
92
94
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificatePEM ())
93
95
94
96
settings := configuration.Settings {
@@ -109,7 +111,7 @@ func TestTlsFactory_SelfSignedTlsModeCertPoolError(t *testing.T) {
109
111
}
110
112
111
113
func TestTlsFactory_SelfSignedTlsModeCertPoolCertificateParseError (t * testing.T ) {
112
- certificates := make (map [string ]map [string ][] byte )
114
+ certificates := make (map [string ]map [string ]core. SecretBytes )
113
115
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificateDataPEM ())
114
116
115
117
settings := configuration.Settings {
@@ -132,7 +134,7 @@ func TestTlsFactory_SelfSignedTlsModeCertPoolCertificateParseError(t *testing.T)
132
134
}
133
135
134
136
func TestTlsFactory_SelfSignedMtlsMode (t * testing.T ) {
135
- certificates := make (map [string ]map [string ][] byte )
137
+ certificates := make (map [string ]map [string ]core. SecretBytes )
136
138
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
137
139
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
138
140
@@ -168,7 +170,7 @@ func TestTlsFactory_SelfSignedMtlsMode(t *testing.T) {
168
170
}
169
171
170
172
func TestTlsFactory_SelfSignedMtlsModeCertPoolError (t * testing.T ) {
171
- certificates := make (map [string ]map [string ][] byte )
173
+ certificates := make (map [string ]map [string ]core. SecretBytes )
172
174
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificatePEM ())
173
175
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
174
176
@@ -190,7 +192,7 @@ func TestTlsFactory_SelfSignedMtlsModeCertPoolError(t *testing.T) {
190
192
}
191
193
192
194
func TestTlsFactory_SelfSignedMtlsModeClientCertificateError (t * testing.T ) {
193
- certificates := make (map [string ]map [string ][] byte )
195
+ certificates := make (map [string ]map [string ]core. SecretBytes )
194
196
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
195
197
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), invalidCertificatePEM ())
196
198
@@ -241,7 +243,7 @@ func TestTlsFactory_CaTlsMode(t *testing.T) {
241
243
}
242
244
243
245
func TestTlsFactory_CaMtlsMode (t * testing.T ) {
244
- certificates := make (map [string ]map [string ][] byte )
246
+ certificates := make (map [string ]map [string ]core. SecretBytes )
245
247
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
246
248
247
249
settings := configuration.Settings {
@@ -276,7 +278,7 @@ func TestTlsFactory_CaMtlsMode(t *testing.T) {
276
278
}
277
279
278
280
func TestTlsFactory_CaMtlsModeClientCertificateError (t * testing.T ) {
279
- certificates := make (map [string ]map [string ][] byte )
281
+ certificates := make (map [string ]map [string ]core. SecretBytes )
280
282
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
281
283
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), invalidCertificatePEM ())
282
284
@@ -430,15 +432,15 @@ z/3KkMx4uqJXZyvQrmkolSg=
430
432
`
431
433
}
432
434
433
- func buildClientCertificateEntry (keyPEM , certificatePEM string ) map [string ][] byte {
434
- return map [string ][] byte {
435
- certification .CertificateKey : []byte (certificatePEM ),
436
- certification .CertificateKeyKey : []byte (keyPEM ),
435
+ func buildClientCertificateEntry (keyPEM , certificatePEM string ) map [string ]core. SecretBytes {
436
+ return map [string ]core. SecretBytes {
437
+ certification .CertificateKey : core . SecretBytes ( []byte (certificatePEM ) ),
438
+ certification .CertificateKeyKey : core . SecretBytes ( []byte (keyPEM ) ),
437
439
}
438
440
}
439
441
440
- func buildCaCertificateEntry (certificatePEM string ) map [string ][] byte {
441
- return map [string ][] byte {
442
- certification .CertificateKey : []byte (certificatePEM ),
442
+ func buildCaCertificateEntry (certificatePEM string ) map [string ]core. SecretBytes {
443
+ return map [string ]core. SecretBytes {
444
+ certification .CertificateKey : core . SecretBytes ( []byte (certificatePEM ) ),
443
445
}
444
446
}
0 commit comments