-
Notifications
You must be signed in to change notification settings - Fork 2k
/
tests.go
1035 lines (898 loc) · 42.8 KB
/
tests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright 2020 The cert-manager Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package certificates
import (
"context"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
"fmt"
"reflect"
"strconv"
"strings"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
networkingv1beta1 "k8s.io/api/networking/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/retry"
"k8s.io/utils/pointer"
"github.com/cert-manager/cert-manager/internal/controller/feature"
cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"
"github.com/cert-manager/cert-manager/pkg/util"
utilfeature "github.com/cert-manager/cert-manager/pkg/util/feature"
"github.com/cert-manager/cert-manager/pkg/util/pki"
"github.com/cert-manager/cert-manager/test/e2e/framework"
"github.com/cert-manager/cert-manager/test/e2e/framework/helper/featureset"
"github.com/cert-manager/cert-manager/test/e2e/framework/helper/validation"
"github.com/cert-manager/cert-manager/test/e2e/framework/helper/validation/certificates"
e2eutil "github.com/cert-manager/cert-manager/test/e2e/util"
)
// Define defines simple conformance tests that can be run against any issuer type.
// If Complete has not been called on this Suite before Define, it will be
// automatically called.
func (s *Suite) Define() {
Describe("with issuer type "+s.Name, func() {
ctx := context.Background()
f := framework.NewDefaultFramework("certificates")
sharedIPAddress := "127.0.0.1"
// Wrap this in a BeforeEach else flags will not have been parsed and
// f.Config will not be populated at the time that this code is run.
BeforeEach(func() {
// Special case Public ACME Servers against being run in the standard
// e2e tests.
if strings.Contains(s.Name, "Public ACME Server") && strings.Contains(f.Config.Addons.ACMEServer.URL, "pebble") {
Skip("Not running public ACME tests against local cluster.")
return
}
if s.completed {
return
}
s.complete(f)
switch s.HTTP01TestType {
case "Ingress":
sharedIPAddress = f.Config.Addons.ACMEServer.IngressIP
case "Gateway":
sharedIPAddress = f.Config.Addons.ACMEServer.GatewayIP
framework.RequireFeatureGate(f, utilfeature.DefaultFeatureGate, feature.ExperimentalGatewayAPISupport)
}
})
s.it(f, "should issue a basic, defaulted certificate for a single distinct DNS Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IssuerRef: issuerRef,
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.OnlySAN)
s.it(f, "should issue a CA certificate with the CA basicConstraint set", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IsCA: true,
IssuerRef: issuerRef,
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.IssueCAFeature)
s.it(f, "should issue an ECDSA, defaulted certificate for a single distinct DNS Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
PrivateKey: &cmapi.CertificatePrivateKey{
Algorithm: cmapi.ECDSAKeyAlgorithm,
},
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.ECDSAFeature, featureset.OnlySAN)
s.it(f, "should issue an Ed25519, defaulted certificate for a single distinct DNS Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
PrivateKey: &cmapi.CertificatePrivateKey{
Algorithm: cmapi.Ed25519KeyAlgorithm,
},
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.OnlySAN, featureset.Ed25519FeatureSet)
s.it(f, "should issue a basic, defaulted certificate for a single Common Name", func(issuerRef cmmeta.ObjectReference) {
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
cn := "test-common-name-" + util.RandStringRunes(10)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IssuerRef: issuerRef,
CommonName: cn,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.CommonNameFeature)
s.it(f, "should issue a basic, defaulted certificate for a single distinct DNS Name with a literal subject", func(issuerRef cmmeta.ObjectReference) {
framework.RequireFeatureGate(f, utilfeature.DefaultFeatureGate, feature.LiteralCertificateSubject)
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
host := fmt.Sprintf("*.%s.foo-long.bar.com", util.RandStringRunes(10))
literalSubject := fmt.Sprintf("CN=%s,OU=FooLong,OU=Bar,OU=Baz,OU=Dept.,O=Corp.", host)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IssuerRef: issuerRef,
LiteralSubject: literalSubject,
DNSNames: []string{host},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*5)
Expect(err).NotTo(HaveOccurred())
//type ValidationFunc func(certificate *cmapi.Certificate, secret *corev1.Secret) error
valFunc := func(certificate *cmapi.Certificate, secret *corev1.Secret) error {
certBytes, ok := secret.Data[corev1.TLSCertKey]
if !ok {
return fmt.Errorf("no certificate data found for Certificate %q (secret %q)", certificate.Name, certificate.Spec.SecretName)
}
createdCert, err := pki.DecodeX509CertificateBytes(certBytes)
if err != nil {
return err
}
var dns pkix.RDNSequence
rest, err := asn1.Unmarshal(createdCert.RawSubject, &dns)
if err != nil {
return err
}
rdnSeq, err2 := pki.ParseSubjectStringToRdnSequence(literalSubject)
if err2 != nil {
return err2
}
fmt.Fprintln(GinkgoWriter, "cert", base64.StdEncoding.EncodeToString(createdCert.RawSubject), dns, err, rest)
if !reflect.DeepEqual(rdnSeq, dns) {
return fmt.Errorf("generated certificate's subject [%s] does not match expected subject [%s]", dns.String(), literalSubject)
}
return nil
}
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, valFunc)
Expect(err).NotTo(HaveOccurred())
}, featureset.LiteralSubjectFeature)
s.it(f, "should issue an ECDSA, defaulted certificate for a single Common Name", func(issuerRef cmmeta.ObjectReference) {
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
cn := "test-common-name-" + util.RandStringRunes(10)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
PrivateKey: &cmapi.CertificatePrivateKey{
Algorithm: cmapi.ECDSAKeyAlgorithm,
},
CommonName: cn,
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.ECDSAFeature, featureset.CommonNameFeature)
s.it(f, "should issue an Ed25519, defaulted certificate for a single Common Name", func(issuerRef cmmeta.ObjectReference) {
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
cn := "test-common-name-" + util.RandStringRunes(10)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
PrivateKey: &cmapi.CertificatePrivateKey{
Algorithm: cmapi.Ed25519KeyAlgorithm,
},
CommonName: cn,
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.Ed25519FeatureSet, featureset.CommonNameFeature)
s.it(f, "should issue a certificate that defines an IP Address", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IPAddresses: []string{sharedIPAddress},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.IPAddressFeature)
s.it(f, "should issue a certificate that defines a DNS Name and IP Address", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IPAddresses: []string{sharedIPAddress},
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.OnlySAN, featureset.IPAddressFeature)
s.it(f, "should issue a certificate that defines a Common Name and IP Address", func(issuerRef cmmeta.ObjectReference) {
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
cn := "test-common-name-" + util.RandStringRunes(10)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
CommonName: cn,
IPAddresses: []string{sharedIPAddress},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.CommonNameFeature, featureset.IPAddressFeature)
s.it(f, "should issue a certificate that defines an Email Address", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
EmailAddresses: []string{"alice@example.com"},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.EmailSANsFeature, featureset.OnlySAN)
s.it(f, "should issue a certificate that defines a Common Name and URI SAN", func(issuerRef cmmeta.ObjectReference) {
// Some issuers use the CN to define the cert's "ID"
// if one cert manages to be in an error state in the issuer it might throw an error
// this makes the CN more unique
cn := "test-common-name-" + util.RandStringRunes(10)
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
CommonName: cn,
URIs: []string{"spiffe://cluster.local/ns/sandbox/sa/foo"},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.URISANsFeature, featureset.CommonNameFeature)
s.it(f, "should issue a certificate that defines a 2 distinct DNS Names with one copied to the Common Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
CommonName: e2eutil.RandomSubdomain(s.DomainSuffix),
IssuerRef: issuerRef,
},
}
testCertificate.Spec.DNSNames = []string{
testCertificate.Spec.CommonName, e2eutil.RandomSubdomain(s.DomainSuffix),
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.CommonNameFeature)
s.it(f, "should issue a certificate that defines a distinct DNS Name and another distinct Common Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
CommonName: e2eutil.RandomSubdomain(s.DomainSuffix),
IssuerRef: issuerRef,
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.CommonNameFeature)
s.it(f, "should issue a certificate that defines a DNS Name and sets a duration", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IssuerRef: issuerRef,
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
Duration: &metav1.Duration{
Duration: time.Hour * 896,
},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
// We set a weird time here as the duration with should never be used as
// a default by an issuer. This lets us test issuers are using our given
// duration.
// We set a 30 second buffer time here since Vault issues certificates
// with an extra 30 seconds on its duration.
f.CertificateDurationValid(testCertificate, time.Hour*896, 30*time.Second)
}, featureset.DurationFeature, featureset.OnlySAN)
s.it(f, "should issue a certificate that defines a wildcard DNS Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
IssuerRef: issuerRef,
DNSNames: []string{"*." + e2eutil.RandomSubdomain(s.DomainSuffix)},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.WildcardsFeature, featureset.OnlySAN)
s.it(f, "should issue a certificate that includes only a URISANs name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
URIs: []string{
"spiffe://cluster.local/ns/sandbox/sa/foo",
},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.URISANsFeature, featureset.OnlySAN)
s.it(f, "should issue a certificate that includes arbitrary key usages", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
Usages: []cmapi.KeyUsage{
cmapi.UsageSigning,
cmapi.UsageDataEncipherment,
cmapi.UsageServerAuth,
cmapi.UsageClientAuth,
},
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
validations := []certificates.ValidationFunc{
certificates.ExpectKeyUsageExtKeyUsageClientAuth,
certificates.ExpectKeyUsageExtKeyUsageServerAuth,
certificates.ExpectKeyUsageUsageDigitalSignature,
certificates.ExpectKeyUsageUsageDataEncipherment,
}
validations = append(validations, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
err = f.Helper().ValidateCertificate(testCertificate, validations...)
Expect(err).NotTo(HaveOccurred())
}, featureset.KeyUsagesFeature, featureset.OnlySAN)
s.it(f, "should issue another certificate with the same private key if the existing certificate and CertificateRequest are deleted", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
},
}
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(testCertificate, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
By("Deleting existing certificate data in Secret")
sec, err := f.KubeClientSet.CoreV1().Secrets(f.Namespace.Name).
Get(context.TODO(), testCertificate.Spec.SecretName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred(), "failed to get secret containing signed certificate key pair data")
sec = sec.DeepCopy()
crtPEM1 := sec.Data[corev1.TLSCertKey]
crt1, err := pki.DecodeX509CertificateBytes(crtPEM1)
Expect(err).NotTo(HaveOccurred(), "failed to get decode first signed certificate data")
sec.Data[corev1.TLSCertKey] = []byte{}
_, err = f.KubeClientSet.CoreV1().Secrets(f.Namespace.Name).Update(context.TODO(), sec, metav1.UpdateOptions{})
Expect(err).NotTo(HaveOccurred(), "failed to update secret by deleting the signed certificate data")
By("Waiting for the Certificate to re-issue a certificate")
sec, err = f.Helper().WaitForSecretCertificateData(f.Namespace.Name, sec.Name, time.Minute*8)
Expect(err).NotTo(HaveOccurred(), "failed to wait for secret to have a valid 2nd certificate")
crtPEM2 := sec.Data[corev1.TLSCertKey]
crt2, err := pki.DecodeX509CertificateBytes(crtPEM2)
Expect(err).NotTo(HaveOccurred(), "failed to get decode second signed certificate data")
By("Ensuing both certificates are signed by same private key")
match, err := pki.PublicKeysEqual(crt1.PublicKey, crt2.PublicKey)
Expect(err).NotTo(HaveOccurred(), "failed to check public keys of both signed certificates")
if !match {
Fail("Both signed certificates not signed by same private key")
}
}, featureset.ReusePrivateKeyFeature, featureset.OnlySAN)
s.it(f, "should issue a certificate for a single distinct DNS Name defined by an ingress with annotations", func(issuerRef cmmeta.ObjectReference) {
if s.HTTP01TestType != "Ingress" {
// TODO @jakexks: remove this skip once either haproxy or traefik fully support gateway API
Skip("Skipping ingress-specific as non ingress HTTP-01 solver is in use")
return
}
var certName string
switch {
case e2eutil.HasIngresses(f.KubeClientSet.Discovery(), networkingv1.SchemeGroupVersion.String()):
ingClient := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace.Name)
name := "testcert-ingress"
secretName := "testcert-ingress-tls"
By("Creating an Ingress with the issuer name annotation set")
ingress, err := ingClient.Create(context.TODO(), e2eutil.NewIngress(name, secretName, map[string]string{
"cert-manager.io/issuer": issuerRef.Name,
"cert-manager.io/issuer-kind": issuerRef.Kind,
"cert-manager.io/issuer-group": issuerRef.Group,
}, e2eutil.RandomSubdomain(s.DomainSuffix)), metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
certName = ingress.Spec.TLS[0].SecretName
case e2eutil.HasIngresses(f.KubeClientSet.Discovery(), networkingv1beta1.SchemeGroupVersion.String()):
ingClient := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace.Name)
name := "testcert-ingress"
secretName := "testcert-ingress-tls"
By("Creating an Ingress with the issuer name annotation set")
ingress, err := ingClient.Create(context.TODO(), e2eutil.NewV1Beta1Ingress(name, secretName, map[string]string{
"cert-manager.io/issuer": issuerRef.Name,
"cert-manager.io/issuer-kind": issuerRef.Kind,
"cert-manager.io/issuer-group": issuerRef.Group,
}, e2eutil.RandomSubdomain(s.DomainSuffix)), metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
certName = ingress.Spec.TLS[0].SecretName
default:
Fail("Neither " + networkingv1.SchemeGroupVersion.String() + " nor " + networkingv1beta1.SchemeGroupVersion.String() + " were discovered in the API server")
}
By("Waiting for the Certificate to exist...")
cert, err := f.Helper().WaitForCertificateToExist(f.Namespace.Name, certName, time.Minute)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
cert, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(cert, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(cert, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
}, featureset.OnlySAN)
s.it(f, "should issue a certificate defined by an ingress with certificate field annotations", func(issuerRef cmmeta.ObjectReference) {
if s.HTTP01TestType != "Ingress" {
// TODO @jakexks: remove this skip once either haproxy or traefik fully support gateway API
Skip("Skipping ingress-specific as non ingress HTTP-01 solver is in use")
return
}
var certName string
domain := e2eutil.RandomSubdomain(s.DomainSuffix)
duration := time.Hour * 999
renewBefore := time.Hour * 111
revisionHistoryLimit := pointer.Int32(7)
privateKeyAlgorithm := cmapi.RSAKeyAlgorithm
privateKeyEncoding := cmapi.PKCS1
privateKeySize := 4096
privateKeyRotationPolicy := cmapi.RotationPolicyAlways
switch {
case e2eutil.HasIngresses(f.KubeClientSet.Discovery(), networkingv1.SchemeGroupVersion.String()):
ingClient := f.KubeClientSet.NetworkingV1().Ingresses(f.Namespace.Name)
name := "testcert-ingress"
secretName := "testcert-ingress-tls"
By("Creating an Ingress with annotations for issuerRef and other Certificate fields")
ingress, err := ingClient.Create(context.TODO(), e2eutil.NewIngress(name, secretName, map[string]string{
"cert-manager.io/issuer": issuerRef.Name,
"cert-manager.io/issuer-kind": issuerRef.Kind,
"cert-manager.io/issuer-group": issuerRef.Group,
"cert-manager.io/common-name": domain,
"cert-manager.io/duration": duration.String(),
"cert-manager.io/renew-before": renewBefore.String(),
"cert-manager.io/revision-history-limit": strconv.FormatInt(int64(*revisionHistoryLimit), 10),
"cert-manager.io/private-key-algorithm": string(privateKeyAlgorithm),
"cert-manager.io/private-key-encoding": string(privateKeyEncoding),
"cert-manager.io/private-key-size": strconv.Itoa(privateKeySize),
"cert-manager.io/private-key-rotation-policy": string(privateKeyRotationPolicy),
}, domain), metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
certName = ingress.Spec.TLS[0].SecretName
case e2eutil.HasIngresses(f.KubeClientSet.Discovery(), networkingv1beta1.SchemeGroupVersion.String()):
ingClient := f.KubeClientSet.NetworkingV1beta1().Ingresses(f.Namespace.Name)
name := "testcert-ingress"
secretName := "testcert-ingress-tls"
By("Creating an Ingress with annotations for issuerRef and other Certificate fields")
ingress, err := ingClient.Create(context.TODO(), e2eutil.NewV1Beta1Ingress(name, secretName, map[string]string{
"cert-manager.io/issuer": issuerRef.Name,
"cert-manager.io/issuer-kind": issuerRef.Kind,
"cert-manager.io/issuer-group": issuerRef.Group,
"cert-manager.io/common-name": domain,
"cert-manager.io/duration": duration.String(),
"cert-manager.io/renew-before": renewBefore.String(),
"cert-manager.io/revision-history-limit": strconv.FormatInt(int64(*revisionHistoryLimit), 10),
"cert-manager.io/private-key-algorithm": string(privateKeyAlgorithm),
"cert-manager.io/private-key-encoding": string(privateKeyEncoding),
"cert-manager.io/private-key-size": strconv.Itoa(privateKeySize),
"cert-manager.io/private-key-rotation-policy": string(privateKeyRotationPolicy),
}, domain), metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
certName = ingress.Spec.TLS[0].SecretName
default:
Fail("Neither " + networkingv1.SchemeGroupVersion.String() + " nor " + networkingv1beta1.SchemeGroupVersion.String() + " were discovered in the API server")
}
By("Waiting for the Certificate to exist...")
cert, err := f.Helper().WaitForCertificateToExist(f.Namespace.Name, certName, time.Minute)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
cert, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(cert, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
// Verify that the ingres-shim has translated all the supplied
// annotations into equivalent Certificate field values
By("Validating the created Certificate")
err = f.Helper().ValidateCertificate(
cert,
func(certificate *cmapi.Certificate, _ *corev1.Secret) error {
Expect(certificate.Spec.DNSNames).To(ConsistOf(domain))
Expect(certificate.Spec.CommonName).To(Equal(domain))
Expect(certificate.Spec.Duration.Duration).To(Equal(duration))
Expect(certificate.Spec.RenewBefore.Duration).To(Equal(renewBefore))
Expect(certificate.Spec.RevisionHistoryLimit).To(Equal(revisionHistoryLimit))
Expect(certificate.Spec.PrivateKey.Algorithm).To(Equal(privateKeyAlgorithm))
Expect(certificate.Spec.PrivateKey.Encoding).To(Equal(privateKeyEncoding))
Expect(certificate.Spec.PrivateKey.Size).To(Equal(privateKeySize))
Expect(certificate.Spec.PrivateKey.RotationPolicy).To(Equal(privateKeyRotationPolicy))
return nil
},
)
Expect(err).NotTo(HaveOccurred())
// Verify that the issuer has preserved all the Certificate values
// in the signed certificate
By("Validating the issued Certificate...")
err = f.Helper().ValidateCertificate(cert, validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)...)
Expect(err).NotTo(HaveOccurred())
})
s.it(f, "Creating a Gateway with annotations for issuerRef and other Certificate fields", func(issuerRef cmmeta.ObjectReference) {
framework.RequireFeatureGate(f, utilfeature.DefaultFeatureGate, feature.ExperimentalGatewayAPISupport)
name := "testcert-gateway"
secretName := "testcert-gateway-tls"
domain := e2eutil.RandomSubdomain(s.DomainSuffix)
duration := time.Hour * 999
renewBefore := time.Hour * 111
By("Creating a Gateway with annotations for issuerRef and other Certificate fields")
gw := e2eutil.NewGateway(name, f.Namespace.Name, secretName, map[string]string{
"cert-manager.io/issuer": issuerRef.Name,
"cert-manager.io/issuer-kind": issuerRef.Kind,
"cert-manager.io/issuer-group": issuerRef.Group,
"cert-manager.io/common-name": domain,
"cert-manager.io/duration": duration.String(),
"cert-manager.io/renew-before": renewBefore.String(),
}, domain)
gw, err := f.GWClientSet.GatewayV1beta1().Gateways(f.Namespace.Name).Create(context.TODO(), gw, metav1.CreateOptions{})
Expect(err).NotTo(HaveOccurred())
// XXX(Mael): the CertificateRef seems to contain the Gateway name
// "testcert-gateway" instead of the secretName
// "testcert-gateway-tls".
certName := string(gw.Spec.Listeners[0].TLS.CertificateRefs[0].Name)
By("Waiting for the Certificate to exist...")
cert, err := f.Helper().WaitForCertificateToExist(f.Namespace.Name, certName, time.Minute)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
cert, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(cert, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
// Verify that the gateway-shim has translated all the supplied
// annotations into equivalent Certificate field values
By("Validating the created Certificate")
Expect(cert.Spec.DNSNames).To(ConsistOf(domain))
Expect(cert.Spec.CommonName).To(Equal(domain))
Expect(cert.Spec.Duration.Duration).To(Equal(duration))
Expect(cert.Spec.RenewBefore.Duration).To(Equal(renewBefore))
})
s.it(f, "should issue a certificate that defines a long domain", func(issuerRef cmmeta.ObjectReference) {
// the maximum length of a single segment of the domain being requested
const maxLengthOfDomainSegment = 63
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
DNSNames: []string{e2eutil.RandomSubdomainLength(s.DomainSuffix, maxLengthOfDomainSegment)},
IssuerRef: issuerRef,
},
}
validations := validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be issued...")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Sanity-check the issued Certificate")
err = f.Helper().ValidateCertificate(testCertificate, validations...)
Expect(err).NotTo(HaveOccurred())
}, featureset.OnlySAN, featureset.LongDomainFeatureSet)
s.it(f, "should allow updating an existing certificate with a new DNS Name", func(issuerRef cmmeta.ObjectReference) {
testCertificate := &cmapi.Certificate{
ObjectMeta: metav1.ObjectMeta{
Name: "testcert",
Namespace: f.Namespace.Name,
},
Spec: cmapi.CertificateSpec{
SecretName: "testcert-tls",
DNSNames: []string{e2eutil.RandomSubdomain(s.DomainSuffix)},
IssuerRef: issuerRef,
},
}
validations := validation.CertificateSetForUnsupportedFeatureSet(s.UnsupportedFeatures)
By("Creating a Certificate")
err := f.CRClient.Create(ctx, testCertificate)
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate to be ready")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)
Expect(err).NotTo(HaveOccurred())
By("Sanity-check the issued Certificate")
err = f.Helper().ValidateCertificate(testCertificate, validations...)
Expect(err).NotTo(HaveOccurred())
By("Updating the Certificate after having added an additional dnsName")
newDNSName := e2eutil.RandomSubdomain(s.DomainSuffix)
retry.RetryOnConflict(retry.DefaultRetry, func() error {
err = f.CRClient.Get(context.Background(), types.NamespacedName{Name: testCertificate.Name, Namespace: testCertificate.Namespace}, testCertificate)
if err != nil {
return err
}
testCertificate.Spec.DNSNames = append(testCertificate.Spec.DNSNames, newDNSName)
err = f.CRClient.Update(context.Background(), testCertificate)
if err != nil {
return err
}
return nil
})
Expect(err).NotTo(HaveOccurred())
By("Waiting for the Certificate Ready condition to be updated")
testCertificate, err = f.Helper().WaitForCertificateReadyAndDoneIssuing(testCertificate, time.Minute*8)