Exemplo n.º 1
0
 def test_create_archive_content_pusher_creates_push_service_with_accepting_guid(
         self, archive_service, storage_service_factory):
     accessor_factory = ArchiveAccessorFactory(archive_service,
                                               storage_service_factory)
     accessor_factory.create_archive_content_pusher(TEST_DEVICE_GUID,
                                                    TEST_ACCEPTING_GUID)
     storage_service_factory.create_push_restore_service.assert_called_once_with(
         TEST_ACCEPTING_GUID)
Exemplo n.º 2
0
 def test_create_archive_content_push_creates_pusher_with_expected_properties(
         self, archive_service, storage_service_factory):
     accessor_factory = ArchiveAccessorFactory(archive_service,
                                               storage_service_factory)
     pusher = accessor_factory.create_archive_content_pusher(
         TEST_DEVICE_GUID, TEST_ACCEPTING_GUID)
     # Set inside device_service mock
     assert pusher.destination_guid == TEST_DESTINATION_GUID_1
     assert pusher._node_guid == TEST_NODE_GUID
Exemplo n.º 3
0
 def test_create_archive_accessor_raises_exception_when_create_backup_client_raises(
         self, archive_service, storage_service_factory):
     storage_service_factory.create_archive_service.side_effect = Exception(
         "Exception in create_backup_client")
     accessor_factory = ArchiveAccessorFactory(archive_service,
                                               storage_service_factory)
     with pytest.raises(Exception):
         accessor_factory.create_archive_accessor(INVALID_DEVICE_GUID,
                                                  ArchiveAccessor)
Exemplo n.º 4
0
 def test_create_archive_accessor_when_given_destination_guid_does_not_auto_select(
         self, archive_service, storage_service_factory):
     accessor_factory = ArchiveAccessorFactory(archive_service,
                                               storage_service_factory)
     accessor_factory.create_archive_accessor(TEST_DEVICE_GUID,
                                              ArchiveAccessor,
                                              TEST_DESTINATION_GUID_1)
     storage_service_factory.auto_select_destination_guid.assert_not_called(
     )
Exemplo n.º 5
0
 def test_create_archive_accessor_with_device_guid_and_destination_guid_returns(
     self,
     archive_service,
     storage_service_factory,
     storage_archive_service,
 ):
     storage_service_factory.create_archive_service.return_value = (
         storage_archive_service)
     accessor_factory = ArchiveAccessorFactory(archive_service,
                                               storage_service_factory)
     assert accessor_factory.create_archive_accessor(
         TEST_DEVICE_GUID, accessor_class=ArchiveAccessor)
Exemplo n.º 6
0
 def test_create_archive_accessor_calls_storage_service_factory_with_correct_args(
     self, archive_service, storage_service_factory, storage_archive_service,
 ):
     storage_service_factory.create_archive_service.return_value = (
         storage_archive_service
     )
     accessor_factory = ArchiveAccessorFactory(
         archive_service, storage_service_factory
     )
     accessor_factory.create_archive_accessor(TEST_DEVICE_GUID, ArchiveAccessor)
     storage_service_factory.create_archive_service.assert_called_with(
         TEST_DEVICE_GUID, TEST_DESTINATION_GUID_1,
     )
Exemplo n.º 7
0
    def test_create_archive_accessor_creates_web_restore_session_with_correct_args(
        self, archive_service, storage_service_factory, storage_archive_service,
    ):
        storage_service_factory.create_archive_service.return_value = (
            storage_archive_service
        )
        accessor_factory = ArchiveAccessorFactory(
            archive_service, storage_service_factory
        )
        accessor_factory.create_archive_accessor(TEST_DEVICE_GUID, ArchiveAccessor)

        storage_archive_service.create_restore_session.assert_called_once_with(
            TEST_DEVICE_GUID, data_key_token=TEST_DATA_KEY_TOKEN
        )
Exemplo n.º 8
0
 def test_create_archive_accessor_when_given_private_password_creates_expected_restore_session(
     self, archive_service, storage_service_factory, storage_archive_service,
 ):
     storage_service_factory.create_archive_service.return_value = (
         storage_archive_service
     )
     accessor_factory = ArchiveAccessorFactory(
         archive_service, storage_service_factory
     )
     accessor_factory.create_archive_accessor(
         TEST_DEVICE_GUID, ArchiveAccessor, private_password=TEST_PASSWORD,
     )
     storage_archive_service.create_restore_session.assert_called_once_with(
         TEST_DEVICE_GUID,
         data_key_token=TEST_DATA_KEY_TOKEN,
         private_password=TEST_PASSWORD,
     )
