Пример #1
0
 def test_get_all_user_security_events_when_cursors_returned_calls_security_service_expected_number_of_times(
     self,
     mocker,
     security_service_one_location,
     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_one_location,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     for _, _ in security_client.get_all_user_security_events("foo"):
         pass
     assert mock_storage_security_service.get_plan_security_events.call_count == 2
Пример #2
0
 def test_get_all_user_security_events_when_multiple_plans_returned_calls_security_service_expected_number_of_times(
     self,
     mocker,
     security_service_two_plans_one_node,
     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_two_plans_one_node,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     for _, _ in security_client.get_all_user_security_events("foo"):
         pass
     assert mock_storage_security_service.get_plan_security_events.call_count == 2
Пример #3
0
 def test_get_all_user_security_events_calls_security_service_with_expected_params(
     self,
     mocker,
     security_service_one_location,
     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_one_location,
         file_event_service,
         preservation_data_service,
         saved_search_service,
         storage_service_factory,
     )
     for _, _ in security_client.get_all_user_security_events("foo"):
         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,
     )