forked from msgboxio/ike
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth_test.go
59 lines (48 loc) · 1.5 KB
/
auth_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
package ike
import (
"net"
"testing"
"github.com/go-kit/kit/log"
"github.com/msgboxio/ike/platform"
)
func TestPskAuth(t *testing.T) {
testWithIdentity(t, pskTestID, pskTestID, logger)
}
func TestCertAuth(t *testing.T) {
localID, remoteID := certTestIds(t)
testWithIdentity(t, localID, remoteID, logger)
}
func TestEcCertAuth(t *testing.T) {
localID, remoteID := eccertTestIds(t)
testWithIdentity(t, localID, remoteID, logger)
}
func BenchmarkEcCert(bt *testing.B) {
localID, remoteID := eccertTestIds(bt)
for n := 0; n < bt.N; n++ {
testWithIdentity(bt, localID, remoteID, logger)
}
}
func BenchmarkIntCert(bt *testing.B) {
localID, remoteID := certTestIds(bt)
for n := 0; n < bt.N; n++ {
testWithIdentity(bt, localID, remoteID, logger)
}
}
func testWithIdentity(t testing.TB, locid, remid Identity, log log.Logger) {
var cfg = testConfig()
cfg.LocalID = locid
cfg.PeerID = remid
_, net, _ := net.ParseCIDR("192.0.2.0/24")
cfg.AddNetworkSelectors(net, net, true)
chi := make(chan []byte, 1)
chr := make(chan []byte, 1)
sa := make(chan *platform.SaParams, 1)
cerr := make(chan error, 1)
go runTestInitiator(cfg, &testcb{chr, sa, cerr}, chi, logger)
go runTestResponder(cfg, &testcb{chi, sa, cerr}, chr, logger)
waitFor2Sa(t, sa, cerr)
}
// server, serverIP := test.SetupContainer(t, "min", 5000, 100, func() (string, error) {
// return test.RunContainer("--rm", "--privileged", "--name", "cli", "-v",
// dir+"/server:/server", "min", "/server", "-local", "0.0.0.0:500", "-v", "2", "-tunnel")
// })