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')
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')
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')
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')
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], '')
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_crack_fails(self, receipt): receipt.crack.side_effect = ValueError eq_(signer()[0][:25], 'Error on cracking receipt')
def test_sign_fails(self, receipt): from lib.crypto.receipt import SigningError receipt.sign.side_effect = SigningError eq_(signer()[0][:16], 'Error on signing')