-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwireguard_test.go
38 lines (35 loc) · 1.11 KB
/
wireguard_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
package main
import (
"testing"
)
var (
validPublicKey = "NkEtSA6GosX40iZFNe9+byAkXweYKvQe3utnFYkQ+00="
validAllowedIPs = []string{"1.1.1.1/32"}
)
func TestNewPeerConfig(t *testing.T) {
var err error
_, err = newPeerConfig("", "", "", nil)
if err == nil {
t.Errorf("newPeerConfig: empty publicKey should generate an error")
}
_, err = newPeerConfig("foobar", "", "", nil)
if err == nil {
t.Errorf("newPeerConfig: invalid publicKey should generate an error")
}
_, err = newPeerConfig(validPublicKey, "", "", []string{""})
if err == nil {
t.Errorf("newPeerConfig: invalid allowedIPs should generate an error")
}
_, err = newPeerConfig(validPublicKey, "foo", "", validAllowedIPs)
if err == nil {
t.Errorf("newPeerConfig: invalid presharedKey should generate an error")
}
_, err = newPeerConfig(validPublicKey, validPublicKey, "foo", validAllowedIPs)
if err == nil {
t.Errorf("newPeerConfig: invalid endpoint should generate an error")
}
_, err = newPeerConfig(validPublicKey, validPublicKey, "1.1.1.1:1111", validAllowedIPs)
if err != nil {
t.Errorf("newPeerConfig: unexpected error: %v", err)
}
}