Example #1
0
def test_forbidden_error1():
    s = HttpServer()
    with pytest.raises(ForbiddenError):
        body, content_type = s._retrieve_resource(b"../../etc/password/")
Example #2
0
def test_retrieve_resources_2():
    s = HttpServer()
    with pytest.raises(ResourceNotFound):
        s._retrieve_resource(b"afilethatdoesntexist.123")
Example #3
0
def test_retrieve_resources_3():
    s = HttpServer()
    body, content_type = s._retrieve_resource(b"")
    assert content_type == b"text/html"
Example #4
0
def test_retrieve_resource_1():
    test_string = u"Here is text with some unicode in it: ÄÄÄÄÄÄÄÄÄÄ"
    s = HttpServer()
    body, content_type = s._retrieve_resource(b"test.html")
    assert content_type == b"text/html"
    assert body.decode('utf-8') == test_string
Example #5
0
def test_gen_response_1():
    s = HttpServer()
    assert s._gen_response(301) == 'HTTP/1.1 301 Moved Permanently\r\n'
Example #6
0
def test_parse_4():
    s = HttpServer()
    with pytest.raises(BadRequestError):
        s._process_request("GET/uri/HTTP/1.0")
Example #7
0
def test_parse_3():
    s = HttpServer()
    with pytest.raises(NotHTTP1_1Error):
        s._process_request("GET /uri/ HTTP/1.0")
Example #8
0
def test_parse_2():
    s = HttpServer()
    with pytest.raises(NotGETRequestError):
        s._process_request("POST /uri/ HTTP/1.1")