def test_mangle_request_edit_len(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): # Intercepting is off, request in scope tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = "GET / HTTP/1.1\r\n" "Test-Head: FOOBIE\n" "Content-Length: 4\n\r\n" "BBBBAAAA" fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert new_req.full_request == ("GET / HTTP/1.1\r\n" "Test-Head: FOOBIE\r\n" "Content-Length: 8\r\n\r\n" "BBBBAAAA")
def test_mangle_request_drop(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): # Intercepting is off, request in scope tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = "" fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert new_req is None
def test_mangle_request_drop(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): # Intercepting is off, request in scope tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = '' fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert new_req is None
def test_mangle_request_edit(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = "GET / HTTP/1.1\r\n" "Content-Length: 4\r\n\r\n" "BBBB" fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert not mock_deep_save.called assert tfile_obj.called assert tfile_instance.write.called assert tfile_instance.write.call_args == ((r.full_request,),) assert new_open.called assert fake_file.read.called assert new_req.full_request == new_contents
def test_mangle_request_edit(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = ('GET / HTTP/1.1\r\n' 'Content-Length: 4\r\n\r\n' 'BBBB') fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert not mock_deep_save.called assert tfile_obj.called assert tfile_instance.write.called assert tfile_instance.write.call_args == ((r.full_request, ), ) assert new_open.called assert fake_file.read.called assert new_req.full_request == new_contents
def test_mangle_request_edit_len(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): # Intercepting is off, request in scope tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = ('GET / HTTP/1.1\r\n' 'Test-Head: FOOBIE\n' 'Content-Length: 4\n\r\n' 'BBBBAAAA') fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert new_req.full_request == ('GET / HTTP/1.1\r\n' 'Test-Head: FOOBIE\r\n' 'Content-Length: 8\r\n\r\n' 'BBBBAAAA')
def test_mangle_request_edit_newlines(req, mock_deep_save, mock_tempfile, ignore_edit, ignore_delete): # Intercepting is off, request in scope tfile_obj, tfile_instance, new_open, fake_file = mock_tempfile r = req new_contents = ('GET / HTTP/1.1\r\n' 'Test-Head: FOOBIE\n' 'Content-Length: 4\n\r\n' 'BBBB') fake_file.read.return_value = new_contents new_req = yield async_mangle_request(r) assert new_req.full_request == ('GET / HTTP/1.1\r\n' 'Test-Head: FOOBIE\r\n' 'Content-Length: 4\r\n\r\n' 'BBBB') assert new_req.headers['Test-Head'] == 'FOOBIE'