def test_update_password(self): """Update existing user password; return success result.""" new_password = '******' pwd = SpokePwd(self.org_name, self.user_id) expected_result = ['success'] result = pwd.modify(self.user_def_pwd, new_password)['data'] self.assertEquals(result, expected_result)
def setUp(self): """Create test organisation and user.""" org = SpokeOrg() org.create(self.org_name, self.org_children) user = SpokeUser(self.org_name) user.create(self.email_addr, self.first, self.last) pwd = SpokePwd(self.org_name, self.user_id) pwd.create(self.user_def_pwd)
def test_delete_password(self): """Delete user password; return True.""" first = 'test' last = 'deletepassword' user_id = first + last email_addr = user_id + '@' + self.email_dom password = '******' user = SpokeUser(self.org_name) user.create(email_addr, first, last) pwd = SpokePwd(self.org_name, user_id) pwd.create(password) self.assertTrue(pwd.delete, password) user.delete(first, last)
def test_get_with_wrong_password(self): """Verify a bad user password; raise AuthError.""" first = 'test' last = 'getbadpassword' user_id = first + last email_addr = user_id + '@' + self.email_dom password = '******' badpassword = '******' user = SpokeUser(self.org_name) user.create(email_addr, first, last) pwd = SpokePwd(self.org_name, user_id) pwd.create(password) self.assertRaises(error.AuthError, pwd.get, badpassword) user.delete(first, last)
def test_create_password(self): """Create a user password; return success result.""" first = 'test' last = 'createpassword' user_id = first + last email_addr = user_id + '@' + self.email_dom password = '******' user = SpokeUser(self.org_name) user.create(email_addr, first, last) expected_result = ['success'] pwd = SpokePwd(self.org_name, user_id) result = pwd.create(password)['data'] self.assertEquals(result, expected_result) user.delete(first, last)
def test_get_password(self): """Verify a user password; return success result.""" pwd = SpokePwd(self.org_name, self.user_id) expected_result = ['success'] result = pwd.get(self.user_def_pwd)['data'] self.assertEquals(result, expected_result)
def test_create_password_twice(self): """Create a user password twice; raise AlreadyExists.""" pwd = SpokePwd(self.org_name, self.user_id) self.assertRaises(error.AlreadyExists, pwd.create, self.user_def_pwd)
def test_update_password_with_wrong_old_password(self): """Update user password with wrong old password; raise AuthError.""" new_pass = '******' bad_pass = '******' pwd = SpokePwd(self.org_name, self.user_id) self.assertRaises(error.AuthError, pwd.modify, bad_pass, new_pass)