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_set_new_pin_for_reset_with_wrong_etag(self, slumber): wrong_etag = 'etag:wrong' buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.side_effect = HttpClientError( response=self.create_error_response( status_code=412, content={'ERROR': ['RESOURCE_MODIFIED']})) slumber.generic.buyer.return_value = buyer with self.assertRaises(ResourceModified): client.set_new_pin(self.uuid, self.pin, wrong_etag)
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_bad_pin(self, slumber): new_pin = '1122' buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.return_value = {} slumber.generic.buyer.return_value = buyer client.set_new_pin(self.uuid, new_pin) slumber.generic.reset_confirm_pin.post.return_value = { 'confirmed': False } assert not client.reset_confirm_pin(self.uuid, new_pin)
def test_reset_pin_flag_set(self): # set client.set_new_pin(self.uuid, '1234') res = client.set_needs_pin_reset(self.uuid) eq_(res, {}) buyer = client.get_buyer(self.uuid) assert buyer['needs_pin_reset'] assert not buyer['new_pin'] # unset client.set_new_pin(self.uuid, '1234') res = client.set_needs_pin_reset(self.uuid, False) eq_(res, {}) buyer = client.get_buyer(self.uuid) assert not buyer['needs_pin_reset'] assert not buyer['new_pin']
def test_set_new_pin_for_reset_with_alpha_pin(self): uuid = 'set_new_pin_for_reset_with_alpha_pin' client.create_buyer(uuid, self.pin) res = client.set_new_pin(uuid, 'meow') assert res.get('errors') eq_(res['errors'].get('new_pin'), [ERROR_STRINGS['PIN may only consists of numbers']])
def test_reset_pin_flag_set(self): # set client.set_new_pin(self.uuid, "1234") res = client.set_needs_pin_reset(self.uuid) eq_(res, {}) buyer = client.get_buyer(self.uuid) assert buyer["needs_pin_reset"] assert not buyer["new_pin"] # unset client.set_new_pin(self.uuid, "1234") res = client.set_needs_pin_reset(self.uuid, False) eq_(res, {}) buyer = client.get_buyer(self.uuid) assert not buyer["needs_pin_reset"] assert not buyer["new_pin"]
def reset_new_pin(request): form = forms.CreatePinForm() if request.method == 'POST': form = forms.ResetPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): try: res = client.set_new_pin(form.uuid, form.cleaned_data['pin']) except ResourceModified: return system_error(request, code=msg.RESOURCE_MODIFIED) if form.handle_client_errors(res): request.session['uuid_has_new_pin'] = True return http.HttpResponseRedirect(reverse('pin.reset_confirm')) form.reset_flow = True return render( request, 'pin/pin_form.html', { 'form': form, 'title': _('Reset Pin'), 'action': reverse('pin.reset_new_pin'), 'pin_form_tracking': { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Reset Pin page', } })
def test_set_new_pin_for_reset_with_alpha_pin(self, slumber): buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.side_effect = HttpClientError( response=self.create_error_response( content={'new_pin': ['PIN_ONLY_NUMBERS']})) slumber.generic.buyer.return_value = buyer res = client.set_new_pin(self.uuid, 'meow') assert res.get('errors') eq_(res['errors'].get('new_pin'), [ERROR_STRINGS['PIN_ONLY_NUMBERS']])
def reset_new_pin(request): form = forms.CreatePinForm() if request.method == "POST": form = forms.CreatePinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): res = client.set_new_pin(form.buyer, form.cleaned_data["pin"]) if form.handle_client_errors(res): set_user_has_pin(request, True) return http.HttpResponseRedirect(reverse("pin.reset_confirm")) return render(request, "pin/reset_create.html", {"form": form})
def test_set_new_pin_for_reset_with_alpha_pin(self, slumber): buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.side_effect = HttpClientError( response=self.create_error_response(content={ 'new_pin': [msg.PIN_ONLY_NUMBERS] })) slumber.generic.buyer.return_value = buyer res = client.set_new_pin(self.uuid, 'meow') assert res.get('errors') eq_(res['errors'].get('new_pin'), [msg.PIN_ONLY_NUMBERS])
def test_set_new_pin_for_reset_with_alpha_pin(self, slumber): buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.side_effect = HttpClientError( response=self.create_error_response(content={ 'new_pin': ['PIN may only consists of numbers'] })) slumber.generic.buyer.return_value = buyer res = client.set_new_pin(self.uuid, 'meow') assert res.get('errors') eq_(res['errors'].get('new_pin'), [ERROR_STRINGS['PIN may only consists of numbers']])
def reset_new_pin(request): form = forms.CreatePinForm() if request.method == 'POST': form = forms.CreatePinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): res = client.set_new_pin(form.buyer, form.cleaned_data['pin']) if form.handle_client_errors(res): set_user_has_pin(request, True) return http.HttpResponseRedirect(reverse('pin.reset_confirm')) return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Enter your new PIN:'), 'action': reverse('pin.reset_new_pin') })
def update(self, request): form = ResetPinForm(uuid=request.session['uuid'], data=request.DATA) if not request.session.get('was_reverified', False): return app_error(request) if form.is_valid(): res = client.set_new_pin(form.uuid, form.cleaned_data['pin']) if form.handle_client_errors(res): request.session['was_reverified'] = False return response.Response(status=204) return app_error(request)
def test_set_new_pin_for_reset_with_bad_etag(self, slumber): wrong_etag = 'etag:wrong' buyer = mock.Mock(return_value=self.buyer_data) buyer.patch.side_effect = HttpClientError( response=self.create_error_response( status_code=412, content={'ERROR': [('The resource has been modified, ' 'please re-fetch it.')]})) slumber.generic.buyer.return_value = buyer res = client.set_new_pin(self.uuid, self.pin, wrong_etag) assert res.get('errors') eq_(res['errors'], [ERROR_STRINGS['The resource has been modified, please re-fetch it.']])
def reset_new_pin(request): form = forms.CreatePinForm() if request.method == 'POST': form = forms.ResetPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): res = client.set_new_pin(form.uuid, form.cleaned_data['pin']) if form.handle_client_errors(res): request.session['uuid_has_new_pin'] = True return http.HttpResponseRedirect(reverse('pin.reset_confirm')) form.reset_flow = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Reset Pin'), 'action': reverse('pin.reset_new_pin')})
def reset_new_pin(request): form = forms.CreatePinForm() if request.method == 'POST': form = forms.ResetPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): try: res = client.set_new_pin(form.uuid, form.cleaned_data['pin']) except ResourceModified: return system_error(request, code=msg.RESOURCE_MODIFIED) if form.handle_client_errors(res): request.session['uuid_has_new_pin'] = True return http.HttpResponseRedirect(reverse('pin.reset_confirm')) form.reset_flow = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Reset Pin'), 'action': reverse('pin.reset_new_pin'), 'pin_form_tracking' : { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Reset Pin page', }})
def test_set_new_pin_for_reset(self): uuid = "set_new_pin_for_reset" client.create_buyer(uuid, self.pin) eq_(client.set_new_pin(uuid, "1122"), {})
def test_set_new_pin_for_reset_with_good_etag(self, slumber): etag = 'etag:good' slumber.generic.set_new_pin.patch.return_value = {} eq_(client.set_new_pin(self.uuid, '1122', etag), {})
def test_set_new_pin_for_reset(self, slumber): slumber.generic.set_new_pin.patch.return_value = {} eq_(client.set_new_pin(self.uuid, '1122'), {})
def test_set_new_pin_for_reset_with_alpha_pin(self): uuid = "set_new_pin_for_reset_with_alpha_pin" client.create_buyer(uuid, self.pin) res = client.set_new_pin(uuid, "meow") assert res.get("errors") eq_(res["errors"].get("new_pin"), [ERROR_STRINGS["PIN may only consists of numbers"]])
def test_set_new_pin_for_reset(self): uuid = 'set_new_pin_for_reset' client.create_buyer(uuid, self.pin) eq_(client.set_new_pin(uuid, '1122'), {})