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 (
@@ -34,7 +36,7 @@ func TestTlsFactory_UnspecifiedModeDefaultsToNoTls(t *testing.T) {
34
36
}
35
37
36
38
func TestTlsFactory_SelfSignedTlsMode (t * testing.T ) {
37
- certificates := make (map [string ]map [string ][] byte )
39
+ certificates := make (map [string ]map [string ]core. SecretBytes )
38
40
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
39
41
40
42
settings := configuration.Settings {
@@ -69,7 +71,7 @@ func TestTlsFactory_SelfSignedTlsMode(t *testing.T) {
69
71
}
70
72
71
73
func TestTlsFactory_SelfSignedTlsModeCertPoolError (t * testing.T ) {
72
- certificates := make (map [string ]map [string ][] byte )
74
+ certificates := make (map [string ]map [string ]core. SecretBytes )
73
75
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificatePEM ())
74
76
75
77
settings := configuration.Settings {
@@ -90,7 +92,7 @@ func TestTlsFactory_SelfSignedTlsModeCertPoolError(t *testing.T) {
90
92
}
91
93
92
94
func TestTlsFactory_SelfSignedTlsModeCertPoolCertificateParseError (t * testing.T ) {
93
- certificates := make (map [string ]map [string ][] byte )
95
+ certificates := make (map [string ]map [string ]core. SecretBytes )
94
96
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificateDataPEM ())
95
97
96
98
settings := configuration.Settings {
@@ -113,7 +115,7 @@ func TestTlsFactory_SelfSignedTlsModeCertPoolCertificateParseError(t *testing.T)
113
115
}
114
116
115
117
func TestTlsFactory_SelfSignedMtlsMode (t * testing.T ) {
116
- certificates := make (map [string ]map [string ][] byte )
118
+ certificates := make (map [string ]map [string ]core. SecretBytes )
117
119
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
118
120
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
119
121
@@ -149,7 +151,7 @@ func TestTlsFactory_SelfSignedMtlsMode(t *testing.T) {
149
151
}
150
152
151
153
func TestTlsFactory_SelfSignedMtlsModeCertPoolError (t * testing.T ) {
152
- certificates := make (map [string ]map [string ][] byte )
154
+ certificates := make (map [string ]map [string ]core. SecretBytes )
153
155
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (invalidCertificatePEM ())
154
156
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
155
157
@@ -171,7 +173,7 @@ func TestTlsFactory_SelfSignedMtlsModeCertPoolError(t *testing.T) {
171
173
}
172
174
173
175
func TestTlsFactory_SelfSignedMtlsModeClientCertificateError (t * testing.T ) {
174
- certificates := make (map [string ]map [string ][] byte )
176
+ certificates := make (map [string ]map [string ]core. SecretBytes )
175
177
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
176
178
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), invalidCertificatePEM ())
177
179
@@ -222,7 +224,7 @@ func TestTlsFactory_CaTlsMode(t *testing.T) {
222
224
}
223
225
224
226
func TestTlsFactory_CaMtlsMode (t * testing.T ) {
225
- certificates := make (map [string ]map [string ][] byte )
227
+ certificates := make (map [string ]map [string ]core. SecretBytes )
226
228
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), clientCertificatePEM ())
227
229
228
230
settings := configuration.Settings {
@@ -257,7 +259,7 @@ func TestTlsFactory_CaMtlsMode(t *testing.T) {
257
259
}
258
260
259
261
func TestTlsFactory_CaMtlsModeClientCertificateError (t * testing.T ) {
260
- certificates := make (map [string ]map [string ][] byte )
262
+ certificates := make (map [string ]map [string ]core. SecretBytes )
261
263
certificates [CaCertificateSecretKey ] = buildCaCertificateEntry (caCertificatePEM ())
262
264
certificates [ClientCertificateSecretKey ] = buildClientCertificateEntry (clientKeyPEM (), invalidCertificatePEM ())
263
265
@@ -411,15 +413,15 @@ z/3KkMx4uqJXZyvQrmkolSg=
411
413
`
412
414
}
413
415
414
- func buildClientCertificateEntry (keyPEM , certificatePEM string ) map [string ][] byte {
415
- return map [string ][] byte {
416
- certification .CertificateKey : []byte (certificatePEM ),
417
- certification .CertificateKeyKey : []byte (keyPEM ),
416
+ func buildClientCertificateEntry (keyPEM , certificatePEM string ) map [string ]core. SecretBytes {
417
+ return map [string ]core. SecretBytes {
418
+ certification .CertificateKey : core . SecretBytes ( []byte (certificatePEM ) ),
419
+ certification .CertificateKeyKey : core . SecretBytes ( []byte (keyPEM ) ),
418
420
}
419
421
}
420
422
421
- func buildCaCertificateEntry (certificatePEM string ) map [string ][] byte {
422
- return map [string ][] byte {
423
- certification .CertificateKey : []byte (certificatePEM ),
423
+ func buildCaCertificateEntry (certificatePEM string ) map [string ]core. SecretBytes {
424
+ return map [string ]core. SecretBytes {
425
+ certification .CertificateKey : core . SecretBytes ( []byte (certificatePEM ) ),
424
426
}
425
427
}
0 commit comments