diff --git a/pkg/apis/v1beta1/api_test.go b/pkg/apis/v1beta1/api_test.go index 5ddd29fa425c..c035fee95694 100644 --- a/pkg/apis/v1beta1/api_test.go +++ b/pkg/apis/v1beta1/api_test.go @@ -35,6 +35,7 @@ func (s *APISuite) TestValidation() { s.T().Run("accepts_ipv6_as_address", func(t *testing.T) { a := APISpec{ Address: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + BindAddress: "2001:0db8:85a3:0000:0000:8a2e:0370:7334", } s.Nil(a.Validate()) @@ -44,6 +45,7 @@ func (s *APISuite) TestValidation() { s.T().Run("invalid_api_address", func(t *testing.T) { a := APISpec{ Address: "somehting.that.is.not.valid//(())", + BindAddress: "0.0.0.0", } errors := a.Validate() @@ -55,6 +57,7 @@ func (s *APISuite) TestValidation() { s.T().Run("invalid_sans_address", func(t *testing.T) { a := APISpec{ Address: "1.2.3.4", + BindAddress: "0.0.0.0", SANs: []string{ "somehting.that.is.not.valid//(())", }, @@ -65,6 +68,18 @@ func (s *APISuite) TestValidation() { s.Len(errors, 1) s.Contains(errors[0].Error(), "is not a valid address for sans") }) + + s.T().Run("invalid_api_bind_address", func(t *testing.T) { + a := APISpec{ + Address: "1.2.3.4", + BindAddress: "somehting.that.is.not.valid//(())", + } + + errors := a.Validate() + s.NotNil(errors) + s.Len(errors, 1) + s.Contains(errors[0].Error(), "is not IP address") + }) } func TestApiSuite(t *testing.T) {