-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathintegration_test.go
60 lines (52 loc) · 1.48 KB
/
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
package goStrongswanVici
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestConnection(t *testing.T) {
client, err := NewClientConnFromDefaultSocket()
require.NoError(t, err)
defer client.Close()
// Get initial list of connections.
initialConnections, err := client.ListConns("")
require.NoError(t, err)
// Create connection object.
childConfMap := make(map[string]ChildSAConf)
childSAConf := ChildSAConf{
Local_ts: []string{"10.10.59.0/24"},
Remote_ts: []string{"10.10.40.0/24"},
ESPProposals: []string{"aes256-sha256-modp2048"},
StartAction: "trap",
CloseAction: "restart",
Mode: "tunnel",
ReqID: "10",
RekeyTime: "10m",
InstallPolicy: "no",
}
childConfMap["test-child-conn"] = childSAConf
localAuthConf := AuthConf{
AuthMethod: "psk",
}
remoteAuthConf := AuthConf{
AuthMethod: "psk",
}
ikeConf := IKEConf{
LocalAddrs: []string{"192.168.198.10"},
RemoteAddrs: []string{"192.168.198.11"},
Proposals: []string{"aes256-sha256-modp2048"},
Version: "1",
LocalAuth: localAuthConf,
RemoteAuth: remoteAuthConf,
Children: childConfMap,
Encap: "no",
}
ikeConfMap := map[string]IKEConf{"test-connection": ikeConf}
// Add connection.
err = client.LoadConn(&ikeConfMap)
require.NoError(t, err)
// Verify connection is added.
connections, err := client.ListConns("")
require.NoError(t, err)
assert.Len(t, connections, len(initialConnections)+1)
}