|
|
@ -28,37 +28,38 @@ class ConstructorTest(testlib.RouterMixin, testlib.TestCase):
|
|
|
|
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_DOAS'))
|
|
|
|
self.assertEquals('1', context.call(os.getenv, 'THIS_IS_STUB_DOAS'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DoasTest(testlib.DockerMixin, testlib.TestCase):
|
|
|
|
# TODO: https://github.com/dw/mitogen/issues/694 they are flaky on python 2.6 MODE=mitogen DISTRO=centos7
|
|
|
|
# Only mitogen/debian-test has doas.
|
|
|
|
# class DoasTest(testlib.DockerMixin, testlib.TestCase):
|
|
|
|
mitogen_test_distro = 'debian'
|
|
|
|
# # Only mitogen/debian-test has doas.
|
|
|
|
|
|
|
|
# mitogen_test_distro = 'debian'
|
|
|
|
|
|
|
|
|
|
|
|
def test_password_required(self):
|
|
|
|
# def test_password_required(self):
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
password='has_sudo_password',
|
|
|
|
# password='has_sudo_password',
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
# e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
lambda: self.router.doas(via=ssh)
|
|
|
|
# lambda: self.router.doas(via=ssh)
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
self.assertTrue(mitogen.doas.password_required_msg in str(e))
|
|
|
|
# self.assertTrue(mitogen.doas.password_required_msg in str(e))
|
|
|
|
|
|
|
|
|
|
|
|
def test_password_incorrect(self):
|
|
|
|
# def test_password_incorrect(self):
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
password='has_sudo_password',
|
|
|
|
# password='has_sudo_password',
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
# e = self.assertRaises(mitogen.core.StreamError,
|
|
|
|
lambda: self.router.doas(via=ssh, password='x')
|
|
|
|
# lambda: self.router.doas(via=ssh, password='x')
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
self.assertTrue(mitogen.doas.password_incorrect_msg in str(e))
|
|
|
|
# self.assertTrue(mitogen.doas.password_incorrect_msg in str(e))
|
|
|
|
|
|
|
|
|
|
|
|
def test_password_okay(self):
|
|
|
|
# def test_password_okay(self):
|
|
|
|
ssh = self.docker_ssh(
|
|
|
|
# ssh = self.docker_ssh(
|
|
|
|
username='mitogen__has_sudo',
|
|
|
|
# username='mitogen__has_sudo',
|
|
|
|
password='has_sudo_password',
|
|
|
|
# password='has_sudo_password',
|
|
|
|
)
|
|
|
|
# )
|
|
|
|
context = self.router.doas(via=ssh, password='has_sudo_password')
|
|
|
|
# context = self.router.doas(via=ssh, password='has_sudo_password')
|
|
|
|
self.assertEquals(0, context.call(os.getuid))
|
|
|
|
# self.assertEquals(0, context.call(os.getuid))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|