예제 #1
0
    def test_valid_iap(self):
        VerifyRequest.record_data(self.valid_iap)
        user = User.get(ifa=self.valid_iap['ifa'])
        xact = IOSTransaction.get(xact_id=self.valid_iap['xact_id'])

        self.assertEqual(xact.local_status, 0)
        self.assertEqual(user.cheat_date, None)
        self.assertEqual(user.cheat_type, None)
예제 #2
0
    def test_valid_iap(self):
        VerifyRequest.record_data(self.valid_iap)
        user = User.get(ifa = self.valid_iap['ifa'])
        xact = IOSTransaction.get(xact_id = self.valid_iap['xact_id'])

        self.assertEqual(xact.local_status, 0)
        self.assertEqual(user.cheat_date, None)
        self.assertEqual(user.cheat_type, None)
예제 #3
0
    def test_true_duplicate_iap(self):
        VerifyRequest.record_data(self.valid_iap)
        VerifyRequest.record_data(self.valid_iap)

        user  = User.get(ifv = self.valid_iap['ifv'])
        xact  = IOSTransaction.get(xact_id = self.valid_iap['xact_id'])
        xacts = IOSTransaction.get_all(xact_id = self.valid_iap['xact_id'])

        self.assertEqual(len(xacts), 1)
        self.assertEqual(user.cheat_date, None)
        self.assertEqual(xact.local_status, Status.VALID)
예제 #4
0
    def test_true_duplicate_iap(self):
        VerifyRequest.record_data(self.valid_iap)
        VerifyRequest.record_data(self.valid_iap)

        user = User.get(ifv=self.valid_iap['ifv'])
        xact = IOSTransaction.get(xact_id=self.valid_iap['xact_id'])
        xacts = IOSTransaction.get_all(xact_id=self.valid_iap['xact_id'])

        self.assertEqual(len(xacts), 1)
        self.assertEqual(user.cheat_date, None)
        self.assertEqual(xact.local_status, Status.VALID)
예제 #5
0
    def test_valid_iap_with_different_bundle_is_invalid(self):
        inv_req = dict(self.valid_iap)
        inv_req['ifa'] = str(uuid.uuid4())
        inv_req['ifv'] = str(uuid.uuid4())
        inv_req['bid'] = 'something altogether different entirely'

        VerifyRequest.record_data(inv_req)
        user = User.get(ifv = inv_req['ifv'])
        xact = IOSTransaction.get(xact_id = inv_req['xact_id'])

        self.assertEqual(user.cheat_type, Status.INVALID_BUNDLE)
        self.assertEqual(user.cheat_date, now())
        self.assertEqual(xact.local_status, Status.INVALID_BUNDLE)
예제 #6
0
    def test_valid_iap_with_different_bundle_is_invalid(self):
        inv_req = dict(self.valid_iap)
        inv_req['ifa'] = str(uuid.uuid4())
        inv_req['ifv'] = str(uuid.uuid4())
        inv_req['bid'] = 'something altogether different entirely'

        VerifyRequest.record_data(inv_req)
        user = User.get(ifv=inv_req['ifv'])
        xact = IOSTransaction.get(xact_id=inv_req['xact_id'])

        self.assertEqual(user.cheat_type, Status.INVALID_BUNDLE)
        self.assertEqual(user.cheat_date, now())
        self.assertEqual(xact.local_status, Status.INVALID_BUNDLE)
예제 #7
0
    def test_invalid_iap(self):
        invalid_iap = dict(self.valid_iap)
        invalid_iap['ifa'] = str(uuid.uuid4())
        invalid_iap['ifv'] = str(uuid.uuid4())
        invalid_iap['xact_id'] = str(uuid.uuid4())
        invalid_iap['receipt'] = 'a' + invalid_iap['receipt'][1:]

        VerifyRequest.record_data(invalid_iap)

        user = User.get(ifa = invalid_iap['ifa'])
        self.assertEqual(user.cheat_date, now())
        self.assertEqual(user.cheat_type, Status.INVALID_RECEIPT)

        xact = IOSTransaction.get(xact_id = invalid_iap['xact_id'])
        self.assertEqual(xact.apple_status, 21002)
        self.assertEqual(xact.local_status, Status.INVALID_RECEIPT)
예제 #8
0
    def test_invalid_iap(self):
        invalid_iap = dict(self.valid_iap)
        invalid_iap['ifa'] = str(uuid.uuid4())
        invalid_iap['ifv'] = str(uuid.uuid4())
        invalid_iap['xact_id'] = str(uuid.uuid4())
        invalid_iap['receipt'] = 'a' + invalid_iap['receipt'][1:]

        VerifyRequest.record_data(invalid_iap)

        user = User.get(ifa=invalid_iap['ifa'])
        self.assertEqual(user.cheat_date, now())
        self.assertEqual(user.cheat_type, Status.INVALID_RECEIPT)

        xact = IOSTransaction.get(xact_id=invalid_iap['xact_id'])
        self.assertEqual(xact.apple_status, 21002)
        self.assertEqual(xact.local_status, Status.INVALID_RECEIPT)
