Esempio n. 1
0
    def setUp(self):
        self.app = Application()
        self.app.route("/", TestController)
        self.app.route("/<action>/", TestController)
        self.app.route("/options/", TestProxyController)
        self.app.route("/reflection/<action>/", ReflectionController)
        self.app.route("/reflection/<action>/<arg>/", ReflectionController)

        self.test_app = TestApp(self.app)
Esempio n. 2
0
    def unauth(cls, app: Application, request: Request, **kwargs) -> bool:
        """ Выполняет деаутентификацию

        @param request: Запрос пользователя
        @type request: Request
        @param kwargs: Параметры окружения
        @return: Результат выполнения авторизации
        @rtype : bool

        """
        request.response.set_cookie("token", "", path="/", expires=datetime.now() - timedelta(seconds=30*60))
        app.redirect(cls.root)
Esempio n. 3
0
    def setUp(self):
        self.app = Application()
        self.app.route("/", TestController)
        self.app.route("/<action>/", TestController)
        self.app.route("/options/", TestProxyController)
        self.app.route("/reflection/<action>/", ReflectionController)
        self.app.route("/reflection/<action>/<arg>/", ReflectionController)

        self.test_app = TestApp(self.app)
Esempio n. 4
0
class ControllerTestsFixture(unittest.TestCase):
    def setUp(self):
        self.app = Application()
        self.app.route("/", TestController)
        self.app.route("/<action>/", TestController)
        self.app.route("/options/", TestProxyController)
        self.app.route("/reflection/<action>/", ReflectionController)
        self.app.route("/reflection/<action>/<arg>/", ReflectionController)

        self.test_app = TestApp(self.app)

    def get_query(self, url, data=None):
        return self.test_app.get(url, data if data else None).body.decode("utf-8")

    def post_query(self, url, data=None):
        return self.test_app.post(url, data if data else {}, xhr=True).body.decode()

    def get_headers_from_get_query(self, url):
        return self.test_app.get(url).headers
Esempio n. 5
0
 def user_initialization_hook_static(cls, app: Application, request: Request, auto_register=None):
     """
     Стандартный алгоритм аутентификации
     :param app: Экземпляр приложения
     :param request: Запрос пользователя
     :return: Аккаунт пользователя
     """
     if request.path in [
         "{}auth/login".format(cls.root),
         "{}auth/auth".format(cls.root),
         "{}auth/change_password".format(cls.root),
     ]:
         return None
     try:
         a = cls.auth_service().authentificate_by_request(request)
         return a
     except (NoDataForAuth, IncorrectToken):
         if auto_register:
             return cls.new_default_account(request, auto_register=auto_register)
         else:
             app.redirect("{}auth/login/".format(cls.root))
Esempio n. 6
0
class ControllerTestsFixture(unittest.TestCase):
    def setUp(self):
        self.app = Application()
        self.app.route("/", TestController)
        self.app.route("/<action>/", TestController)
        self.app.route("/options/", TestProxyController)
        self.app.route("/reflection/<action>/", ReflectionController)
        self.app.route("/reflection/<action>/<arg>/", ReflectionController)

        self.test_app = TestApp(self.app)

    def get_query(self, url, data=None):
        return self.test_app.get(url,
                                 data if data else None).body.decode("utf-8")

    def post_query(self, url, data=None):
        return self.test_app.post(url, data if data else {},
                                  xhr=True).body.decode()

    def get_headers_from_get_query(self, url):
        return self.test_app.get(url).headers
Esempio n. 7
0
"""
PRIVATE API

"""
from envi import Application
from controllers import DefaultPrivateController

application = Application()
application.route("/<action>/", DefaultPrivateController)
Esempio n. 8
0
""" Микро-сервис для обработки изображений

"""

from envi import Application
from controllers import Controller

application = Application()
application.route("/<action>/", Controller)
application.route("/v1/<action>/", Controller)
Esempio n. 9
0
from envi import Application
from controllers import RoutesController

application = Application()
application.route("/<action>/",
                  RoutesController)  # latest version of the controller
application.route("/v1/<action>/",
                  RoutesController)  # specific version of the controller
Esempio n. 10
0
""" Микро-сервис для аутентификации

"""

from envi import Application as EnviApplication
from controllers import AuthController

application = EnviApplication()
application.route("/<action>/", AuthController)
application.route("/v1/<action>/", AuthController)
Esempio n. 11
0
"""
PUBLIC API

"""
from envi import Application
from controllers import DefaultPublicController

application = Application()
application.route("/<action>/", DefaultPublicController)
Esempio n. 12
0
 def setUp(self):
     app = Application()
     app.route("/", JsonRpcController)
     self.test_app = TestApp(app)