about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-10-05 11:12:15 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-10-07 08:26:56 +0200
commit15a5c8abeb73584eeae6cae1d92176da42fa6bc3 (patch)
treef5926ef740ef3e59b298cd99b32f093709c1e913
parent81662183f5cad305d7c011fc53b6bb750b3b0833 (diff)
downloadgenenetwork4-15a5c8abeb73584eeae6cae1d92176da42fa6bc3.tar.gz
Add tests for denying a genuinely <1-year-old non-public dataset
All four 403-deny tests so far used UTHSC_BXD_Cochlea_0225, which was a
real non-public, non-embargoed dataset when first used as a fixture but
is now ~20 months old -- still correctly denied (under the 5-year
embargo threshold), but no longer actually tests "freshly added,
private" data specifically, only "not yet old enough to auto-expire."

Found UTHSC_BXD_2wk_Cochlea_0926 (public=1, confidentiality=1, created
2026-09-01, the most recently added ProbeSetFreeze in the database as
of this writing) and added a parallel test alongside each existing
UTHSC_BXD_Cochlea_0225 test -- dataset_probeset_info, its /values
sibling, the dataset_probesets listing, and the unified /traits
endpoint, in both Rust and Python -- confirming the deny path holds for
data that's actually less than a year old, not just data that merely
hasn't aged past 5 years yet. Verified live against the real database
before adding (is_publicly_readable's two conditions -- flags and age
-- both still correctly deny for this dataset; values/probeset data
exists for it, so the test exercises the authorization check rather
than a 404).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XDDpXvZBQat9uSgDeEMJ8d
-rw-r--r--test/python/test_dataset_probeset_info.py21
-rw-r--r--test/python/test_dataset_probeset_values.py21
-rw-r--r--test/python/test_dataset_probesets.py19
-rw-r--r--test/python/test_traits.py19
-rw-r--r--tests/dataset_probeset_info.rs42
-rw-r--r--tests/dataset_probeset_values.rs42
-rw-r--r--tests/dataset_probesets.rs42
-rw-r--r--tests/traits.rs25
8 files changed, 231 insertions, 0 deletions
diff --git a/test/python/test_dataset_probeset_info.py b/test/python/test_dataset_probeset_info.py
index 32d25a6..c073f3a 100644
--- a/test/python/test_dataset_probeset_info.py
+++ b/test/python/test_dataset_probeset_info.py
@@ -105,6 +105,27 @@ class DatasetProbesetInfoTest(ServerTestCase):
         error = json.loads(body)
         self.assertEqual(error["code"], "forbidden")
 
+    def test_dataset_probeset_info_recent_non_public_dataset_returns_403(self):
+        """Same as above, but with a dataset genuinely less than a year
+        old (UTHSC_BXD_Cochlea_0225 above is real but was already ~20
+        months old by the time this test was written) -- the age-embargo
+        rule and the "not yet linked to any gn-auth resource" deny path
+        both need to hold for freshly-added data, not just for something
+        that merely hasn't aged into public yet.
+        UTHSC_BXD_2wk_Cochlea_0926 (public=1, confidentiality=1, created
+        2026-09-01) is the most recently added ProbeSetFreeze in the
+        database as of this writing.
+        """
+        self.require_fixtures()
+
+        response, body = self.get(
+            "/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180"
+        )
+        self.assertEqual(response.status, 403)
+
+        error = json.loads(body)
+        self.assertEqual(error["code"], "forbidden")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/test/python/test_dataset_probeset_values.py b/test/python/test_dataset_probeset_values.py
index 7a934d0..b11b5d6 100644
--- a/test/python/test_dataset_probeset_values.py
+++ b/test/python/test_dataset_probeset_values.py
@@ -109,6 +109,27 @@ class DatasetProbesetValuesTest(ServerTestCase):
         error = json.loads(body)
         self.assertEqual(error["code"], "forbidden")
 
