コード例 #1
0
ファイル: tests.py プロジェクト: tempbottle/webpay
 def test_change_pin_clear_was_locked(self, slumber):
     buyer = self.setup_buyer(slumber)
     client.change_pin(self.uuid, '1234', clear_was_locked=True)
     buyer.patch.assert_called_with({'pin': '1234',
                                     'pin_confirmed': False,
                                     'pin_was_locked_out': False},
                                    headers={'If-Match': ''})
コード例 #2
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_clear_was_locked(self, slumber):
     buyer = self.setup_buyer(slumber)
     client.change_pin(self.uuid, '1234', clear_was_locked=True)
     buyer.patch.assert_called_with({'pin': '1234',
                                     'pin_confirmed': False,
                                     'pin_was_locked_out': False},
                                    headers={'If-Match': ''})
コード例 #3
0
ファイル: tests.py プロジェクト: raulmalea/webpay
 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)
コード例 #4
0
ファイル: tests.py プロジェクト: raulmalea/webpay
 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)
コード例 #5
0
ファイル: tests.py プロジェクト: raulmalea/webpay
 def test_change_pin_to_remove_exising_pin(self):
     uuid = "change_pin_to_remove_exising_pin"
     pin = "5467"
     new_pin = None
     buyer = client.create_buyer(uuid, pin)
     assert buyer.get("pin")
     client.change_pin(uuid, new_pin)
     buyer = client.get_buyer(uuid)
     assert not buyer.get("pin")
コード例 #6
0
 def test_change_pin_to_remove_exising_pin(self):
     uuid = 'change_pin_to_remove_exising_pin'
     pin = '5467'
     new_pin = None
     buyer = client.create_buyer(uuid, pin)
     assert buyer.get('pin')
     client.change_pin(uuid, new_pin)
     buyer = client.get_buyer(uuid)
     assert not buyer.get('pin')
コード例 #7
0
 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)
コード例 #8
0
ファイル: tests.py プロジェクト: lissyx/webpay
 def test_change_pin_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.change_pin(self.uuid, self.pin, wrong_etag)
コード例 #9
0
 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)
コード例 #10
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_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.change_pin(self.uuid, self.pin, wrong_etag)
コード例 #11
0
ファイル: utils.py プロジェクト: robhudson/webpay
def has_pin(request):
    pin = request.session.get('uuid_has_pin')
    confirmed = request.session.get('uuid_has_confirmed_pin')
    if pin:
        if confirmed:
            return True
        else:
            client.change_pin(request.session['uuid'], None)
            request.session['uuid_has_pin'] = False
    return False
コード例 #12
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                try:
                    res = client.change_pin(form.uuid,
                                            form.cleaned_data['pin'],
                                            etag=form.buyer_etag)
                except ResourceModified:
                    return system_error(request, code=msg.RESOURCE_MODIFIED)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(
        request, 'pin/pin_form.html', {
            'form': form,
            'title': _('Create a Pin'),
            'action': reverse('pin.create'),
            'pin_form_tracking': {
                'pin_error_codes': form.pin_error_codes,
            },
            'track_cancel': {
                'action': 'pin cancel',
                'label': 'Create Pin Page',
            }
        })
コード例 #13
0
ファイル: views.py プロジェクト: Kodextor/webpay
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                try:
                    res = client.change_pin(form.uuid,
                                            form.cleaned_data['pin'],
                                            etag=form.buyer_etag)
                except ResourceModified:
                    return system_error(request, code=msg.RESOURCE_MODIFIED)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create a Pin'),
                  'action': reverse('pin.create'),
                  'pin_form_tracking' : {
                      'pin_error_codes': form.pin_error_codes,
                  },
                  'track_cancel': {
                      'action': 'pin cancel',
                      'label': 'Create Pin Page',
                  }})
コード例 #14
0
ファイル: tests.py プロジェクト: tempbottle/webpay
 def test_change_pin_with_existing_pin(self, slumber):
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, self.pin)
     buyer.patch.assert_called_with({'pin': '1234', 'pin_confirmed': False},
                                    headers={'If-Match': ''})
