def new_recipient(self, recipient, **params): if 'code' in params: return self.send_code(recipient, **params) if recipient.iban[:2] not in ('FR', 'MC'): raise AddRecipientBankError( message=u"LCL n'accepte que les iban commençant par MC ou FR.") for _ in range(2): self.add_recip.go() if self.add_recip.is_here(): break if self.no_perm.is_here() and self.page.get_error_msg(): raise AddRecipientBankError(message=self.page.get_error_msg()) assert self.add_recip.is_here(), 'Navigation failed: not on add_recip' self.page.validate(recipient.iban, recipient.label) assert self.recip_confirm.is_here( ), 'Navigation failed: not on recip_confirm' self.page.check_values(recipient.iban, recipient.label) # Send sms to user. self.open('/outil/UWBE/Otp/envoiCodeOtp?telChoisi=MOBILE') raise AddRecipientStep( self.get_recipient_object(recipient.iban, recipient.label), Value('code', label='Saisissez le code.'))
def on_load(self): errors_msg = ( CleanText('//div[@class="anomalies"]//p[img]')(self.doc), CleanText('//div[@class="error" and contains(@style, "block")]')( self.doc)) if self.doc.xpath('//input[@class="erreur_champs"]'): raise AddRecipientBankError(message="Le code entré est incorrect.") for error_msg in errors_msg: if error_msg: raise AddRecipientBankError(message=error_msg)
def check_recipient_error(self): # this is a copy-paste from RecipientMiscPage, i can't test if it works on this page... # this is for add recipient by initiate transfer msg = CleanText('//tr[@bgcolor="#C74545"]', default='')(self.doc) # there is no id, class or anything... if msg: raise AddRecipientBankError(message=msg)
def send_code(self, recipient, **params): res = self.open('/outil/UWBE/Otp/validationCodeOtp?codeOtp=%s' % params['code']) if res.text == 'false': raise AddRecipientBankError(message='Mauvais code sms.') self.recip_recap.go().check_values(recipient.iban, recipient.label) return self.get_recipient_object(recipient.iban, recipient.label)
def on_load(self): error_msg = CleanText( '//h2[contains(text(), "Compte rendu")]/following-sibling::p')( self.doc) if error_msg: raise AddRecipientBankError(message=error_msg)
def get_sign_method(self): if Dict('donnees/unavailibility_reason', default='')(self.doc) == 'oob_non_enrole': raise AddRecipientBankError( message= "Pour réaliser cette opération il est nécessaire d'utiliser le PASS SECURITE" ) # message from the website return Dict('donnees/sign_proc')(self.doc).upper()
def validate_rcpt_with_sms(self, code): assert self.new_rcpt_validate_form, 'There should have recipient validate form in states' self.new_rcpt_validate_form.update({'code': code}) try: self.confirm_new_recipient.go(data=self.new_rcpt_validate_form) except ClientError as e: assert e.response.status_code == 403, \ 'Something went wrong in add recipient, response status code is %s' % e.response.status_code raise AddRecipientBankError(message='Le code entré est incorrect.')
def choose_country(self, recipient, is_bp_account): # if this is present, we can't add recipient currently more_security_needed = self.doc.xpath('//iframe[@title="Gestion de compte par Internet"]') if more_security_needed: raise AddRecipientBankError(message=u"Pour activer le service Certicode, nous vous invitons à vous rapprocher de votre Conseiller en Bureau de Poste.") form = self.get_form(name='SaisiePaysBeneficiaireVirement') form['compteLBP'] = str(is_bp_account).lower() form['beneficiaireBean.paysDestination'] = recipient.iban[:2] form.submit()
def check_errors(self): # check if user can add new recipient errors_id = ('popinClientNonEligible', 'popinClientNonEligibleBis') for error_id in errors_id: if self.doc.xpath( '//script[contains(text(), "showDivJQInfo(\'%s\')")]' % error_id): msg = CleanText('//div[@id="%s"]//p' % error_id)(self.doc) # get the first sentence of information message # beacause the message is too long and contains unnecessary recommendations raise AddRecipientBankError(message=msg.split('.')[0])
def on_load(self): # if the otp is incorrect error_msg = CleanText('//div[has-class("blc-choix-erreur")]//span')(self.doc) if error_msg: raise AddRecipientBankError(message=error_msg)
def check_recipient_error(self): msg = CleanText('//tr[@bgcolor="#C74545"]', default='')(self.doc) # there is no id, class or anything... if msg: raise AddRecipientBankError(message=msg)
def on_load(self): error_msg = CleanText(u'//span[@class="error_msg"]')(self.doc) if error_msg: raise AddRecipientBankError(message=error_msg)
def on_load(self): code = cast(self.get('codeRetour'), int) if code: raise AddRecipientBankError(message=self.get('message'))
def new_recipient(self, recipient, **params): if not re.match(u"^[-+.,:/?() éèêëïîñàâäãöôòõùûüÿ0-9a-z']+$", recipient.label, re.I): raise RecipientInvalidLabel( 'Recipient label contains invalid characters') if 'sms_code' in params and not re.match(r'^[a-z0-9]{6}$', params['sms_code'], re.I): # check before send sms code because it can crash website if code is invalid raise AddRecipientBankError("SMS code %s is invalid" % params['sms_code']) # avoid `iter_accounts` if there is only one perimeter if len(self.perimeters) > 1: accounts = list(self.iter_accounts()) assert recipient.origin_account_id, 'Origin account id is mandatory for multispace' account = find_object(accounts, id=recipient.origin_account_id, error=AccountNotFound) self.go_to_perimeter(account._perimeter) self.transfer_init_page.go() assert self.transfer_init_page.is_here() if not self.page.add_recipient_is_allowed(): if not [ rec for rec in self.page.iter_recipients() if rec.category == 'Externe' ]: raise AddRecipientBankError( 'Vous ne pouvez pas ajouter de bénéficiaires, veuillez contacter votre banque.' ) assert False, 'Xpath for a recipient add is not catched' self.location(self.page.url_list_recipients()) # there are 2 pages from where we can add a new recipient: # - RecipientListPage, but the link is sometimes missing # - TransferPage, start making a transfer with a new recipient but don't complete the transfer # but it seems dangerous since we have to set an amount, etc. # so we implement it in 2 ways with a preference for RecipientListPage if self.page.url_add_recipient(): self.logger.debug( 'good, we can add a recipient from the recipient list') else: # in this case, the link was missing self.logger.warning( 'cannot add a recipient from the recipient list page, pretending to make a transfer in order to add it' ) self.transfer_init_page.go() assert self.transfer_init_page.is_here() self.location(self.page.url_add_recipient()) if not ('sms_code' in params and self.page.can_send_code()): self.page.send_sms() # go to a GET page, so StatesMixin can reload it self.accounts.go() raise AddRecipientStep( self.build_recipient(recipient), Value('sms_code', label='Veuillez saisir le code SMS')) else: self.page.submit_code(params['sms_code']) err = hasattr(self.page, 'get_sms_error') and self.page.get_sms_error() if err: raise AddRecipientBankError(message=err) self.page.submit_recipient(recipient.label, recipient.iban) self.page.confirm_recipient() self.page.check_recipient_error() if self.transfer_page.is_here(): # in this case, we were pretending to make a transfer, just to add the recipient # go back to transfer page to abort the transfer and see the new recipient self.transfer_init_page.go() assert self.transfer_init_page.is_here() res = self.page.find_recipient(recipient.iban) assert res, 'Recipient with iban %s could not be found' % recipient.iban return res
def check_recipient_iban(self): if not CleanText('//input[@name="codeBic"]/@value')(self.doc): raise AddRecipientBankError( message= "Le bénéficiaire est déjà présent ou bien l'iban est incorrect" )
def on_load(self): if not self.doc.xpath('//input[@id="otp"]') and not self.doc.xpath( '//div[@class="confirmationAjoutCompteExterne"]'): raise AddRecipientBankError(message=CleanText( '//div[@id="aidesecuforte"]/p[contains("Nous vous invitons")]') (self.doc))