示例#1
0
def test_get_no_update_value(mocker):
    """
    Given
    - response with last_modified and etag headers with the same values like in the integration context.

    When
    - Running get_no_update_value method.

    Then
    - Ensure that the response is False
    """
    mocker.patch.object(demisto, 'debug')

    class MockResponse:
        headers = {
            'Last-Modified':
            'Fri, 30 Jul 2021 00:24:13 GMT',  # guardrails-disable-line
            'ETag': 'd309ab6e51ed310cf869dab0dfd0d34b'
        }  # guardrails-disable-line
        status_code = 200

    no_update = get_no_update_value(
        MockResponse(), 'https://www.spamhaus.org/drop/asndrop.txt')
    assert not no_update
    assert demisto.debug.call_args[0][0] == 'New indicators fetched - the Last-Modified value has been updated,' \
                                            ' createIndicators will be executed with noUpdate=False.'
示例#2
0
def test_get_no_update_value(mocker):
    """
    Given
    - response with last_modified and etag headers with the same values like in the integration context.

    When
    - Running get_no_update_value method.

    Then
    - Ensure that the response is False
    """
    mocker.patch.object(
        demisto,
        'getIntegrationContext',
        return_value={
            'last_modified':
            'Fri, 30 Jul 2021 00:24:13 GMT',  # guardrails-disable-line
            'etag': 'd309ab6e51ed310cf869dab0dfd0d34b'
        })  # guardrails-disable-line

    class MockResponse:
        headers = {
            'last_modified':
            'Fri, 30 Jul 2021 00:24:13 GMT',  # guardrails-disable-line
            'etag': 'd309ab6e51ed310cf869dab0dfd0d34b'
        }  # guardrails-disable-line

    no_update = get_no_update_value(MockResponse())
    assert not no_update
示例#3
0
def test_get_no_update_value_empty_context():
    """
    Given
    - response with last_modified and etag headers.

    When
    - Running get_no_update_value method with empty integration context.

    Then
    - Ensure that the response is True.
    """
    class MockResponse:
        headers = {
            'last_modified':
            'Fri, 30 Jul 2021 00:24:13 GMT',  # guardrails-disable-line
            'etag': 'd309ab6e51ed310cf869dab0dfd0d34b'
        }  # guardrails-disable-line

    no_update = get_no_update_value(MockResponse())
    assert no_update
示例#4
0
def test_get_no_update_value_without_headers(mocker):
    """
    Given
    - response without last_modified and etag headers.

    When
    - Running get_no_update_value.

    Then
    - Ensure that the response is False.
    """
    mocker.patch.object(demisto, 'debug')
    mocker.patch('CommonServerPython.get_demisto_version', return_value={"version": "6.5.0"})

    class MockResponse:
        headers = {}
        status_code = 200
    no_update = get_no_update_value(MockResponse(), 'https://www.spamhaus.org/drop/asndrop.txt')
    assert not no_update
    assert demisto.debug.call_args[0][0] == 'Last-Modified and Etag headers are not exists,' \
                                            'createIndicators will be executed with noUpdate=False.'