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
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)
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
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