Merge pull request #36152 from yongtang/01302018-TestAuthAPI

Migrate TestAuthAPI from integration-cli to integration
This commit is contained in:
Yong Tang 2018-01-30 13:37:56 -08:00 committed by GitHub
commit 11ccbeb5c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 25 deletions

View file

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

View file

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