Ejemplo n.º 1
0
    def test_app_inactive(self):
        """App 被禁用
        """
        app_secret = "secret"
        app = App(user=self.current_user,
                  name="fortest", app_secret=app_secret)
        self.db.add(app)
        self.db.commit()
        app_id = str(str(app.app_id))

        resp = self.api_post("/app_token", body={
            "app_id": app_id,
            "app_secret": app_secret,
        })
        body = get_body_json(resp)
        refresh_token = body["data"]["refresh_token"]

        del app
        app = self.db.query(App).filter_by(app_id=app_id).first()
        app.is_active = False
        self.db.commit()

        resp = self.api_post("/app_token/refresh", body={
            "app_id": app_id,
            "refresh_token": refresh_token,
        })
        body = get_body_json(resp)
        self.assertEqual(resp.code, 400)
        validate_default_error(body)
        self.assertEqual(body["status"], "app-inactive")
Ejemplo n.º 2
0
 def test_app_inactive(self):
     """App 被禁用
     """
     app_secret = "secret"
     app = App(user=self.current_user,
               name="fortest", app_secret=app_secret)
     app.is_active = False
     self.db.add(app)
     self.db.commit()
     resp = self.api_post("/app_token", body={
         "app_id": str(app.app_id),
         "app_secret": app_secret,
     })
     body = get_body_json(resp)
     self.assertEqual(resp.code, 400)
     validate_default_error(body)
     self.assertEqual(body["status"], "app-inactive")