Skip to content

Commit

Permalink
Merge pull request #41729 from thaJeztah/add_network_list_regression_…
Browse files Browse the repository at this point in the history
…test

Networking: add regression test for networks endpoint with trailing slash
  • Loading branch information
tiborvass authored Dec 15, 2020
2 parents f001486 + 2680a0f commit 808559d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions integration/network/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package network // import "github.com/docker/docker/integration/network"
import (
"bytes"
"context"
"encoding/json"
"net/http"
"os/exec"
"strings"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 808559d

Please sign in to comment.