mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #41729 from thaJeztah/add_network_list_regression_test
Networking: add regression test for networks endpoint with trailing slash
This commit is contained in:
commit
808559d7f4
1 changed files with 29 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue