Skip to content

Commit

Permalink
Merge pull request #2 from thockin/master
Browse files Browse the repository at this point in the history
Fix tests
  • Loading branch information
Daniel Nardo authored May 30, 2017
2 parents 23600f7 + c6abf8e commit f1c336a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions cmd/ip-masq-agent/ip-masq-agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ func TestSyncMasqRules(t *testing.T) {
m := NewFakeMasqDaemon()
want := `*nat
:` + string(masqChain) + ` - [0:0]
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -m addrtype ! --dst-type LOCAL -d 169.254.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + masqRuleComment + ` -m addrtype ! --dst-type LOCAL -j MASQUERADE
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -d 169.254.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + masqRuleComment + ` -j MASQUERADE
COMMIT
`
m.syncMasqRules()
Expand All @@ -206,11 +206,11 @@ COMMIT
m.config = NewMasqConfig()
want = `*nat
:` + string(masqChain) + ` - [0:0]
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -m addrtype ! --dst-type LOCAL -d 169.254.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -m addrtype ! --dst-type LOCAL -d 10.0.0.0/8 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -m addrtype ! --dst-type LOCAL -d 172.16.0.0/12 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -m addrtype ! --dst-type LOCAL -d 192.168.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + masqRuleComment + ` -m addrtype ! --dst-type LOCAL -j MASQUERADE
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -d 169.254.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -d 10.0.0.0/8 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -d 172.16.0.0/12 -j RETURN
-A ` + string(masqChain) + ` ` + nonMasqRuleComment + ` -d 192.168.0.0/16 -j RETURN
-A ` + string(masqChain) + ` ` + masqRuleComment + ` -j MASQUERADE
COMMIT
`
m.syncMasqRules()
Expand All @@ -237,16 +237,16 @@ func TestWriteNonMasqRule(t *testing.T) {
lines := bytes.NewBuffer(nil)
cidr := "10.0.0.0/8"
want := string(utiliptables.Append) + " " + string(masqChain) +
` -m comment --comment "ip-masq-agent: cluster-local traffic should not be subject to MASQUERADE"` +
" -m addrtype ! --dst-type LOCAL -d " + cidr + " -j RETURN\n"
` -m comment --comment "ip-masq-agent: local traffic is not subject to MASQUERADE"` +
" -d " + cidr + " -j RETURN\n"
writeNonMasqRule(lines, cidr)

s, err := lines.ReadString('\n')
if err != nil {
t.Error("writeRule did not append a newline")
}
if s != want {
t.Errorf("writeNonMasqRule(lines, "+cidr+") wrote %q, want %q", s, want)
t.Errorf("writeNonMasqRule(lines, "+cidr+"):\n got: %q\n want: %q", s, want)
}
}

Expand Down

0 comments on commit f1c336a

Please sign in to comment.