Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ACL syntax and add support for protocol filtering #618

Merged
merged 14 commits into from
Jun 11, 2022
14 changes: 14 additions & 0 deletions acls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ func (s *Suite) TestPortRange(c *check.C) {
c.Assert(rules[0].DstPorts[0].Ports.Last, check.Equals, uint16(5500))
}

func (s *Suite) TestProtocolParsing(c *check.C) {
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_protocols.hujson")
c.Assert(err, check.IsNil)

rules, err := app.generateACLRules()
c.Assert(err, check.IsNil)
c.Assert(rules, check.NotNil)

c.Assert(rules, check.HasLen, 3)
c.Assert(rules[0].IPProto[0], check.Equals, 6) // tcp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why we want constants.

c.Assert(rules[1].IPProto[0], check.Equals, 17) // udp
c.Assert(rules[2].IPProto[1], check.Equals, 58) // icmp v4
}

func (s *Suite) TestPortWildcard(c *check.C) {
err := app.LoadACLPolicy("./tests/acls/acl_policy_basic_wildcards.hujson")
c.Assert(err, check.IsNil)
Expand Down
1 change: 0 additions & 1 deletion tests/acls/acl_policy_1.hujson
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
// ports on git-server or ci-server.
{
"action": "accept",
"protocol": "tcp",
"src": [
"group:example2",
"192.168.1.0/24"
Expand Down