def test_authentication(self): "Confirm Account authentication method is authenticating/denying users." # Valid credentials obj, errors = DefaultAccount.authenticate(self.account.name, self.password) self.assertTrue(obj, 'Account did not authenticate given valid credentials.') # Invalid credentials obj, errors = DefaultAccount.authenticate(self.account.name, 'xyzzy') self.assertFalse(obj, 'Account authenticated using invalid credentials.')
def test_throttle(self): "Confirm throttle activates on too many failures." for x in range(20): obj, errors = DefaultAccount.authenticate(self.account.name, 'xyzzy', ip='12.24.36.48') self.assertFalse(obj, 'Authentication was provided a bogus password; this should NOT have returned an account!') self.assertTrue('too many login failures' in errors[-1].lower(), 'Failed logins should have been throttled.')