How to use get_google_auth_code method in SeleniumBase

Best Python code snippet using SeleniumBase

test_auth.py

Source: test_auth.py Github

copy

Full Screen

...88 user = self.session.query(User).filter_by(username='foo').first()89 self.testapp.post('/​auth/​ga', status=302, params={90 'submit': 'Authenticate',91 'username': 'foo',92 'code': get_google_auth_code(user.secret)93 })94 self.testapp.get('/​')95 def test_submit_success_with_code_check_headers(self):96 from factored.utils import get_google_auth_code97 from factored.models import User98 user = self.session.query(User).filter_by(username='foo').first()99 resp = self.testapp.post('/​auth/​ga', status=302, params={100 'submit': 'Authenticate',101 'username': 'foo',102 'code': get_google_auth_code(user.secret)103 })104 assert 'pnutbtr=' in resp.headers['Set-Cookie']105class TestEmailAuth(BaseTest):106 def setUp(self):107 super(TestEmailAuth, self).setUp()108 from factored.models import User109 self.user = User(110 username='foo@bar.com', secret=generate_random_google_code())111 self.session.add(self.user)112 self.session.commit()113 def test_email_blank_form(self):114 resp = self.testapp.get('/​auth/​em', status=200)115 resp.mustcontain('name="username')116 def test_not_send_mail_without_username(self):...

Full Screen

Full Screen

hpool_xch_withdraw.py

Source: hpool_xch_withdraw.py Github

copy

Full Screen

...97 t2=int(time.time() * 1000)98 res = requests.get(url=f'https:/​/​www.hpool.in/​api/​security/​requestsession?_t={t2}', headers=header)99 session = json.loads(res.text).get('data')100 return session101def get_google_auth_code(path):102 '''103 使用`oathtool`生成谷歌验证码,脚本需要有执行权限,104 脚本内容:`oathtool -b --totp 'key'`.105 非最佳方案,注意保护好`key`谨防泄密,造成财产损失.106 '''107 code = subprocess.getoutput(path)108 # return int(code)109 print(code)110 return code111def xch_withdraw(url, session, code, amount, address, **kwargs):112 '''113 session:请求session接口的返回,114 code:谷歌验证码,115 aomount:剩余全部xch,116 address:提现钱包地址117 118 提现到指定钱包地址payload:119 '{"session":"","code":"","type":"chia","address":"","amount":""}'120 '''121 type = 'chia'122 payload = {123 "session": f"{session}",124 "code": f"{code}",125 "type": "chia",126 "address": f"{address}",127 "amount": f"{amount}"128 }129 payload = json.dumps(payload)130 # print(payload)131 res = requests.post(url=url, headers=header, data=payload)132 result_code = json.loads(res.text).get('code')133 print(res.text)134 if result_code == 200:135 msg=f'提现成功,本次提现金额为:{amount}xch,请注意查收.'136 logger.info(f'{msg}')137 send_tg_msg(text=msg)138 return result_code139 else:140 msg='提现失败,未知错误.'141 logger.error(f"{msg}")142 send_tg_msg(text=msg)143 return None144if __name__ == "__main__":145 # parser = argm(prog='hpool_xch_withdraw',description="hpool xch withdraw helper")146 # parser.add_argument("-K", "--code", dest='code', type=int,help="Google Authenticator Code.")147 # parser.add_argument("-P","--percent", dest='withdraw_percent', default=1,help="Withdraw ratio.")148 # parser.add_argument("-M","--tg",help="Send telegram message.")149 # args = parser.parse_args()150 # code = args.code151 # withdraw_percent = args.withdraw_percent152 # if len(str(code)) == 6:153 # remain_xch=get_total_assets('https:/​/​www.hpool.in/​api/​assets/​totalassets')154 # #sign_url=f'https:/​/​www.hpool.in/​api/​assets/​totalassets'155 # # print(sign_url)156 # t = int(time.time() * 1000)157 # session=get_token(f'https:/​/​www.hpool.in/​api/​security/​requestsession?_t={t}')158 # ## 防止被劫持,强制写死提现address.也可以通过接口获取159 # xch_withdraw(session=session,code=code,amount=remain_xch,address='')160 # else:161 # parser.print_help()162 remain_xch = get_total_assets(163 'https:/​/​www.hpool.in/​api/​assets/​totalassets')164 # t = int(time.time() * 1000)165 session = get_token()166 code = get_google_auth_code('/​home/​chaos/​lab/​scripts/​totp.sh')167 withdraw_url = 'https:/​/​www.hpool.in/​api/​assets/​withdraw'168 ## 防止被劫持,强制写死提现address.也可以通过接口获取169 pay_address = ''170 xch_withdraw(url=withdraw_url,171 session=session,172 code=code,173 amount=remain_xch,...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Feeding your QA Career – Developing Instinctive & Practical Skills

The QA testing profession requires both educational and long-term or experience-based learning. One can learn the basics from certification courses and exams, boot camp courses, and college-level courses where available. However, developing instinctive and practical skills works best when built with work experience.

A Complete Guide To CSS Grid

Ever since the Internet was invented, web developers have searched for the most efficient ways to display content on web browsers.

Keeping Quality Transparency Throughout the organization

In general, software testers have a challenging job. Software testing is frequently the final significant activity undertaken prior to actually delivering a product. Since the terms “software” and “late” are nearly synonymous, it is the testers that frequently catch the ire of the whole business as they try to test the software at the end. It is the testers who are under pressure to finish faster and deem the product “release candidate” before they have had enough opportunity to be comfortable. To make matters worse, if bugs are discovered in the product after it has been released, everyone looks to the testers and says, “Why didn’t you spot those bugs?” The testers did not cause the bugs, but they must bear some of the guilt for the bugs that were disclosed.

A Detailed Guide To Xamarin Testing

Xamarin is an open-source framework that offers cross-platform application development using the C# programming language. It helps to simplify your overall development and management of cross-platform software applications.

How To Run Cypress Tests In Azure DevOps Pipeline

When software developers took years to create and introduce new products to the market is long gone. Users (or consumers) today are more eager to use their favorite applications with the latest bells and whistles. However, users today don’t have the patience to work around bugs, errors, and design flaws. People have less self-control, and if your product or application doesn’t make life easier for users, they’ll leave for a better solution.

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 SeleniumBase 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