-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconn_integration_test.go
56 lines (39 loc) · 1.19 KB
/
conn_integration_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//+build integration
package netfilter
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/mdlayher/netlink"
)
var (
badGroup = []NetlinkGroup{255}
)
func TestConnIntegrationJoinLeaveGroup(t *testing.T) {
c, err := Dial(nil)
require.NoError(t, err, "opening Conn")
// Join all Conntrack event groups, as an example.
err = c.JoinGroups(GroupsCT)
require.NoError(t, err, "JoinGroup")
err = c.LeaveGroups(GroupsCT)
require.NoError(t, err, "LeaveGroup")
err = c.Close()
require.NoError(t, err, "closing Conn")
}
func TestConnIntegrationBadGroups(t *testing.T) {
c, err := Dial(nil)
require.NoError(t, err, "opening Conn")
err = c.JoinGroups(badGroup)
require.EqualError(t, err, "netlink join-group: setsockopt: invalid argument")
err = c.LeaveGroups(badGroup)
require.EqualError(t, err, "netlink leave-group: setsockopt: invalid argument")
err = c.Close()
require.NoError(t, err, "closing Conn")
}
func TestConnIntegrationSetOption(t *testing.T) {
c, err := Dial(nil)
require.NoError(t, err, "opening Conn")
err = c.SetOption(netlink.ListenAllNSID, true)
require.NoError(t, err, "setting SockOption")
err = c.Close()
require.NoError(t, err, "closing Conn")
}