예제 #9
0
    def test_valid_iap_with_different_user_is_invalid(self):
        VerifyRequest.record_data(self.valid_iap)

        inv_req = dict(self.valid_iap)
        inv_req['ifa'] = str(uuid.uuid4())
        inv_req['ifv'] = str(uuid.uuid4())

        VerifyRequest.record_data(inv_req)

        valid_user = User.get(ifv = self.valid_iap['ifv'])
        invalid_user = User.get(ifv = inv_req['ifv'])

        xact = IOSTransaction.get(xact_id = self.valid_iap['xact_id'])
        self.assertEqual(xact.local_status, Status.VALID)
        self.assertEqual(xact.user_id, valid_user.id)

        self.assertNotEqual(valid_user.id, invalid_user.id)
        self.assertEqual(valid_user.cheat_type, None)
        self.assertEqual(invalid_user.cheat_type, Status.INVALID_USER)
예제 #10
0
    def test_valid_iap_with_different_user_is_invalid(self):
        VerifyRequest.record_data(self.valid_iap)

        inv_req = dict(self.valid_iap)
        inv_req['ifa'] = str(uuid.uuid4())
        inv_req['ifv'] = str(uuid.uuid4())

        VerifyRequest.record_data(inv_req)

        valid_user = User.get(ifv=self.valid_iap['ifv'])
        invalid_user = User.get(ifv=inv_req['ifv'])

        xact = IOSTransaction.get(xact_id=self.valid_iap['xact_id'])
        self.assertEqual(xact.local_status, Status.VALID)
        self.assertEqual(xact.user_id, valid_user.id)

        self.assertNotEqual(valid_user.id, invalid_user.id)
        self.assertEqual(valid_user.cheat_type, None)
        self.assertEqual(invalid_user.cheat_type, Status.INVALID_USER)
예제 #11
0
    def test_duplicate_iaps_for_same_user(self):
        VerifyRequest.record_data(self.valid_iap)
        valid_user = User.get(ifv = self.valid_iap['ifv'])
        valid_xact = IOSTransaction.get(uuid = self.valid_iap['uuid'])

        self.assertEqual(valid_user.cheat_date, None)
        self.assertEqual(valid_xact.local_status, Status.VALID)

        inv_req = dict(self.valid_iap)
        inv_req['uuid'] = str(uuid.uuid4())

        set_now(None)
        set_now(now())

        VerifyRequest.record_data(inv_req)
        default_session().commit() # This refreshes all the SQLAlchemy objects

        invalid_user = User.get(ifv = inv_req['ifv'])
        invalid_xact = IOSTransaction.get(uuid = inv_req['uuid'])

        self.assertEqual(invalid_xact.local_status, Status.DUPLICATE_IAP)

        self.assertEqual(valid_user.id, invalid_user.id)
        self.assertEqual(invalid_user.cheat_date, now())
예제 #12
0
    def test_duplicate_iaps_for_same_user(self):
        VerifyRequest.record_data(self.valid_iap)
        valid_user = User.get(ifv=self.valid_iap['ifv'])
        valid_xact = IOSTransaction.get(uuid=self.valid_iap['uuid'])

        self.assertEqual(valid_user.cheat_date, None)
        self.assertEqual(valid_xact.local_status, Status.VALID)

        inv_req = dict(self.valid_iap)
        inv_req['uuid'] = str(uuid.uuid4())

        set_now(None)
        set_now(now())

        VerifyRequest.record_data(inv_req)
        default_session().commit()  # This refreshes all the SQLAlchemy objects

        invalid_user = User.get(ifv=inv_req['ifv'])
        invalid_xact = IOSTransaction.get(uuid=inv_req['uuid'])

        self.assertEqual(invalid_xact.local_status, Status.DUPLICATE_IAP)

        self.assertEqual(valid_user.id, invalid_user.id)
        self.assertEqual(invalid_user.cheat_date, now())
예제 #13
0
 def test_creates_user(self):
     VerifyRequest.record_data(self.valid_iap)
     user = User.get(ifa = self.valid_iap['ifa'], ifv = self.valid_iap['ifv'])
     self.assertEqual(user.game_id, self.game.id)
     self.assertEqual(user.company_id, self.company.id)
예제 #14
0
 def test_creates_user(self):
     VerifyRequest.record_data(self.valid_iap)
     user = User.get(ifa=self.valid_iap['ifa'], ifv=self.valid_iap['ifv'])
     self.assertEqual(user.game_id, self.game.id)
     self.assertEqual(user.company_id, self.company.id)