Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
domain_command,
url_command
)
from CommonServerPython import *
from ReversingLabs.SDK.helper import WrongInputError


Expand Down Expand Up @@ -408,9 +409,67 @@ def test_customer_data_output():
assert result.to_context().get("Contents").get("customer_usage_data").get("rl").get("month") == "2024-06"


def test_ip_command():
with pytest.raises(WrongInputError):
ip_command()
DEFAULT_PARAMS = {
"base": "data.reversinglabs.com",
"credentials": {
"password": "somepassword",
"identifier": "username"
},
"reliability": "C - Fairly reliable",
"verify_certs": "true"
}



@pytest.fixture
def mock_demisto(mocker):
mocker.patch.object(demisto, 'getArg', return_value='8.8.8.8')
mocker.patch.object(demisto, 'args', return_value={'ip': '8.8.8.8'})
results = []
mocker.patch.object(demisto, 'results', side_effect=lambda r: results.append(r))
return results


@pytest.fixture
def mock_ip_response():
return {
"rl": {
"classification": "malicious",
"downloaded_files_statistics": {
"known": 1,
"malicious": 2,
"suspicious": 0,
"unknown": 0,
"total": 3
},
"third_party_reputations": {
"statistics": {
"clean": 0,
"malicious": 2,
"undetected": 1,
"total": 3
},
"sources": [
{"source": "VendorA", "detection": "malicious"},
{"source": "VendorB", "detection": "clean"}
]
}
}
}


def test_ip_command_success(mocker, mock_ip_response, mock_demisto):
mock_ip_ti = mocker.patch('ReversingLabsTitaniumCloudv2.IPThreatIntelligence')
instance = mock_ip_ti.return_value
mock_response = mocker.Mock()
mock_response.json.return_value = mock_ip_response
instance.get_ip_report.return_value = mock_response

ip_command()

assert mock_demisto
output = mock_demisto[0]
assert isinstance(output, dict)


def test_domain_command():
Expand Down
Loading