This commit is contained in:
eric
2026-05-19 09:19:52 +00:00
parent 585bcd9500
commit b617555360
30 changed files with 477 additions and 207 deletions

View File

@@ -89,12 +89,22 @@ class VerifyLocalInstallTests(unittest.TestCase):
def fake_docker_exec(container: str, command: str, *, timeout: float = 8.0):
if "supervisorctl status google-chrome" in command:
return 0, "google-chrome RUNNING pid 8", ""
if "NEKO member env invalid" in command:
return 0, "provider=multiuser admin_password=set user_password=set\n", ""
if "/proc/self/mountinfo" in command:
return 0, "/home/neko/.config/chromium\n/home/neko/.config/google-chrome\n", ""
if "Developer mode preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default/Preferences: developer_mode=true\n", ""
if "policies/managed" in command and "-name '*.json'" in command:
return 0, "", ""
if "supervisorctl status tampermonkey-provisioning" in command:
return 0, "tampermonkey-provisioning RUNNING pid 9", ""
if "tampermonkey-provisioning.json" in command:
return 0, "", ""
if "Tampermonkey preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default: state=1 disable_reasons=None\n", ""
if "no standalone youtube extension" in command:
return 0, "no standalone youtube extension\n", ""
if "grep -R -a -l" in command:
return 0, "/home/neko/.config/google-chrome/Default/Local Extension Settings", ""
self.fail(f"unexpected docker exec: {container} {command}")
@@ -128,8 +138,12 @@ class VerifyLocalInstallTests(unittest.TestCase):
"neko_ip_watch_service",
"youtube_pro_neko_capacity",
"neko_1_browser",
"neko_1_multiuser_admin",
"neko_1_persistent_profile",
"neko_1_developer_mode",
"neko_1_personal_policy_mode",
"neko_1_tm_payload",
"neko_1_tm_enabled",
"neko_1_tm_storage",
"android_devices",
"android_screenshot",
@@ -143,12 +157,22 @@ class VerifyLocalInstallTests(unittest.TestCase):
def fake_docker_exec(container: str, command: str, *, timeout: float = 8.0):
if "supervisorctl status google-chrome" in command:
return 0, "google-chrome RUNNING pid 8", ""
if "NEKO member env invalid" in command:
return 0, "provider=multiuser admin_password=set user_password=set\n", ""
if "/proc/self/mountinfo" in command:
return 0, "/home/neko/.config/chromium\n/home/neko/.config/google-chrome\n", ""
if "Developer mode preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default/Preferences: developer_mode=true\n", ""
if "policies/managed" in command and "-name '*.json'" in command:
return 0, "/etc/opt/chrome/policies/managed/policies.json\n", ""
if "supervisorctl status tampermonkey-provisioning" in command:
return 0, "tampermonkey-provisioning RUNNING pid 9", ""
if "tampermonkey-provisioning.json" in command:
return 0, "", ""
if "Tampermonkey preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default: state=1 disable_reasons=None\n", ""
if "no standalone youtube extension" in command:
return 0, "no standalone youtube extension\n", ""
if "grep -R -a -l" in command:
return 1, "", ""
self.fail(f"unexpected docker exec: {container} {command}")
@@ -174,12 +198,22 @@ class VerifyLocalInstallTests(unittest.TestCase):
def fake_docker_exec(container: str, command: str, *, timeout: float = 8.0):
if "supervisorctl status google-chrome" in command:
return 0, "google-chrome RUNNING pid 8", ""
if "NEKO member env invalid" in command:
return 0, "provider=multiuser admin_password=set user_password=set\n", ""
if "/proc/self/mountinfo" in command:
return 0, "/home/neko/.config/chromium\n/home/neko/.config/google-chrome\n", ""
if "Developer mode preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default/Preferences: developer_mode=true\n", ""
if "policies/managed" in command and "-name '*.json'" in command:
return 0, "/etc/opt/chrome/policies/managed/policies.json\n", ""
if "supervisorctl status tampermonkey-provisioning" in command:
return 0, "tampermonkey-provisioning RUNNING pid 9", ""
if "tampermonkey-provisioning.json" in command:
return 0, "", ""
if "Tampermonkey preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default: state=1 disable_reasons=None\n", ""
if "no standalone youtube extension" in command:
return 0, "no standalone youtube extension\n", ""
if "grep -R -a -l" in command:
return 1, "", ""
self.fail(f"unexpected docker exec: {container} {command}")
@@ -197,6 +231,51 @@ class VerifyLocalInstallTests(unittest.TestCase):
self.assertFalse(report["ready"])
self.assertEqual(report["failing_checks"][0]["id"], "neko_1_tm_storage")
def test_neko_tampermonkey_enabled_rejects_unpacked_profile_state(self) -> None:
checks: list[dict[str, object]] = []
def fake_docker_exec(container: str, command: str, *, timeout: float = 8.0):
if "supervisorctl status google-chrome" in command:
return 0, "google-chrome RUNNING pid 8", ""
if "NEKO member env invalid" in command:
return 0, "provider=multiuser admin_password=set user_password=set\n", ""
if "/proc/self/mountinfo" in command:
return 0, "/home/neko/.config/chromium\n/home/neko/.config/google-chrome\n", ""
if "Developer mode preference not found" in command:
return 0, "/home/neko/.config/google-chrome/Default/Preferences: developer_mode=true\n", ""
if "policies/managed" in command and "-name '*.json'" in command:
return 0, "", ""
if "supervisorctl status tampermonkey-provisioning" in command:
return 0, "tampermonkey-provisioning RUNNING pid 9", ""
if "tampermonkey-provisioning.json" in command:
return 0, "", ""
if "Tampermonkey preference not found" in command:
return (
1,
"/home/neko/.config/google-chrome/Default: "
"state=1 disable_reasons=None from_webstore=False "
"location=8 path=/etc/neko/tampermonkey-seed/Default/Extensions/dhdgffkkebhmkfjojejmpbldmpobfkfo/5.5.0_0\n",
"",
)
if "no standalone youtube extension" in command:
return 0, "no standalone youtube extension\n", ""
if "grep -R -a -l" in command:
return 0, "/home/neko/.config/google-chrome/Default/Local Extension Settings", ""
self.fail(f"unexpected docker exec: {container} {command}")
with patch.object(verify_local_install, "docker_ps_names", return_value=(True, ["live-neko-1", "live-neko-2"], "")):
with patch.object(verify_local_install, "systemd_active", return_value=(True, "active")):
with patch.object(verify_local_install, "docker_exec", side_effect=fake_docker_exec):
verify_local_install.verify_neko(
checks,
{"ENABLE_NEKO": "1", "NEKO_INSTANCE_COUNT": "2", "NEKO_MANAGED_POLICIES": "0"},
timeout=5.0,
)
report = verify_local_install.summarize(checks)
self.assertFalse(report["ready"])
self.assertEqual(report["failing_checks"][0]["id"], "neko_1_tm_enabled")
def test_android_endpoint_without_devices_is_not_a_required_install_failure(self) -> None:
checks: list[dict[str, object]] = []
with patch.object(