示例#1
0
 def test_execute_calls_post_with_expected_uri(self, mock_connection,
                                               py42_response):
     py42_response.text = '{u"searches": [{u"groups": []}]}'
     mock_connection.post.return_value = py42_response
     file_event_service = FileEventService(mock_connection)
     saved_search_service = SavedSearchService(mock_connection,
                                               file_event_service)
     saved_search_service.execute(u"test-id")
     assert (mock_connection.post.call_args[0][0] ==
             "/forensic-search/queryservice/api/v1/fileevent")
示例#2
0
 def test_execute_calls_post_with_expected_uri(self, mock_connection,
                                               mocker):
     response = create_mock_response(mocker, SAVED_SEARCH_GET_RESPONSE)
     mock_connection.post.return_value = response
     file_event_service = FileEventService(mock_connection)
     saved_search_service = SavedSearchService(mock_connection,
                                               file_event_service)
     saved_search_service.execute("test-id")
     assert (mock_connection.post.call_args[0][0] ==
             "/forensic-search/queryservice/api/v1/fileevent")
示例#3
0
 def test_execute_calls_post_with_expected_query(self, mock_connection,
                                                 py42_response):
     py42_response.text = SAVED_SEARCH_GET_RESPONSE
     mock_connection.get.return_value = py42_response
     file_event_service = FileEventService(mock_connection)
     saved_search_service = SavedSearchService(mock_connection,
                                               file_event_service)
     saved_search_service.execute(u"test-id")
     assert mock_connection.post.call_count == 1
     posted_data = json.loads(mock_connection.post.call_args[1]["data"])
     assert (posted_data["pgSize"] == 10000 and posted_data[u"pgNum"] == 1
             and posted_data[u"groups"] == [])
示例#4
0
 def test_execute_calls_post_with_expected_query(self, mock_connection,
                                                 mocker):
     response = create_mock_response(mocker, SAVED_SEARCH_GET_RESPONSE)
     mock_connection.get.return_value = response
     file_event_service = FileEventService(mock_connection)
     saved_search_service = SavedSearchService(mock_connection,
                                               file_event_service)
     saved_search_service.execute("test-id")
     assert mock_connection.post.call_count == 1
     posted_data = mock_connection.post.call_args[1]["json"]
     assert (posted_data["pgSize"] == 10000 and posted_data["pgNum"] == 1
             and posted_data["groups"] == [])
示例#5
0
    def test_execute_calls_post_with_expected_setting_page_param(
            self, mock_connection, py42_response):
        test_custom_page_num = 2
        settings.security_events_per_page = 5000

        py42_response.text = SAVED_SEARCH_GET_RESPONSE
        mock_connection.get.return_value = py42_response
        file_event_client = FileEventService(mock_connection)
        saved_search_client = SavedSearchService(mock_connection,
                                                 file_event_client)
        saved_search_client.execute(
            u"test-id",
            page_number=test_custom_page_num,
        )
        assert mock_connection.post.call_count == 1
        posted_data = json.loads(mock_connection.post.call_args[1]["data"])
        settings.security_events_per_page = 10000
        assert (posted_data[u"pgSize"] == 5000 and posted_data[u"pgNum"] == 2
                and posted_data[u"groups"] == [])
示例#6
0
    def test_execute_calls_post_with_expected_setting_page_param(
            self, mock_connection, mocker):
        test_custom_page_num = 2
        settings.security_events_per_page = 5000

        response = create_mock_response(mocker, SAVED_SEARCH_GET_RESPONSE)
        mock_connection.get.return_value = response
        file_event_service = FileEventService(mock_connection)
        saved_search_client = SavedSearchService(mock_connection,
                                                 file_event_service)
        saved_search_client.execute(
            "test-id",
            page_number=test_custom_page_num,
        )
        assert mock_connection.post.call_count == 1
        posted_data = mock_connection.post.call_args[1]["json"]
        settings.security_events_per_page = 10000
        assert (posted_data["pgSize"] == 5000 and posted_data["pgNum"] == 2
                and posted_data["groups"] == [])