Beispiel #1
0
    def test_wrong_keys(self):
        config = GalaxyDataTestConfig(vault_config_file=VAULT_CONF_DATABASE)
        app = GalaxyDataTestApp(config=config)
        vault = VaultFactory.from_app(app)
        vault.write_secret("my/incorrect/secret", "hello incorrect")

        # should fail because decryption keys are the wrong
        app.config.vault_config_file = VAULT_CONF_DATABASE_INVALID  # type: ignore
        vault = VaultFactory.from_app(app)
        with self.assertRaises(InvalidToken):
            vault.read_secret("my/incorrect/secret")
Beispiel #2
0
    def test_rotate_keys(self):
        config = GalaxyDataTestConfig(vault_config_file=VAULT_CONF_DATABASE)
        app = GalaxyDataTestApp(config=config)
        vault = VaultFactory.from_app(app)
        vault.write_secret("my/rotated/secret", "hello rotated")

        # should succeed after rotation
        app.config.vault_config_file = VAULT_CONF_DATABASE_ROTATED  # type: ignore
        vault = VaultFactory.from_app(app)
        self.assertEqual(vault.read_secret("my/rotated/secret"),
                         "hello rotated")
Beispiel #3
0
    def __init__(self, configure_logging=True, **kwargs):
        super().__init__(**kwargs)
        self._register_singleton(MinimalManagerApp, self)
        self.execution_timer_factory = self._register_singleton(
            ExecutionTimerFactory, ExecutionTimerFactory(self.config))
        self.configure_fluent_log()
        self.application_stack = self._register_singleton(
            ApplicationStack, application_stack_instance(app=self))
        if configure_logging:
            config.configure_logging(self.config, self.application_stack.facts)
        # Initialize job metrics manager, needs to be in place before
        # config so per-destination modifications can be made.
        self.job_metrics = self._register_singleton(
            JobMetrics,
            JobMetrics(self.config.job_metrics_config_file, app=self))
        # Initialize the job management configuration
        self.job_config = self._register_singleton(jobs.JobConfiguration)

        # Tag handler
        self.tag_handler = self._register_singleton(GalaxyTagHandler)
        self.user_manager = self._register_singleton(UserManager)
        self._register_singleton(GalaxySessionManager)
        self.hda_manager = self._register_singleton(HDAManager)
        self.history_manager = self._register_singleton(HistoryManager)
        self.job_search = self._register_singleton(JobSearch)
        self.dataset_collection_manager = self._register_singleton(
            DatasetCollectionManager)
        self.workflow_manager = self._register_singleton(WorkflowsManager)
        self.workflow_contents_manager = self._register_singleton(
            WorkflowContentsManager)
        self.library_folder_manager = self._register_singleton(FolderManager)
        self.library_manager = self._register_singleton(LibraryManager)
        self.library_datasets_manager = self._register_singleton(
            LibraryDatasetsManager)
        self.role_manager = self._register_singleton(RoleManager)
        self.job_manager = self._register_singleton(JobManager)

        # ConfiguredFileSources
        self.file_sources = self._register_singleton(
            ConfiguredFileSources,
            ConfiguredFileSources.from_app_config(self.config))

        self.vault = self._register_singleton(Vault,
                                              VaultFactory.from_app(self))

        # We need the datatype registry for running certain tasks that modify HDAs, and to build the registry we need
        # to setup the installed repositories ... this is not ideal
        self._configure_tool_config_files()
        self.installed_repository_manager = self._register_singleton(
            InstalledRepositoryManager, InstalledRepositoryManager(self))
        self._configure_datatypes_registry(self.installed_repository_manager)
        self._register_singleton(Registry, self.datatypes_registry)
        galaxy.model.set_datatypes_registry(self.datatypes_registry)
        self.configure_sentry_client()
Beispiel #4
0
 def setUp(self) -> None:
     with tempfile.NamedTemporaryFile(
             mode="w", prefix="vault_hashicorp",
             delete=False) as tempconf, open(VAULT_CONF_HASHICORP) as f:
         content = string.Template(f.read()).safe_substitute(
             vault_address=os.environ.get('VAULT_ADDRESS'),
             vault_token=os.environ.get('VAULT_TOKEN'))
         tempconf.write(content)
         self.vault_temp_conf = tempconf.name
     config = GalaxyDataTestConfig(vault_config_file=self.vault_temp_conf)
     app = GalaxyDataTestApp(config=config)
     self.vault = VaultFactory.from_app(app)
Beispiel #5
0
 def setUp(self) -> None:
     with tempfile.NamedTemporaryFile(
             mode="w", prefix="vault_custos",
             delete=False) as tempconf, open(VAULT_CONF_CUSTOS) as f:
         content = string.Template(f.read()).safe_substitute(
             custos_client_id=os.environ.get('CUSTOS_CLIENT_ID'),
             custos_client_secret=os.environ.get('CUSTOS_CLIENT_SECRET'))
         tempconf.write(content)
         self.vault_temp_conf = tempconf.name
     config = GalaxyDataTestConfig(vault_config_file=self.vault_temp_conf)
     app = GalaxyDataTestApp(config=config)
     self.vault = VaultFactory.from_app(app)
Beispiel #6
0
 def setUp(self) -> None:
     config = GalaxyDataTestConfig(vault_config_file=VAULT_CONF_DATABASE)
     app = GalaxyDataTestApp(config=config)
     self.vault = VaultFactory.from_app(app)