コード例 #15
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_with_existing_pin(self, slumber):
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, self.pin)
     buyer.patch.assert_called_with({'pin': '1234', 'pin_confirmed': False},
                                    headers={'If-Match': ''})
コード例 #16
0
ファイル: utils.py プロジェクト: Chiara-De-Liberato/webpay
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')
コード例 #17
0
ファイル: utils.py プロジェクト: ferjm/webpay
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')
コード例 #18
0
ファイル: tests.py プロジェクト: v1ka5/webpay
 def test_change_pin_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': [('The resource has been modified, '
                                       'please re-fetch it.')]}))
     slumber.generic.buyer.return_value = buyer
     res = client.change_pin(self.uuid, self.pin, wrong_etag)
     assert 'errors' in res
     eq_(res['errors'],
     [ERROR_STRINGS['The resource has been modified, please re-fetch it.']])
コード例 #19
0
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_wait_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')
コード例 #20
0
ファイル: api.py プロジェクト: Witia1/webpay
    def update(self, request):
        form = ResetPinForm(uuid=request.session['uuid'], data=request.DATA,
                            user_reset=request.session.get('user_reset', {}))
        if form.is_valid():
            del request.session['user_reset']
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    pin_confirmed=True,
                                    clear_was_locked=True)
            if form.client_response_is_valid(res):
                return response.Response(status=204)

        return api_error(form, request)
コード例 #21
0
ファイル: utils.py プロジェクト: JaredKerim-Mozilla/webpay
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_wait_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')
コード例 #22
0
ファイル: views.py プロジェクト: cvan/webpay
def create(request):
    form = forms.CreatePinForm()
    if request.method == "POST":
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if hasattr(form, "buyer"):
                res = client.change_pin(form.buyer, form.cleaned_data["pin"])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data["pin"])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse("pin.confirm"))
    return render(request, "pin/create.html", {"form": form})
コード例 #23
0
ファイル: api.py プロジェクト: Witia1/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    etag=form.buyer_etag,
                                    pin_confirmed=True,
                                    clear_was_locked=True)

            if form.client_response_is_valid(res):
                set_user_has_pin(request, True)
                return response.Response(status=204)

        return api_error(form, request)
コード例 #24
0
ファイル: views.py プロジェクト: lonnen/webpay
def change(request):
    form = forms.ChangePinForm()
    if request.method == 'POST':
        # TODO(Wraithan): Get the buyer's UUID once identity is figured out
        # with webpay.
        stub_uuid = 'dat:uuid'
        form = forms.ChangePinForm(uuid=stub_uuid, data=request.POST)
        if form.is_valid():
            res = client.change_pin(form.buyer, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                # TODO(Wraithan): Replace with proper redirect
                return render(request, 'pin/change_success.html',
                              {'form': form})
    return render(request, 'pin/change.html', {'form': form})
コード例 #25
0
ファイル: api.py プロジェクト: tempbottle/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    etag=form.buyer_etag,
                                    pin_confirmed=True,
                                    clear_was_locked=True)

            if form.client_response_is_valid(res):
                set_user_has_pin(request, True)
                return response.Response(status=204)

        return api_error(form, request)
コード例 #26
0
ファイル: api.py プロジェクト: tempbottle/webpay
    def update(self, request):
        form = ResetPinForm(uuid=request.session['uuid'],
                            data=request.DATA,
                            user_reset=request.session.get('user_reset', {}))
        if form.is_valid():
            del request.session['user_reset']
            res = client.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    pin_confirmed=True,
                                    clear_was_locked=True)
            if form.client_response_is_valid(res):
                return response.Response(status=204)

        return api_error(form, request)
コード例 #27
0
ファイル: views.py プロジェクト: potch/webpay
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if hasattr(form, 'buyer'):
                res = client.change_pin(form.buyer, form.cleaned_data['pin'])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create your PIN:'),
                  'action': reverse('pin.create') })
