Beispiel #1
0
 def test_disable_requiretty_on_sudoers_raises_exception_on_failure(
         self, *args, **kwargs):
     # this will make if fail
     sudo('rm /etc/sudoers')
     with self.assertRaises(SystemExit) as cm:
         os_helpers.disable_requiretty_on_sudoers()
     self.assertEqual(cm.exception.code, 1)
Beispiel #2
0
    def test_disable_requiretty_on_sudoers_updates_sudoers(
            self, *args, **kwargs):
        # distros have different /etc/sudoers file contents, so we will make
        # sure we target the correct contents for each linux distribution.
        os = sudo('cat /etc/os-release').lower()

        sudo('cat /etc/sudoers')

        # we rely on md5sum of the file so check if our changes were applied
        # correctly
        md5sum = sudo('md5sum /etc/sudoers').split(' ')[0]
        if 'ubuntu' in os:
            # our docker image doesn't contain the entry we need so...
            sudo('echo "Defaults    requiretty" >> /etc/sudoers')

            # update /etc/sudoers
            os_helpers.disable_requiretty_on_sudoers()

            self.assertEquals(md5sum, 'e8e73f16ed73309df7574c12fbcc0af7')
        if 'centos' in os:
            sudo('md5sum /etc/sudoers')

            # update /etc/sudoers
            os_helpers.disable_requiretty_on_sudoers()

            sudo('cat /etc/sudoers')
            self.assertEquals(md5sum, 'ef817e657e3ffa6b0a88f59e3fc7241b')
Beispiel #3
0
 def test_disable_requiretty_on_sudoers_raises_exception_on_failure(
         self, *args, **kwargs):
     # this will make if fail
     sudo('rm /etc/sudoers')
     with self.assertRaises(SystemExit) as cm:
         os_helpers.disable_requiretty_on_sudoers()
     self.assertEqual(cm.exception.code, 1)
Beispiel #4
0
    def test_disable_requiretty_on_sudoers_updates_sudoers(self,
                                                           *args,
                                                           **kwargs):
        # distros have different /etc/sudoers file contents, so we will make
        # sure we target the correct contents for each linux distribution.
        os = sudo('cat /etc/os-release').lower()

        sudo('cat /etc/sudoers')

        # we rely on md5sum of the file so check if our changes were applied
        # correctly
        md5sum = sudo('md5sum /etc/sudoers').split(' ')[0]
        if 'ubuntu' in os:
            # our docker image doesn't contain the entry we need so...
            sudo('echo "Defaults    requiretty" >> /etc/sudoers')

            # update /etc/sudoers
            os_helpers.disable_requiretty_on_sudoers()

            self.assertEquals(md5sum,
                              'e8e73f16ed73309df7574c12fbcc0af7')
        if 'centos' in os:
            sudo('md5sum /etc/sudoers')

            # update /etc/sudoers
            os_helpers.disable_requiretty_on_sudoers()

            sudo('cat /etc/sudoers')
            self.assertEquals(md5sum,
                              'ef817e657e3ffa6b0a88f59e3fc7241b')
Beispiel #5
0
 def test_disable_requiretty_on_sudoers_returns_True(self, *args, **kwargs):
     self.assertTrue(os_helpers.disable_requiretty_on_sudoers())
Beispiel #6
0
 def test_disable_requiretty_on_sudoers_returns_True(self, *args, **kwargs):
     self.assertTrue(os_helpers.disable_requiretty_on_sudoers())