コード例 #1
0
 def test_get_archive_accessor_raises_exception_when_create_backup_client_raises(
         self, archive_client, storage_client_factory):
     storage_client_factory.from_device_guid.side_effect = Exception(
         "Exception in create_backup_client")
     accessor_manager = ArchiveAccessorManager(archive_client,
                                               storage_client_factory)
     with pytest.raises(Exception) as e:
         accessor_manager.get_archive_accessor(INVALID_DEVICE_GUID)
コード例 #2
0
 def test_get_archive_accessor_calls_storage_client_factory_with_correct_args(
         self, archive_client, storage_client_factory, storage_client,
         storage_archive_client):
     storage_client.archive = storage_archive_client
     storage_client_factory.from_device_guid.return_value = storage_client
     accessor_manager = ArchiveAccessorManager(archive_client,
                                               storage_client_factory)
     accessor_manager.get_archive_accessor(DEVICE_GUID)
     storage_client_factory.from_device_guid.assert_called_with(
         DEVICE_GUID, destination_guid=None)
コード例 #3
0
    def test_get_archive_accessor_with_device_guid_and_destination_guid_returns(
            self, archive_client, storage_client_factory, storage_client,
            storage_archive_client):
        storage_client.archive = storage_archive_client
        storage_client_factory.from_device_guid.return_value = storage_client
        accessor_manager = ArchiveAccessorManager(archive_client,
                                                  storage_client_factory)

        assert accessor_manager.get_archive_accessor(DEVICE_GUID,
                                                     DESTINATION_GUID)
コード例 #4
0
    def test_get_archive_accessor_creates_web_restore_session_with_correct_args(
            self, archive_client, storage_client, storage_client_factory,
            storage_archive_client):
        storage_client.archive = storage_archive_client
        storage_client_factory.from_device_guid.return_value = storage_client
        accessor_manager = ArchiveAccessorManager(archive_client,
                                                  storage_client_factory)
        accessor_manager.get_archive_accessor(DEVICE_GUID)

        storage_archive_client.create_restore_session.assert_called_once_with(
            DEVICE_GUID, data_key_token=DATA_KEY_TOKEN)
コード例 #5
0
    def test_get_archive_accessor_when_given_encryption_key_creates_expected_restore_session(
            self, archive_client, storage_client, storage_client_factory,
            storage_archive_client):
        storage_client.archive = storage_archive_client
        storage_client_factory.from_device_guid.return_value = storage_client
        accessor_manager = ArchiveAccessorManager(archive_client,
                                                  storage_client_factory)
        accessor_manager.get_archive_accessor(DEVICE_GUID,
                                              encryption_key="TEST_KEY")

        storage_archive_client.create_restore_session.assert_called_once_with(
            DEVICE_GUID, encryption_key="TEST_KEY")
コード例 #6
0
    def test_get_archive_accessor_when_given_private_password_creates_expected_restore_session(
            self, archive_client, storage_client, storage_client_factory,
            storage_archive_client):
        storage_client.archive = storage_archive_client
        storage_client_factory.from_device_guid.return_value = storage_client
        accessor_manager = ArchiveAccessorManager(archive_client,
                                                  storage_client_factory)
        accessor_manager.get_archive_accessor(DEVICE_GUID,
                                              private_password="******")

        storage_archive_client.create_restore_session.assert_called_once_with(
            DEVICE_GUID,
            data_key_token=DATA_KEY_TOKEN,
            private_password="******")
コード例 #7
0
    def test_get_archive_accessor_calls_create_restore_job_manager_with_correct_args(
            self, mocker, archive_client, storage_client_factory,
            storage_archive_client, storage_client):
        spy = mocker.spy(py42._internal.archive_access,
                         "create_restore_job_manager")
        storage_client.archive = storage_archive_client

        storage_client_factory.from_device_guid.return_value = storage_client

        accessor_manager = ArchiveAccessorManager(archive_client,
                                                  storage_client_factory)
        accessor_manager.get_archive_accessor(DEVICE_GUID)

        assert spy.call_count == 1
        spy.assert_called_once_with(storage_archive_client, DEVICE_GUID,
                                    WEB_RESTORE_SESSION_ID)
コード例 #8
0
    def __init__(self, host_address, session_factory, root_session):
        self._set_v3_session(host_address, session_factory, root_session)

        # authority clients
        authority_client_factory = AuthorityClientFactory(self.session)
        self.administration_client = (
            authority_client_factory.create_administration_client()
        )
        self.user_client = authority_client_factory.create_user_client()
        self.device_client = authority_client_factory.create_device_client()
        self.org_client = authority_client_factory.create_org_client()
        self.legal_hold_client = authority_client_factory.create_legal_hold_client()
        self.archive_client = authority_client_factory.create_archive_client()
        self.security_client = authority_client_factory.create_security_client()
        self.user_context = UserContext(self.administration_client)

        archive_locator_factory = StorageTokenProviderFactory(
            self.session, self.security_client, self.device_client
        )

        self.storage_client_factory = _get_storage_client_factory(
            session_factory, archive_locator_factory
        )

        archive_accessor_manager = ArchiveAccessorManager(
            self.archive_client, self.storage_client_factory
        )

        microservice_client_factory = MicroserviceClientFactory(
            host_address,
            root_session,
            session_factory,
            self.user_context,
            self.user_client,
        )

        # modules (feature sets that combine info from multiple clients)
        self.archive_module = archive_module.ArchiveModule(
            archive_accessor_manager, self.archive_client
        )
        self.security_module = sec_module.SecurityModule(
            self.security_client,
            self.storage_client_factory,
            microservice_client_factory,
        )
        self.detection_lists_module = detectionlists.DetectionListsModule(
            microservice_client_factory
        )

        self.alerts_module = alerts.AlertsModule(microservice_client_factory)
コード例 #9
0
 def test_archive_accessor_manager_constructor_constructs_successfully(
         self, archive_client, storage_client_factory):
     assert ArchiveAccessorManager(archive_client, storage_client_factory)