Best Python code snippet using refurb_python
create_user_and_phone.py
Source: create_user_and_phone.py
2import pprint3import sys4import duo_client5argv_iter = iter(sys.argv[1:])6def get_next_arg(prompt):7 try:8 return argv_iter.next()9 except StopIteration:10 return raw_input(prompt)11# Configuration and information about objects to create.12admin_api = duo_client.Admin(13 ikey=get_next_arg('Admin API integration key ("DI..."): '),14 skey=get_next_arg('integration secret key: '),15 host=get_next_arg('API hostname ("api-....duosecurity.com"): '),16)17USERNAME = get_next_arg('user login name: ')18REALNAME = get_next_arg('user full name: ')19# Refer to http://www.duosecurity.com/docs/adminapi for more20# information about phone types and platforms.21PHONE_NUMBER = get_next_arg('phone number (e.g. +1-555-123-4567): ')22PHONE_TYPE = get_next_arg('phone type (e.g. mobile): ')23PHONE_PLATFORM = get_next_arg('phone platform (e.g. google android): ')24# Create and return a new user object.25user = admin_api.add_user(26 username=USERNAME,27 realname=REALNAME,28)29print 'Created user:'30pprint.pprint(user)31# Create and return a new phone object.32phone = admin_api.add_phone(33 number=PHONE_NUMBER,34 type=PHONE_TYPE,35 platform=PHONE_PLATFORM,36)37print 'Created phone:'...
Duo_selenium_auth.py
Source: Duo_selenium_auth.py
...9from selenium.webdriver.support.ui import WebDriverWait10from selenium.webdriver.support import expected_conditions as EC11from selenium.webdriver.common.by import By12from selenium.webdriver.common.keys import Keys13def get_next_arg(prompt):14 try:15 return next(argv_iter)16 except StopIteration:17 return input(prompt)18if __name__ == '__main__':19 # Configuration and information about objects to create.20 argv_iter = iter(sys.argv[1:])21 sp_url=get_next_arg('Duo SAML protected Service Provider (SP) URL (WITHOUT https://): ')22 idp_username=get_next_arg('Username: ')23 idp_password=get_next_arg('Password: ')24 # Open Browser with Selenium 25 driver = webdriver.Chrome()26 driver.get("https://"+sp_url)27 # Wait for input field28 element_present = EC.presence_of_element_located((By.XPATH, '//input'))29 try:30 WebDriverWait(driver, 7).until(element_present)31 except TimeoutException:32 print("Timeout")33 username_field = driver.find_element(By.XPATH, "//input") 34 print("Sending username...") 35 username_field.send_keys(idp_username)36 username_field.send_keys(Keys.RETURN)37 ...
duo_delete.py
Source: duo_delete.py
...6import duo_client7from six.moves import input89argv_iter = iter(sys.argv[1:])10def get_next_arg(prompt):11 try:12 return next(argv_iter)13 except StopIteration:14 return input(prompt)151617admin_api = duo_client.Admin(18 ikey=get_next_arg('Admin API Integration Key ("DI....."): '),19 skey=get_next_arg('Integration Secret Key: '),20 host=get_next_arg('API Hostname ("api-....duosecurity.com"): '),21)22username = input('Enter the username which has to be deleted from the Org : ')23print("Fetching user information for ",username)24try:25 user_data = admin_api.get_users_by_name(username)26# Retrieve user info from API:27 userdata = user_data[0]28 userid = userdata['user_id']29 print("The user id for ",username," is : ",userid)30 admin_api.delete_user(userid)31 print("User ",username, " with user_id ", userid, "is deleted from DUO Org")32except:
...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.
Entering the world of testers, one question started to formulate in my mind: “what is the reason that bugs happen?”.
Are members of agile teams different from members of other teams? Both yes and no. Yes, because some of the behaviors we observe in agile teams are more distinct than in non-agile teams. And no, because we are talking about individuals!
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!