def test_register(self): sql_manager.register('Dinko', 'asdaFGG45g*&') sql_manager.cursor.execute('SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)', ('Dinko', 'asdaFGG45g*&')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): sql_manager.register('Dinko', '123123') hashed_password = sql_manager.hash_password('123123') sql_manager.cursor.execute('SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)', ('Dinko', hashed_password)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): sql_manager.register('Dinko', '123123', "*****@*****.**") sql_manager.cursor.execute('''SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)''', ('Dinko', '123123')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def setUp(self): sql_manager.create_clients_table() sql_manager.register('Tester', '123qwe@AS') sql_manager.register('Tester_1', '1234Tester_1') sql_manager.register('Tester_3', '12345678Qw') sql_manager.register('Tester_2', '12345678@') sql_manager.register('Tester_4', 'qweqweqwe@')
def test_register(self): sql_manager.register('Dinko', STRONG_PASSWORD2) sql_manager.cursor.execute('SELECT Count(*) FROM clients WHERE username = (?)', ('Dinko',)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def start(self): print(messages.WELCOME_MSG) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your username: "******"Enter your password: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', '123123', "*****@*****.**") sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)''', ('Dinko', '123123')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): sql_manager.register('Dinko', '123123', "*****@*****.**") sql_manager.cursor.execute( 'SELECT Count(*) FROM clients WHERE username = (?)', ('Dinko', )) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def register(): username = input("Enter your username: "******"Enter your password: "******"Registration siccessfull" except StrongPasswordException as e: print(e)
def test_change_password_with_sql_injection(self): sql_manager.register('Dinko', STRONG_PASSWORD1) sql_manager.register('Vladko', STRONG_PASSWORD2) logged_user = sql_manager.login('Dinko', STRONG_PASSWORD1) new_password = "******" sql_manager.change_pass(new_password, logged_user) self.assertFalse(sql_manager.login('Vladko', "1234Asdf$$$Asdf"))
def test_register(self): sql_manager.register('Dinko', '$$$$Dim_4o') sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = ? AND password = ?''', ('Dinko', '$$$$Dim_4o')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register_with_username_not_including_upper_lower_digit_special(self): sql_manager.register('Dinko', 'palachinkooooo!!!') sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = ? AND password = ?''', ('Dinko', 'Dinko_23Lopatata$!!!')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 0)
def main_menu(): failed_log_users = [1] fail_log_counter = 0 wrong_pass_limit = 5 block_message = "you have 5 wrong password inputs\ \n and you`re blocked for 5 minutes" print("Welcome to our bank service. You are not logged in.\ \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your emal: ") sql_manager.register(username, hashed_pass, email) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', 'asdaFGG45g*&') sql_manager.cursor.execute( 'SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)', ('Dinko', 'asdaFGG45g*&')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_hash(self): username = '******' password = '******' sql_manager.register(username, password) sql_manager.cursor.execute("SELECT Count(*) FROM clients\ WHERE username = ? AND password = ?", (username, password)) self.assertEqual(0, sql_manager.cursor.fetchone()[0])
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") command_array = command.split(" ") if command == 'register': username = input("Enter your username: "******"Your Pasword is to short, it must be 8 symbols") elif not have_upper_letters(password): print("Your password must have upper letters") elif not number_function(password): print("Your password must have numbers") elif not have_special(password): print("It must have special symbols") elif username in password: print("Don`t use your name in your password") else: sql_manager.register(username, sql_manager.get_crypted(password), email) break print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(" ") if command[0] == 'register': username = input("Enter your username: "******"Enter your password: "******"Password is not strong enough!") password = getpass.getpass("Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) print("Registration Successfull") elif command[0] == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command[0] == "reset-password" and len(command) >1: reset_hash = hashlib.sha1(str(random.random()).encode()).hexdigest() sql_manager.update_reset_hash(command[1], reset_hash) send_email.send_email(sql_manager.get_email(command[1]), reset_hash) print(command[1]) elif command[0] == "send-reset-password" and len(command) > 1: reset_hash = input("Enter reset hash: ") if reset_hash == sql_manager.get_reset_hash(command[1]): logged_user = sql_manager.login_with_hash(command[1], reset_hash) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command[0] == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") print("reset-password <name> - to reset password") print("send-reset-password <name> - to enter reset password") elif command[0] == 'exit': break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', '123123', '*****@*****.**',) sql_manager.cursor.execute( 'SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)', ('Dinko', '123123') ) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): sql_manager.register('Dinko', '*****@*****.**', 'abAB12*&') sql_manager.cursor.execute('''select Count(*) from clients where username = (?) and password = (?)''', ('Dinko', sha1('abAB12*&'.encode('utf-8')).digest())) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def register(username, password, email): if password_handler.check_password(password) is True: password = password_handler._generate_hash_pw(password, "sha1") try: sql_manager.register(username, password, email) except Exception: print("Username already exists.") return print("Registration successful.") else: print("Your password sucks. Think of a better one and try again to register.")
def test_register(self): sql_manager.register('Dinko', '123123') gen_salt = sql_manager.generate_salt() sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = (?) AND password = (?) AND salt = (?)''', ('Dinko', '123123', gen_salt)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def main_menu(): while True: print('''Welcome to our bank service system! You have the following options: 1. Register 2. Log in 3. Help 4. Exit ''') choice = int(input("Input your choice: ")) if choice == 1: username = input("Enter your username: "******"Enter your password: "******"Password must contain 1 uppercase and lowercase letter at\ least and one special symbol and must\ differ from username") password = getpass.getpass("Enter your password: "******"Verify password: "******"Registration Successfull") else: print("Password mismatch. Try again") elif choice == 2: username = input("Enter your username: "******"Enter your password: "******"Login failed") elif choice == 3: os.system("clear") print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif choice == 4: break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', '123121233Aa@') sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = ? AND password = ?''', ('Dinko', hashlib.md5('123121233Aa@'.encode()).hexdigest())) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): username = '******' password = '******' hashed_pass = sql_manager.hash_function(password) sql_manager.register(username, password) sql_manager.cursor.execute('SELECT Count(*) FROM clients\ WHERE username = (?) AND password = (?)', (username, hashed_pass)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def register(): username = input("Enter your username: "******"Registration Successfull") else: print(is_valid)
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") command_array = command.split(" ") if command == 'register': username = input("Enter your username: "******"Your Pasword is to short, it must be 8 symbols") elif not have_upper_letters(password): print("Your password must have upper letters") elif not number_function(password): print("Your password must have numbers") elif not have_special(password): print("It must have special symbols") elif username in password: print("Don`t use your name in your password") else: sql_manager.register(username, sql_manager.get_crypted(password), email) break print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', '123aB#23123', '*****@*****.**') m = hashlib.sha1() passw = '123aB#23123' m.update(passw.encode('utf-8')) passw = m.hexdigest() sql_manager.cursor.execute('''SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)''', ('Dinko', passw)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def test_register(self): sql_manager.register( 'Dinko', '123123', '*****@*****.**', ) sql_manager.cursor.execute( 'SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)', ('Dinko', '123123')) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def main_menu(conn, cursor): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter a username: "******"Enter a password: "******"Enter a password again: ") print("WEAK password") sql_manager.register(conn, cursor, username, password) print("Registration Successfull") elif command == 'login': count_wrong_input = 0 username = input("Enter your username: "******"" while not sql_manager.login(conn, cursor, username, password): password = getpass.getpass(prompt="Enter your password: "******"You entered wrong password 5 times!") boom = 30 while boom >= 0: time.sleep(1) print("You can enter you password again after:{}sec". format(boom), end='\r') boom -= 1 count_wrong_input = 0 logged_user = sql_manager.login(conn, cursor, username, password) if logged_user: logged_menu(conn, cursor, logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register(self): sql_manager.register('Dinko', '123aB#23123', '*****@*****.**') m = hashlib.sha1() passw = '123aB#23123' m.update(passw.encode('utf-8')) passw = m.hexdigest() sql_manager.cursor.execute( '''SELECT Count(*) FROM clients WHERE username = (?) AND password = (?)''', ('Dinko', passw)) users_count = sql_manager.cursor.fetchone() self.assertEqual(users_count[0], 1)
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"pass must\n-be more than 8 characters\n -must have capital letters and numbers and a special symbol\n -not containing the username" ) sql_manager.register(username, password) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password <username>") print("Reset-password <username>") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in.") print("Please register or login") while True: command = input("$$$>") if command == "register": username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) elif command == "login": username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == "send-reset-password": username = input("Enter your username: "******"reset-password": username = input("Enter your username: "******"Enter the hash code from your email: ") sql_manager.reset_password(username, hash) elif command == "help": print("login - for logging in!") print("register - for creating new account!") print("send-reset-password - to send a " "password reset code to your email!") print( "reset-password - to reset your password using a " "code from your email, to get it use the command above!" ) print("exit - for closing the program!") elif command == "exit": break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in.") print("Please register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") sql_manager.register(username, password, email) elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'send-reset-password': username = input("Enter your username: "******"Enter your username: "******"Enter the hash code from your email: ") sql_manager.reset_password(username, hash) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("send-reset-password - to send a " \ "password reset code to your email!") print("reset-password - to reset your password using a " \ "code from your email, to get it use the command above!") print("exit - for closing the program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': result = print_username_password() username = result['username'] password = result['password'] inp = sql_manager.register(username, password) if inp: print("Registration Successfull") else: print(inp['reason']) elif command == 'login': result = print_username_password() username = result['username'] password = result['password'] logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command == 'help': print_help() elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': result = print_username_password() username = result['username'] password = result['password'] inp = sql_manager.register(username, password) if inp == True: print("Registration Successfull") else: print(inp['reason']) elif command == 'login': result = print_username_password() username = result['username'] password = result['password'] logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command == 'help': print_help() elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(" ") if command[0] == "register": username = input("Enter your username: "******"stty -echo") password = input("Enter your password: "******"stty echo") email = input("Enter your email address: ") print(sql_manager.register(username, password, email)) elif command[0] == "login": username = input("Enter your username: "******"stty -echo") password = input("Enter your password: "******"stty echo") logged_user = sql_manager.login(username, password) if logged_user: logged_menu(logged_user) else: print("Login failed") elif command[0] == "reset-password": if not sql_manager.check_if_username_exists(command[1]): print("Invalid username/password.") else: sql_manager.clear_login_attempts(command[1]) sql_manager.send_reset_password(command[1]) correct = False while correct is False: probable_hash = input("Please enter the code you have received in the email: ") if sql_manager.check_if_hashes_match(command[1], probable_hash): correct = True sql_manager.login(command[1], probable_hash) os.system("stty -echo") new_password = input("Please enter your new password: "******"stty echo") while sql_manager.check_password_strength(command[1], new_password) is False: os.system("stty -echo") new_password = input("Please enter a valid password: "******"stty echo") sql_manager.change_pass(new_password, command[1]) elif command[0] == "help": print("help - for displaying this message!") print("login - for logging in!") print("register - for creating new account!") print("reset-password <username> - for resetting forgotten password!") print("exit - for closing program!") elif command == "exit": break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"pass must\n-be more than 8 characters\n -must have capital letters and numbers and a special symbol\n -not containing the username") sql_manager.register(username, password) print("Registration Successfull") elif command == 'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password <username>") print("Reset-password <username>") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(conn, cursor): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter a username: "******"Enter a password: "******"Enter a password again: ") print("WEAK password") sql_manager.register(conn, cursor, username, password) print("Registration Successfull") elif command == 'login': count_wrong_input = 0 username = input("Enter your username: "******"" while not sql_manager.login(conn, cursor, username, password): password = getpass.getpass(prompt="Enter your password: "******"You entered wrong password 5 times!") boom = 30 while boom >= 0: time.sleep(1) print("You can enter you password again after:{}sec".format(boom), end='\r') boom -= 1 count_wrong_input = 0 logged_user = sql_manager.login(conn, cursor, username, password) if logged_user: logged_menu(conn, cursor, logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): faillogin = 0 print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) counter = 0 while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") except Exception as e: print(e) print('Registration failed') elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") if counter % 5 == 0: print('Are you trying to bruteforce?\nSleep now :)') time.sleep(60 * (5**counter / 5)) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>").split(' ') if command[0] == 'register': username = input("Enter your username: "******"Enter your email: ") password = getpass.getpass(prompt='Password: '******'login': username = input("Enter your username: "******"login - for logging in!") print("register - for creating new account!") print("send-reset-password [username] - for resetting password!") print("exit - for closing program!") elif command[0] == 'exit': break else: print("Not a valid command")
def register(): username = input("Enter your username: "******"Enter your email address: ") registration_succesfull = sql_manager.register(username, password, email) if registration_succesfull: print("Registration Successfull") else: print("Registration failed")
def main_menu(): global counter print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Password must contain at least one number, one uppercase and lowercase letter and a total length of at least six symbols!" ) return main_menu() print("Registration Successful") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"User and password dont match!") return main_menu() if logged_user: counter = 0 logged_menu(logged_user) else: print("Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): faillogin = 0 print("Welcome to our bank service. You are not logged in. \nPlease register or login") while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print('\n'.join(["Welcome to our bank service. You are not logged in.", "Please register or login"])) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your email: ") password = getpass("Enter your password: "******"Password should contain an upper and", "a lowercase letter, a digit and a symbol"])) password = getpass("Enter your password: "******"Registration Successfull") elif command == "send-reset-password": username = input("Enter your username: "******"Enter your username: "******"Enter key: ") if not reset_password(username, key): print("Wrong key entered!") else: print('\n'.join(["Password set to aaAA11**", "Please change your password now!"])) elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed", "Maybe you'd entered wrong password more than 5 times?", "If so, you've been blocked for 5 minutes.."])) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") except StrongPasswordException as e: print(e) elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"the password must be more than 8 symbols and the username is not in the password" ) password = input("Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull!") else: print('Bad password!') elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def handle_registration(): while True: username = input("Enter your username: "******"Enter your password: "******"Username must have more than 8 symbols!") continue """elif username.hasCapital(): print("Username must have CAPITAL letters!") continue elif username.hasNumbers(): print("Username must have NUMBERS!") continue elif password.isSubstringOf(username): print("Username must NOT contain password as a substring!") continue else: break""" sql_manager.register(username, password) print("Registration Successfull")
def main_menu(): print( "Welcome to our bank service. You are not logged in. \nPlease register or login" ) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Registration Successfull") elif command == 'login': username = input("Enter your username: "******"Enter your password: "******"Login failed") elif command == 'reset-password': recepient = input("username> ") sql_manager.send_email(recepient) elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register(self): # prompts for a stronger password # sql_manager.register("user2", "stupidpass") self.assertEqual(True, sql_manager.register("user2", "Tu6^^^pass2")) conn = sqlite3.connect("bank.db") cursor = conn.cursor() select_query = "SELECT id, username, password FROM clients WHERE \ username = ? AND password = ? LIMIT 1" cursor.execute(select_query, ("user2", sql_manager.hash_pass("Tu6^^^pass2"))) user = cursor.fetchone() self.assertEqual("user2", user[1]) self.assertEqual(sql_manager.hash_pass("Tu6^^^pass2"), user[2])
def main_menu(): print("Welcome to our bank service. You are not logged in. \nPlease register or login") datetime_fail = datetime.datetime(1900, 1, 1, 0, 0, 0) while True: command = input("$$$>") if command == 'register': username = input("Enter your username: "******"Enter your password: "******"Enter your email: ") if sql_manager.check_pass(username, password): sql_manager.register(username, hashed_pass, email) print("Registration Successfull") else: print("Registration failed") elif command == 'login': username = input("Enter your username: "******"0:05:00": print("Please try again later.") failed_logins = 0 sql_manager.update_number_of_failed_logins(failed_logins, username) else: if failed_logins < 5: password = getpass.getpass("Enter your password: "******"Login failed") failed_logins += 1 sql_manager.update_number_of_failed_logins(failed_logins, username) else: datetime_fail = menu_functions.current_time() sql_manager.update_failed_datetime(datetime_fail, username) print("You can not login for the next 5 minutes.") elif 'send-reset-password' in command: username = command.split(" ")[1] user_email = sql_manager.get_user_email(username) if user_email is not None: unique_random = str(uuid.uuid4()) sql_manager.update_reset_code(username, unique_random) menu_functions.send_email(user_email, unique_random) else: print("Wrong username or bad input!") elif 'send-reset-password' not in command and "reset-password" in command: username = command.split(" ")[1] hash_code = input("Enter the hash code we sent you: ") if sql_manager.check_hash_code(username, hash_code): new_password = getpass.getpass("Enter your password: "******"Password was reset successfully.") else: print("The hash code you entered is invalid.") elif command == 'help': print("login - for logging in!") print("register - for creating new account!") print("exit - for closing program!") elif command == 'exit': break else: print("Not a valid command")
def test_register_short_password(self): self.assertFalse( sql_manager.register('adad', '123', '*****@*****.**'))
def setUp(self): sql_manager.create_clients_table() sql_manager.register('Tester', '123Ab#78', '*****@*****.**')
def setUp(self): sql_manager.create_database() sql_manager.register('Tester', STRONG_PASSWORD1)
def setUp(self): sql_manager.create_clients_table() sql_manager.register('Tester', '123')