Skip to content

Commit 49eaa70

Browse files
authored
Remove ip access list validator (#852)
1 parent 379f674 commit 49eaa70

File tree

2 files changed

+0
-34
lines changed

2 files changed

+0
-34
lines changed

pkg/controller/atlasproject/ipaccess_list.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package atlasproject
22

33
import (
44
"context"
5-
"errors"
65
"fmt"
76
"net/http"
87
"net/url"
@@ -120,11 +119,6 @@ func validateSingleIPAccessList(list project.IPAccessList) error {
120119
return err
121120
}
122121
}
123-
onlyOneSpecified := onlyOneSpecified(list.AwsSecurityGroup, list.CIDRBlock, list.IPAddress)
124-
allSpecified := isNotEmpty(list.AwsSecurityGroup) && isNotEmpty(list.CIDRBlock) && isNotEmpty(list.IPAddress)
125-
if !onlyOneSpecified || allSpecified {
126-
return errors.New("only one of the 'awsSecurityGroup', 'cidrBlock' or 'ipAddress' is required be specified")
127-
}
128122
if strings.Contains(list.IPAddress, "/") {
129123
return fmt.Errorf("ipAddress %s cannot contain a / character", list.IPAddress)
130124
}
@@ -251,24 +245,3 @@ func filterActiveIPAccessLists(accessLists []project.IPAccessList) ([]project.IP
251245
}
252246
return active, expired
253247
}
254-
255-
func isNotEmpty(s string) bool {
256-
return s != ""
257-
}
258-
259-
func onlyOneSpecified(values ...string) bool {
260-
found := false
261-
for _, v := range values {
262-
if v == "" {
263-
continue
264-
}
265-
266-
if found {
267-
return false
268-
}
269-
270-
found = true
271-
}
272-
273-
return found
274-
}

pkg/controller/atlasproject/ipaccess_list_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ func TestValidateSingleIPAccessList(t *testing.T) {
2121
{in: project.IPAccessList{DeleteAfterDate: "2020-11-02T20:04:05-0700", IPAddress: "192.158.0.0"}},
2222
{in: project.IPAccessList{DeleteAfterDate: "2020-11-02T20:04:05+03", IPAddress: "192.158.0.0"}},
2323
{in: project.IPAccessList{DeleteAfterDate: "2011-01-02T15:04:05", IPAddress: "192.158.0.0"}},
24-
25-
// Only one other field is allowed (and required)
26-
{in: project.IPAccessList{DeleteAfterDate: "2011-01-02T15:04:05", IPAddress: "192.158.0.0", CIDRBlock: "203.0.113.0/24"}, errorExpectedRegex: "only one of the "},
27-
{in: project.IPAccessList{IPAddress: "192.158.0.0", AwsSecurityGroup: "sg-0026348ec11780bd1"}, errorExpectedRegex: "only one of the "},
28-
{in: project.IPAccessList{CIDRBlock: "203.0.113.0/24", AwsSecurityGroup: "sg-0026348ec11780bd1"}, errorExpectedRegex: "only one of the "},
29-
{in: project.IPAccessList{CIDRBlock: "203.0.113.0/24", AwsSecurityGroup: "sg-0026348ec11780bd1", IPAddress: "192.158.0.0"}, errorExpectedRegex: "only one of the "},
30-
{in: project.IPAccessList{}, errorExpectedRegex: "only one of the "},
3124
}
3225

3326
for _, testCase := range testCases {

0 commit comments

Comments
 (0)