Add CA issuer Setup() e2e test

This commit is contained in:
James Munnelly 2017-09-10 23:24:06 +01:00
parent e26ddc8307
commit 5360497de6
2 changed files with 77 additions and 2 deletions

View File

@ -23,8 +23,8 @@ import (
"github.com/jetstack-experimental/cert-manager/test/util"
)
var _ = framework.CertManagerDescribe("Issuer", func() {
f := framework.NewDefaultFramework("create-issuer")
var _ = framework.CertManagerDescribe("ACME Issuer", func() {
f := framework.NewDefaultFramework("create-acme-issuer")
podName := "test-cert-manager"
issuerName := "test-acme-issuer"

75
test/e2e/issuer_ca.go Normal file
View File

@ -0,0 +1,75 @@
/*
Copyright 2017 Jetstack Ltd.
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 e2e
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/jetstack-experimental/cert-manager/pkg/apis/certmanager/v1alpha1"
"github.com/jetstack-experimental/cert-manager/test/e2e/framework"
"github.com/jetstack-experimental/cert-manager/test/util"
)
var _ = framework.CertManagerDescribe("CA Issuer", func() {
f := framework.NewDefaultFramework("create-ca-issuer")
podName := "test-cert-manager"
issuerName := "test-ca-issuer"
secretName := "ca-issuer-signing-keypair"
BeforeEach(func() {
By("Creating a cert-manager pod")
pod, err := f.KubeClientSet.CoreV1().Pods(f.Namespace.Name).Create(NewCertManagerControllerPod(podName))
Expect(err).NotTo(HaveOccurred())
err = framework.WaitForPodRunningInNamespace(f.KubeClientSet, pod)
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
By("Deleting the cert-manager pod")
err := f.KubeClientSet.CoreV1().Pods(f.Namespace.Name).Delete(podName, nil)
Expect(err).NotTo(HaveOccurred())
})
It("should generate a signing keypair", func() {
By("Creating an Issuer")
_, err := f.CertManagerClientSet.CertmanagerV1alpha1().Issuers(f.Namespace.Name).Create(newCertManagerCAIssuer(issuerName, secretName))
Expect(err).NotTo(HaveOccurred())
By("Waiting for Issuer to become Ready")
err = util.WaitForIssuerCondition(f.CertManagerClientSet.CertmanagerV1alpha1().Issuers(f.Namespace.Name),
issuerName,
v1alpha1.IssuerCondition{
Type: v1alpha1.IssuerConditionReady,
Status: v1alpha1.ConditionTrue,
})
Expect(err).NotTo(HaveOccurred())
})
})
func newCertManagerCAIssuer(name, secretName string) *v1alpha1.Issuer {
return &v1alpha1.Issuer{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
Spec: v1alpha1.IssuerSpec{
CA: &v1alpha1.CAIssuer{
SecretRef: v1alpha1.LocalObjectReference{
Name: secretName,
},
},
},
}
}