def test_check_owner_linux(self): self.assertTrue(filesystem.check_owner(self.probe_path)) import os as std_os # pylint: disable=os-module-forbidden uid = std_os.getuid() with mock.patch('os.getuid') as mock_uid: mock_uid.return_value = uid + 1 self.assertFalse(filesystem.check_owner(self.probe_path))
def test_check_owner_windows(self): self.assertTrue(filesystem.check_owner(self.probe_path)) system = win32security.ConvertStringSidToSid(SYSTEM_SID) security = win32security.SECURITY_ATTRIBUTES().SECURITY_DESCRIPTOR security.SetSecurityDescriptorOwner(system, False) with mock.patch('win32security.GetFileSecurity') as mock_get: mock_get.return_value = security self.assertFalse(filesystem.check_owner(self.probe_path))
def test_check_owner_linux(self): self.assertTrue(filesystem.check_owner(self.probe_path)) import os as std_os # pylint: disable=os-module-forbidden # See related inline comment in certbot.compat.filesystem.check_owner method # that explains why MyPy/PyLint check disable is needed here. uid = std_os.getuid() with mock.patch('os.getuid') as mock_uid: mock_uid.return_value = uid + 1 self.assertFalse(filesystem.check_owner(self.probe_path))