cmd/vet: add subtestnames analyzer; fix all existing violations
Add a new vet analyzer that checks t.Run subtest names don't contain characters requiring quoting when re-running via "go test -run". This enforces the style guide rule: don't use spaces or punctuation in subtest names. The analyzer flags: - Direct t.Run calls with string literal names containing spaces, regex metacharacters, quotes, or other problematic characters - Table-driven t.Run(tt.name, ...) calls where tt ranges over a slice/map literal with bad name field values Also fix all 978 existing violations across 81 test files, replacing spaces with hyphens and shortening long sentence-like names to concise hyphenated forms. Updates #19242 Change-Id: Ib0ad96a111bd8e764582d1d4902fe2599454ab65 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
0f02c20c5e
commit
5ef3713c9f
@@ -42,7 +42,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "second last split last empty",
|
||||
name: "second-last-split-last-empty",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -55,7 +55,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "second last no split last empty",
|
||||
name: "second-last-no-split-last-empty",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -68,7 +68,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "second last no split last no split",
|
||||
name: "second-last-no-split-last-no-split",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -81,7 +81,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "second last no split last split",
|
||||
name: "second-last-no-split-last-split",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -94,7 +94,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "second last split last split",
|
||||
name: "second-last-split-last-split",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -107,7 +107,7 @@ func Test_linuxBatchingConn_splitCoalescedMessages(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "second last no split last split overflow",
|
||||
name: "second-last-no-split-last-split-overflow",
|
||||
msgs: []ipv6.Message{
|
||||
newMsg(0, 0),
|
||||
newMsg(0, 0),
|
||||
@@ -161,7 +161,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO []int
|
||||
}{
|
||||
{
|
||||
name: "one message no coalesce",
|
||||
name: "one-message-no-coalesce",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(1, 1),
|
||||
},
|
||||
@@ -169,7 +169,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{0},
|
||||
},
|
||||
{
|
||||
name: "one message no coalesce vni.isSet",
|
||||
name: "one-message-no-coalesce-vni-isSet",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(1, 1),
|
||||
},
|
||||
@@ -178,7 +178,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{0},
|
||||
},
|
||||
{
|
||||
name: "two messages equal len coalesce",
|
||||
name: "two-messages-equal-len-coalesce",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(1, 2),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -187,7 +187,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{1},
|
||||
},
|
||||
{
|
||||
name: "two messages equal len coalesce vni.isSet",
|
||||
name: "two-messages-equal-len-coalesce-vni-isSet",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(1, 2+packet.GeneveFixedHeaderLength),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -197,7 +197,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{1 + packet.GeneveFixedHeaderLength},
|
||||
},
|
||||
{
|
||||
name: "two messages unequal len coalesce",
|
||||
name: "two-messages-unequal-len-coalesce",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 3),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -206,7 +206,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{2},
|
||||
},
|
||||
{
|
||||
name: "two messages unequal len coalesce vni.isSet",
|
||||
name: "two-messages-unequal-len-coalesce-vni-isSet",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 3+packet.GeneveFixedHeaderLength),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -216,7 +216,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{2 + packet.GeneveFixedHeaderLength},
|
||||
},
|
||||
{
|
||||
name: "three messages second unequal len coalesce",
|
||||
name: "three-messages-second-unequal-len-coalesce",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 3),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -226,7 +226,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{2, 0},
|
||||
},
|
||||
{
|
||||
name: "three messages second unequal len coalesce vni.isSet",
|
||||
name: "three-messages-second-unequal-len-coalesce-vni-isSet",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 3+(2*packet.GeneveFixedHeaderLength)),
|
||||
withGeneveSpace(1, 1),
|
||||
@@ -237,7 +237,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{2 + packet.GeneveFixedHeaderLength, 0},
|
||||
},
|
||||
{
|
||||
name: "three messages limited cap coalesce",
|
||||
name: "three-messages-limited-cap-coalesce",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 4),
|
||||
withGeneveSpace(2, 2),
|
||||
@@ -247,7 +247,7 @@ func Test_linuxBatchingConn_coalesceMessages(t *testing.T) {
|
||||
wantGSO: []int{2},
|
||||
},
|
||||
{
|
||||
name: "three messages limited cap coalesce vni.isSet",
|
||||
name: "three-messages-limited-cap-coalesce-vni-isSet",
|
||||
buffs: [][]byte{
|
||||
withGeneveSpace(2, 4+packet.GeneveFixedHeaderLength),
|
||||
withGeneveSpace(2, 2),
|
||||
@@ -376,19 +376,19 @@ func Test_getRXQOverflowsFromControl(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "rxq overflows",
|
||||
name: "rxq-overflows",
|
||||
control: rxqOverflowsControl(1),
|
||||
want: 1,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple cmsg rxq overflows at head",
|
||||
name: "multiple-cmsg-rxq-overflows-at-head",
|
||||
control: append(rxqOverflowsControl(1), gsoControl(1)...),
|
||||
want: 1,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple cmsg rxq overflows at tail",
|
||||
name: "multiple-cmsg-rxq-overflows-at-tail",
|
||||
control: append(gsoControl(1), rxqOverflowsControl(1)...),
|
||||
want: 1,
|
||||
wantErr: false,
|
||||
@@ -432,19 +432,19 @@ func Test_getGSOSizeFromControl(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "rxq overflows",
|
||||
name: "rxq-overflows",
|
||||
control: rxqOverflowsControl(1),
|
||||
want: 0,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple cmsg gso at tail",
|
||||
name: "multiple-cmsg-gso-at-tail",
|
||||
control: append(rxqOverflowsControl(1), gsoControl(1)...),
|
||||
want: 1,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "multiple cmsg gso at head",
|
||||
name: "multiple-cmsg-gso-at-head",
|
||||
control: append(gsoControl(1), rxqOverflowsControl(1)...),
|
||||
want: 1,
|
||||
wantErr: false,
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestLinuxDNSMode(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "no_obvious_resolv.conf_owner",
|
||||
name: "no_obvious_resolvconf_owner",
|
||||
env: env(resolvDotConf("nameserver 10.0.0.1")),
|
||||
wantLog: "dns: [rc=unknown ret=direct]",
|
||||
want: "direct",
|
||||
@@ -153,7 +153,7 @@ func TestLinuxDNSMode(t *testing.T) {
|
||||
// alleged that it was managed by systemd-resolved, but it
|
||||
// was actually a completely static config file pointing
|
||||
// elsewhere.
|
||||
name: "allegedly_resolved_but_not_in_resolv.conf",
|
||||
name: "allegedly_resolved_but_not_in_resolvconf",
|
||||
env: env(resolvDotConf("# Managed by systemd-resolved", "nameserver 10.0.0.1")),
|
||||
wantLog: "dns: resolvedIsActuallyResolver error: resolv.conf doesn't point to systemd-resolved; points to [10.0.0.1]\n" +
|
||||
"dns: [rc=resolved resolved=not-in-use ret=direct]",
|
||||
@@ -163,7 +163,7 @@ func TestLinuxDNSMode(t *testing.T) {
|
||||
// We used to incorrectly decide that resolved wasn't in
|
||||
// charge when handed this (admittedly weird and bugged)
|
||||
// resolv.conf.
|
||||
name: "resolved_with_duplicates_in_resolv.conf",
|
||||
name: "resolved_with_duplicates_in_resolvconf",
|
||||
env: env(
|
||||
resolvDotConf(
|
||||
"# Managed by systemd-resolved",
|
||||
|
||||
@@ -1127,7 +1127,7 @@ func TestForwarderWithManyResolvers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "ServFail+Success",
|
||||
name: "ServFail-and-Success",
|
||||
responses: [][]byte{ // All upstream servers fail except for one.
|
||||
makeTestResponse(t, domain, dns.RCodeServerFailure),
|
||||
makeTestResponse(t, domain, dns.RCodeServerFailure),
|
||||
@@ -1150,7 +1150,7 @@ func TestForwarderWithManyResolvers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "NXDomain+Success",
|
||||
name: "NXDomain-and-Success",
|
||||
responses: [][]byte{ // All upstream servers returned NXDOMAIN except for one.
|
||||
makeTestResponse(t, domain, dns.RCodeNameError),
|
||||
makeTestResponse(t, domain, dns.RCodeNameError),
|
||||
@@ -1173,7 +1173,7 @@ func TestForwarderWithManyResolvers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Refused+Success",
|
||||
name: "Refused-and-Success",
|
||||
responses: [][]byte{ // Some upstream servers refuse, but one succeeds.
|
||||
makeTestResponse(t, domain, dns.RCodeRefused),
|
||||
makeTestResponse(t, domain, dns.RCodeRefused),
|
||||
@@ -1187,7 +1187,7 @@ func TestForwarderWithManyResolvers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Refused+ServFail",
|
||||
name: "Refused-and-ServFail",
|
||||
responses: [][]byte{ // Some servers refuse, at least one fails.
|
||||
makeTestResponse(t, domain, dns.RCodeRefused),
|
||||
makeTestResponse(t, domain, dns.RCodeServerFailure),
|
||||
|
||||
@@ -998,7 +998,7 @@ func TestNodeAddrResolve(t *testing.T) {
|
||||
}
|
||||
t.Logf("got IPv6 addr: %v", ap)
|
||||
})
|
||||
t.Run("IPv6 Failure", func(t *testing.T) {
|
||||
t.Run("IPv6-Failure", func(t *testing.T) {
|
||||
ap, ok := c.nodeAddrPort(ctx, dnV4Only, dn.STUNPort, probeIPv6)
|
||||
if ok {
|
||||
t.Fatalf("expected no addr but got: %v", ap)
|
||||
|
||||
@@ -49,7 +49,7 @@ func TestIgnoreDuplicateNEWADDR(t *testing.T) {
|
||||
return msg
|
||||
}
|
||||
|
||||
t.Run("suppress duplicate NEWADDRs", func(t *testing.T) {
|
||||
t.Run("suppress-duplicate-NEWADDRs", func(t *testing.T) {
|
||||
c := nlConn{
|
||||
buffered: []netlink.Message{
|
||||
newAddrMsg(1, "192.168.0.5", unix.RTM_NEWADDR),
|
||||
@@ -69,7 +69,7 @@ func TestIgnoreDuplicateNEWADDR(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("do not suppress after DELADDR", func(t *testing.T) {
|
||||
t.Run("no-suppress-after-DELADDR", func(t *testing.T) {
|
||||
c := nlConn{
|
||||
buffered: []netlink.Message{
|
||||
newAddrMsg(1, "192.168.0.5", unix.RTM_NEWADDR),
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestDownload(t *testing.T) {
|
||||
// ensure that the test returns an appropriate number of Result structs
|
||||
expectedLen := int(DefaultDuration.Seconds()) + 1
|
||||
|
||||
t.Run("download test", func(t *testing.T) {
|
||||
t.Run("download-test", func(t *testing.T) {
|
||||
// conduct a download test
|
||||
results, err := RunClient(Download, DefaultDuration, serverIP)
|
||||
|
||||
@@ -65,7 +65,7 @@ func TestDownload(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("upload test", func(t *testing.T) {
|
||||
t.Run("upload-test", func(t *testing.T) {
|
||||
// conduct an upload test
|
||||
results, err := RunClient(Upload, DefaultDuration, serverIP)
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ var responseTests = []struct {
|
||||
wantPort: 59029,
|
||||
},
|
||||
{
|
||||
name: "stun.sipgate.net:10000",
|
||||
name: "stun-sipgate-net-10000",
|
||||
data: []byte{
|
||||
0x01, 0x01, 0x00, 0x44, 0x21, 0x12, 0xa4, 0x42,
|
||||
0x48, 0x2e, 0xb6, 0x47, 0x15, 0xe8, 0xb2, 0x8e,
|
||||
@@ -82,7 +82,7 @@ var responseTests = []struct {
|
||||
wantPort: 58539,
|
||||
},
|
||||
{
|
||||
name: "stun.powervoip.com:3478",
|
||||
name: "stun-powervoip-com-3478",
|
||||
data: []byte{
|
||||
0x01, 0x01, 0x00, 0x24, 0x21, 0x12, 0xa4, 0x42,
|
||||
0x7e, 0x57, 0x96, 0x68, 0x29, 0xf4, 0x44, 0x60,
|
||||
@@ -100,7 +100,7 @@ var responseTests = []struct {
|
||||
wantPort: 59859,
|
||||
},
|
||||
{
|
||||
name: "in-process pion server",
|
||||
name: "in-process-pion-server",
|
||||
data: []byte{
|
||||
0x01, 0x01, 0x00, 0x24, 0x21, 0x12, 0xa4, 0x42,
|
||||
0xeb, 0xc2, 0xd3, 0x6e, 0xf4, 0x71, 0x21, 0x7c,
|
||||
@@ -119,7 +119,7 @@ var responseTests = []struct {
|
||||
wantPort: 61300,
|
||||
},
|
||||
{
|
||||
name: "stuntman-server ipv6",
|
||||
name: "stuntman-server-ipv6",
|
||||
data: []byte{
|
||||
0x01, 0x01, 0x00, 0x48, 0x21, 0x12, 0xa4, 0x42,
|
||||
0x06, 0xf5, 0x66, 0x85, 0xd2, 0x8a, 0xf3, 0xe6,
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestSynologyProxyFromConfigCached(t *testing.T) {
|
||||
|
||||
tstest.Replace(t, &synologyProxyConfigPath, filepath.Join(t.TempDir(), "proxy.conf"))
|
||||
|
||||
t.Run("no config file", func(t *testing.T) {
|
||||
t.Run("no-config-file", func(t *testing.T) {
|
||||
if _, err := os.Stat(synologyProxyConfigPath); err == nil {
|
||||
t.Fatalf("%s must not exist for this test", synologyProxyConfigPath)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ func TestSynologyProxyFromConfigCached(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("config file updated", func(t *testing.T) {
|
||||
t.Run("config-file-updated", func(t *testing.T) {
|
||||
cache.updated = time.Now()
|
||||
cache.httpProxy = nil
|
||||
cache.httpsProxy = nil
|
||||
@@ -84,7 +84,7 @@ https_port=443
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("config file removed", func(t *testing.T) {
|
||||
t.Run("config-file-removed", func(t *testing.T) {
|
||||
cache.updated = time.Now()
|
||||
cache.httpProxy = urlMustParse("http://127.0.0.1/")
|
||||
cache.httpsProxy = urlMustParse("http://127.0.0.1/")
|
||||
@@ -108,7 +108,7 @@ https_port=443
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("picks proxy from request scheme", func(t *testing.T) {
|
||||
t.Run("picks-proxy-from-request-scheme", func(t *testing.T) {
|
||||
cache.updated = time.Now()
|
||||
cache.httpProxy = nil
|
||||
cache.httpsProxy = nil
|
||||
@@ -164,7 +164,7 @@ func TestSynologyProxiesFromConfig(t *testing.T) {
|
||||
return openReader, openErr
|
||||
})
|
||||
|
||||
t.Run("with config", func(t *testing.T) {
|
||||
t.Run("with-config", func(t *testing.T) {
|
||||
mc := &mustCloser{Reader: strings.NewReader(`
|
||||
proxy_user=foo
|
||||
proxy_pwd=bar
|
||||
@@ -200,7 +200,7 @@ http_port=80
|
||||
|
||||
})
|
||||
|
||||
t.Run("nonexistent config", func(t *testing.T) {
|
||||
t.Run("nonexistent-config", func(t *testing.T) {
|
||||
openReader = nil
|
||||
openErr = os.ErrNotExist
|
||||
|
||||
@@ -216,7 +216,7 @@ http_port=80
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("error opening config", func(t *testing.T) {
|
||||
t.Run("error-opening-config", func(t *testing.T) {
|
||||
openReader = nil
|
||||
openErr = errors.New("example error")
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestSetSelfProxy(t *testing.T) {
|
||||
wantHTTPS string
|
||||
}{
|
||||
{
|
||||
name: "no self proxy",
|
||||
name: "no-self-proxy",
|
||||
env: map[string]string{
|
||||
"HTTP_PROXY": "127.0.0.1:1234",
|
||||
"HTTPS_PROXY": "127.0.0.1:1234",
|
||||
@@ -107,7 +107,7 @@ func TestSetSelfProxy(t *testing.T) {
|
||||
wantHTTPS: "127.0.0.1:1234",
|
||||
},
|
||||
{
|
||||
name: "skip proxies",
|
||||
name: "skip-proxies",
|
||||
env: map[string]string{
|
||||
"HTTP_PROXY": "127.0.0.1:1234",
|
||||
"HTTPS_PROXY": "127.0.0.1:5678",
|
||||
@@ -117,7 +117,7 @@ func TestSetSelfProxy(t *testing.T) {
|
||||
wantHTTPS: "", // skipped
|
||||
},
|
||||
{
|
||||
name: "localhost normalization of env var",
|
||||
name: "localhost-normalization-of-env-var",
|
||||
env: map[string]string{
|
||||
"HTTP_PROXY": "localhost:1234",
|
||||
"HTTPS_PROXY": "[::1]:5678",
|
||||
@@ -127,7 +127,7 @@ func TestSetSelfProxy(t *testing.T) {
|
||||
wantHTTPS: "", // skipped
|
||||
},
|
||||
{
|
||||
name: "localhost normalization of addr",
|
||||
name: "localhost-normalization-of-addr",
|
||||
env: map[string]string{
|
||||
"HTTP_PROXY": "127.0.0.1:1234",
|
||||
"HTTPS_PROXY": "127.0.0.1:1234",
|
||||
@@ -137,7 +137,7 @@ func TestSetSelfProxy(t *testing.T) {
|
||||
wantHTTPS: "", // skipped
|
||||
},
|
||||
{
|
||||
name: "no ports",
|
||||
name: "no-ports",
|
||||
env: map[string]string{
|
||||
"HTTP_PROXY": "myproxy",
|
||||
"HTTPS_PROXY": "myproxy",
|
||||
|
||||
@@ -28,32 +28,32 @@ func TestServerEndpointJSONUnmarshal(t *testing.T) {
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "invalid ServerDisco",
|
||||
name: "invalid-ServerDisco",
|
||||
json: []byte(`{"ServerDisco":"1","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid LamportID",
|
||||
name: "invalid-LamportID",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":1.1,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid AddrPorts",
|
||||
name: "invalid-AddrPorts",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid VNI",
|
||||
name: "invalid-VNI",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":18446744073709551615,"BindLifetime":"30s","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid BindLifetime",
|
||||
name: "invalid-BindLifetime",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"5","SteadyStateLifetime":"5m0s"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid SteadyStateLifetime",
|
||||
name: "invalid-SteadyStateLifetime",
|
||||
json: []byte(`{"ServerDisco":"discokey:003cd7453e04a653eb0e7a18f206fc353180efadb2facfd05ebd6982a1392c7f","LamportID":18446744073709551615,"AddrPorts":["127.0.0.1:1","127.0.0.2:2"],"VNI":16777215,"BindLifetime":"30s","SteadyStateLifetime":"5"}`),
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -79,7 +79,7 @@ func TestServerEndpointJSONMarshal(t *testing.T) {
|
||||
serverEndpoint ServerEndpoint
|
||||
}{
|
||||
{
|
||||
name: "valid roundtrip",
|
||||
name: "valid-roundtrip",
|
||||
serverEndpoint: ServerEndpoint{
|
||||
ServerDisco: key.NewDisco().Public(),
|
||||
LamportID: uint64(math.MaxUint64),
|
||||
|
||||
@@ -196,15 +196,15 @@ func TestServer(t *testing.T) {
|
||||
forceClientsMixedAF bool
|
||||
}{
|
||||
{
|
||||
name: "over ipv4",
|
||||
name: "over-ipv4",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("127.0.0.1")},
|
||||
},
|
||||
{
|
||||
name: "over ipv6",
|
||||
name: "over-ipv6",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("::1")},
|
||||
},
|
||||
{
|
||||
name: "mixed address families",
|
||||
name: "mixed-address-families",
|
||||
staticAddrs: []netip.Addr{netip.MustParseAddr("127.0.0.1"), netip.MustParseAddr("::1")},
|
||||
forceClientsMixedAF: true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user