def test_to_dictionary(self):
     """
     Test the to_dictionary method of a required field object
     """
     req_field = RequiredField('abc', text='def', placeholder='ghi')
     self.assertDictEqual(req_field.to_dictionary(),
                          {'name': 'abc', 'placeholder': 'ghi', 'text': 'def', 'type': 'text'})
    def make_fast_payment(self, manager):
        if not self.money_community:
            self.transport.write('Switch functionality not enabled (run with --switch to enable it)\n')
            self.show_bank_main_menu(manager)
            return

        amount_field = RequiredField('amount', 'text', 'Please enter the amount of money to transfer')
        destination_field = RequiredField('destination_account', 'text', 'Please enter the destination IBAN account')
        required_input = RequiredInput('fast_payment_info', [amount_field, destination_field])
        payment_input = yield self.handle_required_input(required_input)

        source_iban = manager.get_address()
        destination_iban = payment_input['destination_account']
        amount = float(payment_input['amount'])
        eligable_candidate = yield self.money_community.has_eligable_router(IBANUtil.get_bank_id(source_iban),
                                                                            IBANUtil.get_bank_id(destination_iban),
                                                                            amount)
        if not eligable_candidate:
            self.transport.write('No eligable money switches found for fast transfer\n')
            self.show_bank_main_menu(manager)
            return

        switch_iban = self.money_community.candidate_services_map[eligable_candidate][IBANUtil.get_bank_id(source_iban)]
        self.money_community.send_money_using_router(eligable_candidate, manager, amount,
                                                     switch_iban, destination_iban)\
            .addCallback(self.on_fast_payment_success).addErrback(self.on_fast_payment_error)
Пример #3
0
 def get_payment_info_fields(self):
     """
     Return the fields required for making a payment with an ABN AMRO account.
     """
     amount_field = RequiredField('amount', 'text', 'Please enter the amount of money to transfer')
     destination_field = RequiredField('destination_account', 'text', 'Please enter the destination IBAN account')
     description_field = RequiredField('description', 'text', 'Please the payment description')
     return [amount_field, destination_field, description_field]
Пример #4
0
 def get_payment_info_fields():
     """
     Return the fields required for making a payment in a Dummy manager.
     """
     amount_field = RequiredField('amount', 'text', 'Please enter the amount of money to transfer')
     destination_field = RequiredField('destination_account', 'text', 'Please enter the destination dummy IBAN')
     description_field = RequiredField('description', 'text', 'Please an optional payment description')
     return [amount_field, destination_field, description_field]
Пример #5
0
    def on_register_logon_info(self, response):
        tree = ET.ElementTree(ET.fromstring(response))
        self.logon_token = tree.find('.//{https://bankservices.rabobank.nl/auth/logoninfo/v1/response}LogonToken').text

        account_field = RequiredField('account', 'text', 'Please enter your Rabobank account number')
        card_field = RequiredField('card', 'text', 'Please enter your card number')

        required_input = RequiredInput('rabo_account_info', [account_field, card_field])
        return self.input_handler(required_input).addCallback(self.on_entered_registration_details)
 def test_to_dictionary(self):
     """
     Test the to_dictionary method of a required field object
     """
     req_field = RequiredField('abc', text='def', placeholder='ghi')
     self.assertDictEqual(req_field.to_dictionary(), {
         'name': 'abc',
         'placeholder': 'ghi',
         'text': 'def',
         'type': 'text'
     })
 def get_login_fields():
     """
     Return the fields required for logging in to PayPal.
     """
     email_field = RequiredField('email', 'text',
                                 'Please enter your PayPal email',
                                 'PayPal email')
     password_field = RequiredField('password', 'password',
                                    'Please enter your PayPal password',
                                    'PayPal password')
     return [email_field, password_field]
 def get_payment_info_fields():
     """
     Return the fields required for making a payment in PayPal.
     """
     amount_field = RequiredField(
         'amount', 'text', 'Please enter the amount of money to transfer')
     destination_field = RequiredField(
         'destination_account', 'text',
         'Please enter the destination email address')
     description_field = RequiredField(
         'description', 'text', 'Please an optional payment description')
     return [amount_field, destination_field, description_field]
Пример #9
0
 def test_input(self):
     """
     Test whether input is processed when we use the input endpoint of the RESTful API
     """
     required_fields = [RequiredField('test1'), RequiredField('test2')]
     required_input = RequiredInput('test_input', required_fields)
     test_deferred = self.session.input_handler(required_input)
     self.should_check_equality = False
     self.do_request('input',
                     request_type='POST',
                     post_data={
                         'input_name': 'test_input',
                         'test1': 'abc',
                         'test2': 42
                     })
     return test_deferred