+    def test_dataset_probeset_values_recent_non_public_dataset_returns_403(self):
+        """Same as above, but with a dataset genuinely less than a year
+        old (UTHSC_BXD_Cochlea_0225 above is real but was already ~20
+        months old by the time this test was written) -- the age-embargo
+        rule and the "not yet linked to any gn-auth resource" deny path
+        both need to hold for freshly-added data, not just for something
+        that merely hasn't aged into public yet.
+        UTHSC_BXD_2wk_Cochlea_0926 (public=1, confidentiality=1, created
+        2026-09-01) is the most recently added ProbeSetFreeze in the
+        database as of this writing.
+        """
+        self.require_fixtures()
+
+        response, body = self.get(
+            "/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180/values"
+        )
+        self.assertEqual(response.status, 403)
+
+        error = json.loads(body)
+        self.assertEqual(error["code"], "forbidden")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/test/python/test_dataset_probesets.py b/test/python/test_dataset_probesets.py
index dcfcd99..c12b42a 100644
--- a/test/python/test_dataset_probesets.py
+++ b/test/python/test_dataset_probesets.py
@@ -89,6 +89,25 @@ class DatasetProbesetsTest(ServerTestCase):
         error = json.loads(body)
         self.assertEqual(error["code"], "forbidden")
 
+    def test_dataset_probesets_recent_non_public_dataset_returns_403(self):
+        """Same as above, but with a dataset genuinely less than a year
+        old (UTHSC_BXD_Cochlea_0225 above is real but was already ~20
+        months old by the time this test was written) -- the age-embargo
+        rule and the "not yet linked to any gn-auth resource" deny path
+        both need to hold for freshly-added data, not just for something
+        that merely hasn't aged into public yet.
+        UTHSC_BXD_2wk_Cochlea_0926 (public=1, confidentiality=1, created
+        2026-09-01) is the most recently added ProbeSetFreeze in the
+        database as of this writing.
+        """
+        self.require_fixtures()
+
+        response, body = self.get("/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets")
+        self.assertEqual(response.status, 403)
+
+        error = json.loads(body)
+        self.assertEqual(error["code"], "forbidden")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/test/python/test_traits.py b/test/python/test_traits.py
index 38bf411..6a44bd8 100644
--- a/test/python/test_traits.py
+++ b/test/python/test_traits.py
@@ -176,6 +176,25 @@ class TraitsTest(ServerTestCase):
         error = json.loads(body)
         self.assertEqual(error["code"], "forbidden")
 
+    def test_trait_info_recent_non_public_probeset_dataset_returns_403(self):
+        """Same as above, but with a dataset genuinely less than a year
+        old (UTHSC_BXD_Cochlea_0225 above is real but was already ~20
+        months old by the time this test was written) -- the age-embargo
+        rule and the "not yet linked to any gn-auth resource" deny path
+        both need to hold for freshly-added data, not just for something
+        that merely hasn't aged into public yet.
+        UTHSC_BXD_2wk_Cochlea_0926 (public=1, confidentiality=1, created
+        2026-09-01) is the most recently added ProbeSetFreeze in the
+        database as of this writing.
+        """
+        self.require_fixtures()
+
+        response, body = self.get("/traits/UTHSC_BXD_2wk_Cochlea_0926/ENSMUSG00000028180")
+        self.assertEqual(response.status, 403)
+
+        error = json.loads(body)
+        self.assertEqual(error["code"], "forbidden")
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tests/dataset_probeset_info.rs b/tests/dataset_probeset_info.rs
index 0c387ce..78356f9 100644
--- a/tests/dataset_probeset_info.rs
+++ b/tests/dataset_probeset_info.rs
@@ -177,3 +177,45 @@ async fn dataset_probeset_info_non_public_unlinked_dataset_returns_403() {
     let error: Value = serde_json::from_slice(&body).unwrap();
     assert_eq!(error["code"], "forbidden");
 }
