Commit e8e03c49 authored by thibault douge's avatar thibault douge Committed by Vincent A

[amazon] handle form when we have different device choice

parent 93bc1805
......@@ -95,7 +95,7 @@ def locate_browser(self, state):
self.location(state['url'])
def check_interactive(self):
if not self.config['request_information'].get():
if self.config['request_information'].get() is None:
raise NeedInteractiveFor2FA()
def send_notification_interactive_mode(self):
......@@ -131,7 +131,7 @@ def handle_security(self):
# we don't raise an error because for the seller account 2FA is mandatory
self.logger.warning('2FA is enabled, all connections send an OTP')
if self.page.has_form_verify() or self.page.has_form_auth_mfa():
if self.page.has_form_verify() or self.page.has_form_auth_mfa() or self.page.has_form_select_device():
self.check_interactive()
self.page.send_code()
captcha = self.page.get_captcha_url()
......
......@@ -47,6 +47,8 @@ def get_sub_link(self):
class SecurityPage(HTMLPage):
def get_otp_type(self):
if self.doc.xpath('//form[@id="auth-select-device-form"]'):
return 'auth-select-device-form'
# amazon send us otp in two cases:
# - if it's the first time we connect to this account for an ip => manage it normally
# - if user has activated otp in his options => raise ActionNeeded, an ask user to deactivate it
......@@ -63,6 +65,11 @@ def get_otp_message(self):
def send_code(self):
form = self.get_form()
if form.el.attrib.get('id') == 'auth-select-device-form':
# the first is sms, second email, third application
# the first item is automatically selected
form.submit()
if form.el.attrib.get('id') == 'auth-mfa-form':
# when code is sent by sms, server send it automatically, nothing to do here
return
......@@ -95,6 +102,9 @@ def has_form_verify(self):
def has_form_auth_mfa(self):
return bool(self.doc.xpath('//form[@id="auth-mfa-form"]'))
def has_form_select_device(self):
return bool(self.doc.xpath('//form[@id="auth-select-device-form"]'))
class ApprovalPage(HTMLPage, LoggedPage):
def get_msg_app_validation(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment