From 08f3c10add440b4b71dd625c94775820e3076eb5 Mon Sep 17 00:00:00 2001 From: Claude Sonnet 4.6 Date: Wed, 2 Sep 2026 17:20:23 +0000 Subject: test(gn2): add unauthenticated redirect tests for diffs endpoints Extends Part 1 of the gn2 auth-flow suite with four more @login_required checks covering the remaining metadata-edit endpoints: test_unauthenticated_list_diffs_redirects GET /datasets/diffs → 301/302 without session test_unauthenticated_show_diff_redirects GET /datasets/diffs/ → 301/302 without session test_unauthenticated_approve_diff_redirects POST /datasets//diffs//approve → 301/302 test_unauthenticated_reject_diff_redirects POST /datasets//diffs//reject → 301/302 Co-Authored-By: Frederick Muriuki Muriithi --- tests/test_gn2_auth_flow.py | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/test_gn2_auth_flow.py b/tests/test_gn2_auth_flow.py index f6beddb..6f4caeb 100644 --- a/tests/test_gn2_auth_flow.py +++ b/tests/test_gn2_auth_flow.py @@ -59,3 +59,57 @@ def test_unauthenticated_update_phenotype_redirects(gn2_url, http): f"Expected redirect for unauthenticated phenotype-update, " f"got {resp.status_code}: {resp.text[:200]}" ) + + +def test_unauthenticated_list_diffs_redirects(gn2_url, http): + """GET /datasets/diffs redirects to / without a session.""" + resp = http.get( + f"{gn2_url}/datasets/diffs", + timeout=30, + allow_redirects=False, + ) + assert resp.status_code in (301, 302), ( + f"Expected redirect for unauthenticated diffs listing, " + f"got {resp.status_code}: {resp.text[:200]}" + ) + + +def test_unauthenticated_show_diff_redirects(gn2_url, http): + """GET /datasets/diffs/ redirects to / without a session.""" + resp = http.get( + f"{gn2_url}/datasets/diffs/{_DIFF_NAME}", + timeout=30, + allow_redirects=False, + ) + assert resp.status_code in (301, 302), ( + f"Expected redirect for unauthenticated diff display, " + f"got {resp.status_code}: {resp.text[:200]}" + ) + + +def test_unauthenticated_approve_diff_redirects(gn2_url, http): + """POST /datasets//diffs//approve redirects to / without a session.""" + resp = http.post( + f"{gn2_url}/datasets/{_RESOURCE_ID}/diffs/{_DIFF_NAME}/approve", + data={}, + timeout=30, + allow_redirects=False, + ) + assert resp.status_code in (301, 302), ( + f"Expected redirect for unauthenticated diff approval, " + f"got {resp.status_code}: {resp.text[:200]}" + ) + + +def test_unauthenticated_reject_diff_redirects(gn2_url, http): + """POST /datasets//diffs//reject redirects to / without a session.""" + resp = http.post( + f"{gn2_url}/datasets/{_RESOURCE_ID}/diffs/{_DIFF_NAME}/reject", + data={}, + timeout=30, + allow_redirects=False, + ) + assert resp.status_code in (301, 302), ( + f"Expected redirect for unauthenticated diff rejection, " + f"got {resp.status_code}: {resp.text[:200]}" + ) -- cgit 1.4.1