+
+/// Same as above, but with a dataset genuinely less than a year old
+/// (UTHSC_BXD_Cochlea_0225 above is real but was already ~20 months
+/// old by the time this test was written) -- the age-embargo rule and
+/// the "not yet linked to any gn-auth resource" deny path both need to
+/// hold for freshly-added data, not just for something that merely
+/// hasn't aged into public yet. UTHSC_BXD_2wk_Cochlea_0926
+/// (public=1, confidentiality=1, created 2026-09-01) is the most
+/// recently added ProbeSetFreeze in the database as of this writing.
+#[tokio::test]
+async fn dataset_probeset_info_recent_non_public_dataset_returns_403() {
+    if !common::db_available() {
+        eprintln!(
+            "skipping dataset_probeset_info_recent_non_public_dataset_returns_403: no usable database (check SQL_URI credentials)"
+        );
+        return;
+    }
+    let Some(token) = common::auth_token().await else {
+        eprintln!(
+            "skipping dataset_probeset_info_recent_non_public_dataset_returns_403: set GN4_TEST_AUTH_TOKEN (see docs/gn-auth.md)"
+        );
+        return;
+    };
+    if !common::auth_server_available() {
+        eprintln!(
+            "skipping dataset_probeset_info_recent_non_public_dataset_returns_403: no gn-auth reachable"
+        );
+        return;
+    }
+
+    let response = common::get_with_token(
+        "GET /datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180",
+        "/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180",
+        &token,
+    )
+    .await;
+
+    assert_eq!(response.status(), StatusCode::FORBIDDEN);
+    let body = response.into_body().collect().await.unwrap().to_bytes();
+    let error: Value = serde_json::from_slice(&body).unwrap();
+    assert_eq!(error["code"], "forbidden");
+}
diff --git a/tests/dataset_probeset_values.rs b/tests/dataset_probeset_values.rs
index 2e49735..fa32358 100644
--- a/tests/dataset_probeset_values.rs
+++ b/tests/dataset_probeset_values.rs
@@ -179,3 +179,45 @@ async fn dataset_probeset_values_non_public_unlinked_dataset_returns_403() {
     let error: Value = serde_json::from_slice(&body).unwrap();
     assert_eq!(error["code"], "forbidden");
 }
+
+/// Same as above, but with a dataset genuinely less than a year old
+/// (UTHSC_BXD_Cochlea_0225 above is real but was already ~20 months
+/// old by the time this test was written) -- the age-embargo rule and
+/// the "not yet linked to any gn-auth resource" deny path both need to
+/// hold for freshly-added data, not just for something that merely
+/// hasn't aged into public yet. UTHSC_BXD_2wk_Cochlea_0926
+/// (public=1, confidentiality=1, created 2026-09-01) is the most
+/// recently added ProbeSetFreeze in the database as of this writing.
+#[tokio::test]
+async fn dataset_probeset_values_recent_non_public_dataset_returns_403() {
+    if !common::db_available() {
+        eprintln!(
+            "skipping dataset_probeset_values_recent_non_public_dataset_returns_403: no usable database (check SQL_URI credentials)"
+        );
+        return;
+    }
+    let Some(token) = common::auth_token().await else {
+        eprintln!(
+            "skipping dataset_probeset_values_recent_non_public_dataset_returns_403: set GN4_TEST_AUTH_TOKEN (see docs/gn-auth.md)"
+        );
+        return;
+    };
+    if !common::auth_server_available() {
+        eprintln!(
+            "skipping dataset_probeset_values_recent_non_public_dataset_returns_403: no gn-auth reachable"
+        );
+        return;
+    }
+
+    let response = common::get_with_token(
+        "GET /datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180/values",
+        "/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets/ENSMUSG00000028180/values",
+        &token,
+    )
+    .await;
+
+    assert_eq!(response.status(), StatusCode::FORBIDDEN);
+    let body = response.into_body().collect().await.unwrap().to_bytes();
+    let error: Value = serde_json::from_slice(&body).unwrap();
+    assert_eq!(error["code"], "forbidden");
+}
diff --git a/tests/dataset_probesets.rs b/tests/dataset_probesets.rs
index 149dd73..a68e523 100644
--- a/tests/dataset_probesets.rs
+++ b/tests/dataset_probesets.rs
@@ -142,3 +142,45 @@ async fn dataset_probesets_non_public_unlinked_dataset_returns_403() {
     let error: Value = serde_json::from_slice(&body).unwrap();
     assert_eq!(error["code"], "forbidden");
 }
