コード例 #1
0
 def test_get_user_security_events_when_mutliple_plans_with_cursors_returned_calls_security_client_expected_number_of_times(
     self,
     mocker,
     security_client_two_plans_one_node,
     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_two_plans_one_node,
                                      storage_client_factory,
                                      microservice_client_factory)
     for _, _ in security_module.get_user_security_events("foo"):
         pass
     assert mock_storage_security_client.get_plan_security_events.call_count == 4
コード例 #2
0
 def test_get_user_security_events_calls_security_client_with_expected_params(
     self,
     mocker,
     security_client_one_location,
     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_one_location,
                                      storage_client_factory,
                                      microservice_client_factory)
     for page, cursor in security_module.get_user_security_events("foo"):
         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,
     )