(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestConfigInterfaceNetworks(t *testing.T) { |
| 9 | cfg := &Config{Address: []string{" 10.8.0.1/24 ", ""}} |
| 10 | nets := cfg.InterfaceNetworks() |
| 11 | if len(nets) != 1 { |
| 12 | t.Fatalf("expected 1 network, got %d", len(nets)) |
| 13 | } |
| 14 | if nets[0].String() != "10.8.0.0/24" { |
| 15 | t.Fatalf("unexpected network: %s", nets[0].String()) |
| 16 | } |
| 17 | _, ipn, _ := net.ParseCIDR("10.8.0.5/32") |
| 18 | if !peerIPAllowedOnInterface(ipn, nets) { |
| 19 | t.Fatal("expected 10.8.0.5/32 to be allowed under 10.8.0.0/24") |
| 20 | } |
| 21 | _, wrong, _ := net.ParseCIDR("10.0.0.2/32") |
| 22 | if peerIPAllowedOnInterface(wrong, nets) { |
| 23 | t.Fatal("expected 10.0.0.2/32 to be rejected under 10.8.0.0/24") |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | func TestNewWireGuardConfig(t *testing.T) { |
| 28 | configJSON := `{ |
nothing calls this directly
no test coverage detected