Skip to content

Commit

Permalink
Update Kube API tests to handle BindAddress
Browse files Browse the repository at this point in the history
Signed-off-by: gakio12 <gakio12@gmail.com>
  • Loading branch information
gakio12 committed Sep 20, 2021
1 parent 53788bb commit bff1d0e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pkg/apis/v1beta1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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()
Expand All @@ -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//(())",
},
Expand All @@ -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) {
Expand Down

0 comments on commit bff1d0e

Please sign in to comment.