test(ack): align allowedWorktrees deprecation tests with v0.19 contract
e4d4319 deprecated the allowedWorktrees whitelist (git worktree registry +
same common-dir checks replace it) but left 4 tests asserting the old
contract:
- test_ack_skill: template must NOT contain allowedWorktrees: anymore,
only the deprecation comment
- test_ack_worker_profiles: legacy allowlist field is tolerated (no
'requires at least one path'); receipt no longer validated against it
- test_ack_launch_worker: capture_worktree_identity dropped the
allowlist arg; assert registered-worktree pass, symlink impostor and
unregistered-rejection under the new signature
This commit is contained in:
@@ -603,21 +603,53 @@ class GitIdentityTests(unittest.TestCase):
|
||||
["/usr/bin/git", "init", "-q", str(project)],
|
||||
check=True,
|
||||
)
|
||||
identity = launch_worker.capture_worktree_identity(
|
||||
project,
|
||||
str(project),
|
||||
[str(project)],
|
||||
)
|
||||
self.assertEqual(identity["path"], str(project))
|
||||
|
||||
impostor = base / "impostor"
|
||||
impostor.mkdir()
|
||||
(impostor / ".git").symlink_to(project / ".git")
|
||||
with self.assertRaisesRegex(launch_worker.LaunchError, "symlink"):
|
||||
def registered(git: Path, root: Path) -> set[Path]:
|
||||
return {project}
|
||||
|
||||
# v0.19 起 capture_worktree_identity 不再接收 allowedWorktrees 白名单;
|
||||
# worktree 合法性由 git worktree 注册表 + 同 common-dir 约束保证。
|
||||
with mock.patch.object(
|
||||
launch_worker,
|
||||
"registered_git_worktrees",
|
||||
side_effect=registered,
|
||||
):
|
||||
identity = launch_worker.capture_worktree_identity(
|
||||
project,
|
||||
str(project),
|
||||
)
|
||||
self.assertEqual(identity["path"], str(project))
|
||||
|
||||
impostor = base / "impostor"
|
||||
impostor.mkdir()
|
||||
(impostor / ".git").symlink_to(project / ".git")
|
||||
with self.assertRaisesRegex(launch_worker.LaunchError, "symlink"):
|
||||
launch_worker.capture_worktree_identity(
|
||||
project,
|
||||
str(impostor),
|
||||
)
|
||||
|
||||
def test_unregistered_worktree_is_rejected(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temporary:
|
||||
base = Path(temporary).resolve()
|
||||
project = base / "project"
|
||||
subprocess.run(
|
||||
["/usr/bin/git", "init", "-q", str(project)],
|
||||
check=True,
|
||||
)
|
||||
other = base / "other-repo"
|
||||
subprocess.run(
|
||||
["/usr/bin/git", "init", "-q", str(other)],
|
||||
check=True,
|
||||
)
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
launch_worker.LaunchError,
|
||||
"未出现在 git worktree list",
|
||||
):
|
||||
launch_worker.capture_worktree_identity(
|
||||
project,
|
||||
str(impostor),
|
||||
[str(impostor)],
|
||||
str(other),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user