Update tests to reflect new AuthConfig

This commit is contained in:
Guillaume J. Charmes 2013-05-15 17:31:11 -07:00
parent 95dd6d31a4
commit 10e19e4b97
4 changed files with 11 additions and 7 deletions

4
api.go
View File

@ -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 {

View File

@ -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 {

View File

@ -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,
}
}

View File

@ -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 {