def setUpTestData(cls): for i in range(6): username = '******' + str(i) password = '******' + str(i) login.create_user(username=username, password=password) return
def setUpTestData(cls): for i in range(5): username = '******' + str(i) password = '******' + str(i) login.create_user(username=username, password=password) WordPrompt.objects.create(word='apple', word_class='noun', category='food', active=True) WordPrompt.objects.create(word='banana', word_class='noun', category='food', active=True) WordPrompt.objects.create(word='orange', word_class='noun', category='food', active=True) WordPrompt.objects.create(word='avocado', word_class='noun', category='food', active=True) WordPrompt.objects.create(word='grapes', word_class='noun', category='food', active=True) WordPrompt.objects.create(word='watermelon', word_class='noun', category='food', active=True)
def new_user(): """Screen for new users""" print "Welcome New User!" username = '' email = '' email_check = 1 username_check = 1 name = raw_input("Please enter your name: ") while email_check != 0: email = raw_input("Please enter your email address: ") email_check = login.check_email(email) if email_check == 1: print "Email Address is in use. You already have an account!" while username_check != 0: username = raw_input("Please enter your username: "******"Username is in use. Please select another!" password = getpass.getpass("Please enter your password: "******"There was an error! Please try again." home_screen()
def testLogin(self): # Make a few users first usernames = [] passwords = [] for i in range(5): username = '******' + str(i) password = '******' + str(i) usernames.append(username) passwords.append(password) login.create_user(username=username, password=password) # Try loggin them in for i in range(5): username = usernames[i] password = passwords[i] # Try logging in with incorrect or empty password self.assertRaises(RemoteException, login.login, username=username, password='******') self.assertRaises(RemoteException, login.login, username=username, password=None) user_view = login.login(username=username, password=password) user = User.objects.get(name=username) self.assertEqual(user_view.username, user.name) self.assertEqual(user_view.user_id, user.obfuscated_id) # Try logging in with login token self.assertRaises(login.token_login, user_id=user_view.user_id-1, login_token=(user_view.login_token + '123')) self.assertRaises(login.token_login, user_id=user_view.user_id, login_token=(user_view.login_token + '123')) self.assertRaises(login.token_login, user_id=user_view.user_id-1, login_token=user_view.login_token) user_view_2 = login.token_login(user_id=user_view.user_id, login_token=user_view.login_token) self.assertEqual(user_view_2.username, user.name) self.assertEqual(user_view_2.user_id, user.obfuscated_id) # Auth token should be different but login token should be the same self.assertEqual(user_view.login_token, user_view_2.login_token) self.assertNotEqual(user_view.auth_token, user_view_2.auth_token)
def testChangePassword(self): # Make a few users first usernames = [] passwords = [] for i in range(3): username = '******' + str(i) password = '******' + str(i) usernames.append(username) passwords.append(password) login.create_user(username=username, password=password) # Try loggin them in for i in range(3): username = usernames[i] password = passwords[i] new_password = '******' + str(i) # Login first user_view_1 = login.login(username=username, password=password) # Change their password self.assertRaises(RemoteException, login.update_password, user_id=user_view_1.user_id, old_password='******', new_password=new_password) self.assertRaises(RemoteException, login.update_password, user_id=user_view_1.user_id, old_password=None, new_password=new_password) login.update_password(user_id=user_view_1.user_id, old_password=password, new_password=new_password) # Login with new pw (old pw doesnt work) self.assertRaises(RemoteException, login.login, username=username, password=password) user_view_2 = login.login(username=username, password=new_password) # Login token and auth token is different self.assertNotEqual(user_view_1.login_token, user_view_2.login_token) self.assertNotEqual(user_view_1.auth_token, user_view_2.auth_token)
def testCreateUser(self): # Make a few users to test making for i in range(5): username = '******' + str(i) password = '******' + str(i) user_view = login.create_user(username=username, password=password) user = User.objects.get(name=username) self.assertEqual(user_view.username, user.name) self.assertEqual(user_view.user_id, user.obfuscated_id) # Test duplicate create user failing self.assertRaises(RemoteException, login.create_user, username='******', password='******')
def main(name=None): try: print '''Welcome to the plog - personal blogging assistant''' ch = raw_input("Login(y|n) : ") if ch == 'y': cur_user = login.check_login() action(cur_user) else: if login.create_user() == False: print "user creation failed" sys.exit(0) cur_user = login.check_login() action(cur_user) except: print sys.exc_info()[0] print "logging out system...bye " sys.exit(0)
def setUpTestData(cls): username = '******' password = '******' login.create_user(username=username, password=password) WordPrompt.objects.create(word='apple', word_class='noun', category='food', active=True)
def setUpTestData(cls): username = '******' password = '******' login.create_user(username=username, password=password)
break except error.PasswordIncorrect: # If the password is incorrect, not login print('Password wrong.') except error.UserNotFound: # If the user is not registered, not login print('Username not found.') elif choice == '2': # Sign up. # Create a new user account print('Creating a new user account:') login.create_user() # Let the user login with that user account. print('Now log in with your new account:') try: # Try logging in username, mail = login.verify_user() print('Signed in successfully.') break except error.PasswordIncorrect: # If the password is incorrect, not login print('Password wrong.') except error.UserNotFound: # If the user is not registered, not login