mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Networking: add regression test for networks endpoint with trailing slash
This adds a regression test for https://github.com/moby/moby/issues/24595 make DOCKER_GRAPHDRIVER=vfs TEST_FILTER='TestNetworkList' test-integration INFO: Testing against a local daemon === RUN TestNetworkList === RUN TestNetworkList//networks === PAUSE TestNetworkList//networks === RUN TestNetworkList//networks/ === PAUSE TestNetworkList//networks/ === CONT TestNetworkList//networks === CONT TestNetworkList//networks/ --- PASS: TestNetworkList (0.05s) --- PASS: TestNetworkList//networks/ (0.01s) --- PASS: TestNetworkList//networks (0.01s) PASS Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
e1bba7456d
commit
2680a0fe2c
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