How to use login_options method in molecule

Best Python code snippet using molecule_python

Main.py

Source:Main.py Github

copy

Full Screen

1import random2from unittest.main import main3class User:4 def __init__(self, email, password, confirmPassword):5 self.email = email6 self.password = password7 self.confirmPassword = confirmPassword8 9 users = []10 def createUser(email, password, confirmPassword):11 """12 This method creates a new user13 """14 newUser = User(email, password, confirmPassword)15 return newUser16 17 def saveUser(email, password):18 """19 This method saves user20 """21 newUser=[email, password]22 User.users.append(newUser)23 24 def loginMessage():25 """26 This method diplays to user upon successful login27 """28 print("Login successful")29 30 @classmethod31 #Decorator for displaying users32 def displayUsers(self):33 for user in self.users:34 print(user)35 36 37 @classmethod38 #decorator for deleting users39 def deleteUsers(self):40 User.users.remove(self) 41 42 43class Credentials:44 def __init__(self, username, password):45 """46 This is a credentials constructor 47 """48 self.username = username49 self.password = password50 credentials = []51 52 def createNewCredentials(self, username, password):53 """54 This method creates new credentials55 """56 newCredentials = Credentials(username, password)57 return newCredentials58 59 def save_credentials(self, username, password):60 """61 This methods saves credentials62 """63 Credentials.credentials.append(self)64 65 def display_credentials(self):66 for credential in Credentials.credentials:67 print(credential) 68 69 def check_existance(self, email):70 """71 This is a method to check the existatnce of data72 """73 if Credentials.credentials:74 for credential in Credentials.credentials:75 if credential.email == email:76 return True77 print("Details in the account provided doesn't exist")78 else:79 print("No saved data yet")80 81 def deleteCredential(accountName):82 """83 This method will delete user credentials84 """85 for credential in Credentials.credentials:86 if credential.username == accountName:87 Credentials.credentials.remove(credential)88 89 90 91def main():92 while True: 93 print("*"*50)94 options = input("Hey there, what's your name? ")95 login_options = input(f"How can I help you {options}. Kindly select option using the following short codes:\n cc - Create account.\n lg - Login\n ex - Exit\n")96 print("*"*50)97 if login_options == 'cc':98 username = input("Enter username / email address: \n")99 100 passwordoption = input(101 "Choose password option: \n 1. Enter password\n2. Use autogenerated password\n")102 103 if passwordoption == "1": 104 password = input("Enter password: \n")105 106 confirmPassword = input("Confirm password: \n")107 108 if password == confirmPassword:109 print("Welcome to password locker. Login")110 User.createUser(username,password,confirmPassword)111 User.saveUser(username, password)112 print(f"Account created successfully with {username} as username")113 114 115 elif passwordoption == "2":116 password = random.randint(10000, 90000)117 User.saveUser(username, password)118 119 print(f"Account created successfully with user {username}.\n")120 print("Password is ")121 print(password)122 # break123 124 elif login_options == 'lg':125 print("Welcome to password locker. Login\n")126 print("Enter your username: \n")127 login_username = input()128 print("\n")129 130 print("Enter your password: \n")131 login_password = input()132 for credential in User.users:133 if credential[0] == login_username and credential[1] == int(login_password):134 prompt_selection = input("Kindly select the option you would like to do using number:\n 1. Store already existing account credentials.\n 2. Create new account credentials.\n 3. View account credentials and passwords. \n 4. Delete account details.\n 5. Exit")135 136 if prompt_selection == "1":137 for user in User.users:138 Credentials.save_credentials(username, password)139 print(f"Your credentials {user} have been save successfully.")140 141 elif prompt_selection == "2":142 newAccount = input("Enter your username: \n")143 144 newPassword = input("Enter your password: \n")145 Credentials.createNewCredentials(newAccount, newPassword)146 Credentials.save_credentials(newAccount, newPassword)147 break148 149 elif prompt_selection == "3":150 Credentials.display_credentials()151 152 elif prompt_selection == "4":153 accountName = input("Enter username of the credential to delete: \n")154 Credentials.deleteCredential(accountName)155 print(f"Credential with username {accountName} deleted successfully")156 157 elif prompt_selection == "5":158 print("Exiting application")159 break160 161 else:162 print("Invalid selection")163 else:164 print("Incorrect username or password")165 break166 elif login_options == "ex":167 print("Bye for now. See you again")168 break169 170if __name__ == '__main__':...

Full Screen

Full Screen

test_login_login.py

Source:test_login_login.py Github

copy

Full Screen

...15from simcore_service_webserver.login.settings import LoginOptions, get_plugin_options16from simcore_service_webserver.session_settings import get_plugin_settings17EMAIL, PASSWORD = "tester@test.com", "password"18@pytest.fixture19def login_options(client: TestClient) -> LoginOptions:20 assert client.app21 options: LoginOptions = get_plugin_options(client.app)22 return options23def test_login_plugin_setup_succeeded(client: TestClient):24 assert client.app25 print(client.app[APP_SETTINGS_KEY].json(indent=1, sort_keys=True))26 # this should raise AssertionError if not succeedd27 settings = get_plugin_settings(client.app)28 assert settings29async def test_login_with_unknown_email(30 client: TestClient, login_options: LoginOptions31):32 assert client.app33 url = client.app.router["auth_login"].url_for()...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1import tg2from datetime import datetime, timedelta3from six.moves.urllib.parse import urlparse, parse_qs, urlunparse, urlencode4def redirect_on_fail():5 return tg.redirect(tg.request.referer or tg.config.sa_auth['post_logout_url'])6def validate_token(token, expiry):7 if not token or not token.strip():8 tg.flash(_('Missing facebook token'), 'error')9 return redirect_on_fail()10 try:11 expiry = expirydate_from_sec(int(expiry))12 except ValueError:13 tg.flash(_('Invalid Expiry Time for facebook token'), 'error')14 return redirect_on_fail()15 return token, expiry16def login_user(user_name, expire=None):17 request = tg.request18 response = tg.response19 request.cookies.clear()20 authentication_plugins = request.environ['repoze.who.plugins']21 identifier = authentication_plugins['main_identifier']22 login_options = {'repoze.who.userid':user_name}23 if expire:24 login_options['max_age'] = expire25 if not request.environ.get('repoze.who.identity'):26 response.headers = identifier.remember(request.environ, login_options)27def has_fbtoken_expired(user):28 expire = user.access_token_expiry29 if not expire:30 return True31 if datetime.now() > expire:32 return True33 return False34def expirydate_from_sec(seconds):35 seconds -= 336 if seconds <= 0:37 raise ValueError('Facebook token already expired')38 return datetime.now() + timedelta(seconds=seconds)39def add_param_to_query_string(url, param, value):40 url_parts = list(urlparse(url))41 query_parts = parse_qs(url_parts[4])42 query_parts[param] = value43 url_parts[4] = urlencode(query_parts, doseq=True)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful