cheroot.test.test_core module#
Tests for managing HTTP issues (malformed requests, etc).
- class cheroot.test.test_core.CloseController#
Bases:
object
Controller for testing the close callback.
- close()#
Close, writing hello.
- class cheroot.test.test_core.CloseResponse(close)#
Bases:
object
Dummy empty response to trigger the no body status.
- output()#
Return self to hook the close method.
- class cheroot.test.test_core.HelloController#
Bases:
cheroot.test.helper.Controller
Controller for serving WSGI apps.
- _munge()#
Encode PATH_INFO correctly depending on Python version.
WSGI 1.0 is a mess around unicode. Create endpoints that match the PATH_INFO that it produces.
- asterisk(resp)#
Render request method value.
- body_required(resp)#
Render Hello world or set 411.
- handlers = {'/*': <function HelloController.asterisk>, '/body_required': <function HelloController.body_required>, '/hello': <function HelloController.hello>, '/no_body': <function HelloController.hello>, '/query_string': <function HelloController.query_string>, '/\xa0Ðblah key 0 900 4 data': <function HelloController.hello>, '/ЮÑ\x85Ñ\x85Ñ\x83Ñ\x83Ñ\x83': <function HelloController.hello>, '/пÑ\x80ивÑ\x96Ñ\x82': <function HelloController.hello>}#
- hello(resp)#
Render Hello world.
- query_string(resp)#
Render QUERY_STRING value.
- cheroot.test.test_core._get_http_response(connection, method='GET')#
- cheroot.test.test_core.test_client(testing_server)#
Get and return a test client out of the given server.
- cheroot.test.test_core.test_client_with_defaults(testing_server_with_defaults)#
Get and return a test client out of the given server.
- cheroot.test.test_core.test_content_length_required(test_client)#
Test POST query with body failing because of missing Content-Length.
- cheroot.test.test_core.test_garbage_in(test_client)#
Test that server sends an error for garbage received over TCP.
- cheroot.test.test_core.test_http_connect_request(test_client)#
Check that CONNECT query results in Method Not Allowed status.
- cheroot.test.test_core.test_large_request(test_client_with_defaults)#
Test GET query with maliciously large Content-Length.
- cheroot.test.test_core.test_malformed_header(test_client)#
Check that broken HTTP header results in Bad Request.
- cheroot.test.test_core.test_malformed_http_method(test_client)#
Test non-uppercase HTTP method.
- cheroot.test.test_core.test_malformed_request_line(test_client, request_line, status_code, expected_body)#
Test missing or invalid HTTP version in Request-Line.
- cheroot.test.test_core.test_no_content_length(test_client)#
Test POST query with an empty body being successful.
- cheroot.test.test_core.test_normal_request(test_client)#
Check that normal GET query succeeds.
- cheroot.test.test_core.test_parse_acceptable_uri(test_client, uri)#
Check that server responds with OK to valid GET queries.
- cheroot.test.test_core.test_parse_no_leading_slash_invalid(test_client, uri)#
Check that server responds with Bad Request to invalid GET queries.
Invalid request line test case: it should have leading slash (be absolute).
- cheroot.test.test_core.test_parse_uri_absolute_uri(test_client)#
Check that server responds with Bad Request to Absolute URI.
Only proxy servers should allow this.
- cheroot.test.test_core.test_parse_uri_asterisk_uri(test_client)#
Check that server responds with OK to OPTIONS with “*” Absolute URI.
- cheroot.test.test_core.test_parse_uri_fragment_uri(test_client)#
Check that server responds with Bad Request to URI with fragment.
- cheroot.test.test_core.test_parse_uri_invalid_uri(test_client)#
Check that server responds with Bad Request to invalid GET queries.
Invalid request line test case: it should only contain US-ASCII.
- cheroot.test.test_core.test_parse_uri_unsafe_uri(test_client)#
Test that malicious URI does not allow HTTP injection.
This effectively checks that sending GET request with URL
/%A0%D0blah%20key%200%20900%204%20data
is not converted into
GET / blah key 0 900 4 data HTTP/1.1
which would be a security issue otherwise.
- cheroot.test.test_core.test_query_string_request(test_client)#
Check that GET param is parsed well.
- cheroot.test.test_core.test_request_line_split_issue_1220(test_client)#
Check that HTTP request line of exactly 256 chars length is OK.
- cheroot.test.test_core.test_send_header_before_closing(testing_server_close)#
Test we are actually sending the headers before calling ‘close’.
- cheroot.test.test_core.testing_server(wsgi_server_client)#
Attach a WSGI app to the given server and preconfigure it.
- cheroot.test.test_core.testing_server_close(wsgi_server_client)#
Attach a WSGI app to the given server and preconfigure it.
- cheroot.test.test_core.testing_server_with_defaults(wsgi_server_client)#
Attach a WSGI app to the given server and preconfigure it.