app/tests/auth/test_proton.py

24 lines
650 B
Python
Raw Normal View History

2022-03-14 16:33:31 +08:00
from flask import url_for
from urllib.parse import parse_qs
from urllib3.util import parse_url
from app.config import URL, PROTON_CLIENT_ID
def test_login_with_proton(flask_client):
r = flask_client.get(
url_for("auth.proton_login"),
follow_redirects=False,
)
location = r.headers.get("Location")
assert location is not None
parsed = parse_url(location)
query = parse_qs(parsed.query)
expected_redirect_url = f"{URL}/auth/proton/callback"
assert "code" == query["response_type"][0]
assert PROTON_CLIENT_ID == query["client_id"][0]
assert expected_redirect_url == query["redirect_uri"][0]