def testGetSudoContextNoSudo(self): self._SudoContextHelper() self.mox.ReplayAll() sudo, sudo_pass = certs._GetSudoContext('notsystemkeychain') self.mox.VerifyAll() self.assertFalse(sudo) self.assertEqual(sudo_pass, None)
def testGetSudoContextWithoutCertHandler(self): self._SudoContextHelper() self.mox.StubOutWithMock(certs.getauth, 'GetPassword') certs.getauth.GetPassword(gui=True).AndReturn('pass') self.mox.ReplayAll() sudo, sudo_pass = certs._GetSudoContext(self.keychain, gui=True) self.mox.VerifyAll() self.assertTrue(sudo) self.assertEqual(sudo_pass, 'pass')
def testGetSudoContextWithCertHandler(self): self._SudoContextHelper() self.mox.StubOutWithMock(certs.gmacpyutil, 'RunProcess') certs.gmacpyutil.RunProcess( ['-v'], sudo=True, sudo_password=self.password).AndReturn(['', '', 0]) self.mox.ReplayAll() sudo, sudo_pass = certs._GetSudoContext(self.keychain, gui=True, password=self.password) self.mox.VerifyAll() self.assertTrue(sudo) self.assertEqual(sudo_pass, 'hunter2')