Example #1
0
    def start_server(self,
                     port,
                     address,
                     *,
                     xsrf_protection=XSRF_PROTECTION_TOKEN):
        file_download_feature = FileDownloadFeature(
            UserFileStorage(b'some_secret'), test_utils.temp_folder)
        config = ServerConfig()
        config.port = port
        config.address = address
        config.xsrf_protection = xsrf_protection
        config.max_request_size_mb = 1

        authorizer = Authorizer(ANY_USER, [], [], EmptyGroupProvider())
        execution_service = MagicMock()
        execution_service.start_script.return_value = 3

        server.init(config,
                    None,
                    authorizer,
                    execution_service,
                    MagicMock(),
                    MagicMock(),
                    ConfigService(authorizer, self.conf_folder),
                    MagicMock(),
                    FileUploadFeature(UserFileStorage(b'cookie_secret'),
                                      test_utils.temp_folder),
                    file_download_feature,
                    'cookie_secret',
                    None,
                    self.conf_folder,
                    start_server=False)
        self.start_loop()
Example #2
0
    def start_server(self,
                     port,
                     address,
                     *,
                     xsrf_protection=XSRF_PROTECTION_TOKEN):
        file_download_feature = FileDownloadFeature(
            UserFileStorage(b'some_secret'), test_utils.temp_folder)
        config = ServerConfig()
        config.port = port
        config.address = address
        config.xsrf_protection = xsrf_protection
        config.max_request_size_mb = 1

        authorizer = Authorizer(ANY_USER, ['admin_user'], [], ['admin_user'],
                                EmptyGroupProvider())
        execution_service = MagicMock()
        execution_service.start_script.return_value = 3

        cookie_secret = b'cookie_secret'

        server.init(config,
                    MockAuthenticator(),
                    authorizer,
                    execution_service,
                    MagicMock(),
                    MagicMock(),
                    ConfigService(authorizer, self.conf_folder),
                    MagicMock(),
                    FileUploadFeature(UserFileStorage(cookie_secret),
                                      test_utils.temp_folder),
                    file_download_feature,
                    'cookie_secret',
                    None,
                    self.conf_folder,
                    start_server=False)
        self.start_loop()

        self._user_session = requests.Session()
        self._user_session.cookies['username'] = create_signed_value(cookie_secret, 'username', 'normal_user') \
            .decode('utf8')

        self._admin_session = requests.Session()
        self._admin_session.cookies['username'] = create_signed_value(cookie_secret, 'username', 'admin_user') \
            .decode('utf8')
    def start_server(self, port, address):
        file_download_feature = FileDownloadFeature(UserFileStorage(b'123456'),
                                                    test_utils.temp_folder)
        config = ServerConfig()
        config.port = port
        config.address = address

        server.init(config,
                    None,
                    None,
                    None,
                    None,
                    None,
                    None,
                    None,
                    file_download_feature,
                    None,
                    None,
                    start_server=False)
        self.start_loop()
    def start_server(self, port, address):
        file_download_feature = FileDownloadFeature(
            UserFileStorage(b'some_secret'), test_utils.temp_folder)
        config = ServerConfig()
        config.port = port
        config.address = address

        authorizer = Authorizer(ANY_USER, [], [], EmptyGroupProvider())
        server.init(config,
                    None,
                    authorizer,
                    None,
                    None,
                    ConfigService(authorizer, self.conf_folder),
                    None,
                    None,
                    file_download_feature,
                    'cookie_secret',
                    None,
                    start_server=False)
        self.start_loop()