Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test(workbench): share setup for scan targets and ownership transfers (#1404)

mldangelo-oai9911573a1794
diff --git a/plugins/codex-security/tests/test_workbench_db.py b/plugins/codex-security/tests/test_workbench_db.py
index 3b45c8636..b5cb8769c 100644
--- a/plugins/codex-security/tests/test_workbench_db.py
+++ b/plugins/codex-security/tests/test_workbench_db.py
@@ -572,24 +572,13 @@ def test_workbench_reopens_workspace_only_from_owning_thread(tmp_path: Path) ->
target.mkdir()
workspace = create_saved_workspace(state_dir, target, thread_id="thread-a")
- reopened = run_workbench(
- state_dir,
- "get-workspace",
- "--workspace-id",
- str(workspace["id"]),
- "--thread-id",
- "thread-a",
+ reopened = workspace_command(
+ state_dir, "get-workspace", str(workspace["id"]), "--thread-id", "thread-a"
)
assert reopened["id"] == workspace["id"]
- rejected = run_workbench(
- state_dir,
- "get-workspace",
- "--workspace-id",
- str(workspace["id"]),
- "--thread-id",
- "thread-b",
- check=False,
+ rejected = workspace_command(
+ state_dir, "get-workspace", str(workspace["id"]), "--thread-id", "thread-b", check=False
)
assert rejected["returncode"] != 0
assert "workspace not found in this thread" in str(rejected["stderr"])
@@ -695,14 +684,8 @@ def test_scan_start_rejects_artifact_root_inside_target(tmp_path: Path) -> None:
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- failed = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- str(saved["id"]),
- "--scan-root",
- str(target / "scan-artifacts"),
- check=False,
+ failed = start_scan_command(
+ state_dir, str(saved["id"]), "--scan-root", str(target / "scan-artifacts"), check=False
)
assert failed["returncode"] != 0
@@ -2209,7 +2192,7 @@ def test_workbench_defaults_scan_artifacts_to_persistent_state_dir(tmp_path: Pat
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_dir = Path(str(started["results"]["scanDir"]))
assert scan_dir.is_relative_to(state_dir / "scans")
@@ -2223,13 +2206,8 @@ def test_workbench_serializes_concurrent_scan_starts(tmp_path: Path) -> None:
with ThreadPoolExecutor(max_workers=2) as executor:
results = list(
executor.map(
- lambda _: run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- "--scan-root",
- str(tmp_path / "scans"),
+ lambda _: start_scan_command(
+ state_dir, workspace_id, "--scan-root", str(tmp_path / "scans")
),
range(2),
)
@@ -2246,21 +2224,9 @@ def test_workbench_rejects_setup_changes_after_scan_starts(tmp_path: Path) -> No
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ start_scan_command(state_dir, str(saved["id"]))
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- str(saved["id"]),
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "standard",
- check=False,
- )
+ failed = save_workspace(state_dir, str(saved["id"]), str(target), ".", "standard", check=False)
assert failed["returncode"] != 0
assert "already has a scan" in str(failed["stderr"])
@@ -2271,20 +2237,8 @@ def test_workbench_rejects_scoped_deep_scan(tmp_path: Path) -> None:
target = tmp_path / "target"
target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- "src",
- "--mode",
- "deep",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), "src", "deep", check=False)
assert failed["returncode"] != 0
assert "repository-wide" in str(failed["stderr"])
@@ -2294,20 +2248,8 @@ def test_workbench_rejects_diff_scan_for_non_git_target(tmp_path: Path) -> None:
target = tmp_path / "target"
target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "diff",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), ".", "diff", check=False)
assert failed["returncode"] != 0
assert "non-bare Git worktree" in str(failed["stderr"])
@@ -2317,14 +2259,7 @@ def test_workbench_derives_git_branch_revision_and_detached_head(tmp_path: Path)
target = tmp_path / "target"
revision = initialize_git_repository(target)
workspace_id = str(uuid.uuid4())
- created = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- )
+ created = create_workspace(state_dir, workspace_id, "--target-path", str(target))
assert created["targetMetadata"] == {
"branch": "main",
"commitSubject": "Initial commit",
@@ -2337,16 +2272,11 @@ def test_workbench_derives_git_branch_revision_and_detached_head(tmp_path: Path)
"shortRevision": revision[:7],
}
- saved = run_workbench(
+ saved = save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(target),
- "--scope",
".",
- "--mode",
"diff",
"--target-summary",
"Latest commit",
@@ -2360,16 +2290,11 @@ def test_workbench_derives_git_branch_revision_and_detached_head(tmp_path: Path)
assert saved["diffTarget"]["kind"] == "commit"
assert saved["diffTarget"]["headRevision"] == revision
- relabeled = run_workbench(
+ relabeled = save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(target),
- "--scope",
".",
- "--mode",
"diff",
"--target-summary",
"",
@@ -2381,7 +2306,7 @@ def test_workbench_derives_git_branch_revision_and_detached_head(tmp_path: Path)
assert relabeled["targetSummary"] == f"Commit {revision[:7]}"
subprocess.run(["git", "checkout", "-q", "--detach", "HEAD"], cwd=target, check=True)
- detached = run_workbench(state_dir, "get-workspace", "--workspace-id", workspace_id)
+ detached = workspace_command(state_dir, "get-workspace", workspace_id)
assert detached["targetMetadata"]["branch"] is None
assert detached["targetMetadata"]["detachedHead"] is True
assert detached["targetMetadata"]["shortRevision"] == revision[:7]
@@ -2420,18 +2345,13 @@ def test_workbench_rejects_nested_git_target_for_review_changes(tmp_path: Path)
nested_target = target / "nested"
nested_target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
+ create_workspace(state_dir, workspace_id)
- failed = run_workbench(
+ failed = save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(nested_target),
- "--scope",
".",
- "--mode",
"diff",
"--diff-target-kind",
"commit",
@@ -2456,14 +2376,7 @@ def test_workbench_inspects_target_without_submitting_workspace(tmp_path: Path)
assert not (state_dir / "workbench.sqlite3").exists()
workspace_id = str(uuid.uuid4())
- workspace = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- )
+ workspace = create_workspace(state_dir, workspace_id, "--target-path", str(target))
assert workspace["setup"] == {"submitted": False}
@@ -2481,33 +2394,11 @@ def assert_unversioned_codebase_scan_starts(
environment=environment,
)
workspace_id = str(uuid.uuid4())
- run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- environment=environment,
- )
- saved = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "standard",
- environment=environment,
- )
- started = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- environment=environment,
+ create_workspace(state_dir, workspace_id, environment=environment)
+ saved = save_workspace(
+ state_dir, workspace_id, str(target), ".", "standard", environment=environment
)
+ started = start_scan_command(state_dir, workspace_id, environment=environment)
assert saved["setup"] == {"submitted": True}
assert started["results"]["targetRevision"] == "unversioned"
@@ -2568,10 +2459,8 @@ def test_workbench_marks_nested_git_paths_as_review_changes_unsupported(tmp_path
def test_workbench_opens_invalid_target_for_correction(tmp_path: Path) -> None:
state_dir = tmp_path / "state"
missing = tmp_path / "missing"
- workspace = run_workbench(
+ workspace = create_workspace(
state_dir,
- "create-workspace",
- "--workspace-id",
str(uuid.uuid4()),
"--target-path",
str(missing),
@@ -2591,32 +2480,14 @@ def test_workbench_preserves_long_user_context(tmp_path: Path) -> None:
initialize_git_repository(target)
workspace_id = str(uuid.uuid4())
created_context = "Initial guidance " + "x" * 10_000
- created = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--user-context",
- created_context,
+ created = create_workspace(
+ state_dir, workspace_id, "--target-path", str(target), "--user-context", created_context
)
assert created["userContext"] == created_context
saved_context = "Updated guidance " + "y" * 10_000
- saved = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "standard",
- "--user-context",
- saved_context,
+ saved = save_workspace(
+ state_dir, workspace_id, str(target), ".", "standard", "--user-context", saved_context
)
assert saved["userContext"] == saved_context
@@ -2629,15 +2500,8 @@ def test_workbench_preserves_url_user_context_on_workspace_creation(tmp_path: Pa
"Repository: https://github.com/example/security-review\n"
"OAuth callback: https://accounts.example.test/oauth/callback"
)
- workspace = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- str(uuid.uuid4()),
- "--target-path",
- str(target),
- "--user-context",
- user_context,
+ workspace = create_workspace(
+ state_dir, str(uuid.uuid4()), "--target-path", str(target), "--user-context", user_context
)
assert workspace["userContext"] == user_context
with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:
@@ -2654,10 +2518,9 @@ def test_workbench_replaces_context_only_for_running_owned_scan(tmp_path: Path)
started = start_delivered_scan(state_dir, "--workspace-id", str(workspace["id"]))
scan_id = str(started["results"]["scanId"])
- updated = run_workbench(
+ updated = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--workspace-id",
str(workspace["id"]),
@@ -2667,10 +2530,9 @@ def test_workbench_replaces_context_only_for_running_owned_scan(tmp_path: Path)
assert updated["scan"]["userContext"] == "Prioritize tenant isolation."
assert updated["workspace"]["userContext"] == "Prioritize tenant isolation."
- rejected_workspace = run_workbench(
+ rejected_workspace = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--workspace-id",
str(uuid.uuid4()),
@@ -2682,10 +2544,9 @@ def test_workbench_replaces_context_only_for_running_owned_scan(tmp_path: Path)
assert "selected workspace" in str(rejected_workspace["stderr"])
url_context = "OAuth issuer: https://accounts.example.test/oauth/authorize"
- updated_url = run_workbench(
+ updated_url = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--workspace-id",
str(workspace["id"]),
@@ -2695,11 +2556,10 @@ def test_workbench_replaces_context_only_for_running_owned_scan(tmp_path: Path)
assert updated_url["scan"]["userContext"] == url_context
assert updated_url["workspace"]["userContext"] == url_context
- run_workbench(state_dir, "fail-scan", "--scan-id", scan_id, "--message", "fixture")
- rejected_terminal = run_workbench(
+ fail_scan(state_dir, scan_id, "fixture")
+ rejected_terminal = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--workspace-id",
str(workspace["id"]),
@@ -2715,15 +2575,8 @@ def test_workbench_marks_invalid_initial_scope_for_correction(tmp_path: Path) ->
state_dir = tmp_path / "state"
target = tmp_path / "target"
target.mkdir()
- workspace = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- str(uuid.uuid4()),
- "--target-path",
- str(target),
- "--scope",
- "missing",
+ workspace = create_workspace(
+ state_dir, str(uuid.uuid4()), "--target-path", str(target), "--scope", "missing"
)
assert workspace["targetMetadata"]["isGit"] is False
assert workspace["scope"] == "missing"
@@ -2809,19 +2662,10 @@ def create_saved_working_tree_workspace(
revision,
*(["--diff-head-revision", head_revision] if head_revision is not None else []),
)
- run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- *diff_arguments,
- )
- return run_workbench(
+ create_workspace(state_dir, workspace_id, "--target-path", str(target), *diff_arguments)
+ return workspace_command(
state_dir,
"save-workspace",
- "--workspace-id",
workspace_id,
"--target-path",
str(target),
@@ -2845,13 +2689,7 @@ def test_workbench_rejects_working_tree_target_after_head_moves(tmp_path: Path)
subprocess.run(["git", "add", "README.md"], cwd=target, check=True)
subprocess.run(["git", "commit", "-qm", "Second commit"], cwd=target, check=True)
- failed = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- check=False,
- )
+ failed = start_scan_command(state_dir, workspace_id, check=False)
assert failed["returncode"] != 0
assert "HEAD changed" in str(failed["stderr"])
@@ -2867,13 +2705,7 @@ def test_workbench_rejects_working_tree_target_after_contents_change(tmp_path: P
)
(target / "new-file.txt").write_text("new untracked content\n")
- failed = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- check=False,
- )
+ failed = start_scan_command(state_dir, workspace_id, check=False)
assert failed["returncode"] != 0
assert "contents changed" in str(failed["stderr"])
@@ -2977,13 +2809,7 @@ def test_workbench_can_validate_legacy_nested_working_tree_scan(tmp_path: Path)
(str(nested_target.resolve()), scan_id),
)
- failed = run_workbench(
- state_dir,
- "complete-scan",
- "--scan-id",
- scan_id,
- check=False,
- )
+ failed = scan_command(state_dir, "complete-scan", scan_id, check=False)
assert failed["returncode"] != 0
assert "repository root" not in str(failed["stderr"])
assert "scan-manifest.json" in str(failed["stderr"])
@@ -3155,10 +2981,8 @@ def test_workbench_preserves_invalid_requested_initial_deep_scope(
target = tmp_path / "target"
target.mkdir()
(target / "src").mkdir()
- workspace = run_workbench(
+ workspace = create_workspace(
state_dir,
- "create-workspace",
- "--workspace-id",
str(uuid.uuid4()),
"--target-path",
str(target),
@@ -3172,17 +2996,8 @@ def test_workbench_preserves_invalid_requested_initial_deep_scope(
assert workspace["setupValidation"]["valid"] is False
assert "repository-wide" in str(workspace["setupValidation"]["error"])
- workspace = run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- str(uuid.uuid4()),
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "deep",
+ workspace = create_workspace(
+ state_dir, str(uuid.uuid4()), "--target-path", str(target), "--scope", ".", "--mode", "deep"
)
assert workspace["mode"] == "deep"
assert workspace["scope"] == "."
@@ -3192,10 +3007,8 @@ def test_workbench_discards_diff_target_for_non_diff_mode(tmp_path: Path) -> Non
state_dir = tmp_path / "state"
target = tmp_path / "target"
target.mkdir()
- workspace = run_workbench(
+ workspace = create_workspace(
state_dir,
- "create-workspace",
- "--workspace-id",
str(uuid.uuid4()),
"--target-path",
str(target),
@@ -3226,18 +3039,13 @@ def test_workbench_rejects_diff_target_when_saving_non_diff_mode(tmp_path: Path)
target = tmp_path / "target"
target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
+ create_workspace(state_dir, workspace_id)
- failed = run_workbench(
+ failed = save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(target),
- "--scope",
".",
- "--mode",
"standard",
"--diff-target-kind",
"range",
@@ -3257,20 +3065,8 @@ def test_workbench_requires_exact_diff_target(tmp_path: Path) -> None:
target = tmp_path / "target"
initialize_git_repository(target)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "diff",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), ".", "diff", check=False)
assert failed["returncode"] != 0
assert "Choose which Git changes" in str(failed["stderr"])
@@ -3280,17 +3076,12 @@ def test_workbench_starts_diff_without_presentation_label(tmp_path: Path) -> Non
target = tmp_path / "target"
revision = initialize_git_repository(target)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- run_workbench(
+ create_workspace(state_dir, workspace_id)
+ save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(target),
- "--scope",
".",
- "--mode",
"diff",
"--target-summary",
"Latest commit",
@@ -3303,14 +3094,7 @@ def test_workbench_starts_diff_without_presentation_label(tmp_path: Path) -> Non
connection.execute(
"UPDATE workspaces SET target_summary = NULL WHERE id = ?", (workspace_id,)
)
- started = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- "--scan-root",
- str(tmp_path / "scans"),
- )
+ started = start_scan_command(state_dir, workspace_id, "--scan-root", str(tmp_path / "scans"))
assert started["results"]["diffTarget"]["headRevision"] == revision
assert started["results"]["targetSummary"] == f"Commit {revision[:7]}"
@@ -3320,20 +3104,8 @@ def test_workbench_rejects_bare_repository_for_audit(tmp_path: Path) -> None:
target = tmp_path / "bare.git"
subprocess.run(["git", "init", "-q", "--bare", str(target)], check=True)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "standard",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), ".", "standard", check=False)
assert failed["returncode"] != 0
assert "checked-out worktree" in str(failed["stderr"])
@@ -3358,10 +3130,8 @@ def test_workbench_refreshes_title_only_when_target_changes(tmp_path: Path) -> N
original.mkdir()
replacement.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(
+ create_workspace(
state_dir,
- "create-workspace",
- "--workspace-id",
workspace_id,
"--target-path",
str(original),
@@ -3370,32 +3140,10 @@ def test_workbench_refreshes_title_only_when_target_changes(tmp_path: Path) -> N
"--target-summary",
"Original repository context.",
)
- unchanged = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(original),
- "--scope",
- ".",
- "--mode",
- "standard",
- )
+ unchanged = save_workspace(state_dir, workspace_id, str(original), ".", "standard")
assert unchanged["targetTitle"] == "Friendly title"
assert unchanged["targetSummary"] == "Original repository context."
- changed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(replacement),
- "--scope",
- ".",
- "--mode",
- "standard",
- )
+ changed = save_workspace(state_dir, workspace_id, str(replacement), ".", "standard")
assert changed["targetTitle"] == "replacement"
assert changed["targetSummary"] is None
@@ -3412,20 +3160,8 @@ def test_review_changes_rejects_unborn_and_bare_git_repositories(tmp_path: Path)
inspected = run_workbench(state_dir, "inspect-target", "--target-path", str(target))
assert inspected["targetMetadata"]["reviewChangesSupported"] is False
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "diff",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), ".", "diff", check=False)
assert failed["returncode"] != 0, index
expected = "non-bare Git worktree" if target == unborn else "checked-out worktree"
assert expected in str(failed["stderr"])
@@ -3437,21 +3173,11 @@ def test_workbench_rejects_missing_or_file_scope(tmp_path: Path) -> None:
target.mkdir()
(target / "file.py").write_text("print('fixture')\n")
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
+ create_workspace(state_dir, workspace_id)
for scope in ("missing", "file.py"):
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- scope,
- "--mode",
- "standard",
- check=False,
+ failed = save_workspace(
+ state_dir, workspace_id, str(target), scope, "standard", check=False
)
assert failed["returncode"] != 0
assert "existing directory" in str(failed["stderr"])
@@ -3463,34 +3189,12 @@ def test_workbench_normalizes_absolute_scope_inside_target(tmp_path: Path) -> No
scoped = target / "src"
scoped.mkdir(parents=True)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
+ create_workspace(state_dir, workspace_id)
- workspace = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- str(scoped),
- "--mode",
- "standard",
- )
+ workspace = save_workspace(state_dir, workspace_id, str(target), str(scoped), "standard")
assert workspace["scope"] == "src"
- workspace = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- str(target),
- "--mode",
- "standard",
- )
+ workspace = save_workspace(state_dir, workspace_id, str(target), str(target), "standard")
assert workspace["scope"] == "."
@@ -3499,19 +3203,9 @@ def test_workbench_rejects_scope_escape(tmp_path: Path) -> None:
target = tmp_path / "target"
target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- "../outside",
- "--mode",
- "standard",
- check=False,
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(
+ state_dir, workspace_id, str(target), "../outside", "standard", check=False
)
assert failed["returncode"] != 0
assert "stay inside" in str(failed["stderr"])
@@ -3525,20 +3219,8 @@ def test_workbench_rejects_symlinked_scope_escape(tmp_path: Path) -> None:
outside.mkdir()
(target / "linked").symlink_to(outside, target_is_directory=True)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- failed = run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- "linked",
- "--mode",
- "standard",
- check=False,
- )
+ create_workspace(state_dir, workspace_id)
+ failed = save_workspace(state_dir, workspace_id, str(target), "linked", "standard", check=False)
assert failed["returncode"] != 0
assert "stay inside" in str(failed["stderr"])
diff --git a/plugins/codex-security/tests/test_workbench_handoff.py b/plugins/codex-security/tests/test_workbench_handoff.py
index db5e274ef..4d4dca71f 100644
--- a/plugins/codex-security/tests/test_workbench_handoff.py
+++ b/plugins/codex-security/tests/test_workbench_handoff.py
@@ -8,11 +8,17 @@ from pathlib import Path
import pytest
from workbench_test_support import (
attach_continuation,
+ cancel_scan,
create_saved_workspace,
+ create_workspace,
+ get_scan,
mark_handoff_delivered,
run_workbench,
+ save_workspace,
scan_claim_command,
+ scan_command,
start_scan_command,
+ update_progress,
)
@@ -24,33 +30,16 @@ def test_running_scan_context_is_owned_by_attached_continuation(tmp_path: Path,
original_thread_id = "original-thread"
continuation_thread_id = "continuation-thread"
saved = create_saved_workspace(state_dir, target, thread_id=original_thread_id, mode=mode)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
claim_token = str(uuid.uuid4())
- run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- )
- run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- "--thread-id",
- continuation_thread_id,
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, claim_token)
+ attach_continuation(state_dir, scan_id, claim_token, continuation_thread_id)
updated_context = "Prioritize password-reset token validation."
- updated = run_workbench(
+ updated = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--thread-id",
continuation_thread_id,
@@ -63,10 +52,9 @@ def test_running_scan_context_is_owned_by_attached_continuation(tmp_path: Path,
assert updated["workspace"]["userContext"] == updated_context
for rejected_thread_id in (original_thread_id, "unrelated-thread"):
- rejected_owner = run_workbench(
+ rejected_owner = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--thread-id",
rejected_thread_id,
@@ -79,10 +67,9 @@ def test_running_scan_context_is_owned_by_attached_continuation(tmp_path: Path,
assert rejected_owner["returncode"] != 0
assert "current Codex thread" in str(rejected_owner["stderr"])
- rejected_claim = run_workbench(
+ rejected_claim = scan_command(
state_dir,
"update-scan-context",
- "--scan-id",
scan_id,
"--thread-id",
continuation_thread_id,
@@ -95,7 +82,7 @@ def test_running_scan_context_is_owned_by_attached_continuation(tmp_path: Path,
assert rejected_claim["returncode"] != 0
assert "owned by another continuation" in str(rejected_claim["stderr"])
- persisted = run_workbench(state_dir, "get-scan", "--scan-id", scan_id)
+ persisted = get_scan(state_dir, scan_id)
assert persisted["scan"]["userContext"] == updated_context
assert persisted["workspace"]["userContext"] == updated_context
@@ -105,24 +92,15 @@ def test_workbench_serializes_concurrent_handoff_delivery(tmp_path: Path) -> Non
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
claim_token = str(uuid.uuid4())
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", claim_token
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, claim_token)
with ThreadPoolExecutor(max_workers=2) as executor:
results = list(
executor.map(
- lambda _: run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- ),
+ lambda _: mark_handoff_delivered(state_dir, scan_id, claim_token),
range(2),
)
)
@@ -148,41 +126,14 @@ def test_deep_handoff_leaves_preflight_progress_to_coordinator(tmp_path: Path) -
target = tmp_path / "target"
target.mkdir()
workspace_id = str(uuid.uuid4())
- run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- )
- run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "deep",
- )
- started = run_workbench(state_dir, "start-scan", "--workspace-id", workspace_id)
+ create_workspace(state_dir, workspace_id, "--target-path", str(target))
+ save_workspace(state_dir, workspace_id, str(target), ".", "deep")
+ started = start_scan_command(state_dir, workspace_id)
scan_id = str(started["results"]["scanId"])
claim_token = str(uuid.uuid4())
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", claim_token
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, claim_token)
- delivered = run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- )
+ delivered = mark_handoff_delivered(state_dir, scan_id, claim_token)
assert delivered["results"]["progress"]["phaseProgress"] == {
"completed": 0,
@@ -205,40 +156,15 @@ def test_workbench_upgrade_keeps_preexisting_delivered_continuation_writable(
pending_target.mkdir()
delivered_workspace = create_saved_workspace(state_dir, delivered_target)
pending_workspace = create_saved_workspace(state_dir, pending_target)
- delivered_scan = run_workbench(
- state_dir, "start-scan", "--workspace-id", str(delivered_workspace["id"])
- )
- pending_scan = run_workbench(
- state_dir, "start-scan", "--workspace-id", str(pending_workspace["id"])
- )
+ delivered_scan = start_scan_command(state_dir, str(delivered_workspace["id"]))
+ pending_scan = start_scan_command(state_dir, str(pending_workspace["id"]))
delivered_scan_id = str(delivered_scan["results"]["scanId"])
pending_scan_id = str(pending_scan["results"]["scanId"])
delivered_token = str(uuid.uuid4())
pending_token = str(uuid.uuid4())
- run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- delivered_scan_id,
- "--claim-token",
- delivered_token,
- )
- run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- delivered_scan_id,
- "--claim-token",
- delivered_token,
- )
- run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- pending_scan_id,
- "--claim-token",
- pending_token,
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", delivered_scan_id, delivered_token)
+ mark_handoff_delivered(state_dir, delivered_scan_id, delivered_token)
+ scan_claim_command(state_dir, "claim-handoff-delivery", pending_scan_id, pending_token)
with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:
connection.execute("DELETE FROM schema_migrations WHERE version = 18")
@@ -251,14 +177,7 @@ def test_workbench_upgrade_keeps_preexisting_delivered_continuation_writable(
assert connection.execute(
"SELECT handoff_claim_token FROM scans WHERE id = ?", (pending_scan_id,)
).fetchone() == (pending_token,)
- updated = run_workbench(
- state_dir,
- "update-progress",
- "--scan-id",
- delivered_scan_id,
- "--phase",
- "discovery",
- )
+ updated = update_progress(state_dir, delivered_scan_id, "--phase", "discovery")
assert updated["scan"]["progress"]["phase"] == "discovery"
@@ -267,19 +186,14 @@ def test_workbench_handoff_claim_is_owned_by_one_token(tmp_path: Path) -> None:
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
tokens = [str(uuid.uuid4()), str(uuid.uuid4())]
with ThreadPoolExecutor(max_workers=2) as executor:
claims = list(
executor.map(
- lambda token: run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- token,
+ lambda token: scan_claim_command(
+ state_dir, "claim-handoff-delivery", scan_id, token
),
tokens,
)
@@ -288,24 +202,9 @@ def test_workbench_handoff_claim_is_owned_by_one_token(tmp_path: Path) -> None:
assert len(owners) == 1
owner = owners.pop()
non_owner = next(token for token in tokens if token != owner)
- wrong_release = run_workbench(
- state_dir,
- "release-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- non_owner,
- )
+ wrong_release = scan_claim_command(state_dir, "release-handoff-delivery", scan_id, non_owner)
assert wrong_release["results"]["handoffClaimToken"] == owner
- wrong_delivery = run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- scan_id,
- "--claim-token",
- non_owner,
- check=False,
- )
+ wrong_delivery = mark_handoff_delivered(state_dir, scan_id, non_owner, check=False)
assert "delivery could not be recorded" in str(wrong_delivery["stderr"])
@@ -314,29 +213,14 @@ def test_workbench_handoff_claim_only_allows_stale_takeover(tmp_path: Path) -> N
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
owner = str(uuid.uuid4())
replacement = str(uuid.uuid4())
- run_workbench(state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", owner)
- run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- owner,
- "--thread-id",
- "stale-continuation",
- )
- live = run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- replacement,
- "--take-over-stale",
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, owner)
+ attach_continuation(state_dir, scan_id, owner, "stale-continuation")
+ live = scan_claim_command(
+ state_dir, "claim-handoff-delivery", scan_id, replacement, "--take-over-stale"
)
assert live["results"]["handoffClaimToken"] == owner
with sqlite3.connect(state_dir / "workbench.sqlite3") as connection:
@@ -344,22 +228,14 @@ def test_workbench_handoff_claim_only_allows_stale_takeover(tmp_path: Path) -> N
"UPDATE scans SET handoff_claimed_at = ? WHERE id = ?",
("2000-01-01T00:00:00Z", scan_id),
)
- stale = run_workbench(
- state_dir,
- "claim-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- replacement,
- "--take-over-stale",
+ stale = scan_claim_command(
+ state_dir, "claim-handoff-delivery", scan_id, replacement, "--take-over-stale"
)
assert stale["results"]["handoffClaimToken"] == replacement
assert stale["results"]["continuationThreadId"] is None
for claim_token in (None, owner):
- rejected_update = run_workbench(
+ rejected_update = update_progress(
state_dir,
- "update-progress",
- "--scan-id",
scan_id,
"--phase",
"discovery",
@@ -367,35 +243,11 @@ def test_workbench_handoff_claim_only_allows_stale_takeover(tmp_path: Path) -> N
check=False,
)
assert "owned by another continuation" in str(rejected_update["stderr"])
- attached = run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- replacement,
- "--thread-id",
- "replacement-continuation",
- )
+ attached = attach_continuation(state_dir, scan_id, replacement, "replacement-continuation")
assert attached["results"]["continuationThreadId"] == "replacement-continuation"
- delivered = run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- scan_id,
- "--claim-token",
- replacement,
- )
+ delivered = mark_handoff_delivered(state_dir, scan_id, replacement)
assert delivered["results"]["handoffClaimToken"] == replacement
- superseded_delivery = run_workbench(
- state_dir,
- "mark-handoff-delivered",
- "--scan-id",
- scan_id,
- "--claim-token",
- owner,
- check=False,
- )
+ superseded_delivery = mark_handoff_delivered(state_dir, scan_id, owner, check=False)
assert "owned by another continuation" in str(superseded_delivery["stderr"])
@@ -440,31 +292,13 @@ def test_workbench_allows_attached_continuation_thread_to_cancel_scan(
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target, thread_id="workspace-thread")
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
claim_token = str(uuid.uuid4())
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", claim_token
- )
- run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- "--thread-id",
- "continuation-thread",
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, claim_token)
+ attach_continuation(state_dir, scan_id, claim_token, "continuation-thread")
- canceled = run_workbench(
- state_dir,
- "cancel-scan",
- "--scan-id",
- scan_id,
- "--thread-id",
- "continuation-thread",
- )
+ canceled = cancel_scan(state_dir, scan_id, "continuation-thread")
assert canceled["results"]["progress"]["status"] == "canceled"
@@ -476,48 +310,19 @@ def test_workbench_releases_attached_continuation_for_a_fresh_handoff(
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
first_token = str(uuid.uuid4())
second_token = str(uuid.uuid4())
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", first_token
- )
- run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- first_token,
- "--thread-id",
- "failed-continuation",
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, first_token)
+ attach_continuation(state_dir, scan_id, first_token, "failed-continuation")
- released = run_workbench(
- state_dir,
- "release-handoff-delivery",
- "--scan-id",
- scan_id,
- "--claim-token",
- first_token,
- )
+ released = scan_claim_command(state_dir, "release-handoff-delivery", scan_id, first_token)
assert released["results"]["handoffClaimToken"] is None
assert released["results"]["continuationThreadId"] is None
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", second_token
- )
- attached = run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- second_token,
- "--thread-id",
- "replacement-continuation",
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, second_token)
+ attached = attach_continuation(state_dir, scan_id, second_token, "replacement-continuation")
assert attached["results"]["continuationThreadId"] == "replacement-continuation"
@@ -537,37 +342,14 @@ def test_released_pending_handoff_rejects_tokenless_mutations(
target = tmp_path / "target"
target.mkdir()
saved = create_saved_workspace(state_dir, target)
- started = run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ started = start_scan_command(state_dir, str(saved["id"]))
scan_id = str(started["results"]["scanId"])
claim_token = str(uuid.uuid4())
- run_workbench(
- state_dir, "claim-handoff-delivery", "--scan-id", scan_id, "--claim-token", claim_token
- )
- run_workbench(
- state_dir,
- "attach-scan-continuation-thread",
- "--scan-id",
- scan_id,
- "--claim-token",
- claim_token,
- "--thread-id",
- "released-continuation",
- )
- run_workbench(
- state_dir, "release-handoff-delivery", "--scan-id", scan_id, "--claim-token", claim_token
- )
+ scan_claim_command(state_dir, "claim-handoff-delivery", scan_id, claim_token)
+ attach_continuation(state_dir, scan_id, claim_token, "released-continuation")
+ scan_claim_command(state_dir, "release-handoff-delivery", scan_id, claim_token)
- rejected = run_workbench(
- state_dir,
- command,
- "--scan-id",
- scan_id,
- *arguments,
- check=False,
- )
+ rejected = scan_command(state_dir, command, scan_id, *arguments, check=False)
assert "owned by another continuation" in str(rejected["stderr"])
- assert (
- run_workbench(state_dir, "get-scan", "--scan-id", scan_id)["scan"]["handoffStatus"]
- == "pending"
- )
+ assert get_scan(state_dir, scan_id)["scan"]["handoffStatus"] == "pending"
diff --git a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
index 5c505148a..d31e7421b 100644
--- a/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
+++ b/plugins/codex-security/tests/test_workbench_setup_and_migrations.py
@@ -23,8 +23,11 @@ from workbench_test_support import (
configure_git_command,
create_saved_git_workspace,
create_saved_workspace,
+ create_workspace,
+ get_scan,
initialize_git_repository,
run_workbench,
+ save_workspace,
scan_command,
start_delivered_scan,
start_scan_command,
@@ -383,7 +386,7 @@ def test_workbench_does_not_run_fsmonitor_during_scan_start(tmp_path: Path) -> N
marker.unlink()
saved = create_saved_git_workspace(state_dir, target)
- run_workbench(state_dir, "start-scan", "--workspace-id", str(saved["id"]))
+ start_scan_command(state_dir, str(saved["id"]))
assert not marker.exists()
@@ -448,13 +451,7 @@ def test_scan_start_rejects_dirty_initialized_submodule(tmp_path: Path) -> None:
saved = create_saved_git_workspace(state_dir, target)
(target / "vendor/dependency/README.md").write_text("dirty dependency\n")
- failed = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- str(saved["id"]),
- check=False,
- )
+ failed = start_scan_command(state_dir, str(saved["id"]), check=False)
assert failed["returncode"] != 0
assert "Dirty Git submodules are not supported" in str(failed["stderr"])
@@ -489,12 +486,7 @@ def test_scan_start_allows_uninitialized_submodule(tmp_path: Path) -> None:
assert not (target / "vendor/dependency/.git").exists()
saved = create_saved_git_workspace(state_dir, target)
- started = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- str(saved["id"]),
- )
+ started = start_scan_command(state_dir, str(saved["id"]))
assert started["results"]["progress"]["status"] == "running"
@@ -531,13 +523,7 @@ def test_scan_start_rejects_submodule_at_unrecorded_revision(tmp_path: Path) ->
)
saved = create_saved_git_workspace(state_dir, target)
- failed = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- str(saved["id"]),
- check=False,
- )
+ failed = start_scan_command(state_dir, str(saved["id"]), check=False)
assert failed["returncode"] != 0
assert "revision recorded by the parent repository" in str(failed["stderr"])
@@ -557,26 +543,8 @@ def test_nested_target_name_is_a_literal_git_pathspec(tmp_path: Path) -> None:
["git", "rev-parse", "HEAD"], cwd=repository, text=True
).strip()
workspace_id = str(uuid.uuid4())
- run_workbench(
- state_dir,
- "create-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- )
- run_workbench(
- state_dir,
- "save-workspace",
- "--workspace-id",
- workspace_id,
- "--target-path",
- str(target),
- "--scope",
- ".",
- "--mode",
- "standard",
- )
+ create_workspace(state_dir, workspace_id, "--target-path", str(target))
+ save_workspace(state_dir, workspace_id, str(target), ".", "standard")
scan_id, scan_dir = start_workspace_scan(state_dir, workspace_id, tmp_path / "scans")
(repository / "outside.py").write_text("outside = 2\n")
write_completed_contract(
@@ -588,7 +556,7 @@ def test_nested_target_name_is_a_literal_git_pathspec(tmp_path: Path) -> None:
target_revision=revision,
)
- completed = run_workbench(state_dir, "complete-scan", "--scan-id", scan_id)
+ completed = scan_command(state_dir, "complete-scan", scan_id)
assert completed["scan"]["progress"]["status"] == "complete"
@@ -2165,17 +2133,12 @@ def test_workbench_preserves_diff_target_summary_on_scan(tmp_path: Path) -> None
target = tmp_path / "target"
revision = initialize_git_repository(target)
workspace_id = str(uuid.uuid4())
- run_workbench(state_dir, "create-workspace", "--workspace-id", workspace_id)
- run_workbench(
+ create_workspace(state_dir, workspace_id)
+ save_workspace(
state_dir,
- "save-workspace",
- "--workspace-id",
workspace_id,
- "--target-path",
str(target),
- "--scope",
".",
- "--mode",
"diff",
"--target-summary",
"Authentication callback changes",
@@ -2185,20 +2148,12 @@ def test_workbench_preserves_diff_target_summary_on_scan(tmp_path: Path) -> None
revision,
)
- started = run_workbench(
- state_dir,
- "start-scan",
- "--workspace-id",
- workspace_id,
- "--scan-root",
- str(tmp_path / "scans"),
- )
+ started = start_scan_command(state_dir, workspace_id, "--scan-root", str(tmp_path / "scans"))
scan_id = started["results"]["scanId"]
assert started["results"]["targetSummary"] == "Authentication callback changes"
assert (
- run_workbench(state_dir, "get-scan", "--scan-id", scan_id)["scan"]["targetSummary"]
- == "Authentication callback changes"
+ get_scan(state_dir, scan_id)["scan"]["targetSummary"] == "Authentication callback changes"
)