def METHOD_NAME(flask_oso, oso, flask_app, app_ctx):
    """Test that route authorization middleware works."""
    flask_oso.perform_route_authorization(app=flask_app)
    flask_app.testing = True
    @flask_app.route("/test_route", methods=("GET",))
    def test():
        return "Test"
    with flask_app.test_client() as c:
        with pytest.raises(OsoError) as e:
            c.get("/test_route")
        assert "Query for undefined rule `allow`" in str(e)
    # Add rule to policy.
    oso.load_str('allow("user", "GET", _: Request{path: "/test_route"});')
    flask_oso.set_get_actor(lambda: "other_user")
    with flask_app.test_client() as c:
        assert c.get("/test_route").status_code == 403
    flask_oso.set_get_actor(lambda: "user")
    with flask_app.test_client() as c:
        assert c.get("/test_route").status_code == 200
    # Confirm that route authorization doesn't mess with errors.
    with flask_app.test_client() as c:
        assert c.get("/not_a_route").status_code == 404
    with flask_app.test_client() as c:
        assert c.post("/test_route").status_code == 405