func (s *S) TestDeleteAppsByTeam(c *C) { app.Create(alice, team) c.Assert(app.Exists(), Equals, true) newApp := account.App{ClientId: "android", ClientSecret: "secret", Name: "Andoird App", Team: team.Alias, Owner: owner.Email, RedirectUris: []string{"http://www.example.org/auth"}} newApp.Create(alice, team) account.DeleteAppsByTeam(team, alice) _, err := account.FindAppByClientId("ios") c.Check(err, Not(IsNil)) _, err = account.FindAppByClientId("android") c.Check(err, Not(IsNil)) }
func (api *Api) appUpdate(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(app.Team, user) if err != nil { handleError(rw, err) return } if err := json.NewDecoder(r.Body).Decode(&app); err != nil { handleError(rw, errors.ErrBadRequest) return } // It is not allowed to change the client id yet. app.ClientId = mux.Vars(r)["client_id"] err = app.Update() if err != nil { handleError(rw, err) return } Ok(rw, app) }
func (s *S) TestFindAppByClientId(c *C) { err := app.Create(owner, team) a, err := account.FindAppByClientId(app.ClientId) c.Check(a, Not(IsNil)) c.Check(err, IsNil) defer app.Delete(owner) }
func (api *Api) appDelete(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } if err = app.Delete(*user); err != nil { handleError(rw, err) return } Ok(rw, app) }
func (api *Api) appInfo(rw http.ResponseWriter, r *http.Request, user *account.User) { app, err := account.FindAppByClientId(mux.Vars(r)["client_id"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(app.Team, user) if err != nil { handleError(rw, err) return } Ok(rw, app) }
func (s *S) TestFindAppByClientIdNotFound(c *C) { a, err := account.FindAppByClientId("not-found") c.Check(a, IsNil) _, ok := err.(errors.NotFoundError) c.Assert(ok, Equals, true) }