コード例 #28
0
ファイル: api.py プロジェクト: unghost/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session["uuid"], data=request.DATA)
        if form.is_valid():
            if getattr(form, "buyer_exists", None):
                res = client.change_pin(form.uuid, form.cleaned_data["pin"], etag=form.buyer_etag)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data["pin"])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return response.Response(status=201)

            return response.Response(status=201)

        return app_error(request)
コード例 #29
0
def create(request):
    form = forms.CreatePinForm()
    if request.method == 'POST':
        form = forms.CreatePinForm(uuid=get_user(request), data=request.POST)
        if form.is_valid():
            if getattr(form, 'buyer_exists', False):
                res = client.change_pin(form.uuid, form.cleaned_data['pin'])
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])
            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return http.HttpResponseRedirect(reverse('pin.confirm'))
    form.no_pin = True
    return render(request, 'pin/pin_form.html', {'form': form,
                  'title': _('Create a Pin'),
                  'action': reverse('pin.create')})
コード例 #30
0
ファイル: api.py プロジェクト: Joergen/webpay
    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.change_pin(form.uuid,
                                    form.cleaned_data['pin'],
                                    pin_confirmed=True,
                                    clear_was_locked=True)
            if form.handle_client_errors(res):
                request.session['was_reverified'] = False
                return response.Response(status=204)

        return app_error(request)
コード例 #31
0
ファイル: api.py プロジェクト: lissyx/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            if getattr(form, 'buyer_exists', None):
                res = client.change_pin(form.uuid,
                                        form.cleaned_data['pin'],
                                        etag=form.buyer_etag)
            else:
                res = client.create_buyer(form.uuid, form.cleaned_data['pin'])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)
                return response.Response(status=201)

            return response.Response(status=201)

        return app_error(request)
コード例 #32
0
ファイル: api.py プロジェクト: kyoshino/webpay
    def create(self, request):
        form = CreatePinForm(uuid=request.session['uuid'], data=request.DATA)
        if form.is_valid():
            if getattr(form, 'buyer_exists', None):
                res = client.change_pin(form.uuid,
                                        form.cleaned_data['pin'],
                                        etag=form.buyer_etag,
                                        pin_confirmed=True,
                                        clear_was_locked=True)
            else:
                res = client.create_buyer(form.uuid,
                                          pin=form.cleaned_data['pin'],
                                          pin_confirmed=True,
                                          email=request.session[
                                              'logged_in_user'])

            if form.handle_client_errors(res):
                set_user_has_pin(request, True)

            return response.Response(status=204)

        return app_error(request)
コード例 #33
0
ファイル: tests.py プロジェクト: tempbottle/webpay
 def test_change_pin_and_not_confirmed(self, slumber):
     buyer = self.setup_buyer(slumber)
     client.change_pin(self.uuid, '1234', pin_confirmed=False)
     buyer.patch.assert_called_with({'pin': '1234', 'pin_confirmed': False},
                                    headers={'If-Match': ''})
コード例 #34
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_and_not_confirmed(self, slumber):
     buyer = self.setup_buyer(slumber)
     client.change_pin(self.uuid, '1234', pin_confirmed=False)
     buyer.patch.assert_called_with({'pin': '1234', 'pin_confirmed': False},
                                    headers={'If-Match': ''})
コード例 #35
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_with_etag(self, slumber):
     etag = 'etag:good'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, self.pin, etag)
コード例 #36
0
ファイル: tests.py プロジェクト: lissyx/webpay
 def test_change_pin_to_remove_existing_pin(self, slumber):
     new_pin = None
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, new_pin)
コード例 #37
0
ファイル: tests.py プロジェクト: lonnen/webpay
 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), {})
コード例 #38
0
ファイル: tests.py プロジェクト: MorrisJobke/webpay
 def test_change_pin_to_remove_existing_pin(self, slumber):
     new_pin = None
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, new_pin)
コード例 #39
0
ファイル: tests.py プロジェクト: lissyx/webpay
 def test_change_pin_with_etag(self, slumber):
     etag = 'etag:good'
     buyer = mock.Mock(return_value=self.buyer_data)
     buyer.patch.return_value = {}
     slumber.generic.buyer.return_value = buyer
     assert 'errors' not in client.change_pin(self.uuid, self.pin, etag)