Ejemplo n.º 1
0
 def test_get_all_plan_security_events_when_multiple_plans_with_cursors_returned_calls_security_client_expected_number_of_times(
         self, mocker, security_client, storage_client_factory,
         microservice_client_factory):
     mock_storage_client = mocker.MagicMock(spec=StorageClient)
     mock_storage_security_client = mocker.MagicMock(
         spec=StorageSecurityClient)
     mock_storage_client.securitydata = mock_storage_security_client
     response1 = mocker.MagicMock(spec=Py42Response)
     response1.text = '{"cursor": "1:1"}'
     response2 = mocker.MagicMock(spec=Py42Response)
     response2.text = "{}"
     mock_storage_security_client.get_plan_security_events.side_effect = [
         response1,
         response2,
         response1,
         response2,
     ]
     storage_client_factory.from_plan_info.return_value = mock_storage_client
     security_module = SecurityModule(security_client,
                                      storage_client_factory,
                                      microservice_client_factory)
     plans = [
         PlanStorageInfo("111111111111111111", "41", "4"),
         PlanStorageInfo("222222222222222222", "41", "4"),
     ]
     for _, _ in security_module.get_all_plan_security_events(plans):
         pass
     assert mock_storage_security_client.get_plan_security_events.call_count == 4
Ejemplo n.º 2
0
 def test_get_all_plan_security_events_calls_security_client_with_expected_params(
         self, mocker, security_client, storage_client_factory,
         microservice_client_factory):
     mock_storage_client = mocker.MagicMock(spec=StorageClient)
     mock_storage_security_client = mocker.MagicMock(
         spec=StorageSecurityClient)
     mock_storage_client.securitydata = mock_storage_security_client
     response = mocker.MagicMock(spec=Py42Response)
     response.text = "{}"
     mock_storage_security_client.get_plan_security_events.return_value = response
     storage_client_factory.from_plan_info.return_value = mock_storage_client
     security_module = SecurityModule(security_client,
                                      storage_client_factory,
                                      microservice_client_factory)
     for _, _ in security_module.get_all_plan_security_events(
             PlanStorageInfo("111111111111111111", "41", "4")):
         pass
     mock_storage_security_client.get_plan_security_events.assert_called_once_with(
         "111111111111111111",
         cursor=None,
         event_types=None,
         include_files=True,
         max_timestamp=None,
         min_timestamp=None,
     )