def test_fetch_indicators_command(self, mocker, iterator_value, expected_value, expected_type, limit): mocker.patch.object(Client, "build_iterator", return_value=iterator_value) results = fetch_indicators_command(client, limit=limit) if expected_value and expected_type: for i, res in enumerate(results): assert expected_value[i] in res["value"] assert expected_type[i] in res["type"] else: assert not results
def test_fetch_indicators_command(self, mocker, iterator_value, expected_value, expected_type, limit): mocker.patch.object(Client, "build_iterator", return_value=iterator_value) results = fetch_indicators_command(client, limit=limit) if expected_value and expected_type: for i, res in enumerate(results): assert expected_value[i] in res["value"] assert expected_type[i] in res["type"] assert res['fields']['tags'] == client.tags assert res['fields'][ 'trafficlightprotocol'] == client.tlp_color else: assert not results
def test_indicator_fields_for_fetch_indicators_command(self, mocker): """ Test indicator fields for fetch_indicators_command. Given - A valid response When - run fetch_indicators_command Then - Verify indicator fields """ with open("TestData/fetch_indicators.json") as file: indicators = json.load(file) mocker.patch.object(Client, "build_iterator", return_value=[threats[1]]) results = fetch_indicators_command(client) assert results == indicators['indicators']
def test_fetch_indicators_command( self, mocker, iterator_value, expected_value, expected_type, limit ): """ Test fetch_indicators_command for success cases. Given - A valid response When - run fetch_indicators_command Then - Verify value, type, tags and tlp for indicator """ mocker.patch.object(Client, "build_iterator", return_value=iterator_value) results = fetch_indicators_command(client, limit=limit) if expected_value and expected_type: for i, res in enumerate(results): assert expected_value[i] in res["value"] assert expected_type[i] in res["type"] assert res['fields']['tags'] == client.tags assert res['fields']['trafficlightprotocol'] == client.tlp_color else: assert not results