about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorPjotr Prins <pjotr.public01@thebird.nl>2026-11-14 16:01:55 +0000
committerPjotr Prins <pjotr.public01@thebird.nl>2026-11-14 16:01:55 +0000
commit05907254d44ccde0aa0c1f536d2ba838d0645402 (patch)
treea2abf7978944730426a4452e654425a8f6e02b34 /tests
parent0d016ee2211fe08722377c4089ce24fa4c98ccdf (diff)
downloadgenenetwork4-05907254d44ccde0aa0c1f536d2ba838d0645402.tar.gz
gemma: read ccwl's YAML when checking the workflow's inputs, and fix two stale tests
`ccwl compile` emits CWL as YAML (its only other target is dot), so the
new input check must read that shape -- it was parsing JSON and would
have turned a working request into a 502.  A hand-written scan of the
`inputs:` block, deliberately not a YAML dependency: ccwl's output is
machine-generated and unvaried, and adding serde_yaml would mean
regenerating the crate list in guix.scm for one small check.

Two tests were stale in ways only the package's own check phase shows:

- tests/auth.rs built AuthToken literals without the new `scheme`/`id`
  fields, so the crate's integration tests did not compile;
- test/python/test_envelope.py asserted that /version carries no `next`
  links, which stopped being true when every read endpoint gained them
  ("always offer the next step").  The deployed build fails that test
  too, so it is not a regression from this work -- but it did block
  `guix build -f guix.scm` at the python-rest-test phase.

Verified with the packaged binary (guix build -f guix.scm, all phases
including both test suites): POST /compute/gemma/ravanan through ravanan
and the Slurm container returned 200 with 636 rows in 13.6 s, on a
request authenticated with a gn4ai_ short token -- the log line naming
user zachs, scheme opaque and token smoke-2.
Diffstat (limited to 'tests')
-rw-r--r--tests/auth.rs6
-rw-r--r--tests/tokens.rs18
2 files changed, 15 insertions, 9 deletions
diff --git a/tests/auth.rs b/tests/auth.rs
index df89c9f..1541a6f 100644
--- a/tests/auth.rs
+++ b/tests/auth.rs
@@ -179,6 +179,8 @@ fn owner_is_authorised_and_stranger_is_not() {
     }
 
     let owner = AuthToken {
+        scheme: auth::Scheme::Jwt,
+        id: None,
         sub: "owner".to_string(),
         scope: "profile resource".to_string(),
         raw: token,
@@ -199,6 +201,8 @@ fn owner_is_authorised_and_stranger_is_not() {
     // resource at all -- gn-auth's own default, not something this
     // client invents.
     let stranger = AuthToken {
+        scheme: auth::Scheme::Jwt,
+        id: None,
         sub: "stranger".to_string(),
         scope: "profile resource".to_string(),
         raw: "not-a-real-token".to_string(),
@@ -229,6 +233,8 @@ fn authorisation_result_is_cached() {
     }
 
     let owner = AuthToken {
+        scheme: auth::Scheme::Jwt,
+        id: None,
         sub: "cache-test-owner".to_string(),
         scope: "profile resource".to_string(),
         raw: token,
diff --git a/tests/tokens.rs b/tests/tokens.rs
index f751c0b..b1b2b41 100644
--- a/tests/tokens.rs
+++ b/tests/tokens.rs
@@ -129,11 +129,11 @@ async fn a_token_minted_locally_authenticates_and_is_then_revoked() {
     .await;
     assert_eq!(response.status(), StatusCode::OK);
     let reply = json_of(response).await;
-    let token = reply["token"].as_str().expect("the secret, once").to_string();
+    let token = reply["data"]["token"].as_str().expect("the secret, once").to_string();
     assert!(token.starts_with("gn4ai_"), "{token}");
     assert_eq!(token.len(), 64, "{token}");
-    assert_eq!(reply["id"], "it-1");
-    assert_eq!(reply["status"], "active");
+    assert_eq!(reply["data"]["id"], "it-1");
+    assert_eq!(reply["data"]["status"], "active");
 
     // The listing never repeats the secret or its hash.
     let response = call(Method::GET, "/tokens", Some(local), None).await;
@@ -141,7 +141,7 @@ async fn a_token_minted_locally_authenticates_and_is_then_revoked() {
     let listing_text = listing.to_string();
     assert!(!listing_text.contains(&token), "the listing leaked the token");
     assert!(!listing_text.contains("sha256"));
-    assert_eq!(listing["tokens"][0]["id"], "it-1");
+    assert_eq!(listing["data"][0]["id"], "it-1");
 
     // A second mint with the same id is a conflict, not a server error.
     let response = call(
@@ -158,15 +158,15 @@ async fn a_token_minted_locally_authenticates_and_is_then_revoked() {
     let response = call_with_bearer(Method::GET, "/tokens/who", local, &token).await;
     assert_eq!(response.status(), StatusCode::OK);
     let who = json_of(response).await;
-    assert_eq!(who["scheme"], "opaque");
-    assert_eq!(who["subject"], "zachs");
-    assert_eq!(who["id"], "it-1");
-    assert!(who["created_at"].as_i64().is_some());
+    assert_eq!(who["data"]["scheme"], "opaque");
+    assert_eq!(who["data"]["subject"], "zachs");
+    assert_eq!(who["data"]["id"], "it-1");
+    assert!(who["data"]["created_at"].as_i64().is_some());
 
     // Revoking takes effect on the next request, with no restart.
     let response = call(Method::DELETE, "/tokens/it-1", Some(local), None).await;
     assert_eq!(response.status(), StatusCode::OK);
-    assert_eq!(json_of(response).await["status"], "revoked");
+    assert_eq!(json_of(response).await["data"]["status"], "revoked");
 
     let response = call_with_bearer(Method::GET, "/tokens/who", local, &token).await;
     assert_eq!(response.status(), StatusCode::UNAUTHORIZED);