|
|
@ -64,45 +64,46 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
del os.environ['PREHISTORIC_SUDO']
|
|
|
|
del os.environ['PREHISTORIC_SUDO']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NonEnglishPromptTest(testlib.DockerMixin, testlib.TestCase):
|
|
|
|
# TODO: https://github.com/dw/mitogen/issues/694
|
|
|
|
# Only mitogen/debian-test has a properly configured sudo.
|
|
|
|
# class NonEnglishPromptTest(testlib.DockerMixin, testlib.TestCase):
|
|
|
|
mitogen_test_distro = 'debian'
|
|
|
|
# # Only mitogen/debian-test has a properly configured sudo.
|
|
|
|
|
|
|
|
# mitogen_test_distro = 'debian'
|
|
|
|
def test_password_required(self):
|
|
|
|
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# def test_password_required(self):
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
password='has_sudo_password',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
)
|
|
|
|
# password='has_sudo_password',
|
|
|
|
ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
# )
|
|
|
|
ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
# ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
# ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
lambda: self.router.sudo(via=ssh)
|
|
|
|
# e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
)
|
|
|
|
# lambda: self.router.sudo(via=ssh)
|
|
|
|
self.assertTrue(mitogen.sudo.password_required_msg in str(e))
|
|
|
|
# )
|
|
|
|
|
|
|
|
# self.assertTrue(mitogen.sudo.password_required_msg in str(e))
|
|
|
|
def test_password_incorrect(self):
|
|
|
|
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# def test_password_incorrect(self):
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
password='has_sudo_password',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
)
|
|
|
|
# password='has_sudo_password',
|
|
|
|
ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
# )
|
|
|
|
ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
# ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
# ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
lambda: self.router.sudo(via=ssh, password='x')
|
|
|
|
# e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
)
|
|
|
|
# lambda: self.router.sudo(via=ssh, password='x')
|
|
|
|
self.assertTrue(mitogen.sudo.password_incorrect_msg in str(e))
|
|
|
|
# )
|
|
|
|
|
|
|
|
# self.assertTrue(mitogen.sudo.password_incorrect_msg in str(e))
|
|
|
|
def test_password_okay(self):
|
|
|
|
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# def test_password_okay(self):
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
password='has_sudo_password',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
)
|
|
|
|
# password='has_sudo_password',
|
|
|
|
ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
# )
|
|
|
|
ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
# ssh.call(os.putenv, 'LANGUAGE', 'fr')
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
# ssh.call(os.putenv, 'LC_ALL', 'fr_FR.UTF-8')
|
|
|
|
lambda: self.router.sudo(via=ssh, password='rootpassword')
|
|
|
|
# e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
)
|
|
|
|
# lambda: self.router.sudo(via=ssh, password='rootpassword')
|
|
|
|
self.assertTrue(mitogen.sudo.password_incorrect_msg in str(e))
|
|
|
|
# )
|
|
|
|
|
|
|
|
# self.assertTrue(mitogen.sudo.password_incorrect_msg in str(e))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|