Merge pull request #36152 from yongtang/01302018-TestAuthAPI
Migrate TestAuthAPI from integration-cli to integration
This commit is contained in:
commit
11ccbeb5c5
2 changed files with 27 additions and 25 deletions
|
@ -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
integration/system/login_test.go
Normal file
27
integration/system/login_test.go
Normal 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)
|
||||
}
|
Loading…
Reference in a new issue