about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorClaude Sonnet 4.62026-09-02 17:20:23 +0000
committerFrederick Muriuki Muriithi2026-09-02 12:25:33 -0500
commit08f3c10add440b4b71dd625c94775820e3076eb5 (patch)
treebb9e191e42d97b4dd6deebe1002f35b21abfb7b2 /tests
parent88b88bb52602f85de335de0bc45fabfcc7072b2d (diff)
downloadgn-integration-tests-08f3c10add440b4b71dd625c94775820e3076eb5.tar.gz
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/<name> → 301/302 without session

  test_unauthenticated_approve_diff_redirects
    POST /datasets/<resource_id>/diffs/<name>/approve → 301/302

  test_unauthenticated_reject_diff_redirects
    POST /datasets/<resource_id>/diffs/<name>/reject → 301/302

Co-Authored-By: Frederick Muriuki Muriithi <fmuriit1@uthsc.edu>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_gn2_auth_flow.py54
1 files changed, 54 insertions, 0 deletions
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/<name> 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/<resource_id>/diffs/<name>/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/<resource_id>/diffs/<name>/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]}"
+    )