Esempio n. 1
0
 def test_get_all_plan_security_events_when_cursors_returned_calls_security_service_expected_number_of_times(
     self,
     mocker,
     security_service,
     file_event_service,
     preservation_data_service,
     saved_search_service,
     storage_service_factory,
 ):
     mock_storage_security_service = mocker.MagicMock(
         spec=StorageSecurityDataService)
     response1 = mocker.MagicMock(spec=Py42Response)
     cursor_json = '{"cursor": "1:1"}'
     response1.text = cursor_json
     response1.data = json.loads(cursor_json)
     response2 = mocker.MagicMock(spec=Py42Response)
     response2.text = "{}"
     response2.data = {}
     mock_storage_security_service.get_plan_security_events.side_effect = [
         response1,
         response2,
     ]
     storage_service_factory.create_security_data_service.return_value = (
         mock_storage_security_service)
     security_client = SecurityDataClient(
         security_service,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     for _, _ in security_client.get_all_plan_security_events(
             PlanStorageInfo("111111111111111111", "41", "4")):
         pass
     assert mock_storage_security_service.get_plan_security_events.call_count == 2
Esempio n. 2
0
 def test_get_all_plan_security_events_when_multiple_plans_returned_calls_security_service_expected_number_of_times(
     self,
     mocker,
     security_service,
     file_event_service,
     preservation_data_service,
     saved_search_service,
     storage_service_factory,
 ):
     mock_storage_security_service = mocker.MagicMock(
         spec=StorageSecurityDataService)
     response = mocker.MagicMock(spec=Py42Response)
     response.text = "{}"
     response.data = {}
     mock_storage_security_service.get_plan_security_events.return_value = response
     storage_service_factory.create_security_data_service.return_value = (
         mock_storage_security_service)
     security_client = SecurityDataClient(
         security_service,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     plans = [
         PlanStorageInfo("111111111111111111", "41", "4"),
         PlanStorageInfo("222222222222222222", "41", "4"),
     ]
     for _, _ in security_client.get_all_plan_security_events(plans):
         pass
     assert mock_storage_security_service.get_plan_security_events.call_count == 2
Esempio n. 3
0
 def test_get_all_plan_security_events_calls_security_service_with_expected_params(
     self,
     mocker,
     security_service,
     file_event_service,
     preservation_data_service,
     saved_search_service,
     storage_service_factory,
     plan_storage_info,
 ):
     mock_storage_security_service = mocker.MagicMock(
         spec=StorageSecurityDataService)
     response = mocker.MagicMock(spec=Py42Response)
     response.text = "{}"
     response.data = {}
     mock_storage_security_service.get_plan_security_events.return_value = response
     storage_service_factory.create_security_data_service.return_value = (
         mock_storage_security_service)
     security_client = SecurityDataClient(
         security_service,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     for _, _ in security_client.get_all_plan_security_events(
             plan_storage_info):
         pass
     mock_storage_security_service.get_plan_security_events.assert_called_once_with(
         "111111111111111111",
         cursor=None,
         event_types=None,
         include_files=True,
         max_timestamp=None,
         min_timestamp=None,
     )