Browse code

Migrate TestAuthAPI from integration-cli to integration

This fix migrates TestAuthAPI from integration-cli to integration

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>

Yong Tang authored on 2018/01/31 03:19:20
Showing 2 changed files
1 1
deleted file mode 100644
... ...
@@ -1,25 +0,0 @@
1
-package main
2
-
3
-import (
4
-	"github.com/docker/docker/api/types"
5
-	"github.com/docker/docker/client"
6
-	"github.com/docker/docker/integration-cli/checker"
7
-	"github.com/go-check/check"
8
-	"golang.org/x/net/context"
9
-)
10
-
11
-// Test case for #22244
12
-func (s *DockerSuite) TestAuthAPI(c *check.C) {
13
-	testRequires(c, Network)
14
-	config := types.AuthConfig{
15
-		Username: "no-user",
16
-		Password: "no-password",
17
-	}
18
-	cli, err := client.NewEnvClient()
19
-	c.Assert(err, checker.IsNil)
20
-	defer cli.Close()
21
-
22
-	_, err = cli.RegistryLogin(context.Background(), config)
23
-	expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
24
-	c.Assert(err.Error(), checker.Contains, expected)
25
-}
26 1
new file mode 100644
... ...
@@ -0,0 +1,27 @@
0
+package system
1
+
2
+import (
3
+	"testing"
4
+
5
+	"github.com/docker/docker/api/types"
6
+	"github.com/docker/docker/integration/util/request"
7
+	"github.com/docker/docker/integration/util/requirement"
8
+	"github.com/gotestyourself/gotestyourself/skip"
9
+	"github.com/stretchr/testify/assert"
10
+	"golang.org/x/net/context"
11
+)
12
+
13
+// Test case for GitHub 22244
14
+func TestLoginFailsWithBadCredentials(t *testing.T) {
15
+	skip.IfCondition(t, !requirement.HasHubConnectivity(t))
16
+
17
+	client := request.NewAPIClient(t)
18
+
19
+	config := types.AuthConfig{
20
+		Username: "no-user",
21
+		Password: "no-password",
22
+	}
23
+	_, err := client.RegistryLogin(context.Background(), config)
24
+	expected := "Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
25
+	assert.EqualError(t, err, expected)
26
+}