예제 #1
0
 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)
예제 #2
0
파일: tests.py 프로젝트: lissyx/webpay
 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)
예제 #3
0
파일: tests.py 프로젝트: raulmalea/webpay
 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)
예제 #4
0
파일: tests.py 프로젝트: lissyx/webpay
 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)
예제 #5
0
파일: tests.py 프로젝트: MorrisJobke/webpay
 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)
예제 #6
0
파일: tests.py 프로젝트: MorrisJobke/webpay
 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)
예제 #7
0
    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']
예제 #8
0
 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']])
예제 #9
0
파일: tests.py 프로젝트: raulmalea/webpay
    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"]
예제 #10
0
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',
            }
        })
예제 #11
0
파일: tests.py 프로젝트: lissyx/webpay
 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']])
예제 #12
0
파일: views.py 프로젝트: cvan/webpay
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})
예제 #13
0
파일: tests.py 프로젝트: petercpg/webpay
 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])
예제 #14
0
파일: tests.py 프로젝트: v1ka5/webpay
 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']])
예제 #15
0
파일: views.py 프로젝트: potch/webpay
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') })
예제 #16
0
파일: api.py 프로젝트: lissyx/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.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)
예제 #17
0
파일: api.py 프로젝트: ShimaYasuhiro/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.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)
예제 #18
0
파일: tests.py 프로젝트: v1ka5/webpay
 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.']])
예제 #19
0
파일: views.py 프로젝트: markh-bz/webpay
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')})
예제 #20
0
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')})
예제 #21
0
파일: views.py 프로젝트: Kodextor/webpay
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',
                  }})
예제 #22
0
파일: tests.py 프로젝트: raulmalea/webpay
 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"), {})
예제 #23
0
파일: tests.py 프로젝트: MorrisJobke/webpay
 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), {})
예제 #24
0
파일: tests.py 프로젝트: MorrisJobke/webpay
 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'), {})
예제 #25
0
파일: tests.py 프로젝트: raulmalea/webpay
 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"]])
예제 #26
0
 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'), {})
예제 #27
0
파일: tests.py 프로젝트: lissyx/webpay
 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'), {})
예제 #28
0
파일: tests.py 프로젝트: lissyx/webpay
 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), {})