def test_login(self): userdb = {} dbutil.create_account(userdb, 'abc', 'abc') # Success ret = server.login(userdb, 'abc', 'abc') self.assertEqual(ret, (True, server.E_OK)) # Failure ret = server.login(userdb, 'abc', 'ab') self.assertTrue(ret, (True, server.E_INVALID_PASSWORD)) ret = server.login(userdb, 'a', 'ab') self.assertTrue(ret, (True, server.E_NO_USERNAME))
def delete_user(client_socket, username, address): user_list = get_user_list() data = client_socket.recv(BUFFER_SIZE).decode('utf-8') if data == 'y': del user_list[username] else: return with open('users.txt', 'w') as outfile: json.dump(user_list, outfile) server.login(client_socket, address)
def login(): '''Tries to get a fresh session id from the server by sending password and user_email to it. If a new session is granted (password and user_email match), gui switches to logged-in home view (login/register button hide, logged-in-as shows) ''' password = app.views_dict['login'].get('pw_entry').get() user_email = app.views_dict['login'].get('email_entry').get() with db_conn as cursor: session_id = server.login(cursor, user_email, password) if session_id is not None: app.data['session_id'] = session_id app.views_dict['login'].hide_component('login_failed_label') switch_to_home() #pylint: disable=unbalanced-tuple-unpacking with db_conn as cursor: session_id, user_data = server.query_user_data( cursor, user_email, user_email=user_email, session_id=session_id) app.data['session_id'] = session_id store_user_data(user_data) app.views_dict['main_menu'].unhide_component('logged_in_as_frame') app.views_dict['main_menu'].hide_component('message_frame') app.views_dict['main_menu'].hide_component('login_button') app.views_dict['main_menu'].hide_component('register_button') set_logged_in_as_user_text() clear_login_data() else: app.views_dict['login'].unhide_component('login_failed_label')
def do_login(): pin = request.forms.get('pin') if s.login(pin)["Status"]: redirect(config.WEBROOT + '/') else: return template('login_template', Message='Login incorrect', Web_Root=config.WEBROOT)
def user_login(): """ Render login page and process login requests. """ if request.method == "POST": form = request.form user_name = form["user_name"] password = form["password"] # Login and validate the user. login(user_name, password) return redirect(url_for("main_page")) error = request.args.get("error") return render_template("login.html", error=error)
def create_account(): """ Render register page and process register requests. """ if request.method == "POST": form = request.form user_name = form["user_name"] password = form["password"] # Register and Login the user. create_user(g.session, user_name, password) g.session.commit() login(user_name, password) return redirect(url_for("main_page")) return render_template("register.html")
def sendTestEmail(): try: with open('test.data', 'r') as f: test_data = f.read() google.protobuf.text_format.Merge(test_data, EMAILS_DATA) server = smtplib.SMTP(SMTP_SERVER, 587) server.starttls() server.login(FROM_EMAIL, FROM_PWD) print("Sending " + str(len(EMAILS_DATA.emails)) + " emails to test...") for email in EMAILS_DATA.emails: server.sendmail( FROM_EMAIL, email.to_email, composeEmail(email.subject, email.content, email.to_email)) except Exception as e: print(str(e)) finally: server.quit()
def fuzzing(username, password): """ To be used only for fuzzing sections :return: """ # Connect to database for credentials sql_ip, user, pwd, sql_port = server.db_info() credentials = server.db_connect(sql_ip, user, pwd, sql_port) database = server.db_setup(sql_ip, user, pwd, sql_port, credentials) return server.login(database, username, password)
def create_user(client_socket, address): user_list = get_user_list() password_list = get_passwords() while True: data = client_socket.recv(BUFFER_SIZE).decode('utf-8') name = data.lower() if name == '--': server.authenticate(client_socket, address) if name not in user_list: client_socket.send('pass'.encode('utf-8')) break else: client_socket.send('error'.encode('utf-8')) password = client_socket.recv(BUFFER_SIZE).decode('utf-8') hashed_password = hash_password(password) if not bool(user_list): identifier = 1 else: identifier = max(user_list.values()) + 1 user_list[name] = identifier password_list[name] = hashed_password with open('users.txt', 'w') as outfile: json.dump(user_list, outfile) with open('passwords.txt', 'w') as outfile: json.dump(password_list, outfile) server.login(client_socket, address)
def assertLogin: #this function to work requires user import, how do I test it the? same with the rest assert login() == ""
def youraccount() : #return render_template('login.html') print("endpoint hit") return server.login()