Sfoglia il codice sorgente

Merge pull request #36152 from yongtang/01302018-TestAuthAPI

Migrate TestAuthAPI from integration-cli to integration
Yong Tang 7 anni fa
parent
commit
11ccbeb5c5
2 ha cambiato i file con 27 aggiunte e 25 eliminazioni
  1. 0 25
      integration-cli/docker_api_auth_test.go
  2. 27 0
      integration/system/login_test.go

+ 0 - 25
integration-cli/docker_api_auth_test.go

@@ -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)
-}

+ 27 - 0
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)
+}