Skip to content

Commit

Permalink
TEST: make access control e2e tests more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
hdurand0710 authored and oktalz committed Dec 11, 2023
1 parent 9e83018 commit 17ea85e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions deploy/tests/e2e/access-control/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.168.2.3", http.StatusOK)
suite.eventuallyReturns("192.168.5.3", http.StatusForbidden)
suite.TearDownSubSuite()
})

suite.Run("Inline deprecated annotation name", func() {
Expand All @@ -60,6 +61,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.168.4.3", http.StatusOK)
suite.eventuallyReturns("192.168.5.3", http.StatusForbidden)
suite.TearDownSubSuite()
})

suite.Run("Inline: when new and deprecated annotation names are defined then only new name is considered", func() {
Expand All @@ -73,6 +75,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.168.5.3", http.StatusOK)
suite.eventuallyReturns("192.168.4.3", http.StatusForbidden)
suite.TearDownSubSuite()
})

suite.Run("Patternfile", func() {
Expand All @@ -86,6 +89,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.168.0.3", http.StatusOK)
suite.eventuallyReturns("192.168.2.3", http.StatusForbidden)
suite.TearDownSubSuite()
})

suite.Run("Patternfile deprecated annotation name", func() {
Expand All @@ -99,6 +103,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.169.0.3", http.StatusOK)
suite.eventuallyReturns("192.168.2.3", http.StatusForbidden)
suite.TearDownSubSuite()
})

suite.Run("Patternfile: when new and deprecated annotation names are defined then only new name is considered", func() {
Expand All @@ -113,6 +118,7 @@ func (suite *AccessControlSuite) Test_Whitelist() {

suite.eventuallyReturns("192.168.0.3", http.StatusOK)
suite.eventuallyReturns("192.168.2.3", http.StatusForbidden)
suite.TearDownSubSuite()
})
}

Expand All @@ -127,6 +133,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.168.2.3", http.StatusForbidden)
suite.eventuallyReturns("192.168.5.3", http.StatusOK)
suite.TearDownSubSuite()
})

suite.Run("Inline deprecated annotation name", func() {
Expand All @@ -139,6 +146,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.168.4.3", http.StatusForbidden)
suite.eventuallyReturns("192.168.5.3", http.StatusOK)
suite.TearDownSubSuite()
})

suite.Run("Inline: when new and deprecated annotation names are defined then only new name is considered", func() {
Expand All @@ -152,6 +160,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.168.5.3", http.StatusForbidden)
suite.eventuallyReturns("192.168.4.3", http.StatusOK)
suite.TearDownSubSuite()
})

suite.Run("Patternfile", func() {
Expand All @@ -165,6 +174,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.168.0.3", http.StatusForbidden)
suite.eventuallyReturns("192.168.2.3", http.StatusOK)
suite.TearDownSubSuite()
})

suite.Run("Patternfile deprecated annotation name", func() {
Expand All @@ -178,6 +188,7 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.169.0.3", http.StatusForbidden)
suite.eventuallyReturns("192.168.2.3", http.StatusOK)
suite.TearDownSubSuite()
})
suite.Run("Patternfile: when new and deprecated annotation names are defined then only new name is considered", func() {
suite.tmplData.IngAnnotations = []struct{ Key, Value string }{
Expand All @@ -191,5 +202,6 @@ func (suite *AccessControlSuite) Test_Blacklist() {

suite.eventuallyReturns("192.168.0.3", http.StatusForbidden)
suite.eventuallyReturns("192.169.2.3", http.StatusOK)
suite.TearDownSubSuite()
})
}
4 changes: 4 additions & 0 deletions deploy/tests/e2e/access-control/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (suite *AccessControlSuite) TearDownSuite() {
suite.test.TearDown()
}

func (suite *AccessControlSuite) TearDownSubSuite() {
suite.test.Apply("config/patternfile-empty.yml", "", nil)
}

func TestAccessControlSuite(t *testing.T) {
suite.Run(t, new(AccessControlSuite))
}

0 comments on commit 17ea85e

Please sign in to comment.