@@ -33,6 +33,7 @@ import (
3333 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434 "k8s.io/apimachinery/pkg/types"
3535 "k8s.io/client-go/util/retry"
36+ "sigs.k8s.io/controller-runtime/pkg/client"
3637
3738 "conformance/framework"
3839 "conformance/framework/helper/featureset"
@@ -49,7 +50,16 @@ import (
4950// automatically called.
5051func (s * Suite ) Define () {
5152 Describe ("with issuer type " + s .Name , func () {
52- f := framework .NewFramework ("certificates" , s .KubeClientConfig )
53+ f := framework .NewFramework (
54+ "certificates" ,
55+ s .KubeClientConfig ,
56+ s .Namespace ,
57+ []client.Object {
58+ & cmapi.Certificate {},
59+ & cmapi.CertificateRequest {},
60+ & corev1.Secret {},
61+ },
62+ )
5363
5464 sharedIPAddress := "127.0.0.1"
5565
@@ -371,14 +381,26 @@ func (s *Suite) Define() {
371381
372382 defineTest := func (test testCase ) {
373383 s .it (f , test .name , func (ctx context.Context , issuerRef cmmeta.ObjectReference ) {
384+ randomTestID := e2eutil .RandStringRunes (10 )
374385 certificate := & cmapi.Certificate {
375386 ObjectMeta : metav1.ObjectMeta {
376- Name : "testcert" ,
377- Namespace : f .Namespace .Name ,
387+ Name : "e2e-conformance-" + randomTestID ,
388+ Namespace : f .Namespace ,
389+ Labels : map [string ]string {
390+ f .CleanupLabel : "true" ,
391+ },
392+ Annotations : map [string ]string {
393+ "conformance.cert-manager.io/test-name" : s .Name + " " + test .name ,
394+ },
378395 },
379396 Spec : cmapi.CertificateSpec {
380- SecretName : "testcert- tls" ,
397+ SecretName : "e2e-conformance- tls-" + randomTestID ,
381398 IssuerRef : issuerRef ,
399+ SecretTemplate : & cmapi.CertificateSecretTemplate {
400+ Labels : map [string ]string {
401+ f .CleanupLabel : "true" ,
402+ },
403+ },
382404 },
383405 }
384406
@@ -407,15 +429,27 @@ func (s *Suite) Define() {
407429 }
408430
409431 s .it (f , "should issue another certificate with the same private key if the existing certificate and CertificateRequest are deleted" , func (ctx context.Context , issuerRef cmmeta.ObjectReference ) {
432+ randomTestID := e2eutil .RandStringRunes (10 )
410433 testCertificate := & cmapi.Certificate {
411434 ObjectMeta : metav1.ObjectMeta {
412- Name : "testcert" ,
413- Namespace : f .Namespace .Name ,
435+ Name : "e2e-conformance-" + randomTestID ,
436+ Namespace : f .Namespace ,
437+ Labels : map [string ]string {
438+ f .CleanupLabel : "true" ,
439+ },
440+ Annotations : map [string ]string {
441+ "conformance.cert-manager.io/test-name" : s .Name + " should issue another certificate with the same private key if the existing certificate and CertificateRequest are deleted" ,
442+ },
414443 },
415444 Spec : cmapi.CertificateSpec {
416- SecretName : "testcert- tls" ,
445+ SecretName : "e2e-conformance- tls-" + randomTestID ,
417446 DNSNames : []string {e2eutil .RandomSubdomain (s .DomainSuffix )},
418447 IssuerRef : issuerRef ,
448+ SecretTemplate : & cmapi.CertificateSecretTemplate {
449+ Labels : map [string ]string {
450+ f .CleanupLabel : "true" ,
451+ },
452+ },
419453 },
420454 }
421455 By ("Creating a Certificate" )
@@ -431,7 +465,7 @@ func (s *Suite) Define() {
431465 Expect (err ).NotTo (HaveOccurred ())
432466
433467 By ("Deleting existing certificate data in Secret" )
434- sec , err := f .KubeClientSet .CoreV1 ().Secrets (f .Namespace . Name ).
468+ sec , err := f .KubeClientSet .CoreV1 ().Secrets (f .Namespace ).
435469 Get (ctx , testCertificate .Spec .SecretName , metav1.GetOptions {})
436470 Expect (err ).NotTo (HaveOccurred (), "failed to get secret containing signed certificate key pair data" )
437471
@@ -442,11 +476,11 @@ func (s *Suite) Define() {
442476
443477 sec .Data [corev1 .TLSCertKey ] = []byte {}
444478
445- _ , err = f .KubeClientSet .CoreV1 ().Secrets (f .Namespace . Name ).Update (ctx , sec , metav1.UpdateOptions {})
479+ _ , err = f .KubeClientSet .CoreV1 ().Secrets (f .Namespace ).Update (ctx , sec , metav1.UpdateOptions {})
446480 Expect (err ).NotTo (HaveOccurred (), "failed to update secret by deleting the signed certificate data" )
447481
448482 By ("Waiting for the Certificate to re-issue a certificate" )
449- sec , err = f .Helper ().WaitForSecretCertificateData (ctx , sec .Name , f .Namespace . Name , time .Minute * 8 )
483+ sec , err = f .Helper ().WaitForSecretCertificateData (ctx , sec .Name , f .Namespace , time .Minute * 8 )
450484 Expect (err ).NotTo (HaveOccurred (), "failed to wait for secret to have a valid 2nd certificate" )
451485
452486 crtPEM2 := sec .Data [corev1 .TLSCertKey ]
@@ -463,15 +497,27 @@ func (s *Suite) Define() {
463497 }, featureset .ReusePrivateKeyFeature , featureset .OnlySAN )
464498
465499 s .it (f , "should allow updating an existing certificate with a new DNS Name" , func (ctx context.Context , issuerRef cmmeta.ObjectReference ) {
500+ randomTestID := e2eutil .RandStringRunes (10 )
466501 testCertificate := & cmapi.Certificate {
467502 ObjectMeta : metav1.ObjectMeta {
468- Name : "testcert" ,
469- Namespace : f .Namespace .Name ,
503+ Name : "e2e-conformance-" + randomTestID ,
504+ Namespace : f .Namespace ,
505+ Labels : map [string ]string {
506+ f .CleanupLabel : "true" ,
507+ },
508+ Annotations : map [string ]string {
509+ "conformance.cert-manager.io/test-name" : s .Name + " should allow updating an existing certificate with a new DNS Name" ,
510+ },
470511 },
471512 Spec : cmapi.CertificateSpec {
472- SecretName : "testcert- tls" ,
513+ SecretName : "e2e-conformance- tls-" + randomTestID ,
473514 DNSNames : []string {e2eutil .RandomSubdomain (s .DomainSuffix )},
474515 IssuerRef : issuerRef ,
516+ SecretTemplate : & cmapi.CertificateSecretTemplate {
517+ Labels : map [string ]string {
518+ f .CleanupLabel : "true" ,
519+ },
520+ },
475521 },
476522 }
477523 validations := validation .CertificateSetForUnsupportedFeatureSet (s .UnsupportedFeatures )
0 commit comments