def test_is_last_name(self):
     """
     Test the last field name check in a required input object
     """
     req_input = RequiredInput('abc', self.req_fields)
     self.assertFalse(req_input.is_last_name('a'))
     self.assertTrue(req_input.is_last_name('b'))
 def test_is_last_name(self):
     """
     Test the last field name check in a required input object
     """
     req_input = RequiredInput('abc', self.req_fields)
     self.assertFalse(req_input.is_last_name('a'))
     self.assertTrue(req_input.is_last_name('b'))
 def test_get_field_name_index(self):
     """
     Test whether the right index of a field name is returned
     """
     req_input = RequiredInput('abc', self.req_fields)
     self.assertEqual(req_input.get_index_of_field_name('a'), 0)
     self.assertEqual(req_input.get_index_of_field_name('b'), 1)
     self.assertEqual(req_input.get_index_of_field_name('c'), -1)
 def test_get_field_name_index(self):
     """
     Test whether the right index of a field name is returned
     """
     req_input = RequiredInput('abc', self.req_fields)
     self.assertEqual(req_input.get_index_of_field_name('a'), 0)
     self.assertEqual(req_input.get_index_of_field_name('b'), 1)
     self.assertEqual(req_input.get_index_of_field_name('c'), -1)
Exemple #5
0
 def register(self):
     """
     Register an existing bank account to use the mobile services.
     :return: A deferred that fires when the account has been registered.
     """
     required_input = RequiredInput('abn_account_info', self.get_registration_fields())
     return self.input_handler(required_input).addCallback(self.perform_first_login_challenge_request)
 def on_access_token_error(self, failure):
     self._logger.error("PayPal access token request failed: %s", failure)
     required_input = RequiredInput('paypal_credentials',
                                    PayPalManager.get_login_fields(),
                                    error_text='PayPal login failed')
     return self.input_handler(required_input).addCallback(
         self.on_entered_credentials)
    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)
 def make_payment(self):
     """
     Initiate a new payment by asking the user for payment details.
     """
     required_input = RequiredInput('paypal_payment_info',
                                    PayPalManager.get_payment_info_fields())
     return self.input_handler(required_input).addCallback(
         self.on_entered_payment_details)
Exemple #9
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))
Exemple #10
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))
Exemple #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))
    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 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)
    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)
    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']})
Exemple #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)
 def login(self):
     """
     Login to a PayPal account. This method uses the credentials stored in the persistent storage and if they
     are not available, they are asked to the user.
     """
     self.database.log_event(
         'info', 'Starting login sequence for %s' % self.get_bank_name())
     if 'password' in self.persistent_storage and 'email' in self.persistent_storage:
         return self.login_with_credentials(
             str(self.persistent_storage['email']),
             str(self.persistent_storage['password']))
     else:
         required_input = RequiredInput('paypal_credentials',
                                        PayPalManager.get_login_fields())
         return self.input_handler(required_input).addCallback(
             self.on_entered_credentials)
Exemple #18
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
Exemple #19
0
 def on_first_challenge_request_error(self, failure):
     required_input = RequiredInput('abn_account_info', self.get_registration_fields(),
                                    error_text='Invalid information entered')
     return self.input_handler(required_input).addCallback(self.perform_first_login_challenge_request)
 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)
 def test_to_dictionary(self):
     """
     Test the to_dictionary method of a required input object
     """
     req_input = RequiredInput('abc', self.req_fields, error_text='error')
     self.assertIsInstance(req_input.to_dictionary(), dict)
 def test_to_dictionary(self):
     """
     Test the to_dictionary method of a required input object
     """
     req_input = RequiredInput('abc', self.req_fields, error_text='error')
     self.assertIsInstance(req_input.to_dictionary(), dict)