summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTibor Vass <tiborvass@users.noreply.github.com>2020-12-15 15:08:04 -0800
committerGitHub <noreply@github.com>2020-12-15 15:08:04 -0800
commit808559d7f40f655856d14f1a812b57702831fa7b (patch)
tree9954c444e63ee84b5976c619b28057796f8f81e8
parentf0014860c1b3345e1fcc7ed81c491298de2633fb (diff)
parent2680a0fe2c10b8a3acf8b73ae6311a8358ae41b5 (diff)
downloaddocker-808559d7f40f655856d14f1a812b57702831fa7b.tar.gz
Merge pull request #41729 from thaJeztah/add_network_list_regression_test
Networking: add regression test for networks endpoint with trailing slash
-rw-r--r--integration/network/network_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/integration/network/network_test.go b/integration/network/network_test.go
index 8a08cb3450..a4057d2410 100644
--- a/integration/network/network_test.go
+++ b/integration/network/network_test.go
@@ -3,6 +3,7 @@ package network // import "github.com/docker/docker/integration/network"
import (
"bytes"
"context"
+ "encoding/json"
"net/http"
"os/exec"
"strings"
@@ -93,6 +94,34 @@ func TestNetworkInvalidJSON(t *testing.T) {
}
}
+// TestNetworkList verifies that /networks returns a list of networks either
+// with, or without a trailing slash (/networks/). Regression test for https://github.com/moby/moby/issues/24595
+func TestNetworkList(t *testing.T) {
+ defer setupTest(t)()
+
+ endpoints := []string{
+ "/networks",
+ "/networks/",
+ }
+
+ for _, ep := range endpoints {
+ t.Run(ep, func(t *testing.T) {
+ t.Parallel()
+
+ res, body, err := request.Get(ep, request.JSON)
+ assert.NilError(t, err)
+ assert.Equal(t, res.StatusCode, http.StatusOK)
+
+ buf, err := request.ReadBody(body)
+ assert.NilError(t, err)
+ var nws []types.NetworkResource
+ err = json.Unmarshal(buf, &nws)
+ assert.NilError(t, err)
+ assert.Assert(t, len(nws) > 0)
+ })
+ }
+}
+
func TestHostIPv4BridgeLabel(t *testing.T) {
skip.If(t, testEnv.OSType == "windows")
skip.If(t, testEnv.IsRemoteDaemon)