示例#1
0
def test_hello_content_xss(app):
    with app.test_request_context(json={'name': '<script>alert(1)</script>'}):
        res = main.hello_content(flask.request)
        assert '<script>' not in res
示例#2
0
def test_hello_content_empty_json(app):
    with app.test_request_context(json=''):
        with pytest.raises(
                ValueError,
                message="JSON is invalid, or missing a 'name' property"):
            main.hello_content(flask.request)
示例#3
0
def test_hello_content_urlencoded(app):
    with app.test_request_context(
            data={'name': 'test'},
            content_type='application/x-www-form-urlencoded'):
        res = main.hello_content(flask.request)
        assert 'Hello test!' in res
示例#4
0
def test_hello_content_json(app):
    with app.test_request_context(json={'name': 'test'}):
        res = main.hello_content(flask.request)
        assert 'Hello test!' in res