Esempio n. 1
0
 def _create_config_and_reset_app(self, server):
     """Create config, and reset Flask app
     :type server: module
     """
     self.server_configuration = self.create_configuration()
     utils.copy_resources(self.server_configuration.file_server_root)
     server.SQL_DIALECT = 'sqlite'
     server.reset_app(self.server_configuration)
Esempio n. 2
0
    def _create_config_and_reset_app(cls):
        """Create config, and reset Flask app
        """
        cls.server_configuration = cls.create_configuration()
        utils.copy_resources(cls.server_configuration.file_server_root)
        server.reset_app(cls.server_configuration)

        cls._set_hash_mechanism_to_plaintext()
    def _create_config_and_reset_app(cls):
        """Create config, and reset Flask app
        """
        cls.server_configuration = cls.create_configuration()
        utils.copy_resources(cls.server_configuration.file_server_root)
        server.reset_app(cls.server_configuration)

        cls._set_hash_mechanism_to_plaintext()
Esempio n. 4
0
    def setUp(self):
        self.tmpdir = tempfile.mkdtemp(prefix='fileserver-')
        fd, self.rest_service_log = tempfile.mkstemp(prefix='rest-log-')
        os.close(fd)
        fd, self.sqlite_db_file = tempfile.mkstemp(prefix='sqlite-db-')
        os.close(fd)
        self.file_server = FileServer(self.tmpdir)
        self.maintenance_mode_dir = tempfile.mkdtemp(prefix='maintenance-')

        self.addCleanup(self.cleanup)
        self.file_server.start()

        # workaround for setting the rest service log path, since it's
        # needed when 'server' module is imported.
        # right after the import the log path is set normally like the rest
        # of the variables (used in the reset_state)
        fd, self.tmp_conf_file = tempfile.mkstemp(prefix='conf-file-')
        os.close(fd)
        with open(self.tmp_conf_file, 'w') as f:
            json.dump({'rest_service_log_path': self.rest_service_log,
                       'rest_service_log_file_size_MB': 1,
                       'rest_service_log_files_backup_count': 1,
                       'rest_service_log_level': 'DEBUG'},
                      f)
        os.environ['MANAGER_REST_CONFIG_PATH'] = self.tmp_conf_file
        try:
            from manager_rest import server
        finally:
            del(os.environ['MANAGER_REST_CONFIG_PATH'])

        self.server_configuration = self.create_configuration()
        server.SQL_DIALECT = 'sqlite'
        server.reset_app(self.server_configuration)
        utils.copy_resources(config.instance.file_server_root)

        self._flask_app_context = server.app.test_request_context()
        self._flask_app_context.push()
        self.addCleanup(self._flask_app_context.pop)

        self.app = self._get_app(server.app)
        self.client = self.create_client()
        server.db.create_all()
        default_tenant = self._init_default_tenant(server.db, server.app)
        self.sm = get_storage_manager()
        self._add_users_and_roles(server.user_datastore, default_tenant)
        self.initialize_provider_context()