예제 #1
0
def test_header_missing():
    """ Test a simple http response """

    block_raw = """
name: test
description: test
module: header
parameter:
    url: http://test.com/missing
    method: GET
    headers_required:
        X-XSS-Protection: 1
"""

    responses.add(
        responses.GET,
        "http://test.com/missing",
        body="success",
        status=200,
        content_type="text/html",
    )

    blocks = explo.core.load_blocks(block_raw)
    ret, scope = http.execute(blocks[0], {})

    assert not ret
예제 #2
0
def test_header_available():
    """ Test a simple http response """

    block_raw = """
name: test
description: test
module: http_header
parameter:
    url: http://test.com/valid
    method: GET
    headers_required:
        X-XSS-Protection: 1
"""

    responses.add(responses.GET, 'http://test.com/valid',
                  body='success', status=200,
                  adding_headers={'X-XSS-Protection':'1'},
                  content_type='text/html')

    blocks = explo.core.load_blocks(block_raw)
    ret, scope = http.execute(blocks[0], {})

    print(ret, scope)

    assert ret == False
    assert scope['test']['response']['content'] == 'success'
예제 #3
0
def test_header_available():
    """ Test a simple http response """

    block_raw = """
name: test
description: test
module: header
parameter:
    url: http://test.com/valid
    method: GET
    headers_required:
        X-XSS-Protection: 1
"""

    responses.add(
        responses.GET,
        "http://test.com/valid",
        body="success",
        status=200,
        adding_headers={"X-XSS-Protection": "1"},
        content_type="text/html",
    )

    blocks = explo.core.load_blocks(block_raw)
    ret, scope = http.execute(blocks[0], {})

    print(ret, scope)

    assert ret == False
    assert scope["test"]["response"]["content"] == "success"
예제 #4
0
def test_multiple_headers():
    """ Test if one of the given headers is missing """

    block_raw = """
name: test
description: test
module: header
parameter:
    url: http://test.com/missing
    method: GET
    headers_required:
        iDontExist: NoNo
        Content-Type: .
"""

    responses.add(
        responses.GET,
        "http://test.com/missing",
        body="success",
        status=200,
        content_type="text/html",
    )

    blocks = explo.core.load_blocks(block_raw)
    ret, scope = http.execute(blocks[0], {})

    assert not ret