def verify(request): form = forms.VerifyPinForm() if utils.pin_recently_entered(request): return http.HttpResponseRedirect(get_payment_url()) if request.method == 'POST': form = forms.VerifyPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): request.session['last_pin_success'] = datetime.now() return http.HttpResponseRedirect(get_payment_url()) return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Enter Pin'), 'action': reverse('pin.verify')})
def verify(request): form = forms.VerifyPinForm() if request.method == "POST": form = forms.VerifyPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): return http.HttpResponseRedirect(get_payment_url()) return render(request, "pin/verify.html", {"form": form})
def test_recently_entered_pin_redirect(self, get_price, get_secret): get_secret.return_value = self.secret self.session['last_pin_success'] = datetime.now() self.session.save() payload = self.request(iss=self.key, app_secret=self.secret) res = self.get(payload) eq_(res.status_code, 302) assert res['Location'].endswith(get_payment_url())
def verify(request): form = forms.VerifyPinForm() # pin_recently_entered is on the form because the template expect it as it # is rendered from pay.lobby as well as here. form.pin_recently_entered = utils.pin_recently_entered(request) if form.pin_recently_entered: return http.HttpResponseRedirect(get_payment_url()) if request.method == 'POST': form = forms.VerifyPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): request.session['last_pin_success'] = datetime.now() return http.HttpResponseRedirect(get_payment_url()) form.pin_recently_entered = False return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Enter your PIN:'), 'action': reverse('pin.verify') })
def test_pin_recently_entered(self): self.request.session['last_pin_success'] = datetime.now() self.request.session.save() # If they get the bypass prompt then there # will be no data posted to the view. res = self.client.post(self.url) eq_(res.status_code, 302) assert res.get('Location', '').endswith(get_payment_url())
def confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): return http.HttpResponseRedirect(get_payment_url()) return render(request, 'pin/pin_form.html', { 'form': form, 'title': _('Confirm your PIN:'), 'action': reverse('pin.confirm') })
def test_recently_entered_pin_redirect(self, update_session, get_price, get_active_product): self.set_secret(get_active_product) self.session["uuid"] = "something" self.session["last_pin_success"] = datetime.now() self.save_session() payload = self.request(iss=self.key, app_secret=self.secret) res = self.get(payload) eq_(res.status_code, 302) assert res["Location"].endswith("?next={0}".format(get_payment_url(mock.Mock()))), res["Location"]
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == "POST": form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url()) return render(request, "pin/reset_confirm.html", {"form": form})
def test_recently_entered_pin_redirect(self, update_session, get_price, get_active_product): self.set_secret(get_active_product) self.session['uuid'] = 'something' self.session['last_pin_success'] = datetime.now() self.save_session() payload = self.request(iss=self.key, app_secret=self.secret) res = self.get(payload) eq_(res.status_code, 302) assert res['Location'].endswith(get_payment_url(mock.Mock()))
def verify(request): form = forms.VerifyPinForm() if request.method == 'POST': # TODO(Wraithan): Get the buyer's UUID once identity is figured out # with webpay. stub_uuid = 'dat:uuid' form = forms.VerifyPinForm(uuid=stub_uuid, data=request.POST) if form.is_valid(): return http.HttpResponseRedirect(get_payment_url()) return render(request, 'pin/verify.html', {'form': form})
def test_recently_entered_pin_redirect(self, update_session, get_price, get_active_product): self.set_secret(get_active_product) self.session['uuid'] = 'something' self.session['last_pin_success'] = datetime.now() self.session.save() payload = self.request(iss=self.key, app_secret=self.secret) res = self.get(payload) eq_(res.status_code, 302) assert res['Location'].endswith(get_payment_url())
def confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): set_user_has_confirmed_pin(request, True) return http.HttpResponseRedirect(get_payment_url(request)) form.no_pin = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.confirm')})
def verify(request): form = forms.VerifyPinForm() if request.method == 'POST': form = forms.VerifyPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): request.session['last_pin_success'] = datetime.now() return http.HttpResponseRedirect(get_payment_url()) return render(request, 'pin/pin_form.html', { 'form': form, 'title': _('Enter Pin'), 'action': reverse('pin.verify') })
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url()) return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm your new PIN:'), 'action': reverse('pin.reset_confirm') })
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Clear reverification state since this PIN reset is finished. request.session['was_reverified'] = False # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url()) form.reset_flow = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.reset_confirm')})
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Clear reverification state since this PIN reset is finished. request.session['was_reverified'] = False messages.success(request, _('Pin reset')) # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url(request)) form.reset_flow = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.reset_confirm')})
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url()) form.reset_flow = True return render( request, 'pin/pin_form.html', { 'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.reset_confirm') })
def confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): set_user_has_confirmed_pin(request, True) return http.HttpResponseRedirect(get_payment_url(request)) form.no_pin = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.confirm'), 'pin_form_tracking' : { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Confirm Pin Page', }})
def check_pin_status(request): if request.session.get('uuid_pin_is_locked'): return reverse('pin.is_locked') if request.session.get('uuid_pin_was_locked'): return reverse('pin.was_locked') last_success = request.session.get('last_pin_success') if (last_success and ((datetime.now() - last_success).seconds < settings.PIN_UNLOCK_LENGTH)): return get_payment_url(request) if request.session.get('uuid_has_pin'): if request.session.get('uuid_has_confirmed_pin'): return None else: client.change_pin(request.session['uuid'], None) request.session['uuid_has_pin'] = False return reverse('pin.create')
def check_pin_status(request): if request.session.get('uuid_pin_is_locked'): return reverse('pin.is_locked') if request.session.get('uuid_pin_was_locked'): return reverse('pin.was_locked') last_success = request.session.get('last_pin_success') if (last_success and ( (datetime.now() - last_success).seconds < settings.PIN_UNLOCK_LENGTH)): return get_payment_url() if request.session.get('uuid_has_pin'): if request.session.get('uuid_has_confirmed_pin'): return None else: client.change_pin(request.session['uuid'], None) request.session['uuid_has_pin'] = False return reverse('pin.create')
def verify(request): form = forms.VerifyPinForm() if request.method == 'POST': form = forms.VerifyPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): request.session['last_pin_success'] = datetime.now() return http.HttpResponseRedirect(get_payment_url(request)) elif form.pin_is_locked: request.session['uuid_pin_is_locked'] = True return http.HttpResponseRedirect(reverse('pin.is_locked')) return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Enter Pin'), 'action': reverse('pin.verify'), 'pin_form_tracking' : { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Verify Pin Page', }})
def check_pin_status(request): if request.session.get('uuid_pin_is_locked'): return reverse('pin.is_locked') if request.session.get('uuid_pin_was_locked'): return reverse('pin.was_locked') last_success = request.session.get('last_pin_success') if (last_success and ((datetime.now() - last_success).seconds < settings.PIN_UNLOCK_LENGTH)): return get_payment_url(request) if request.session.get('uuid_has_pin'): if request.session.get('uuid_has_confirmed_pin'): return None else: try: client.change_pin(request.session['uuid'], None) except ResourceModified: return system_error(request, code=msg.RESOURCE_MODIFIED) request.session['uuid_has_pin'] = False return reverse('pin.create')
def reset_confirm(request): form = forms.ConfirmPinForm() if request.method == 'POST': form = forms.ResetConfirmPinForm(uuid=get_user(request), data=request.POST) if form.is_valid(): # Clear reverification state since this PIN reset is finished. request.session['was_reverified'] = False messages.success(request, _('Pin reset')) # Copy pin into place is handled in solitude, webpay # merely asked solitude to verify the new pin which # happens in validation of the form. return http.HttpResponseRedirect(get_payment_url(request)) form.reset_flow = True return render(request, 'pin/pin_form.html', {'form': form, 'title': _('Confirm Pin'), 'action': reverse('pin.reset_confirm'), 'pin_form_tracking' : { 'pin_error_codes': form.pin_error_codes, }, 'track_cancel': { 'action': 'pin cancel', 'label': 'Reset Pin page', }})
def test_good_pin(self): res = self.client.post(self.url, data={'pin': '1234'}) assert res['Location'].endswith(get_payment_url(Mock())) # Make sure the reverification flag was cleared out. eq_(res.client.session['was_reverified'], False)
def test_good_pin(self, set_user_has_confirmed_pin): res = self.client.post(self.url, data={'pin': '1234'}) set_user_has_confirmed_pin.assert_called_with(ANY, True) assert res['Location'].endswith(get_payment_url(Mock()))
def test_good_pin(self): res = self.client.post(self.url, data={'pin': '1234'}) assert res['Location'].endswith(get_payment_url())
def test_pin_recently_entered_successfully(self): self.request.session['last_pin_success'] = datetime.now() eq_(utils.check_pin_status(self.request), get_payment_url())
def test_pin_recently_entered_successfully(self): self.request.session['last_pin_success'] = datetime.now() eq_(utils.check_pin_status(self.request), get_payment_url(mock.Mock()))
def test_good_pin(self): res = self.client.post(self.url, data={'pin': '1234'}) assert res['Location'].endswith(get_payment_url(Mock()))
def test_good_pin(self, set_user_has_confirmed_pin): res = self.client.post(self.url, data={"pin": "1234"}) set_user_has_confirmed_pin.assert_called_with(ANY, True) assert res["Location"].endswith(get_payment_url())
def test_good_pin(self): res = self.client.post(self.url, data={'pin': '1234'}) self.assertRedirects(res, get_payment_url())
def test_good_pin(self): res = self.client.post(self.url, data={"pin": "1234"}) assert res["Location"].endswith(get_payment_url()) # Make sure the reverification flag was cleared out. eq_(res.client.session["was_reverified"], False)
def test_good_pin(self): res = self.client.post(self.url, data={"pin": "1234"}) assert res["Location"].endswith(get_payment_url())