From fc048f804e6928bae539dec84a6b388b737d9850 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 30 Jan 2024 22:59:14 +0100 Subject: [PATCH] tests/sso: fix redirect test, gotta explicitly tell python to not follow 302s --- src/tests/test_sso_and_portalapi.py | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/tests/test_sso_and_portalapi.py b/src/tests/test_sso_and_portalapi.py index a3d776d9d..3bc79295e 100644 --- a/src/tests/test_sso_and_portalapi.py +++ b/src/tests/test_sso_and_portalapi.py @@ -81,26 +81,16 @@ def request(webpath, logged_as=None, session=None): # Anonymous access if session: - r = session.get(webpath, verify=False) + r = session.get(webpath, verify=False, allow_redirects=False) elif not logged_as: - r = requests.get(webpath, verify=False) + r = requests.get(webpath, verify=False, allow_redirects=False) # Login as a user using dummy password else: with requests.Session() as session: r = login(session, logged_as) # We should have some cookies related to authentication now assert session.cookies - r = session.get(webpath, verify=False) - - # If we can't access it, we got redirected to the SSO - # with `r=` for anonymous access because they're encouraged to log-in, - # and `msg=access_denied` if we are logged but not allowed for this url - # with `r= - #sso_url = f"https://{maindomain}/yunohost/sso/" - #if not logged_as: - # sso_url += "?r=" - #else: - # sso_url += "?msg=access_denied" + r = session.get(webpath, verify=False, allow_redirects=False) return r