Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 3
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))
     return cleaned_data
Exemplo n.º 4
0
 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 7
0
 def test_sign_unicode(self):
     sig = sign('123')
     assert verify_sig(sig, u'123')
Exemplo n.º 8
0
 def test_sign(self):
     sig = sign('123')
     assert verify_sig(sig, '123')
Exemplo n.º 9
0
 def test_sign_unicode(self):
     sig = sign('123')
     assert verify_sig(sig, u'123')
Exemplo n.º 10
0
 def test_sign(self):
     sig = sign('123')
     assert verify_sig(sig, '123')