MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestIPTablesAction_AddItem

Function TestIPTablesAction_AddItem

internal/iplibrary/action_iptables_test.go:11–46  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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
48func TestIPTablesAction_DeleteItem(t *testing.T) {
49 _, lookupErr := executils.LookPath("firewalld")

Callers

nothing calls this directly

Calls 4

NewIPTablesActionFunction · 0.85
UnixMethod · 0.80
LogMethod · 0.80
AddItemMethod · 0.65

Tested by

no test coverage detected