+
+/// Same as above, but with a dataset genuinely less than a year old
+/// (UTHSC_BXD_Cochlea_0225 above is real but was already ~20 months
+/// old by the time this test was written) -- the age-embargo rule and
+/// the "not yet linked to any gn-auth resource" deny path both need to
+/// hold for freshly-added data, not just for something that merely
+/// hasn't aged into public yet. UTHSC_BXD_2wk_Cochlea_0926
+/// (public=1, confidentiality=1, created 2026-09-01) is the most
+/// recently added ProbeSetFreeze in the database as of this writing.
+#[tokio::test]
+async fn dataset_probesets_recent_non_public_dataset_returns_403() {
+    if !common::db_available() {
+        eprintln!(
+            "skipping dataset_probesets_recent_non_public_dataset_returns_403: no usable database (check SQL_URI credentials)"
+        );
+        return;
+    }
+    let Some(token) = common::auth_token().await else {
+        eprintln!(
+            "skipping dataset_probesets_recent_non_public_dataset_returns_403: set GN4_TEST_AUTH_TOKEN (see docs/gn-auth.md)"
+        );
+        return;
+    };
+    if !common::auth_server_available() {
+        eprintln!(
+            "skipping dataset_probesets_recent_non_public_dataset_returns_403: no gn-auth reachable"
+        );
+        return;
+    }
+
+    let response = common::get_with_token(
+        "GET /datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets",
+        "/datasets/UTHSC_BXD_2wk_Cochlea_0926/probesets",
+        &token,
+    )
+    .await;
+
+    assert_eq!(response.status(), StatusCode::FORBIDDEN);
+    let body = response.into_body().collect().await.unwrap().to_bytes();
+    let error: Value = serde_json::from_slice(&body).unwrap();
+    assert_eq!(error["code"], "forbidden");
+}
diff --git a/tests/traits.rs b/tests/traits.rs
index 7e892ae..9ee1008 100644
--- a/tests/traits.rs
+++ b/tests/traits.rs
@@ -238,3 +238,28 @@ async fn trait_info_non_public_unlinked_probeset_dataset_returns_403() {
     let error: Value = serde_json::from_slice(&body).unwrap();
     assert_eq!(error["code"], "forbidden");
 }
+
+/// Same as above, but with a dataset genuinely less than a year old
+/// (UTHSC_BXD_Cochlea_0225 above is real but was already ~20 months
+/// old by the time this test was written) -- the age-embargo rule and
+/// the "not yet linked to any gn-auth resource" deny path both need to
+/// hold for freshly-added data, not just for something that merely
+/// hasn't aged into public yet. UTHSC_BXD_2wk_Cochlea_0926
+/// (public=1, confidentiality=1, created 2026-09-01) is the most
+/// recently added ProbeSetFreeze in the database as of this writing.
+#[tokio::test]
+async fn trait_info_recent_non_public_probeset_dataset_returns_403() {
+    let Some(token) = fixtures().await else { return };
+
+    let response = common::get_with_token(
+        "GET /traits/UTHSC_BXD_2wk_Cochlea_0926/ENSMUSG00000028180",
+        "/traits/UTHSC_BXD_2wk_Cochlea_0926/ENSMUSG00000028180",
+        &token,
+    )
+    .await;
+
+    assert_eq!(response.status(), StatusCode::FORBIDDEN);
+    let body = response.into_body().collect().await.unwrap().to_bytes();
+    let error: Value = serde_json::from_slice(&body).unwrap();
+    assert_eq!(error["code"], "forbidden");
+}