예제 #1
0
 def test_wrong_key(self):
     tmp = tempfile.NamedTemporaryFile(mode='w', delete=False)
     tmp.write('some secret')
     tmp.close()
     self.addCleanup(lambda: os.unlink(tmp.name))
     with self.settings(AES_KEYS={'bango:signature': tmp.name}):
         sig = sign('123')
     assert not verify_sig(sig, '123')
예제 #2
0
 def test_wrong_key(self):
     tmp = tempfile.NamedTemporaryFile(mode='w', delete=False)
     tmp.write('some secret')
     tmp.close()
     self.addCleanup(lambda: os.unlink(tmp.name))
     with self.settings(AES_KEYS={'bango:signature': tmp.name}):
         sig = sign('123')
     assert not verify_sig(sig, '123')
예제 #3
0
파일: forms.py 프로젝트: ngokevin/solitude
 def clean(self):
     cleaned_data = super(NotificationForm, self).clean()
     trans = cleaned_data.get('moz_transaction')
     sig = cleaned_data.get('moz_signature')
     if trans and sig:
         # Both fields were non-empty so check the signature.
         if not verify_sig(sig, trans.uuid):
             log.info('Signature failed: %s'
                      % cleaned_data.get('billing_config_id'))
             raise forms.ValidationError(
                     'Signature did not match: %s for %s'
                     % (sig, trans.uuid))
     return cleaned_data
예제 #4
0
파일: forms.py 프로젝트: dimonov/solitude
 def clean(self):
     cleaned_data = super(PaymentNoticeForm, self).clean()
     trans = cleaned_data.get('moz_transaction')
     sig = cleaned_data.get('moz_signature')
     if trans and sig:
         # Both fields were non-empty so check the signature.
         if not verify_sig(sig, trans.uuid):
             log.info('Bango payment notice signature failed for '
                      'billing_config_id %r'
                      % cleaned_data.get('billing_config_id'))
             raise forms.ValidationError(
                     'Signature %r of transaction UUID %r did not match'
                     % (sig, trans.uuid))
     return cleaned_data
예제 #5
0
    def clean(self):
        cleaned_data = super(NotificationForm, self).clean()
        trans = cleaned_data.get('moz_transaction')
        sig = cleaned_data.get('moz_signature')
        if trans and sig:
            # Both fields were non-empty so check the signature.
            if not verify_sig(sig, trans.uuid):
                log.info('Signature failed: %s' %
                         cleaned_data.get('billing_config_id'))
                raise forms.ValidationError(
                    'Signature did not match: %s for %s' % (sig, trans.uuid))

        tok = cleaned_data.get('bango_token')
        if settings.CHECK_BANGO_TOKEN and tok:
            self._check_for_tampering(tok, cleaned_data)

        return cleaned_data
예제 #6
0
    def clean(self):
        cleaned_data = super(NotificationForm, self).clean()
        trans = cleaned_data.get('moz_transaction')
        sig = cleaned_data.get('moz_signature')
        if trans and sig:
            # Both fields were non-empty so check the signature.
            if not verify_sig(sig, trans.uuid):
                log.info('Signature failed: %s'
                         % cleaned_data.get('billing_config_id'))
                raise forms.ValidationError(
                        'Signature did not match: %s for %s'
                        % (sig, trans.uuid))

        tok = cleaned_data.get('bango_token')
        if settings.CHECK_BANGO_TOKEN and tok:
            self._check_for_tampering(tok, cleaned_data)

        return cleaned_data
예제 #7
0
 def test_sign_unicode(self):
     sig = sign('123')
     assert verify_sig(sig, u'123')
예제 #8
0
 def test_sign(self):
     sig = sign('123')
     assert verify_sig(sig, '123')
예제 #9
0
 def test_sign_unicode(self):
     sig = sign('123')
     assert verify_sig(sig, u'123')
예제 #10
0
 def test_sign(self):
     sig = sign('123')
     assert verify_sig(sig, '123')