def test_authenticateWithUsernameAndPassword_bad_user(self): """ `False` is returned when a bad user is provided. """ result, token = system_users.authenticateWithUsernameAndPassword( username=mk.string(), password=mk.string()) self.assertFalse(result) self.assertIsNone(token)
def test_authenticateWithUsernameAndPassword_bad_password(self): """ `False` is returned when a bad password is provided. """ result, token = system_users.authenticateWithUsernameAndPassword( username=TEST_ACCOUNT_USERNAME_DOMAIN, password=mk.string()) self.assertFalse(result) self.assertIsNone(token)
def test_authenticateWithUsernameAndPassword_bad_user(self): """ Check authentication for bad password. This is slow since the OS adds a timeout or checks for various PAM modules. """ result, token = system_users.authenticateWithUsernameAndPassword( username=mk.string(), password=mk.string()) self.assertFalse(result) self.assertIsNone(token)
def test_authenticateWithUsernameAndPassword_bad_password(self): """ authenticateWithUsernameAndPassword will return False if credentials are not valid. """ result, token = system_users.authenticateWithUsernameAndPassword( username=TEST_ACCOUNT_USERNAME, password=mk.string(), ) self.assertFalse(result) self.assertIsNone(token)
def _getToken(self): """ Generate the Windows token for `user`. """ result, token = system_users.authenticateWithUsernameAndPassword( username=self.upn, password=self.password) if not result: message = u'Failed to get a valid token for "%s" with "%s".' % ( self.upn, self.password) raise AssertionError(message.encode('utf-8')) return token
def test_authenticateWithUsernameAndPassword_good(self): """ Check successful call to authenticateWithUsernameAndPassword. """ result, token = system_users.authenticateWithUsernameAndPassword( username=TEST_ACCOUNT_USERNAME, password=TEST_ACCOUNT_PASSWORD, ) if self.os_name in ['osx']: self.assertIsNone(result) else: self.assertTrue(result) if self.os_family != 'nt': self.assertIsNone(token) else: self.assertIsNotNone(token)
def test_authenticateWithUsernameAndPassword_centrify(self): """ Test username and password authentication using Centrify. Centrify client is only installed on SLES-11-x64. """ # FIXME:1265: # The Centrify server was accidentally removed. We wait for it # to be reinstalled and re-enabled this test. raise self.skipTest() if 'sles-11-x64' not in self.getHostname(): raise self.skipTest() result, token = system_users.authenticateWithUsernameAndPassword( username=TEST_ACCOUNT_CENTRIFY_USERNAME, password=TEST_ACCOUNT_CENTRIFY_PASSWORD, ) self.assertIsTrue(result) self.assertIsNone(token)
def test_authenticateWithUsernameAndPassword_good(self): """ Return `True` when username and passwords are valid, together with a token that can be used for impersonating the account. """ result, token = system_users.authenticateWithUsernameAndPassword( username=TEST_ACCOUNT_USERNAME_DOMAIN, password=TEST_ACCOUNT_PASSWORD_DOMAIN, ) self.assertIsTrue(result) self.assertIsNotNone(token) with system_users.executeAsUser( username=TEST_ACCOUNT_USERNAME_DOMAIN, token=token): self.assertEqual( TEST_ACCOUNT_USERNAME_DOMAIN, system_users.getCurrentUserName(), )