Exemplo n.º 9
0
def _init_clients(services, connection):
    # clients are imported within function to prevent circular imports when a client
    # imports anything from py42.sdk.queries
    from py42.clients import Clients
    from py42.clients._archiveaccess.accessorfactory import ArchiveAccessorFactory
    from py42.clients.alertrules import AlertRulesClient
    from py42.clients.alerts import AlertsClient
    from py42.clients.archive import ArchiveClient
    from py42.clients.auditlogs import AuditLogsClient
    from py42.clients.authority import AuthorityClient
    from py42.clients.cases import CasesClient
    from py42.clients.detectionlists import DetectionListsClient
    from py42.clients.loginconfig import LoginConfigurationClient
    from py42.clients.securitydata import SecurityDataClient
    from py42.clients.trustedactivities import TrustedActivitiesClient
    from py42.services.storage._service_factory import ConnectionManager
    from py42.services.storage._service_factory import StorageServiceFactory

    authority = AuthorityClient(
        administration=services.administration,
        archive=services.archive,
        devices=services.devices,
        legalhold=services.legalhold,
        orgs=services.orgs,
        users=services.users,
    )
    detectionlists = DetectionListsClient(services.userprofile,
                                          services.departingemployee,
                                          services.highriskemployee)
    storage_service_factory = StorageServiceFactory(connection,
                                                    services.devices,
                                                    ConnectionManager())
    alertrules = AlertRulesClient(services.alerts, services.alertrules)
    securitydata = SecurityDataClient(
        services.fileevents,
        services.preservationdata,
        services.savedsearch,
        storage_service_factory,
    )
    alerts = AlertsClient(services.alerts, alertrules)
    archive_accessor_factory = ArchiveAccessorFactory(services.archive,
                                                      storage_service_factory)
    archive = ArchiveClient(archive_accessor_factory, services.archive)
    auditlogs = AuditLogsClient(services.auditlogs)
    loginconfig = LoginConfigurationClient(connection)
    trustedactivities = TrustedActivitiesClient(services.trustedactivities)
    clients = Clients(
        authority=authority,
        detectionlists=detectionlists,
        alerts=alerts,
        securitydata=securitydata,
        archive=archive,
        auditlogs=auditlogs,
        cases=CasesClient(services.cases, services.casesfileevents),
        loginconfig=loginconfig,
        trustedactivities=trustedactivities,
    )
    return clients
Exemplo n.º 10
0
    def test_create_archive_accessor_when_given_encryption_key_creates_expected_restore_session(
        self,
        archive_service,
        storage_service_factory,
        storage_archive_service,
    ):
        storage_service_factory.create_archive_service.return_value = (
            storage_archive_service)
        accessor_factory = ArchiveAccessorFactory(archive_service,
                                                  storage_service_factory)
        accessor_factory.create_archive_accessor(
            TEST_DEVICE_GUID,
            encryption_key=TEST_ENCRYPTION_KEY,
            accessor_class=ArchiveAccessor,
        )

        storage_archive_service.create_restore_session.assert_called_once_with(
            TEST_DEVICE_GUID, encryption_key=TEST_ENCRYPTION_KEY)
Exemplo n.º 11
0
    def test_create_archive_accessor_calls_create_restore_job_manager_with_correct_args(
        self, mocker, archive_service, storage_service_factory, storage_archive_service,
    ):
        spy = mocker.spy(
            py42.clients._archiveaccess.accessorfactory, "create_restore_job_manager"
        )
        storage_service_factory.create_archive_service.return_value = (
            storage_archive_service
        )
        accessor_factory = ArchiveAccessorFactory(
            archive_service, storage_service_factory
        )
        accessor_factory.create_archive_accessor(TEST_DEVICE_GUID, ArchiveAccessor)

        assert spy.call_count == 1
        spy.assert_called_once_with(
            storage_archive_service, TEST_DEVICE_GUID, TEST_SESSION_ID
        )
Exemplo n.º 12
0
def _init_clients(services, connection):
    authority = AuthorityClient(
        administration=services.administration,
        archive=services.archive,
        devices=services.devices,
        legalhold=services.legalhold,
        orgs=services.orgs,
        securitydata=services.securitydata,
        users=services.users,
    )
    detectionlists = DetectionListsClient(services.userprofile,
                                          services.departingemployee,
                                          services.highriskemployee)
    storage_service_factory = StorageServiceFactory(connection,
                                                    services.devices,
                                                    ConnectionManager())
    alertrules = AlertRulesClient(services.alerts, services.alertrules)
    securitydata = SecurityDataClient(
        services.securitydata,
        services.fileevents,
        services.preservationdata,
        services.savedsearch,
        storage_service_factory,
    )
    alerts = AlertsClient(services.alerts, alertrules)
    archive_accessor_factory = ArchiveAccessorFactory(services.archive,
                                                      storage_service_factory)
    archive = ArchiveClient(archive_accessor_factory, services.archive)
    auditlogs = AuditLogsClient(services.auditlogs)
    clients = Clients(
        authority=authority,
        detectionlists=detectionlists,
        alerts=alerts,
        securitydata=securitydata,
        archive=archive,
        auditlogs=auditlogs,
        cases=CasesClient(services.cases, services.casesfileevents),
    )
    return clients
Exemplo n.º 13
0
 def test_archive_accessor_manager_constructor_constructs_successfully(
         self, archive_service, storage_service_factory):
     assert ArchiveAccessorFactory(archive_service, storage_service_factory)