| 12345678910111213141516171819202122232425262728293031 |
- package firewall
- import (
- "strings"
- "testing"
- )
- func TestBuildNATRuleLines_InterfaceList(t *testing.T) {
- rule := NATRule{
- ID: "nat-test-1",
- Order: 1,
- Chain: "srcnat",
- Action: "masquerade",
- OutInterfaceList: "WAN",
- Disabled: false,
- }
- lines := buildNATRuleLines(rule)
- if len(lines) == 0 {
- t.Fatalf("expected non-empty lines for WAN interface list, got 0")
- }
- for _, l := range lines {
- if !strings.Contains(l, "-j MASQUERADE") {
- t.Errorf("line missing -j MASQUERADE: %s", l)
- }
- if !strings.Contains(l, "-o ") {
- t.Errorf("expected -o flag in expanded NAT rule, got: %s", l)
- }
- }
- }
|