From bbb554bc58671ef9e3d1695812f6a65917169ff2 Mon Sep 17 00:00:00 2001 From: Yong Tang Date: Tue, 30 Jan 2018 18:19:20 +0000 Subject: [PATCH] Migrate TestAuthAPI from integration-cli to integration This fix migrates TestAuthAPI from integration-cli to integration Signed-off-by: Yong Tang Upstream-commit: d9247557898d1d15a7349ecb0044b73d4a5a41a9 Component: engine --- .../integration-cli/docker_api_auth_test.go | 25 ----------------- .../engine/integration/system/login_test.go | 27 +++++++++++++++++++ 2 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 components/engine/integration-cli/docker_api_auth_test.go create mode 100644 components/engine/integration/system/login_test.go diff --git a/components/engine/integration-cli/docker_api_auth_test.go b/components/engine/integration-cli/docker_api_auth_test.go deleted file mode 100644 index a1f7a098cd..0000000000 --- a/components/engine/integration-cli/docker_api_auth_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package main - -import ( - "github.com/docker/docker/api/types" - "github.com/docker/docker/client" - "github.com/docker/docker/integration-cli/checker" - "github.com/go-check/check" - "golang.org/x/net/context" -) - -// Test case for #22244 -func (s *DockerSuite) TestAuthAPI(c *check.C) { - testRequires(c, Network) - config := types.AuthConfig{ - Username: "no-user", - Password: "no-password", - } - cli, err := client.NewEnvClient() - c.Assert(err, checker.IsNil) - defer cli.Close() - - _, err = cli.RegistryLogin(context.Background(), config) - expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password" - c.Assert(err.Error(), checker.Contains, expected) -} diff --git a/components/engine/integration/system/login_test.go b/components/engine/integration/system/login_test.go new file mode 100644 index 0000000000..a3e296c3ac --- /dev/null +++ b/components/engine/integration/system/login_test.go @@ -0,0 +1,27 @@ +package system + +import ( + "testing" + + "github.com/docker/docker/api/types" + "github.com/docker/docker/integration/util/request" + "github.com/docker/docker/integration/util/requirement" + "github.com/gotestyourself/gotestyourself/skip" + "github.com/stretchr/testify/assert" + "golang.org/x/net/context" +) + +// Test case for GitHub 22244 +func TestLoginFailsWithBadCredentials(t *testing.T) { + skip.IfCondition(t, !requirement.HasHubConnectivity(t)) + + client := request.NewAPIClient(t) + + config := types.AuthConfig{ + Username: "no-user", + Password: "no-password", + } + _, err := client.RegistryLogin(context.Background(), config) + expected := "Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password" + assert.EqualError(t, err, expected) +}