def test_reset_confirm_pin_with_bad_pin(self): uuid = 'reset_confirm_pin_bad_pin' new_pin = '1122' client.create_buyer(uuid, self.pin) client.set_new_pin(uuid, new_pin) assert client.reset_confirm_pin(uuid, new_pin) assert client.verify_pin(uuid, new_pin) assert not client.reset_confirm_pin(uuid, self.pin) assert client.verify_pin(uuid, new_pin)
def test_reset_confirm_pin_with_good_pin(self): uuid = "reset_confirm_pin_good_pin" new_pin = "1122" client.create_buyer(uuid, self.pin) client.set_new_pin(uuid, new_pin) assert client.reset_confirm_pin(uuid, new_pin) assert client.verify_pin(uuid, new_pin)
def test_change_pin_without_existing_pin(self): uuid = 'change_pin_without_existing_pin' new_pin = '1234' buyer = client.create_buyer(uuid) assert not buyer.get('pin') client.change_pin(uuid, new_pin) buyer = client.get_buyer(uuid) assert buyer.get('pin') assert client.verify_pin(uuid, new_pin)
def test_change_pin_with_existing_pin(self): uuid = 'change_pin_with_existing_pin' pin = '5432' new_pin = pin[::-1] client.create_buyer(uuid, pin) client.change_pin(uuid, new_pin) buyer = client.get_buyer(uuid) assert buyer.get('pin') assert client.verify_pin(uuid, new_pin)
def test_change_pin_with_existing_pin(self): uuid = "change_pin_with_existing_pin" pin = "5432" new_pin = pin[::-1] client.create_buyer(uuid, pin) client.change_pin(uuid, new_pin) buyer = client.get_buyer(uuid) assert buyer.get("pin") assert client.verify_pin(uuid, new_pin)
def test_change_pin_without_existing_pin(self): uuid = "change_pin_without_existing_pin" new_pin = "1234" buyer = client.create_buyer(uuid) assert not buyer.get("pin") client.change_pin(uuid, new_pin) buyer = client.get_buyer(uuid) assert buyer.get("pin") assert client.verify_pin(uuid, new_pin)
def clean_pin(self, *args, **kwargs): pin = self.cleaned_data['pin'] res = client.verify_pin(self.uuid, pin) self.pin_is_locked = False if self.handle_client_errors(res): if res.get('locked'): self.pin_is_locked = True # Not displayed to the user. raise forms.ValidationError('pin locked') elif res.get('valid'): return pin raise forms.ValidationError(_('Wrong pin'))
def clean_pin(self, *args, **kwargs): pin = self.cleaned_data['pin'] res = client.verify_pin(self.uuid, pin) self.pin_is_locked = False if self.handle_client_errors(res): if res.get('locked'): self.pin_is_locked = True raise forms.ValidationError(_('Your PIN was entered ' 'incorrectly too many times. ' 'Sign in to continue.')) elif res.get('valid'): return pin raise forms.ValidationError(_('Wrong pin'))
def clean_pin(self, *args, **kwargs): pin = self.cleaned_data['pin'] res = client.verify_pin(self.uuid, pin) self.pin_is_locked = False if self.handle_client_errors(res): if res.get('locked'): self.pin_is_locked = True raise forms.ValidationError(_('Your PIN was entered ' 'incorrectly too many times. ' 'Sign in to continue.')) elif res.get('valid'): return pin raise forms.ValidationError(_('PIN does not match.'))
def clean_pin(self, *args, **kwargs): pin = self.cleaned_data['pin'] res = client.verify_pin(self.uuid, pin) self.pin_is_locked = False if self.client_response_is_valid(res): if res.get('locked'): self.pin_is_locked = True # Not displayed to the user. raise forms.ValidationError('pin locked') elif res.get('valid'): return pin self.add_error_code(msg.WRONG_PIN) raise forms.ValidationError(msg.WRONG_PIN)
def test_verify_alpha_pin(self): assert 'pin' in client.verify_pin(self.uuid, 'lame')['errors']
def test_verify_without_confirm_and_good_pin(self): uuid = 'verify_pin_good_pin' client.create_buyer(uuid, self.pin) assert not client.verify_pin(uuid, self.pin)['valid']
def test_verify_alpha_pin(self): assert "pin" in client.verify_pin(self.uuid, "lame")["errors"]
def test_change_pin(self): buyer_id = client.get_buyer(self.uuid)['id'] eq_(client.change_pin(buyer_id, '4321'), {}) assert client.verify_pin(self.uuid, '4321') eq_(client.change_pin(buyer_id, self.pin), {})
def test_verify_good_pin(self): assert client.verify_pin(self.uuid, self.pin)
def test_verify_alpha_pin(self, slumber): slumber.generic.verify_pin.post.side_effect = HttpClientError( response=self.create_error_response( content={'pin': ['PIN_ONLY_NUMBERS']})) assert 'pin' in client.verify_pin(self.uuid, 'lame')['errors']
def test_verify_pin_without_confirm(self, slumber): slumber.generic.verify_pin.post.return_value = {'valid': False} assert not client.verify_pin(self.uuid, self.pin)['valid']
def clean_old_pin(self, *args, **kwargs): old_pin = self.cleaned_data['old_pin'] if self.handle_client_errors(client.verify_pin(self.uuid, old_pin)): self.buyer = self.handle_client_errors(client.get_buyer(self.uuid)) return old_pin raise forms.ValidationError(_('Incorrect PIN'))
def test_verify_with_confirm_and_good_pin(self): uuid = 'verify_pin_confirm_pin_good_pin' client.create_buyer(uuid, self.pin) assert client.confirm_pin(uuid, self.pin) assert client.verify_pin(uuid, self.pin)
def test_verify_alpha_pin(self): assert not client.verify_pin(self.uuid, 'lame')
def test_verify_alpha_pin(self, slumber): slumber.generic.verify_pin.post.side_effect = HttpClientError( response=self.create_error_response(content={ 'pin': ['PIN_ONLY_NUMBERS'] })) assert 'pin' in client.verify_pin(self.uuid, 'lame')['errors']
def clean_pin(self, *args, **kwargs): pin = self.cleaned_data['pin'] if self.handle_client_errors(client.verify_pin(self.uuid, pin)): return pin raise forms.ValidationError(_('Incorrect PIN.'))