def create_http_flow(): http_request = factory(HttpRequest, 'proxy').make() http_request.save() http_response = factory(HttpResponse, 'http_response').make() http_response.save() http_flow = factory(HttpFlow, 'proxy').make(request_id=http_request.id, response_id=http_response.id, client_id=1) http_flow.save()
def test_values_for_table_no_response(self, database, cleanup_database): http_request = factory(HttpRequest, 'proxy').make() http_request.save() http_flow = factory(HttpFlow, 'proxy').make(request_id=http_request.id, client_id=1) http_flow.save() result = http_flow.values_for_table() assert result == [ http_flow.id, 1, 'http', 'GET', 'wonderbill.com', '/', None, False ]
def test_create_for_http_flow(self, database, cleanup_database): http_request = factory(HttpRequest, 'proxy').make() http_request.save() http_flow = factory(HttpFlow, 'proxy').make(request_id=http_request.id) http_flow.save() item = EditorItem.create_for_http_flow(http_flow) assert item.id is not None assert item.item_type == EditorItem.TYPE_HTTP_FLOW assert item.item_id == http_flow.id
def test_modify_request(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make() http_request.save() http_flow = factory(HttpFlow, 'editor').make(request_id=http_request.id, client_id=1) http_flow.modify_request('PATCH', '/modified', {"hello": "world"}, 'asdf') assert http_flow.original_request_id == http_request.id assert http_flow.request_id != http_request.id assert http_flow.request_id is not None
def test_duplicate(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make() http_request.save() http_flow = factory(HttpFlow, 'editor').make(request_id=http_request.id) http_flow.save() item = EditorItem.create_for_http_flow(http_flow) new_item = item.duplicate() assert new_item.name == item.name assert new_item.item_type == item.item_type assert new_item.item_id != http_flow.id
def test_duplicate_for_editor(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make() http_request.save() http_flow = factory(HttpFlow, 'editor').make(request_id=http_request.id, client_id=1) http_flow.save() new_flow = http_flow.duplicate_for_editor() assert new_flow.id != http_flow.id assert new_flow.id is not None assert new_flow.type == HttpFlow.TYPE_EDITOR assert new_flow.request_id != http_flow.request_id assert new_flow.request_id is not None
def test_modify_response(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make() http_request.save() http_response = factory(HttpResponse, 'http_response').make() http_response.save() http_flow = factory(HttpFlow, 'editor').make(request_id=http_request.id, response_id=http_response.id, client_id=1) http_flow.modify_response(203, {"hello": "world"}, 'Somethings-changed') assert http_flow.original_response_id == http_response.id assert http_flow.response_id != http_response.id assert http_flow.response_id is not None
def test_overwrite_calculated_headers(self, database, cleanup_database): http_request = factory(HttpRequest, 'proxy').make( headers= '{"Content-Length": 1234, "Host": "wonderbill.com", "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "User-Agent": "pntest/0.1"}' ) http_request.overwrite_calculated_headers() assert http_request.headers == '{"Content-Length": "<calculated when request is sent>", "Host": "<calculated when request is sent>", "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Connection": "keep-alive", "User-Agent": "pntest/0.1"}'
def test_get_url_https(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make(host='wonderbill.com', port=443, path='/index.html', scheme='https') http_request.save() assert http_request.get_url() == 'https://wonderbill.com/index.html'
def test_get_url_weird_port(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make(host='wonderbill.com', port=1234, path='/index.html', scheme='http') http_request.save() assert http_request.get_url( ) == 'http://wonderbill.com:1234/index.html'
def test_duplicate_for_example(self, database, cleanup_database): http_request = factory(HttpRequest, 'editor').make() http_request.save() new_request = http_request.duplicate() new_request.save() http_response = factory(HttpResponse, 'http_response').make() http_response.save() http_flow = factory(HttpFlow, 'editor').make(request_id=http_request.id, response_id=http_response.id, client_id=1) http_flow.save() new_flow = http_flow.duplicate_for_example(new_request, http_response) assert new_flow.type == HttpFlow.TYPE_EDITOR_EXAMPLE assert new_flow.request_id == new_request.id assert new_flow.response_id == http_response.id assert new_flow.http_flow_id == http_flow.id
def test_delete_everything(self, database, cleanup_database): item_dir = factory(EditorItem, 'dir').create() item_child1 = factory(EditorItem, 'request').create(parent_id=item_dir.id) factory(EditorItem, 'request').create(parent_id=item_dir.id) factory(EditorItem, 'request').create(parent_id=item_child1.id) item_dir.delete_everything() assert EditorItem.count() == 0
def test_save(self, database, cleanup_database): item = factory(EditorItem, 'request').make(item_id=None) item.save() flow = HttpFlow.where('id', '=', item.id).first() assert flow is not None