mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Update tests to reflect new AuthConfig
This commit is contained in:
parent
95dd6d31a4
commit
10e19e4b97
4 changed files with 11 additions and 7 deletions
4
api.go
4
api.go
|
@ -67,9 +67,9 @@ func postAuth(srv *Server, w http.ResponseWriter, r *http.Request, vars map[stri
|
|||
status, err := auth.Login(newAuthConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
srv.registry.ResetClient(newAuthConfig)
|
||||
}
|
||||
srv.registry.ResetClient(newAuthConfig)
|
||||
|
||||
if status != "" {
|
||||
b, err := json.Marshal(&ApiAuth{Status: status})
|
||||
if err != nil {
|
||||
|
|
10
api_test.go
10
api_test.go
|
@ -51,6 +51,7 @@ func TestGetAuth(t *testing.T) {
|
|||
if err := postAuth(srv, r, req, nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if r.Code != http.StatusOK && r.Code != 0 {
|
||||
t.Fatalf("%d OK or 0 expected, received %d\n", http.StatusOK, r.Code)
|
||||
}
|
||||
|
@ -229,7 +230,7 @@ func TestGetImagesSearch(t *testing.T) {
|
|||
|
||||
srv := &Server{
|
||||
runtime: runtime,
|
||||
registry: registry.NewRegistry(runtime.authConfig),
|
||||
registry: registry.NewRegistry(runtime.root),
|
||||
}
|
||||
|
||||
r := httptest.NewRecorder()
|
||||
|
@ -484,13 +485,16 @@ func TestPostAuth(t *testing.T) {
|
|||
}
|
||||
defer nuke(runtime)
|
||||
|
||||
srv := &Server{runtime: runtime}
|
||||
srv := &Server{
|
||||
runtime: runtime,
|
||||
registry: registry.NewRegistry(runtime.root),
|
||||
}
|
||||
|
||||
authConfigOrig := &auth.AuthConfig{
|
||||
Username: "utest",
|
||||
Email: "utest@yopmail.com",
|
||||
}
|
||||
runtime.authConfig = authConfigOrig
|
||||
srv.registry.ResetClient(authConfigOrig)
|
||||
|
||||
r := httptest.NewRecorder()
|
||||
if err := getAuth(srv, r, nil, nil); err != nil {
|
||||
|
|
|
@ -432,7 +432,7 @@ func (r *Registry) ResetClient(authConfig *auth.AuthConfig) {
|
|||
func (r *Registry) GetAuthConfig() *auth.AuthConfig {
|
||||
return &auth.AuthConfig{
|
||||
Username: r.authConfig.Username,
|
||||
Email: r.authConfig.Password,
|
||||
Email: r.authConfig.Email,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ func init() {
|
|||
// Create the "Server"
|
||||
srv := &Server{
|
||||
runtime: runtime,
|
||||
registry: registry.NewRegistry(runtime.authConfig),
|
||||
registry: registry.NewRegistry(runtime.root),
|
||||
}
|
||||
// Retrieve the Image
|
||||
if err := srv.ImagePull(unitTestImageName, "", "", os.Stdout); err != nil {
|
||||
|
|
Loading…
Reference in a new issue