Exemple #1
0
    def test_sign_fails(self, receipt):
        from lib.crypto.receipt import SigningError

        receipt.sign.side_effect = SigningError
        eq_(signer()[0][:16], "Error on signing")
Exemple #2
0
 def test_crack_fails(self, receipt):
     receipt.crack.side_effect = ValueError
     eq_(signer()[0][:25], "Error on cracking receipt")
Exemple #3
0
 def test_expire(self, receipt):
     now = time.time()
     receipt.crack.return_value = [{'exp': now + (60 * 60 * 12)}, '']
     eq_(signer()[0], False)
Exemple #4
0
 def test_good(self, receipt):
     now = time.time()
     receipt.crack.return_value = [{'exp': now + (60 * 60 * 36)}, '']
     eq_(signer()[0], True)
Exemple #5
0
 def test_public_cert_no_json(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = lambda: None
     eq_(signer()[0][:29], "Error on checking public cert")
Exemple #6
0
 def test_crack_fails(self, receipt):
     receipt.crack.side_effect = ValueError
     eq_(signer()[0][:25], 'Error on cracking receipt')
Exemple #7
0
 def test_public_cert_invalid_jwk(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = {'foo': 1}
     eq_(signer()[0][:29], 'Error on checking public cert')
Exemple #8
0
 def test_public_cert_connection_error(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.side_effect = Exception
     eq_(signer()[0][:29], "Error on checking public cert")
Exemple #9
0
 def test_public_cert_not_found(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = False
     cert_response.return_value.reason = 'Not Found'
     eq_(signer()[0][:29], 'Error on checking public cert')
Exemple #10
0
 def test_public_cert_no_json(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = None
     eq_(signer()[0][:29], 'Error on checking public cert')
Exemple #11
0
 def test_public_cert_connection_error(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.side_effect = Exception
     eq_(signer()[0][:29], 'Error on checking public cert')
Exemple #12
0
 def test_good(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = {'jwk': []}
     eq_(signer()[0], '')
Exemple #13
0
 def test_expire(self, receipt):
     now = time.time()
     receipt.crack.return_value = [{'exp': now + (3600 * 12)}, '']
     eq_(signer()[0][:21], 'Cert will expire soon')
Exemple #14
0
 def test_expire(self, receipt):
     now = time.time()
     receipt.crack.return_value = [{"exp": now + (3600 * 12)}, ""]
     eq_(signer()[0][:21], "Cert will expire soon")
 def test_expire(self, receipt):
     now = time.time()
     receipt.crack.return_value = [{'exp': now + (3600 * 12)}, '']
     eq_(signer()[0][:21], 'Cert will expire soon')
Exemple #16
0
 def test_good(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = lambda: {"jwk": []}
     eq_(signer()[0], "")
Exemple #17
0
 def test_sign_fails(self, receipt):
     receipt.sign.side_effect = receipt.SigningError
     eq_(signer()[0], False)
Exemple #18
0
 def test_public_cert_not_found(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = False
     cert_response.return_value.reason = "Not Found"
     eq_(signer()[0][:29], "Error on checking public cert")
Exemple #19
0
 def test_crack_fails(self, receipt):
     receipt.crack.side_effect = ValueError
     eq_(signer()[0], False)
Exemple #20
0
 def test_public_cert_invalid_jwk(self, receipt, cert_response):
     receipt.crack.return_value = self._make_receipt()
     cert_response.return_value.ok = True
     cert_response.return_value.json = lambda: {"foo": 1}
     eq_(signer()[0][:29], "Error on checking public cert")
Exemple #21
0
 def test_sign_fails(self, receipt):
     from lib.crypto.receipt import SigningError
     receipt.sign.side_effect = SigningError
     eq_(signer()[0][:16], 'Error on signing')