| | @@ -57,6 +57,36 @@ class LifecycleTests(unittest.TestCase): |
| 57 | 57 | env=env, check=True) |
| 58 | 58 | self.assertEqual(len(log.read_text().splitlines()), count) |
| 59 | 59 | |
| 60 | +추가: def test_prerm_restores_only_on_remove_for_known_user(self): |
| 61 | +추가: commands = self.directory / "bin" |
| 62 | +추가: commands.mkdir() |
| 63 | +추가: log = self.directory / "calls" |
| 64 | +추가: for name, content in { |
| 65 | +추가: "getent": '#!/bin/sh\nprintf "tester:x:1000:1000::%s:/bin/sh\\n" "$TEST_HOME"\n', |
| 66 | +추가: "runuser": '#!/bin/sh\nprintf "%s\\n" "$*" >> "$TEST_LOG"\n', |
| 67 | +추가: }.items(): |
| 68 | +추가: executable = commands / name |
| 69 | +추가: executable.write_text(content) |
| 70 | +추가: executable.chmod(0o755) |
| 71 | +추가: env = {**os.environ, "PATH": str(commands) + os.pathsep + os.environ["PATH"], |
| 72 | +추가: "SUDO_USER": "tester", "TEST_HOME": str(self.directory), "TEST_LOG": str(log)} |
| 73 | +추가: for action, count in (("upgrade", 0), ("failed-upgrade", 0), ("remove", 1)): |
| 74 | +추가: with self.subTest(action=action): |
| 75 | +추가: log.write_text("") |
| 76 | +추가: subprocess.run(["sh", str(ROOT / "packaging/ubuntu/rust/prerm"), action], |
| 77 | +추가: env=env, check=True, capture_output=True) |
| 78 | +추가: calls = log.read_text().splitlines() |
| 79 | +추가: self.assertEqual(len(calls), count) |
| 80 | +추가: if count: |
| 81 | +추가: self.assertIn("HOME=" + str(self.directory), calls[0]) |
| 82 | +추가: self.assertTrue(calls[0].endswith("/usr/lib/zipelo/default-apps remove")) |
| 83 | +추가: env.pop("SUDO_USER") |
| 84 | +추가: log.write_text("") |
| 85 | +추가: result = subprocess.run(["sh", str(ROOT / "packaging/ubuntu/rust/prerm"), "remove"], |
| 86 | +추가: env=env, check=True, capture_output=True, text=True) |
| 87 | +추가: self.assertEqual(log.read_text(), "") |
| 88 | +추가: self.assertIn("사용자를 확인할 수 없어", result.stdout) |
| 89 | +추가: |
| 60 | 90 | def check_smoke(self, install_fails=False, purge_fails=False, body_fails=False): |
| 61 | 91 | calls = [] |
| 62 | 92 | |