(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestIPTablesAction_AddItem(t *testing.T) { |
| 12 | _, lookupErr := executils.LookPath("iptables") |
| 13 | if lookupErr != nil { |
| 14 | return |
| 15 | } |
| 16 | |
| 17 | var action = NewIPTablesAction() |
| 18 | action.config = &firewallconfigs.FirewallActionIPTablesConfig{ |
| 19 | Path: "/usr/bin/iptables", |
| 20 | } |
| 21 | { |
| 22 | err := action.AddItem(IPListTypeWhite, &pb.IPItem{ |
| 23 | Type: "ipv4", |
| 24 | Id: 1, |
| 25 | IpFrom: "192.168.1.100", |
| 26 | ExpiredAt: time.Now().Unix() + 30, |
| 27 | }) |
| 28 | if err != nil { |
| 29 | t.Fatal(err) |
| 30 | } |
| 31 | t.Log("ok") |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | err := action.AddItem(IPListTypeBlack, &pb.IPItem{ |
| 36 | Type: "ipv4", |
| 37 | Id: 1, |
| 38 | IpFrom: "192.168.1.100", |
| 39 | ExpiredAt: time.Now().Unix() + 30, |
| 40 | }) |
| 41 | if err != nil { |
| 42 | t.Fatal(err) |
| 43 | } |
| 44 | t.Log("ok") |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | func TestIPTablesAction_DeleteItem(t *testing.T) { |
| 49 | _, lookupErr := executils.LookPath("firewalld") |
nothing calls this directly
no test coverage detected