Example #1
0
def test_unsign_value(app: Flask):
    with app.app_context():
        value = {"key": "hello"}
        signed_value = sign_value(app, value)
        decoded_value = unsign_value(app, signed_value)
        assert "key" in decoded_value
        assert decoded_value["key"] == "hello"
Example #2
0
def test_unsign_value_fails_when_expires(app: Flask):
    with app.app_context():
        value = {"key": "hello"}
        signed_value = sign_value(app, value, expire_in=0)
        time.sleep(1)
        decoded_value = unsign_value(app, signed_value)
        assert decoded_value is None
Example #3
0
def test_signup_with_google(app: Flask):
    with patch("authlib.flask.client.oauth.session", new={}) as sess:
        with app.app_context():
            with app.test_request_context('/auth/signup/with/google'):
                resp = signup_with('google')
                assert resp.status_code == 302
                p = urlparse(resp.location)
                q = parse_qs(p.query)
                assert q['response_type'] == ['code']
                assert q['client_id'] == ['None']
                assert q['scope'] == ['openid email profile']

                p = urlparse(q['redirect_uri'][0])
                assert p.path == '/auth/allowed/via/google'

                assert '_google_state_' in sess
                state = unsign_value(app, sess['_google_state_'])
                assert 'via' in state
                assert state['via'] == 'signup'