Beispiel #1
0
    def test_expired(self):
        old = Receipt(sample).receipt_decoded()
        new = Receipt(reissue_receipt(sample)).receipt_decoded()
        for greater in ['exp', 'iat', 'nbf']:
            assert new[greater] > old[greater], (
                '{0} for new: {1} should be greater than old: {2}'.format(
                    greater, new[greater], old[greater]))

        for same in ['product', 'detail', 'iss', 'reissue', 'typ', 'user',
                     'verify']:
            eq_(new[same], old[same], (
                '{0} for new: {1} should be the same as old: {2}'.format(
                    greater, new[same], old[same])))
Beispiel #2
0
    def test_expired(self):
        old = Receipt(sample).receipt_decoded()
        new = Receipt(reissue_receipt(sample)).receipt_decoded()
        for greater in ['exp', 'iat', 'nbf']:
            assert new[greater] > old[greater], (
                '{0} for new: {1} should be greater than old: {2}'.format(
                    greater, new[greater], old[greater]))

        for same in [
                'product', 'detail', 'iss', 'reissue', 'typ', 'user', 'verify'
        ]:
            eq_(new[same], old[same],
                ('{0} for new: {1} should be the same as old: {2}'.format(
                    greater, new[same], old[same])))
Beispiel #3
0
def reissue(request):
    """
    Reissues an existing receipt, provided from the client. Will only do
    so if the receipt is a full receipt and expired.
    """
    raw = request.read()
    verify = Verify(raw, request.META)
    output = verify.check_full()

    # We will only re-sign expired receipts.
    if output["status"] != "expired":
        log.info("Receipt not expired returned: {0}".format(output))
        receipt_cef.log(request._request, None, "sign", "Receipt reissue failed")
        output["receipt"] = ""
        return Response(output, status=400)

    receipt_cef.log(request._request, None, "sign", "Receipt reissue signing")
    return Response({"reason": "", "receipt": reissue_receipt(raw), "status": "expired"})
Beispiel #4
0
    def test_expired(self):
        receipt_data = get_sample_app_receipt()
        curr_time = calendar.timegm(time.gmtime())
        receipt_data['iat'] = curr_time - 1000
        receipt_data['nbf'] = curr_time - 1000
        receipt_data['exp'] = curr_time
        receipt = sign(receipt_data)
        old = Receipt(receipt).receipt_decoded()
        new = Receipt(reissue_receipt(receipt)).receipt_decoded()
        for greater in ['exp', 'iat', 'nbf']:
            assert new[greater] > old[greater], (
                '{0} for new: {1} should be greater than old: {2}'.format(
                    greater, new[greater], old[greater]))

        for same in ['product', 'detail', 'iss', 'reissue', 'typ', 'user',
                     'verify']:
            eq_(new[same], old[same], (
                '{0} for new: {1} should be the same as old: {2}'.format(
                    greater, new[same], old[same])))
Beispiel #5
0
def reissue(request):
    """
    Reissues an existing receipt, provided from the client. Will only do
    so if the receipt is a full receipt and expired.
    """
    raw = request.read()
    verify = Verify(raw, request.META)
    output = verify.check_full()

    # We will only re-sign expired receipts.
    if output['status'] != 'expired':
        log.info('Receipt not expired returned: {0}'.format(output))
        receipt_cef.log(request._request, None, 'sign',
                        'Receipt reissue failed')
        output['receipt'] = ''
        return Response(output, status=400)

    receipt_cef.log(request._request, None, 'sign', 'Receipt reissue signing')
    return Response({'reason': '', 'receipt': reissue_receipt(raw),
                     'status': 'expired'})
Beispiel #6
0
def reissue(request):
    """
    Reissues an existing receipt, provided from the client. Will only do
    so if the receipt is a full receipt and expired.
    """
    raw = request.read()
    verify = Verify(raw, request.META)
    output = verify.check_full()

    # We will only re-sign expired receipts.
    if output['status'] != 'expired':
        log.info('Receipt not expired returned: {0}'.format(output))
        receipt_cef.log(request._request, None, 'sign',
                        'Receipt reissue failed')
        output['receipt'] = ''
        return Response(output, status=400)

    receipt_cef.log(request._request, None, 'sign', 'Receipt reissue signing')
    return Response({'reason': '', 'receipt': reissue_receipt(raw),
                     'status': 'expired'})
Beispiel #7
0
    def test_expired(self):
        receipt_data = self.sample_app_receipt()
        curr_time = calendar.timegm(time.gmtime())
        receipt_data['iat'] = curr_time - 1000
        receipt_data['nbf'] = curr_time - 1000
        receipt_data['exp'] = curr_time
        receipt = sign(receipt_data)
        old = Receipt(receipt).receipt_decoded()
        new = Receipt(reissue_receipt(receipt)).receipt_decoded()
        for greater in ['exp', 'iat', 'nbf']:
            assert new[greater] > old[greater], (
                '{0} for new: {1} should be greater than old: {2}'.format(
                    greater, new[greater], old[greater]))

        for same in [
                'product', 'detail', 'iss', 'reissue', 'typ', 'user', 'verify'
        ]:
            eq_(new[same], old[same],
                ('{0} for new: {1} should be the same as old: {2}'.format(
                    greater, new[same], old[same])))