2016-04-23 06:00:47 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2016-09-06 21:18:12 +03:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-12-30 20:23:00 +03:00
|
|
|
"github.com/docker/docker/integration-cli/checker"
|
2016-12-30 12:49:36 +03:00
|
|
|
"github.com/docker/docker/integration-cli/request"
|
2016-04-23 06:00:47 +03:00
|
|
|
"github.com/go-check/check"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Test case for #22244
|
[nit] integration-cli: obey Go's naming convention
No substantial code change.
- Api --> API
- Cli --> CLI
- Http, Https --> HTTP, HTTPS
- Id --> ID
- Uid,Gid,Pid --> UID,PID,PID
- Ipam --> IPAM
- Tls --> TLS (TestDaemonNoTlsCliTlsVerifyWithEnv --> TestDaemonTLSVerifyIssue13964)
Didn't touch in this commit:
- Git: because it is officially "Git": https://git-scm.com/
- Tar: because it is officially "Tar": https://www.gnu.org/software/tar/
- Cpu, Nat, Mac, Ipc, Shm: for keeping a consistency with existing production code (not changable, for compatibility)
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-09-28 04:50:12 +03:00
|
|
|
func (s *DockerSuite) TestAuthAPI(c *check.C) {
|
2016-04-25 20:17:17 +03:00
|
|
|
testRequires(c, Network)
|
2016-04-23 06:00:47 +03:00
|
|
|
config := types.AuthConfig{
|
|
|
|
Username: "no-user",
|
|
|
|
Password: "no-password",
|
|
|
|
}
|
|
|
|
|
2016-05-21 14:56:04 +03:00
|
|
|
expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
|
2016-12-30 12:49:36 +03:00
|
|
|
status, body, err := request.SockRequest("POST", "/auth", config, daemonHost())
|
2016-04-23 06:00:47 +03:00
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
c.Assert(status, check.Equals, http.StatusUnauthorized)
|
2016-05-21 14:56:04 +03:00
|
|
|
msg := getErrorMessage(c, body)
|
|
|
|
c.Assert(msg, checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, msg))
|
2016-04-23 06:00:47 +03:00
|
|
|
}
|