2016-04-22 23:00:47 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2016-09-06 14:18:12 -04:00
|
|
|
"github.com/docker/docker/api/types"
|
2016-04-22 23:00:47 -04:00
|
|
|
"github.com/docker/docker/pkg/integration/checker"
|
|
|
|
"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-27 21:50:12 -04:00
|
|
|
func (s *DockerSuite) TestAuthAPI(c *check.C) {
|
2016-04-25 13:17:17 -04:00
|
|
|
testRequires(c, Network)
|
2016-04-22 23:00:47 -04:00
|
|
|
config := types.AuthConfig{
|
|
|
|
Username: "no-user",
|
|
|
|
Password: "no-password",
|
|
|
|
}
|
|
|
|
|
2016-05-21 07:56:04 -04:00
|
|
|
expected := "Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password"
|
2016-04-22 23:00:47 -04:00
|
|
|
status, body, err := sockRequest("POST", "/auth", config)
|
|
|
|
c.Assert(err, check.IsNil)
|
|
|
|
c.Assert(status, check.Equals, http.StatusUnauthorized)
|
2016-05-21 07:56:04 -04:00
|
|
|
msg := getErrorMessage(c, body)
|
|
|
|
c.Assert(msg, checker.Contains, expected, check.Commentf("Expected: %v, got: %v", expected, msg))
|
2016-04-22 23:00:47 -04:00
|
|
|
}
|