-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathexpect_integration_test.go
65 lines (53 loc) · 1.44 KB
/
expect_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
57
58
59
60
61
62
63
64
65
//go:build integration
package conntrack
import (
"net/netip"
"testing"
"golang.org/x/sys/unix"
"github.com/stretchr/testify/require"
)
// No meaningful integration test possible until we can figure out how
// to create expects from userspace.
func TestConnDumpExpect(t *testing.T) {
c, _, err := makeNSConn()
require.NoError(t, err)
_, err = c.DumpExpect()
require.NoError(t, err, "unexpected error dumping expect table")
}
// Attempt at creating conntrack expectation from userspace.
func TestConnCreateExpect(t *testing.T) {
c, _, err := makeNSConn()
require.NoError(t, err)
f := NewFlow(6, 0, netip.MustParseAddr("1.2.3.4"), netip.MustParseAddr("5.6.7.8"), 42000, 21, 120, 0)
err = c.Create(f)
require.NoError(t, err, "unexpected error creating flow", f)
ex := Expect{
Timeout: 300,
TupleMaster: f.TupleOrig,
Tuple: Tuple{
IP: IPTuple{
SourceAddress: netip.MustParseAddr("1.2.3.4"),
DestinationAddress: netip.MustParseAddr("5.6.7.8"),
},
Proto: ProtoTuple{
Protocol: 6,
SourcePort: 0,
DestinationPort: 30000,
},
},
Mask: Tuple{
IP: IPTuple{
SourceAddress: netip.MustParseAddr("255.255.255.255"),
DestinationAddress: netip.MustParseAddr("255.255.255.255"),
},
Proto: ProtoTuple{
Protocol: 6,
SourcePort: 0,
DestinationPort: 65535,
},
},
HelpName: "ftp",
Class: 0x30,
}
require.ErrorIs(t, c.CreateExpect(ex), unix.EINVAL)
}