(t *testing.T)
| 25 | } |
| 26 | |
| 27 | func 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 | |
| 54 | func TestNewWireGuardConfigDefaults(t *testing.T) { |
| 55 | configJSON := `{}` |
nothing calls this directly
no test coverage detected