Ejemplo n.º 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
Ejemplo n.º 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)
Ejemplo n.º 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
Ejemplo n.º 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