2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/integration/system"
|
2018-01-30 13:19:20 -05:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2022-02-26 17:13:01 -05:00
|
|
|
"fmt"
|
2018-01-30 13:19:20 -05:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
2018-02-09 13:13:26 -05:00
|
|
|
"github.com/docker/docker/integration/internal/requirement"
|
2022-02-26 17:13:01 -05:00
|
|
|
"github.com/docker/docker/registry"
|
2020-02-07 08:39:24 -05:00
|
|
|
"gotest.tools/v3/assert"
|
|
|
|
is "gotest.tools/v3/assert/cmp"
|
|
|
|
"gotest.tools/v3/skip"
|
2018-01-30 13:19:20 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// Test case for GitHub 22244
|
|
|
|
func TestLoginFailsWithBadCredentials(t *testing.T) {
|
2018-06-11 09:32:11 -04:00
|
|
|
skip.If(t, !requirement.HasHubConnectivity(t))
|
2018-01-30 13:19:20 -05:00
|
|
|
|
2019-01-02 08:16:25 -05:00
|
|
|
defer setupTest(t)()
|
|
|
|
client := testEnv.APIClient()
|
2018-01-30 13:19:20 -05:00
|
|
|
|
|
|
|
config := types.AuthConfig{
|
|
|
|
Username: "no-user",
|
|
|
|
Password: "no-password",
|
|
|
|
}
|
|
|
|
_, err := client.RegistryLogin(context.Background(), config)
|
2020-02-07 09:34:34 -05:00
|
|
|
assert.Assert(t, err != nil)
|
|
|
|
assert.Check(t, is.ErrorContains(err, "unauthorized: incorrect username or password"))
|
2022-02-26 17:13:01 -05:00
|
|
|
assert.Check(t, is.ErrorContains(err, fmt.Sprintf("https://%s/v2/", registry.DefaultRegistryHost)))
|
2018-01-30 13:19:20 -05:00
|
|
|
}
|