Example #1
0
def request_replay():
    """
    Send a duplicate request previously sent.
    Expected: The second request should fail.
    """
    global params
    client = SecurestClient(**params)

    data1 = {'url': 'http://localhost:8000/test/'}
    data = {'name': 'ashish', 'last': 'dubey'}

    (status, headers, res) = client.make_request(
                                'http://localhost:8000/session_token/',
                                headers={},
                                data=json.dumps(data1))

    (url, req_headers, content) = client.create_request(
                                'http://localhost:8000/test/', headers={},
                                data=res+json.dumps(data))

    (status, headers, res) = client.send((url, req_headers, content))

    res = client.send((url, req_headers, content))
    return res
Example #2
0
def tampered_payload():
    """
    Change the payload without changing the signature.
    Expected: Should give a 'Bad signature.' response.
    """
    global params
    client = SecurestClient(**params)

    data = {'name': 'ashish', 'last': 'dubey'}
    (url, headers, content) = client.create_request(
                                'http://localhost:8000/test/', headers={},
                                data=json.dumps(data))

    (status, headers, res) = client.send((url, headers, 'tampered'))

    logging.info('received finally: %s' % res)
    return (status, headers, res)