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