Skip to content

Commit

Permalink
Add search test
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloperezj committed May 9, 2024
1 parent 4087141 commit d11b0cc
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1128,3 +1128,39 @@ def test_file_sigma_analysis_command(mocker, requests_mock):

assert results.execution_metrics is None
assert results.outputs == expected_results


def test_search_command(mocker, requests_mock):
"""
Given:
- A valid query
When:
- Running the !gti-search command
Then:
- Validate the command results are valid
"""
from GoogleThreatIntelligence import search_command, Client
import CommonServerPython

mocker.patch.object(demisto, 'params', return_value=DEFAULT_PARAMS)
mocker.patch.object(CommonServerPython, 'is_demisto_version_ge', return_value=True)
params = demisto.params()
client = Client(params=params)

mock_response = {
'data': [{
'id': 'random_id',
'attributes': {},
}]
}

mocker.patch.object(demisto, 'args', return_value={'query': 'random', 'limit': 2})
requests_mock.get('https://www.virustotal.com/api/v3/search?query=random&limit=2',
json=mock_response)

results = search_command(client=client, args=demisto.args())

assert results.execution_metrics is None
assert results.outputs == mock_response['data']

0 comments on commit d11b0cc

Please sign in to comment.