Beispiel #1
0
def test_get_blacklist_query_and_filter(requests_mock):
    """
    Given:
        - The `filter` arg set to `ip`
        - The `query` arg set to `8.8.*.8`
        - API response with a URL and IP

    When:
        - Running the get-blacklist command

    Then:
        - Ensure only the IP is returned
    """
    import Zscaler
    api_res = {
        'blacklistUrls': [
            'demisto.com',
            '8.8.8.8',
        ],
    }
    requests_mock.get(
        'http://cloud/api/v1/security/advanced',
        json=api_res,
    )
    args = {
        'filter': 'ip',
        'query': '8.8.*.8',
    }
    cmd_res = Zscaler.get_blacklist_command(args)
    assert cmd_res['Contents'] == [api_res['blacklistUrls'][1]]
Beispiel #2
0
def test_get_blacklist_query(requests_mock):
    """
    Given:
        - The `query` arg set to `demisto`
        - API response with a URL and IP

    When:
        - Running the get-blacklist command

    Then:
        - Ensure only the URL (which contains `demisto`) is returned
    """
    import Zscaler
    api_res = {
        'blacklistUrls': [
            'demisto.com',
            '8.8.8.8',
        ],
    }
    requests_mock.get(
        'http://cloud/api/v1/security/advanced',
        json=api_res,
    )
    args = {
        'query': 'demisto',
    }
    cmd_res = Zscaler.get_blacklist_command(args)
    assert cmd_res['Contents'] == [api_res['blacklistUrls'][0]]