Make tests work

Signed-off-by: Maartje Eyskens <maartje@eyskens.me>
This commit is contained in:
Maartje Eyskens
2020-09-30 16:04:23 +02:00
parent ed70dff3e1
commit d960199caa
3 changed files with 16 additions and 18 deletions
-5
View File
@@ -37,14 +37,10 @@ func (h *Helper) DefaultValidationSet() []ValidationFunc {
validations.ExpectValidAnnotations,
validations.ExpectValidPrivateKeyData,
validations.ExpectValidCertificate,
//validations.ExpectCertificateOrganizationToMatch,
validations.ExpectCertificateDNSNamesToMatch,
validations.ExpectCertificateURIsToMatch,
validations.ExpectValidCommonName,
validations.ExpectValidNotAfterDate,
validations.ExpectKeyUsageExtKeyUsageServerAuth,
validations.ExpectKeyUsageExtKeyUsageClientAuth,
validations.ExpectKeyUsageKeyUsageKeyAgreement,
validations.ExpectEmailsToMatch,
}
}
@@ -60,7 +56,6 @@ func (h *Helper) ValidationSetForUnsupportedFeatureSet(fs featureset.FeatureSet)
validations.ExpectCertificateDNSNamesToMatch,
validations.ExpectValidCommonName,
validations.ExpectValidNotAfterDate,
validations.ExpectKeyUsageKeyUsageKeyAgreement,
}
if !fs.Contains(featureset.URISANsFeature) {
@@ -65,20 +65,22 @@ func ExpectValidPrivateKeyData(certificate *cmapi.Certificate, secret *corev1.Se
}
// validate private key is of the correct type (rsa or ecdsa)
switch certificate.Spec.PrivateKey.Algorithm {
case cmapi.PrivateKeyAlgorithm(""),
cmapi.RSAKeyAlgorithm:
_, ok := key.(*rsa.PrivateKey)
if !ok {
return fmt.Errorf("Expected private key of type RSA, but it was: %T", key)
if certificate.Spec.PrivateKey != nil {
switch certificate.Spec.PrivateKey.Algorithm {
case cmapi.PrivateKeyAlgorithm(""),
cmapi.RSAKeyAlgorithm:
_, ok := key.(*rsa.PrivateKey)
if !ok {
return fmt.Errorf("Expected private key of type RSA, but it was: %T", key)
}
case cmapi.ECDSAKeyAlgorithm:
_, ok := key.(*ecdsa.PrivateKey)
if !ok {
return fmt.Errorf("Expected private key of type ECDSA, but it was: %T", key)
}
default:
return fmt.Errorf("unrecognised requested private key algorithm %q", certificate.Spec.PrivateKey.Algorithm)
}
case cmapi.ECDSAKeyAlgorithm:
_, ok := key.(*ecdsa.PrivateKey)
if !ok {
return fmt.Errorf("Expected private key of type ECDSA, but it was: %T", key)
}
default:
return fmt.Errorf("unrecognised requested private key algorithm %q", certificate.Spec.PrivateKey.Algorithm)
}
// TODO: validate private key KeySize
@@ -46,6 +46,7 @@ var _ = framework.ConformanceDescribe("Certificates", func() {
featureset.CommonNameFeature,
featureset.IPAddressFeature,
featureset.URISANsFeature,
featureset.OnlySAN,
)
provisioner := new(venafiProvisioner)