def from_log_record(log_record): return storage_pb2.LogRecord(id=log_record.id, transaction=log_record.transaction.hex, item_id=log_record.item_id.hex, type=log_record.type.value, data=s11n.to_json(log_record.data), created_at=time.mktime(log_record.created_at.timetuple()) + log_record.created_at.microsecond / 1000000)
async def test_restrictions_saved(self): await helpers.call_change_balance(account_id=666, currency=1, amount=1000) await helpers.call_change_balance(account_id=667, currency=1, amount=1000) restrictions_data = { 'hard_minimum': 0, 'hard_maximum': 10000, 'soft_minimum': 7, 'soft_maximum': 7000 } restrictions = s11n.to_json(restrictions_data) request = await self.client.post( '/transactions/start', data=bank_pb2.StartTransactionRequest( operations=TEST_OPERATIONS, lifetime=0, restrictions=restrictions).SerializeToString()) answer = await self.check_success(request, bank_pb2.StartTransactionResponse) results = await db.sql('SELECT * FROM transactions WHERE id=%(id)s', {'id': answer.transaction_id}) self.assertEqual(results[0]['data']['restrictions'], restrictions_data)
def create_effect(uid, id=None): return objects.Effect(id=id, attribute=random.randint(1, 100), entity=random.randint(1, 100), value='some.value.{}'.format(uid), caption='effect caption {}'.format(uid), data=s11n.to_json({'expired_at': 666, 'uid': uid}))
def from_event(event): return events_log_pb2.Event( id=event.id, data=s11n.to_json(event.data), tags=tuple(event.tags), turn=event.created_at_turn, time=time.mktime(event.created_at.timetuple()) + event.created_at.microsecond / 1000000)
async def test_no_signature(self): request_data = await self.user_validateion_request() response = await self.client.post('/xsolla-hook', data=s11n.to_json(request_data)) await self.check_xsolla_error(response, 'INVALID_SIGNATURE', 'xsolla.hook.signature_has_not_found')
async def request_hook(self, request_data): content = s11n.to_json(request_data) response = await self.client.post('/xsolla-hook', data=content, headers=self.headers(content)) return response
def from_log_record(log_record): return storage_pb2.LogRecord( id=log_record.id, transaction=log_record.transaction.hex, item_id=log_record.item_id.hex, type=log_record.type.value, data=s11n.to_json(log_record.data), created_at=time.mktime(log_record.created_at.timetuple()) + log_record.created_at.microsecond / 1000000)
def from_report(report): return data_protector_pb2.Report( state=report.state.value, data=s11n.to_json(report.data['report']) if report.data is not None else '[]', completed_at=utils.postgres_time_to_timestamp(report.completed_at) if report.completed_at else None, expire_at=utils.postgres_time_to_timestamp(report.expire_at) if report.expire_at else None)
async def test_unexpected_signature(self): request_data = await self.user_validateion_request() response = await self.client.post( '/xsolla-hook', data=s11n.to_json(request_data), headers={'Authorization': 'Signature: blablabla'}) await self.check_xsolla_error(response, 'INVALID_SIGNATURE', 'xsolla.hook.unexpected_signature')
async def data_protection_collect_data(message, config, **kwargs): if config['custom']['data_protector']['secret'] != message.secret: raise tt_exceptions.ApiError(code='properties.data_protection_collect_data.wrong_secret', message='wrong secret code') report = await operations.get_data_report(object_id=int(message.account_id)) return data_protector_pb2.PluginReportResponse(result=data_protector_pb2.PluginReportResponse.ResultType.SUCCESS, data=s11n.to_json(report))
def xsolla_error(code, message, details): status_code = 400 if code == 'api.unknown_error': details['code'] = code status_code = 500 data = {'error': {'code': code, 'message': message, 'details': details}} return web.Response(content_type='application/json', status=status_code, body=s11n.to_json(data))
async def data_protection_collect_data(message, config, **kwargs): if config['custom']['data_protector']['secret'] != message.secret: raise tt_exceptions.ApiError( code='discord.data_protection_collect_data.wrong_secret', message='wrong secret code') account_info = await operations.get_account_info_by_game_id( int(message.account_id), create_if_not_exists=False) report = await operations.get_data_report(account_info=account_info) return data_protector_pb2.PluginReportResponse( result=data_protector_pb2.PluginReportResponse.ResultType.SUCCESS, data=s11n.to_json(report))
def from_item(item): return storage_pb2.Item(id=item.id.hex, owner_id=item.owner_id, storage_id=item.storage_id, data=s11n.to_json(item.data))
def from_item(item): return storage_pb2.Item(id=item.id.hex, owner_id=item.owner_id, storage_id=item.storage_id, data=s11n.to_json(item.data))
def xsolla_ok(message): return web.Response(content_type='application/json', status=204, body=s11n.to_json(message))
def from_event(event): return events_log_pb2.Event(id=event.id, data=s11n.to_json(event.data), tags=tuple(event.tags), turn=event.created_at_turn, time=time.mktime(event.created_at.timetuple())+event.created_at.microsecond / 1000000)