Пример #1
0
func handleAdminDelete(d db.DB) htr.Handle {
	return func(w http.ResponseWriter, r *http.Request, ps htr.Params) {
		if err := r.ParseForm(); err != nil {
			WriteResponse(w, newApiError(err.Error(), err))
			log.Printf("bad admin request: %#v", r)
			return
		}

		key := util.Key(r.Form.Get("key"))
		if err := admin.IsAdmin(d, key); err != nil {
			WriteResponse(w, newApiError(err.Error(), err))
			log.Printf("bad admin request: %s", err.Error())
			return
		}

		if err := admin.Delete(d, key); err != nil {
			WriteResponse(w, newApiError(err.Error(), err))
			log.Printf("error deleting admin for %s: %s", key, err.Error())
			return
		}

		log.Printf("admin %s deleted", key)
		WriteResponse(w, &admin.Admin{
			Key: key,
		})
	}
}
Пример #2
0
func (s *AdminSuite) deleteTests(adm t.TestAdmin, c *gc.C) error {
	if err := admin.Delete(s.d, adm.Key); err != nil {
		c.Logf("failed to delete admin %q", adm.Email)
		return err
	}

	err := admin.IsAdmin(s.d, adm.Key)
	c.Assert(err, gc.ErrorMatches, fmt.Sprintf("admin for key %s: user not found", adm.Key))
	return nil
}
Пример #3
0
func (s *AdminSuite) deleteAdmins(c *gc.C) {
	for _, u := range s.admins {
		err := admin.Delete(s.d, u.Key)
		c.Assert(err, jc.ErrorIsNil)
	}
}