Skip to content

Commit

Permalink
Added ACL test file
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfont committed Jun 8, 2022
1 parent 8287ba2 commit 39f03b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
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
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

0 comments on commit 39f03b8

Please sign in to comment.