Merge pull request #2153 from JoshVanL/ingress-shim-common-name
The ingress shim checks certificate common names and ensures they are empty
This commit is contained in:
commit
ddabf64e00
@ -184,6 +184,7 @@ func (c *controller) buildCertificates(ctx context.Context, ing *extv1beta1.Ingr
|
||||
updateCrt.Spec.IssuerRef.Name = issuerName
|
||||
updateCrt.Spec.IssuerRef.Kind = issuerKind
|
||||
updateCrt.Spec.IssuerRef.Group = issuerGroup
|
||||
updateCrt.Spec.CommonName = ""
|
||||
updateCrt.Labels = ing.Labels
|
||||
err = c.setIssuerSpecificConfig(updateCrt, ing, tls)
|
||||
if err != nil {
|
||||
@ -241,6 +242,10 @@ func certNeedsUpdate(a, b *cmapi.Certificate) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
if a.Spec.CommonName != b.Spec.CommonName {
|
||||
return true
|
||||
}
|
||||
|
||||
if len(a.Spec.DNSNames) != len(b.Spec.DNSNames) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -802,6 +802,68 @@ func TestSync(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "should update a Certificate if is contains a Common Name that is not defined on the ingress annotations",
|
||||
Issuer: acmeIssuer,
|
||||
IssuerLister: []runtime.Object{acmeIssuer},
|
||||
Ingress: &extv1beta1.Ingress{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "ingress-name",
|
||||
Namespace: gen.DefaultTestNamespace,
|
||||
Annotations: map[string]string{
|
||||
cmapi.IngressIssuerNameAnnotationKey: "issuer-name",
|
||||
cmapi.IssuerKindAnnotationKey: "Issuer",
|
||||
cmapi.IssuerGroupAnnotationKey: "cert-manager.io",
|
||||
},
|
||||
UID: types.UID("ingress-name"),
|
||||
},
|
||||
Spec: extv1beta1.IngressSpec{
|
||||
TLS: []extv1beta1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{"example.com"},
|
||||
SecretName: "example-com-tls",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
CertificateLister: []runtime.Object{
|
||||
&cmapi.Certificate{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "example-com-tls",
|
||||
Namespace: gen.DefaultTestNamespace,
|
||||
OwnerReferences: buildOwnerReferences("ingress-name", gen.DefaultTestNamespace),
|
||||
},
|
||||
Spec: cmapi.CertificateSpec{
|
||||
DNSNames: []string{"example.com"},
|
||||
SecretName: "example-com-tls",
|
||||
CommonName: "example-common-name",
|
||||
IssuerRef: cmmeta.ObjectReference{
|
||||
Name: "issuer-name",
|
||||
Kind: "Issuer",
|
||||
Group: "cert-manager.io",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ExpectedUpdate: []*cmapi.Certificate{
|
||||
{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "example-com-tls",
|
||||
Namespace: gen.DefaultTestNamespace,
|
||||
OwnerReferences: buildOwnerReferences("ingress-name", gen.DefaultTestNamespace),
|
||||
},
|
||||
Spec: cmapi.CertificateSpec{
|
||||
DNSNames: []string{"example.com"},
|
||||
SecretName: "example-com-tls",
|
||||
IssuerRef: cmmeta.ObjectReference{
|
||||
Name: "issuer-name",
|
||||
Kind: "Issuer",
|
||||
Group: "cert-manager.io",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
testFn := func(test testT) func(t *testing.T) {
|
||||
return func(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user