示例#1
0
def test_signal_oauth_before_login(request):
    app, bp = make_app()

    def callback(*args, **kwargs):
        del flask.session["user_id"]

    oauth_before_login.connect(callback)
    request.addfinalizer(lambda: oauth_before_login.disconnect(callback))
    with app.test_request_context():
        with app.test_client() as client:
            flask.session["user_id"] = 1
            assert flask.session["user_id"] == 1
            client.get("/login/test-service")
            assert "user_id" not in flask.session
示例#2
0
def test_signal_oauth_before_login(request):
    app, bp = make_app()

    def callback(*args, **kwargs):
        del flask.session["user_id"]

    oauth_before_login.connect(callback)
    request.addfinalizer(lambda: oauth_before_login.disconnect(callback))
    with app.test_request_context():
        with app.test_client() as client:
            flask.session["user_id"] = 1
            assert flask.session["user_id"] == 1
            client.get("/login/test-service")
            assert "user_id" not in flask.session
示例#3
0
def test_signal_oauth_before_login(request):
    app, bp = make_app()
    bp.session.fetch_request_token = mock.Mock(return_value="test-token")

    def callback(*args, **kwargs):
        del flask.session["user_id"]
        return False

    oauth_before_login.connect(callback)
    request.addfinalizer(lambda: oauth_before_login.disconnect(callback))
    with app.test_request_context():
        with app.test_client() as client:
            flask.session["user_id"] = 1
            assert flask.session["user_id"] == 1
            client.get("/login/test-service")
            assert "user_id" not in flask.session