Skip to content

Commit

Permalink
Fixed rule test when tables are not listed on same order
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtbnfgl committed Jul 4, 2022
1 parent f4f02db commit 6083b05
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions network/iptables_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,18 @@ func TestRules(t *testing.T) {
{"-A", "INPUT", "-s", "127.0.0.1", "!", "-d", "224.0.0.0/4", "-m", "comment", "--comment", "flanneld masq", "-j", "MASQUERADE", "--random-fully"},
},
}
expectedPayload := `*filter
expectedFilterPayload := `*filter
-A INPUT -s 127.0.0.1 -d 127.0.0.1 -j RETURN
-A INPUT -s 127.0.0.1 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
COMMIT
*nat
`
expectedNATPayload := `*nat
-A INPUT -s 127.0.0.1 -d 127.0.0.1 -j RETURN
-A INPUT -s 127.0.0.1 ! -d 224.0.0.0/4 -m comment --comment "flanneld masq" -j MASQUERADE --random-fully
COMMIT
`
payload := buildIPTablesRestorePayload(baseRules)
if payload != expectedPayload {
t.Errorf("iptables-restore payload not as expected. Expected: %#v, Actual: %#v", expectedPayload, payload)
if payload != expectedFilterPayload+expectedNATPayload && payload != expectedNATPayload+expectedFilterPayload {
t.Errorf("iptables-restore payload not as expected. Expected: %#v, Actual: %#v", expectedFilterPayload+expectedNATPayload, payload)
}
}

0 comments on commit 6083b05

Please sign in to comment.