1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-15 17:51:03 +00:00

Fixed validation of tls.caSecretName=None

This commit is contained in:
Ewout Prangsma 2018-03-22 08:27:35 +01:00
parent cd44faad43
commit 18197de483
No known key found for this signature in database
GPG key ID: 4DBAD380D93D0698
2 changed files with 8 additions and 5 deletions

View file

@ -71,11 +71,13 @@ func (s TLSSpec) GetAltNames() (dnsNames, ipAddresses, emailAddresses []string,
// Validate the given spec // Validate the given spec
func (s TLSSpec) Validate() error { func (s TLSSpec) Validate() error {
if err := k8sutil.ValidateOptionalResourceName(s.CASecretName); err != nil { if s.IsSecure() {
return maskAny(err) if err := k8sutil.ValidateOptionalResourceName(s.CASecretName); err != nil {
} return maskAny(err)
if _, _, _, err := s.GetAltNames(); err != nil { }
return maskAny(err) if _, _, _, err := s.GetAltNames(); err != nil {
return maskAny(err)
}
} }
return nil return nil
} }

View file

@ -33,6 +33,7 @@ func TestTLSSpecValidate(t *testing.T) {
// Valid // Valid
assert.Nil(t, TLSSpec{CASecretName: ""}.Validate()) assert.Nil(t, TLSSpec{CASecretName: ""}.Validate())
assert.Nil(t, TLSSpec{CASecretName: "foo"}.Validate()) assert.Nil(t, TLSSpec{CASecretName: "foo"}.Validate())
assert.Nil(t, TLSSpec{CASecretName: "None"}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{}}.Validate()) assert.Nil(t, TLSSpec{AltNames: []string{}}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{"foo"}}.Validate()) assert.Nil(t, TLSSpec{AltNames: []string{"foo"}}.Validate())
assert.Nil(t, TLSSpec{AltNames: []string{"email@example.com", "127.0.0.1"}}.Validate()) assert.Nil(t, TLSSpec{AltNames: []string{"email@example.com", "127.0.0.1"}}.Validate())