Пример #10
0
    def on_soft_token_challenge_response(self, response, challenge_input):
        challenge_json = json.loads(response)

        new_code_field = RequiredField('id_code', 'text', 'Please enter your new 5-digit identification code',
                                       placeholder='New identification code')
        required_input = RequiredInput('abn_registration_id_code', [new_code_field])
        return self.input_handler(required_input).addCallback(
            lambda user_input: self.perform_soft_token_request(user_input, challenge_json, challenge_input))
Пример #11
0
    def on_first_challenge_request_response(self, response):
        challenge_json = json.loads(response)
        self.tool_id = challenge_json['loginChallenge']['userId']

        code_field = RequiredField('first_challenge', 'text',
                                   'Please enter the login challenge code from your edentifier')
        required_input = RequiredInput('abn_first_challenge', [code_field])
        return self.input_handler(required_input).addCallback(
            lambda input: self.on_first_challenge_input(input, challenge_json))
Пример #12
0
    def on_signing_challenge_response(self, response):
        json_response = json.loads(response)
        signing_code = json_response['softTokenSigningChallenge']['challenge']

        input_text = 'Please enter the edentifier response to the code %s' % str(signing_code)
        code_field = RequiredField('scenario_challenge', 'text', input_text, placeholder='Edentifier response')
        required_input = RequiredInput('abn_scenario_challenge', [code_field])
        return self.input_handler(required_input).addCallback(
            lambda input: self.on_user_token_input(input, signing_code))
Пример #13
0
    def on_register_challenge_response(self, response):
        image_data = response
        with open(os.path.join(self.cache_dir, 'rabo_challenge.png'), 'wb') as fp:
            fp.write(image_data)

        required_input = RequiredInput('rabo_register_challenge_response',
                                       [RequiredField('challenge', 'text',
                                                      'Please enter the response of the challenge')],
                                       additional_data={'image': b64encode(image_data)})
        return self.input_handler(required_input).addCallback(self.on_entered_registration_challenge_response)
Пример #14
0
    def on_submit_second_challenge_error(self, failure):
        self._logger.debug("Second challlenge failed, trying again")
        with open(os.path.join(self.cache_dir, 'rabo_challenge.png'), 'r') as challenge_file:
            image_data = challenge_file.read()

        required_input = RequiredInput('rabo_second_challenge_response',
                                       [RequiredField('challenge', 'text',
                                                      'Please enter the response of the challenge')],
                                       additional_data={'image': b64encode(image_data)},
                                       error_text='Invalid challenge response entered')
        return self.input_handler(required_input).addCallback(self.on_entered_second_registration_challenge_response)
Пример #15
0
    def on_logon_info(self, response):
        tree = ET.ElementTree(ET.fromstring(response))
        self.logon_token = tree.find('.//{https://bankservices.rabobank.nl/auth/logoninfo/v1/response}LogonToken').text

        if 'access_token' not in self.persistent_storage:
            required_input = RequiredInput('rabo_login_info',
                                           [RequiredField('access_token', 'text',
                                                          'Please enter your Rabobank access token')])
            return self.input_handler(required_input).addCallback(self.on_entered_access_token)
        else:
            return self.on_entered_access_token({'access_token': self.persistent_storage['access_token']})
Пример #16
0
 def login(self):
     """
     Login to an ABN AMRO account. First, check whether we have an identification code set. If not, ask for it and
     use it to login.
     """
     if 'identification_code' in self.persistent_storage:
         return self.login_with_code(str(self.persistent_storage['identification_code']))
     else:
         id_code_field = RequiredField('id_code', 'text', 'Please enter your ABN identification code',
                                       placeholder='Identification code')
         required_input = RequiredInput('abn_id_code', [id_code_field])
         return self.input_handler(required_input).addCallback(self.on_entered_login_code)
Пример #17
0
 def get_registration_fields(self):
     account_field = RequiredField('account', 'text', 'Please enter your ABN account number (without the IBAN part)',
                                   placeholder='Account number')
     card_field = RequiredField('card', 'text', 'Please enter your card number', placeholder='Card number')
     return [account_field, card_field]
 def setUp(self):
     self.req_fields = [RequiredField('a'), RequiredField('b')]
Пример #19
0
 def on_login_error(self, failure):
     required_input = RequiredInput('rabo_login_info',
                                    [RequiredField('access_token', 'text',
                                                   'Please enter your Rabobank access token')],
                                    error_text='Invalid access code entered')
     return self.input_handler(required_input).addCallback(self.on_entered_access_token)