mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-17 09:44:01 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
36
tests/test_skill_runtime_restricted_fs_permissions.py
Normal file
36
tests/test_skill_runtime_restricted_fs_permissions.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from oclaw.tools.skills_runtime.subprocess_exec import run_skill_runtime_entry
|
||||
|
||||
|
||||
class SkillRuntimeRestrictedFsPermissionTests(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self._tmp = tempfile.TemporaryDirectory(ignore_cleanup_errors=True)
|
||||
self.skill_dir = Path(self._tmp.name) / "skill"
|
||||
self.skill_dir.mkdir(parents=True, exist_ok=True)
|
||||
(self.skill_dir / "scripts").mkdir(parents=True, exist_ok=True)
|
||||
(self.skill_dir / "scripts" / "ok.py").write_text("print('{\"ok\": true}')\n", encoding="utf-8")
|
||||
|
||||
def tearDown(self) -> None:
|
||||
self._tmp.cleanup()
|
||||
|
||||
def test_fs_write_disabled_blocks_output_path(self) -> None:
|
||||
res = run_skill_runtime_entry(
|
||||
skill_name="demo",
|
||||
skill_dir=str(self.skill_dir),
|
||||
runtime={"type": "python", "entry": "scripts/ok.py", "permissions": {"fs_write": False}},
|
||||
args={"output_path": "out.txt"},
|
||||
)
|
||||
self.assertFalse(res.get("ok"))
|
||||
self.assertEqual(str(res.get("error_code")), "path_restricted")
|
||||
self.assertIn("fs_write_disabled", str(res.get("error") or ""))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue