From 8331a1a5cf1f7f751fdb011cb9e1aa4b0642c1e5 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 8 Feb 2018 00:21:29 +0000 Subject: [PATCH 1/2] Remove integration-cli/docker_cli_create_unix_test.go Signed-off-by: Yong Tang --- .../docker_cli_create_unix_test.go | 43 ------------------- 1 file changed, 43 deletions(-) delete mode 100644 integration-cli/docker_cli_create_unix_test.go diff --git a/integration-cli/docker_cli_create_unix_test.go b/integration-cli/docker_cli_create_unix_test.go deleted file mode 100644 index 1b0bb4a3dc..0000000000 --- a/integration-cli/docker_cli_create_unix_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// +build !windows - -package main - -import ( - "strings" - - "github.com/go-check/check" -) - -// Test case for #30166 (target was not validated) -func (s *DockerSuite) TestCreateTmpfsMountsTarget(c *check.C) { - testRequires(c, DaemonIsLinux) - type testCase struct { - target string - expectedError string - } - cases := []testCase{ - { - target: ".", - expectedError: "mount path must be absolute", - }, - { - target: "foo", - expectedError: "mount path must be absolute", - }, - { - target: "/", - expectedError: "destination can't be '/'", - }, - { - target: "//", - expectedError: "destination can't be '/'", - }, - } - for _, x := range cases { - out, _, _ := dockerCmdWithError("create", "--tmpfs", x.target, "busybox", "sh") - if x.expectedError != "" && !strings.Contains(out, x.expectedError) { - c.Fatalf("mounting tmpfs over %q should fail with %q, but got %q", - x.target, x.expectedError, out) - } - } -} From f601bc16d555238c86dad1cc0a67bcfcf36a3301 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Thu, 8 Feb 2018 00:21:44 +0000 Subject: [PATCH 2/2] Migrate TestCreateTmpfsMountsTarget test to api test This fix migrates TestCreateTmpfsMountsTarget test to api test, and removed integration-cli/docker_cli_create_unix_test.go Signed-off-by: Yong Tang --- integration/container/create_test.go | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/integration/container/create_test.go b/integration/container/create_test.go index 6c8a084e5b..364720d8ba 100644 --- a/integration/container/create_test.go +++ b/integration/container/create_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/network" "github.com/docker/docker/integration/util/request" "github.com/docker/docker/internal/testutil" + "github.com/gotestyourself/gotestyourself/skip" ) func TestCreateFailsWhenIdentifierDoesNotExist(t *testing.T) { @@ -91,3 +92,47 @@ func TestCreateWithInvalidEnv(t *testing.T) { }) } } + +// Test case for #30166 (target was not validated) +func TestCreateTmpfsMountsTarget(t *testing.T) { + skip.If(t, testEnv.DaemonInfo.OSType != "linux") + + defer setupTest(t)() + client := request.NewAPIClient(t) + + testCases := []struct { + target string + expectedError string + }{ + { + target: ".", + expectedError: "mount path must be absolute", + }, + { + target: "foo", + expectedError: "mount path must be absolute", + }, + { + target: "/", + expectedError: "destination can't be '/'", + }, + { + target: "//", + expectedError: "destination can't be '/'", + }, + } + + for _, tc := range testCases { + _, err := client.ContainerCreate(context.Background(), + &container.Config{ + Image: "busybox", + }, + &container.HostConfig{ + Tmpfs: map[string]string{tc.target: ""}, + }, + &network.NetworkingConfig{}, + "", + ) + testutil.ErrorContains(t, err, tc.expectedError) + } +}