Exemple #1
0
 def test_check_user__wrong_md5(self):
     self.assertTrue(
         check_user(command=COMMAND_TYPE.CHECK,
                    external_md5='bla-bla',
                    v1=self.user_email,
                    v2=None,
                    v3=None).is_WRONG_MD5)
Exemple #2
0
 def test_check_user__no_v1(self):
     self.assertTrue(
         check_user(command=COMMAND_TYPE.CHECK,
                    external_md5=self.check_user_md5,
                    v1=None,
                    v2=None,
                    v3=None).is_NOT_SPECIFIED_V1)
Exemple #3
0
    def test_check_user__user_not_exists(self):
        with mock.patch('the_tale.finances.bank.logic.get_account_id', mock.Mock(return_value=None)) as bank_check_user:
            self.assertTrue(check_user(command=COMMAND_TYPE.CHECK,
                                       external_md5=self.check_user_md5,
                                       v1=self.user_email,
                                       v2=None,
                                       v3=None).is_USER_NOT_EXISTS)

        self.assertEqual(bank_check_user.call_count, 1)
        self.assertEqual(bank_check_user.call_args, mock.call(email=self.user_email))
Exemple #4
0
    def command(self,
                command=None,
                md5=None,
                v1=None,
                v2=None,
                v3=None,
                id=None,
                sum=None,
                test=None,
                date=None):
        try:
            self.log(command)

            if self.user_ip not in xsolla_settings.ALLOWED_IPS:
                return self.create_answer(COMMON_RESULT.DISALLOWED_IP)

            try:
                command = COMMAND_TYPE(command)
            except:
                return self.create_answer(COMMON_RESULT.WRONG_COMMAND)

            if command.is_CHECK:
                return self.create_check_answer(
                    xsolla_logic.check_user(command=command,
                                            external_md5=md5,
                                            v1=v1,
                                            v2=v2,
                                            v3=v3))
            elif command.is_PAY:
                pay_result, internal_id = xsolla_logic.pay(
                    command=command,
                    external_md5=md5,
                    v1=v1,
                    v2=v2,
                    v3=v3,
                    id=id,
                    sum=sum,
                    test=test,
                    date=date,
                    request_url=self.request.build_absolute_uri())
                return self.create_pay_answer(pay_result,
                                              xsolla_id=id,
                                              internal_id=internal_id,
                                              sum=sum)

            elif command.is_CANCEL:
                return self.create_cancel_answer()
        except:
            logger.error('XSOLLA command exception',
                         exc_info=sys.exc_info(),
                         extra={})
            return self.create_answer(COMMON_RESULT.UNKNOWN_ERROR)
Exemple #5
0
    def test_check_user__user_not_exists(self):
        with mock.patch('the_tale.finances.bank.logic.get_account_id',
                        mock.Mock(return_value=None)) as bank_check_user:
            self.assertTrue(
                check_user(command=COMMAND_TYPE.CHECK,
                           external_md5=self.check_user_md5,
                           v1=self.user_email,
                           v2=None,
                           v3=None).is_USER_NOT_EXISTS)

        self.assertEqual(bank_check_user.call_count, 1)
        self.assertEqual(bank_check_user.call_args,
                         mock.call(email=self.user_email))
Exemple #6
0
    def command(self,
                command=None, md5=None,
                v1=None, v2=None, v3=None,
                id=None, sum=None, test=None, date=None):
        try:
            self.log(command)

            if self.user_ip not in xsolla_settings.ALLOWED_IPS:
                return self.create_answer(COMMON_RESULT.DISALLOWED_IP)

            try:
                command = COMMAND_TYPE(command)
            except:
                return self.create_answer(COMMON_RESULT.WRONG_COMMAND)


            if command.is_CHECK:
                return self.create_check_answer(xsolla_logic.check_user(command=command,
                                                                        external_md5=md5,
                                                                        v1=v1,
                                                                        v2=v2,
                                                                        v3=v3))
            elif command.is_PAY:
                pay_result, internal_id = xsolla_logic.pay(command=command,
                                                           external_md5=md5,
                                                           v1=v1,
                                                           v2=v2,
                                                           v3=v3,
                                                           id=id,
                                                           sum=sum,
                                                           test=test,
                                                           date=date,
                                                           request_url=self.request.build_absolute_uri())
                return self.create_pay_answer(pay_result, xsolla_id=id, internal_id=internal_id, sum=sum)

            elif command.is_CANCEL:
                return self.create_cancel_answer()
        except:
            logger.error('XSOLLA command exception',
                         exc_info=sys.exc_info(),
                         extra={} )
            return self.create_answer(COMMON_RESULT.UNKNOWN_ERROR)
Exemple #7
0
 def test_check_user__no_v1(self):
     self.assertTrue(check_user(command=COMMAND_TYPE.CHECK,
                                external_md5=self.check_user_md5,
                                v1=None,
                                v2=None,
                                v3=None).is_NOT_SPECIFIED_V1)
Exemple #8
0
 def test_check_user__wrong_md5(self):
     self.assertTrue(check_user(command=COMMAND_TYPE.CHECK,
                                external_md5='bla-bla',
                                v1=self.user_email,
                                v2=None,
                                v3=None).is_WRONG_MD5)