示例#1
0
 def get_routes_register(self,
                         url_path: str,
                         url_path_cb_suffix: str = "/callback") -> list:
     """ Returns routes for user registration (login and login-callback) """
     callback_path = url_path_join(url_path, url_path_cb_suffix)
     callback_url = url_path_join(url_path,
                                  url_path_cb_suffix,
                                  base_url=self._app_base_url)
     routes = [
         self._get_oauth2_authorization_route(url_path, callback_url),
         self._get_user_register_route_callback(callback_path, callback_url)
     ]
     return routes
示例#2
0
def create_routes(
    endpoints: UserEndpoints, msg_bus: MessageBus,
    new_user_accounts: UserAccountActivationStorage
) -> List[tornado.routing.Rule]:
    routes = [
        tornado.routing.Rule(
            tornado.routing.PathMatches(endpoints.api_endpoints), ApiEndpoints,
            dict(args=ApiEndpointsArguments(endpoints,
                                            JsonUserEndpointsSerializer()))),
        tornado.routing.Rule(
            tornado.routing.PathMatches(endpoints.websocket),
            UnixAccountAuthorizationWebsocket,
            dict(args=UnixAccountAuthorizationWebsocketArguments(
                msg_bus, AuthenticatedUserSerializer(),
                WebsocketMessageProtocol()))),
        tornado.routing.Rule(
            tornado.routing.PathMatches(
                url_path_join(endpoints.user_registration, "(.*)")),
            UserAccountActivation,
            dict(args=UserAccountActivationArguments(
                AuthenticatedUserSerializer(), new_user_accounts))),
        tornado.routing.Rule(tornado.routing.PathMatches(endpoints.logout),
                             UserAccountLogout)
    ]
    return routes
示例#3
0
    def test_template1_file1(self, renderer, default_name):
        instance = default_name.return_value
        name = str(uuid.uuid4())
        instance.render.return_value = name
        renderer.return_value = "dummy content"
        path = generate_path()
        body = dict(dummy="hello", smart="world")

        answer = self.api_tester.post(
            ["files", quote("template1/file1", safe=""), path], body=body
        )
        assert answer.status_code == 201

        instance.render.assert_called_with(**body)
        renderer.assert_called_with(**body)
        model = answer.json()
        assert model["content"] is None
        assert model["name"] == name + ".py"
        assert model["path"] == url_path_join(path, name + ".py")
示例#4
0
 def _abs_path(self, path: str) -> str:
     return url_path_join(self._prefix, path)