@@ -86,6 +86,10 @@ func TestReconcileCerts(t *testing.T) {
86
86
primaryService .Namespace = namespace
87
87
primaryService .Name = "the-primary"
88
88
89
+ replicaService := new (corev1.Service )
90
+ replicaService .Namespace = namespace
91
+ replicaService .Name = "the-replicas"
92
+
89
93
t .Run ("check root certificate reconciliation" , func (t * testing.T ) {
90
94
91
95
initialRoot , err := r .reconcileRootCertificate (ctx , cluster1 )
@@ -295,14 +299,14 @@ func TestReconcileCerts(t *testing.T) {
295
299
assert .NilError (t , err )
296
300
297
301
t .Run ("check standard secret projection" , func (t * testing.T ) {
298
- secretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster1 , primaryService )
302
+ secretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster1 , primaryService , replicaService )
299
303
assert .NilError (t , err )
300
304
301
305
assert .DeepEqual (t , testSecretProjection , secretCertProj )
302
306
})
303
307
304
308
t .Run ("check custom secret projection" , func (t * testing.T ) {
305
- customSecretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster2 , primaryService )
309
+ customSecretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster2 , primaryService , replicaService )
306
310
assert .NilError (t , err )
307
311
308
312
assert .DeepEqual (t , customSecretProjection , customSecretCertProj )
@@ -319,7 +323,7 @@ func TestReconcileCerts(t *testing.T) {
319
323
testSecretProjection := clusterCertSecretProjection (testSecret )
320
324
321
325
// reconcile the secret project using the normal process
322
- customSecretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster2 , primaryService )
326
+ customSecretCertProj , err := r .reconcileClusterCertificate (ctx , initialRoot , cluster2 , primaryService , replicaService )
323
327
assert .NilError (t , err )
324
328
325
329
// results should be the same
@@ -349,7 +353,7 @@ func TestReconcileCerts(t *testing.T) {
349
353
assert .NilError (t , err )
350
354
351
355
// pass in the new root, which should result in a new cluster cert
352
- _ , err = r .reconcileClusterCertificate (ctx , returnedRoot , cluster1 , primaryService )
356
+ _ , err = r .reconcileClusterCertificate (ctx , returnedRoot , cluster1 , primaryService , replicaService )
353
357
assert .NilError (t , err )
354
358
355
359
// get the new cluster cert secret
@@ -371,11 +375,16 @@ func TestReconcileCerts(t *testing.T) {
371
375
"got %q" , leaf .Certificate .CommonName ())
372
376
373
377
if dnsNames := leaf .Certificate .DNSNames (); assert .Check (t , len (dnsNames ) > 1 ) {
374
- assert .DeepEqual (t , dnsNames [1 :], []string {
378
+ assert .DeepEqual (t , dnsNames [1 :4 ], []string {
375
379
"the-primary." + namespace + ".svc" ,
376
380
"the-primary." + namespace ,
377
381
"the-primary" ,
378
382
})
383
+ assert .DeepEqual (t , dnsNames [5 :8 ], []string {
384
+ "the-replicas." + namespace + ".svc" ,
385
+ "the-replicas." + namespace ,
386
+ "the-replicas" ,
387
+ })
379
388
}
380
389
})
381
390
})
0 commit comments