MCPcopy Index your code
hub / github.com/coder/coder / TestConvertRouterConfig

Function TestConvertRouterConfig

vpn/router_internal_test.go:11–67  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestConvertRouterConfig(t *testing.T) {
12 t.Parallel()
13
14 tests := []struct {
15 name string
16 cfg router.Config
17 expected *NetworkSettingsRequest
18 }{
19 {
20 name: "IPv4 and IPv6 configuration",
21 cfg: router.Config{
22 LocalAddrs: []netip.Prefix{netip.MustParsePrefix("100.64.0.1/32"), netip.MustParsePrefix("fd7a:115c:a1e0::1/128")},
23 Routes: []netip.Prefix{netip.MustParsePrefix("192.168.0.0/24"), netip.MustParsePrefix("fd00::/64")},
24 LocalRoutes: []netip.Prefix{netip.MustParsePrefix("10.0.0.0/8"), netip.MustParsePrefix("2001:db8::/32")},
25 NewMTU: 1500,
26 },
27 expected: &NetworkSettingsRequest{
28 Mtu: 1500,
29 Ipv4Settings: &NetworkSettingsRequest_IPv4Settings{
30 Addrs: []string{"100.64.0.1"},
31 SubnetMasks: []string{"255.255.255.255"},
32 IncludedRoutes: []*NetworkSettingsRequest_IPv4Settings_IPv4Route{
33 {Destination: "192.168.0.0", Mask: "255.255.255.0", Router: ""},
34 },
35 ExcludedRoutes: []*NetworkSettingsRequest_IPv4Settings_IPv4Route{
36 {Destination: "10.0.0.0", Mask: "255.0.0.0", Router: ""},
37 },
38 },
39 Ipv6Settings: &NetworkSettingsRequest_IPv6Settings{
40 Addrs: []string{"fd7a:115c:a1e0::1"},
41 PrefixLengths: []uint32{128},
42 IncludedRoutes: []*NetworkSettingsRequest_IPv6Settings_IPv6Route{
43 {Destination: "fd00::", PrefixLength: 64, Router: ""},
44 },
45 ExcludedRoutes: []*NetworkSettingsRequest_IPv6Settings_IPv6Route{
46 {Destination: "2001:db8::", PrefixLength: 32, Router: ""},
47 },
48 },
49 },
50 },
51 {
52 name: "Empty",
53 cfg: router.Config{},
54 expected: &NetworkSettingsRequest{
55 Ipv4Settings: nil,
56 Ipv6Settings: nil,
57 },
58 },
59 }
60 for _, tt := range tests {
61 t.Run(tt.name, func(t *testing.T) {
62 t.Parallel()
63 result := convertRouterConfig(tt.cfg)
64 require.Equal(t, tt.expected, result)
65 })
66 }
67}

Callers

nothing calls this directly

Calls 3

convertRouterConfigFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected