Ejemplo n.º 1
0
 def test_unicode_query_search_calls_post_with_query(
         self, session, successful_response):
     client = FileEventClient(session)
     session.post.return_value = successful_response
     client.search(RAW_UNICODE_QUERY)
     session.post.assert_called_once_with(FILE_EVENT_URI,
                                          data=RAW_UNICODE_QUERY)
Ejemplo n.º 2
0
 def test_get_file_location_detail_by_sha256_calls_get_with_hash(
     self, session, successful_response
 ):
     client = FileEventClient(session)
     session.get.return_value = successful_response
     client.get_file_location_detail_by_sha256("abc")
     session.get.assert_called_once_with(
         u"/forensic-search/queryservice/api/v1/filelocations",
         params={"sha256": "abc"},
     )
Ejemplo n.º 3
0
 def test_get_by_id_calls_get_with_expected_uri(self, mock_session,
                                                py42_response):
     mock_session.get.return_value = py42_response
     file_event_client = FileEventClient(mock_session)
     saved_search_client = SavedSearchClient(mock_session,
                                             file_event_client)
     saved_search_client.get_by_id(u"TEst-id")
     assert (mock_session.get.call_args[0][0] ==
             "/forensic-search/queryservice/api/v1/saved/TEst-id")
Ejemplo n.º 4
0
 def test_get_query_calls_get_with_expected_uri(self, mock_session,
                                                py42_response):
     py42_response.text = '{u"searches": [{u"groups": []}]}'
     mock_session.post.return_value = py42_response
     file_event_client = FileEventClient(mock_session)
     saved_search_client = SavedSearchClient(mock_session,
                                             file_event_client)
     saved_search_client.get_query(u"test-id")
     assert (mock_session.get.call_args[0][0] ==
             "/forensic-search/queryservice/api/v1/saved/test-id")
Ejemplo n.º 5
0
 def test_execute_calls_post_with_expected_query(self, mock_session,
                                                 py42_response):
     py42_response.text = SAVED_SEARCH_GET_RESPONSE
     mock_session.get.return_value = py42_response
     file_event_client = FileEventClient(mock_session)
     saved_search_client = SavedSearchClient(mock_session,
                                             file_event_client)
     saved_search_client.execute(u"test-id")
     assert mock_session.post.call_count == 1
     posted_data = json.loads(mock_session.post.call_args[1]["data"])
     assert (posted_data["pgSize"] == 10000 and posted_data[u"pgNum"] == 1
             and posted_data[u"groups"] == [])
Ejemplo n.º 6
0
 def get_file_event_client(self):
     if not self._file_event_client:
         self._file_event_client = FileEventClient(
             self._get_file_event_session())
     return self._file_event_client
Ejemplo n.º 7
0
 def get_file_event_client(self):
     if not self._file_event_client:
         session = self._get_jwt_session(u"FORENSIC_SEARCH-API_URL")
         self._file_event_client = FileEventClient(session)
     return self._file_event_client