ce7cb702218693d08ea6d83464d2457c9250027c
This commit is contained in:
commit
34c5f8963c
1 changed files with 145336 additions and 0 deletions
33
services/short/tunnel/vici_test.go
Normal file
33
services/short/tunnel/vici_test.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package tunnel
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/strongswan/govici/vici"
|
||||
"quorate.dev/services/short/config"
|
||||
)
|
||||
|
||||
func TestReturnPeer(t *testing.T) {
|
||||
sa := func(index int, state, childState string) *vici.Message {
|
||||
m, err := vici.MarshalMessage(map[string]any{peerName(index): map[string]any{"state": state, "child-sas": map[string]any{"child": map[string]any{"state": childState}}}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
both := []*vici.Message{sa(0, "ESTABLISHED", "INSTALLED"), sa(1, "ESTABLISHED", "INSTALLED")}
|
||||
if got := returnPeer(livePeers(both)); got != 0 {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if got := returnPeer(livePeers(both[1:])); got != 1 {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if got := returnPeer(livePeers([]*vici.Message{sa(0, "CONNECTING", "INSTALLED"), sa(1, "ESTABLISHED", "REKEYING")})); got != -1 {
|
||||
t.Fatal(got)
|
||||
}
|
||||
first := settings("192.0.2.1", config.Peer{Address: "192.0.2.2"}, 0)
|
||||
second := settings("192.0.2.1", config.Peer{Address: "192.0.2.3"}, 1)
|
||||
if first.Children["short0"].In == second.Children["short1"].In {
|
||||
t.Fatal("overlapping XFRM policies")
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue