MCPcopy Create free account
hub / github.com/PasarGuard/node / TestNewWireGuardConfig

Function TestNewWireGuardConfig

backend/wireguard/config_test.go:27–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestNewWireGuardConfig(t *testing.T) {
28 configJSON := `{
29 "interface_name": "wg0",
30 "private_key": "cGVlckNvbmZpZ0VudHJ5AA==",
31 "listen_port": 51820,
32 "address": ["10.0.0.1/16"]
33 }`
34
35 config, err := NewConfig(configJSON)
36 if err != nil {
37 t.Fatalf("NewConfig failed: %v", err)
38 }
39
40 if config.InterfaceName != "wg0" {
41 t.Errorf("Expected interface_name 'wg0', got: %s", config.InterfaceName)
42 }
43
44 if config.ListenPort != 51820 {
45 t.Errorf("Expected listen_port 51820, got: %d", config.ListenPort)
46 }
47
48 if len(config.Address) != 1 || config.Address[0] != "10.0.0.1/16" {
49 t.Errorf("Expected address '10.0.0.1/16', got: %v", config.Address)
50 }
51
52}
53
54func TestNewWireGuardConfigDefaults(t *testing.T) {
55 configJSON := `{}`

Callers

nothing calls this directly

Calls 1

NewConfigFunction · 0.70

Tested by

no test coverage detected