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

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