def test_fetch_indicators_command(mocker, auto_focus_client): mocker.patch.object(auto_focus_client, 'daily_http_request', return_value=INDICATORS) indicators = fetch_indicators_command(auto_focus_client, 9, 0) for i in range(0, 9): assert indicators[i]['type'] == TYPES[i]
def test_feed_tags_param(mocker): """Unit test Given - fetch indicators command - command args - command raw response When - mock the feed tags param. - mock the Client's daily_http_request. Then - run the fetch incidents command using the Client Validate The value of the tags field. """ client = Client(api_key="a", insecure=False) mocker.patch.object(client, 'daily_http_request', return_value=INDICATORS) indicators = fetch_indicators_command(client, ['test_tag']) assert indicators[0].get('fields').get('tags') == ['test_tag']
def test_feed_tags_param(mocker, auto_focus_client, tlp_color): """Unit test Given - fetch indicators command - command args - command raw response When - mock the feed tags param. - mock the Client's daily_http_request. Then - run the fetch incidents command using the Client Validate The value of the tags field. """ mocker.patch.object(auto_focus_client, 'daily_http_request', return_value=INDICATORS) indicators = fetch_indicators_command(auto_focus_client, ['test_tag'], tlp_color) assert indicators[0].get('fields').get('tags') == ['test_tag'] if tlp_color: assert indicators[0].get('fields').get( 'trafficlightprotocol') == tlp_color else: assert not indicators[0].get('fields').get('trafficlightprotocol')
def test_fetch_indicators_filtered_correctly(mocker, auto_focus_client, offset, limit): """ Given - a limit and an offset When - fetching indicators Then - The indicator response is filtered correctly. """ mocker.patch.object(auto_focus_client, 'daily_http_request', return_value=INDICATORS) indicators = fetch_indicators_command(auto_focus_client, feed_tags=[], tlp_color=None, limit=limit, offset=offset) assert len(indicators) == limit indicator_types = [indicator['type'] for indicator in indicators] assert indicator_types == TYPES[offset:offset + limit]
def test_fetch_indicators_command(mocker): client = Client(api_key="a", insecure=False) mocker.patch.object(client, 'daily_http_request', return_value=INDICATORS) indicators = fetch_indicators_command(client, 9, 0) for i in range(0, 9): assert indicators[i]['type'] == TYPES[i]