Skip to content

Commit ed04403

Browse files
committed
test(e2e): walk the v3.0 envelope for list --json output
The e2e (real-registry) suite was asserting on `list["patches"]` — the pre-v3 ad-hoc shape. v3.0 migrated `list --json` to the unified envelope, which emits `{command, status, events, summary}` with one `discovered` event per manifest entry. Patch metadata (vulnerabilities, tier, license) lives under `details`. Updated four sites (e2e_npm × 2, e2e_pypi × 1, e2e_gem × 1) to filter events by `action == "discovered"` and walk `details.vulnerabilities[]` for CVE assertions. Closes the `e2e (ubuntu/macos, e2e_npm|e2e_pypi|e2e_gem)` matrix failures surfaced once the e2e workflow started passing on the v3.0 branch. Assisted-by: Claude Code:opus-4-7
1 parent db0f5fc commit ed04403

3 files changed

Lines changed: 33 additions & 7 deletions

File tree

crates/socket-patch-cli/tests/e2e_gem.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,14 +332,21 @@ fn test_gem_full_lifecycle() {
332332
assert_after_hashes(&gem_dir, files);
333333

334334
// -- LIST: verify JSON output ---------------------------------------------
335+
// v3.0 envelope: `list --json` emits {command,status,events,summary}
336+
// with one `discovered` event per manifest entry. Vulnerabilities
337+
// live under `details.vulnerabilities[]`.
335338
let (stdout, _) = assert_run_ok(cwd, &["list", "--json"], "list --json");
336339
let list: serde_json::Value = serde_json::from_str(&stdout).unwrap();
337-
let patches = list["patches"].as_array().expect("patches should be an array");
340+
let events = list["events"].as_array().expect("envelope events array");
341+
let patches: Vec<&serde_json::Value> = events
342+
.iter()
343+
.filter(|e| e["action"] == "discovered")
344+
.collect();
338345
assert_eq!(patches.len(), 1);
339346
assert_eq!(patches[0]["uuid"].as_str().unwrap(), GEM_UUID);
340347
assert_eq!(patches[0]["purl"].as_str().unwrap(), GEM_PURL);
341348

342-
let vulns = patches[0]["vulnerabilities"]
349+
let vulns = patches[0]["details"]["vulnerabilities"]
343350
.as_array()
344351
.expect("vulnerabilities array");
345352
assert!(!vulns.is_empty(), "patch should report at least one vulnerability");

crates/socket-patch-cli/tests/e2e_npm.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,21 @@ fn test_npm_full_lifecycle() {
163163
);
164164

165165
// -- LIST: verify JSON output ------------------------------------------
166+
// v3.0 envelope: `list --json` emits {command,status,events,summary}
167+
// with one `discovered` event per manifest entry. Patch metadata
168+
// (vulnerabilities, tier, license, etc.) lives under `details`.
166169
let (stdout, _) = assert_run_ok(cwd, &["list", "--json"], "list --json");
167170
let list: serde_json::Value = serde_json::from_str(&stdout).unwrap();
168-
let patches = list["patches"].as_array().expect("patches should be an array");
171+
let events = list["events"].as_array().expect("envelope events array");
172+
let patches: Vec<&serde_json::Value> = events
173+
.iter()
174+
.filter(|e| e["action"] == "discovered")
175+
.collect();
169176
assert_eq!(patches.len(), 1);
170177
assert_eq!(patches[0]["uuid"].as_str().unwrap(), NPM_UUID);
171178
assert_eq!(patches[0]["purl"].as_str().unwrap(), NPM_PURL);
172179

173-
let vulns = patches[0]["vulnerabilities"]
180+
let vulns = patches[0]["details"]["vulnerabilities"]
174181
.as_array()
175182
.expect("vulnerabilities array");
176183
assert!(!vulns.is_empty(), "patch should report at least one vulnerability");
@@ -342,9 +349,14 @@ fn test_npm_global_lifecycle() {
342349
);
343350

344351
// -- LIST: verify patch in output ----------------------------------------
352+
// v3.0 envelope shape — see the main lifecycle test for details.
345353
let (stdout, _) = assert_run_ok(cwd, &["list", "--json"], "list --json");
346354
let list: serde_json::Value = serde_json::from_str(&stdout).unwrap();
347-
let patches = list["patches"].as_array().expect("patches array");
355+
let events = list["events"].as_array().expect("envelope events array");
356+
let patches: Vec<&serde_json::Value> = events
357+
.iter()
358+
.filter(|e| e["action"] == "discovered")
359+
.collect();
348360
assert_eq!(patches.len(), 1);
349361
assert_eq!(patches[0]["uuid"].as_str().unwrap(), NPM_UUID);
350362

crates/socket-patch-cli/tests/e2e_pypi.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,14 +242,21 @@ fn test_pypi_full_lifecycle() {
242242
}
243243

244244
// -- LIST: verify JSON output ------------------------------------------
245+
// v3.0 envelope: `list --json` emits {command,status,events,summary}
246+
// with one `discovered` event per manifest entry. Vulnerabilities
247+
// live under `details.vulnerabilities[]`.
245248
let (stdout, _) = assert_run_ok(cwd, &["list", "--json"], "list --json");
246249
let list: serde_json::Value = serde_json::from_str(&stdout).unwrap();
247-
let patches = list["patches"].as_array().expect("patches array");
250+
let events = list["events"].as_array().expect("envelope events array");
251+
let patches: Vec<&serde_json::Value> = events
252+
.iter()
253+
.filter(|e| e["action"] == "discovered")
254+
.collect();
248255
assert_eq!(patches.len(), 1, "should have exactly one patch");
249256
assert_eq!(patches[0]["uuid"].as_str().unwrap(), PYPI_UUID);
250257

251258
// Verify vulnerability
252-
let vulns = patches[0]["vulnerabilities"]
259+
let vulns = patches[0]["details"]["vulnerabilities"]
253260
.as_array()
254261
.expect("vulnerabilities array");
255262
assert!(!vulns.is_empty(), "should have vulnerability info");

0 commit comments

Comments
 (0)