def login_message(app): lm = LoginManager() lm.login_view = "login" lm.login_message = u"Log in or the owl will eat you." lm.setup_app(app) lm.unauthorized() assert u"Log in or the owl will eat you." in get_flashed_messages()
def unauthorized_redirect(app): lm = LoginManager() lm.login_view = "login" lm.setup_app(app) res = lm.unauthorized() assert res.headers["Location"] == "/login?next=%2F" assert LOGIN_MESSAGE in get_flashed_messages()
def unauthorized_callback(app): lm = LoginManager() lm.login_view = "login" @lm.unauthorized_handler def unauth(): return "UNAUTHORIZED!" lm.setup_app(app) assert lm.unauthorized() == "UNAUTHORIZED!" assert len(get_flashed_messages()) == 0
def unauthorized_401(app): lm = LoginManager() lm.setup_app(app) with raises(Unauthorized): with assert_fired(user_unauthorized): res = lm.unauthorized()