Пример #1
0
 def test_setting_groups(self):
     expected_output = subprocess.Popen(
         ["sudo", "-u", "#" + os.environ["SUDO_UID"], "id"],
         stdout=subprocess.PIPE).communicate()[0]
     sh = shell.Shell({})
     sh.job_controller.shell_to_foreground()
     write_fh, read_fh = shell_test.make_fh_pair()
     sh.run_command("id", {1: write_fh, 2: write_fh})
     self.assertEquals(read_fh.read(), expected_output)
Пример #2
0
 def test_sudo_command(self):
     sh = shell.Shell({})
     sh.job_controller.shell_to_foreground()
     write_fh, read_fh = shell_test.make_fh_pair()
     sh.run_command("sudo id -u", {1: write_fh, 2: write_fh})
     self.assertEquals(read_fh.read(), "0\n")
Пример #3
0
 def test_normal_command(self):
     sh = shell.Shell({})
     sh.job_controller.shell_to_foreground()
     write_fh, read_fh = shell_test.make_fh_pair()
     sh.run_command("id -u", {1: write_fh, 2: write_fh})
     self.assertEquals(read_fh.read(), os.environ["SUDO_UID"] + "\n")