2011-09-27 07:40:51 +01:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2009 Alistair Riddoch
|
|
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
|
// along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG
|
|
|
|
|
#undef NDEBUG
|
|
|
|
|
#endif
|
|
|
|
|
#ifndef DEBUG
|
|
|
|
|
#define DEBUG
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
#include "TestBase.h"
|
|
|
|
|
#include "TestWorld.h"
|
|
|
|
|
|
2011-09-27 18:57:57 +01:00
|
|
|
#include "server/Account.h"
|
|
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
#include "server/Connection.h"
|
2012-09-13 00:02:41 +01:00
|
|
|
#include "server/Lobby.h"
|
2012-08-31 20:00:41 +01:00
|
|
|
#include "server/ServerRouting.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/simulation/Entity.h"
|
2012-08-31 20:00:41 +01:00
|
|
|
|
2012-11-23 11:05:59 +00:00
|
|
|
#include "common/CommSocket.h"
|
2012-08-31 20:00:41 +01:00
|
|
|
#include "common/compose.hpp"
|
2012-09-08 14:15:13 +01:00
|
|
|
#include "common/debug.h"
|
2012-09-08 17:34:48 +01:00
|
|
|
#include "common/id.h"
|
2018-05-19 23:18:40 +02:00
|
|
|
#include "DatabaseNull.h"
|
2012-08-31 20:00:41 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
#include <Atlas/Message/Element.h>
|
|
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
|
|
|
|
#include <Atlas/Objects/Operation.h>
|
2012-08-31 20:00:41 +01:00
|
|
|
#include <Atlas/Objects/SmartPtr.h>
|
|
|
|
|
|
2011-09-27 07:40:51 +01:00
|
|
|
#include <cassert>
|
2018-05-19 23:18:40 +02:00
|
|
|
#include <server/Persistence.h>
|
2018-08-04 01:12:45 +02:00
|
|
|
#include <server/PossessionAuthenticator.h>
|
2011-09-27 07:40:51 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::ListType;
|
2011-09-27 18:57:57 +01:00
|
|
|
using Atlas::Message::MapType;
|
2012-09-07 13:59:52 +01:00
|
|
|
using Atlas::Objects::Root;
|
2012-09-08 14:15:13 +01:00
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
2012-08-31 20:00:41 +01:00
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
2012-09-08 14:15:13 +01:00
|
|
|
using Atlas::Objects::Operation::RootOperation;
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
using String::compose;
|
|
|
|
|
|
2018-07-24 21:18:50 +02:00
|
|
|
|
2012-09-05 22:21:21 +01:00
|
|
|
std::ostream & operator<<(std::ostream & os,
|
2018-10-27 13:13:45 +02:00
|
|
|
const std::map<std::string, Ref<LocatedEntity>>::const_iterator &)
|
2012-09-05 22:21:21 +01:00
|
|
|
{
|
|
|
|
|
os << "[iterator]";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const std::map<long, Ref<LocatedEntity>>::const_iterator &)
|
|
|
|
|
{
|
|
|
|
|
os << "[iterator]";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const std::map<const long, const LocatedEntity*>::const_iterator &)
|
|
|
|
|
{
|
|
|
|
|
os << "[iterator]";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const std::map<const long, LocatedEntity*>::const_iterator &)
|
|
|
|
|
{
|
|
|
|
|
os << "[iterator]";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const Ref<LocatedEntity> & e)
|
|
|
|
|
{
|
|
|
|
|
os << e->describeEntity();
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const Element & e)
|
|
|
|
|
{
|
|
|
|
|
debug_dump(e, os);
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
std::ostream & operator<<(std::ostream & os,
|
|
|
|
|
const std::list<T> & sl)
|
|
|
|
|
{
|
|
|
|
|
typename std::list<T>::const_iterator I = sl.begin();
|
|
|
|
|
typename std::list<T>::const_iterator Iend = sl.end();
|
|
|
|
|
os << "[";
|
|
|
|
|
for (; I != Iend; ++I) {
|
|
|
|
|
if (I != sl.begin()) {
|
|
|
|
|
os << ", ";
|
|
|
|
|
}
|
|
|
|
|
os << *I;
|
|
|
|
|
}
|
|
|
|
|
os << "]";
|
|
|
|
|
return os;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
class TestAccount;
|
|
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
PossessionAuthenticator* possessionAuthenticator = new PossessionAuthenticator();
|
|
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
class Accounttest : public Cyphesis::TestBase
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
long m_id_counter;
|
|
|
|
|
|
2018-05-19 23:18:40 +02:00
|
|
|
DatabaseNull m_database;
|
2018-08-04 01:12:45 +02:00
|
|
|
Ref<Entity> m_gw;
|
2018-05-19 23:18:40 +02:00
|
|
|
Persistence* m_persistence;
|
2018-08-04 01:12:45 +02:00
|
|
|
TestWorld* m_world;
|
2012-08-31 20:00:41 +01:00
|
|
|
ServerRouting * m_server;
|
|
|
|
|
Connection * m_connection;
|
2018-04-25 21:05:59 +02:00
|
|
|
TestAccount * m_account;
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
static Ref<Entity> TestWorld_addNewEntity_ret_value;
|
|
|
|
|
static Ref<Entity> TeleportAuthenticator_ret_value;
|
2012-09-08 14:15:13 +01:00
|
|
|
static OpVector Link_send_sent;
|
|
|
|
|
static int characterError_ret_value;
|
2012-09-09 18:15:37 +01:00
|
|
|
static int Lobby_operation_called;
|
2013-01-17 10:17:07 +00:00
|
|
|
static std::list<std::pair<RootOperation, LocatedEntity *> > TestWorld_message_called;
|
2012-08-31 20:00:41 +01:00
|
|
|
public:
|
|
|
|
|
Accounttest();
|
|
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
|
|
|
|
|
|
|
|
|
void test_null();
|
2012-09-05 22:21:21 +01:00
|
|
|
void test_characterDestroyed();
|
|
|
|
|
void test_characterDestroyed_invalid();
|
|
|
|
|
void test_connectCharacter_raw_Entity();
|
2012-09-05 22:39:07 +01:00
|
|
|
void test_addCharacter_raw_Entity();
|
2012-09-07 13:59:52 +01:00
|
|
|
void test_addNewCharacter_fail();
|
2018-10-27 13:13:45 +02:00
|
|
|
void test_addNewCharacter_Entity();
|
2012-09-07 13:59:52 +01:00
|
|
|
void test_addNewCharacter_unconnected();
|
2012-09-08 14:15:13 +01:00
|
|
|
void test_LogoutOperation_no_serialno();
|
|
|
|
|
void test_LogoutOperation_serialno();
|
|
|
|
|
void test_LogoutOperation_unconnected();
|
|
|
|
|
void test_getType();
|
|
|
|
|
void test_store();
|
|
|
|
|
void test_addToMessage();
|
|
|
|
|
void test_addToEntity();
|
|
|
|
|
void test_operation_Create();
|
|
|
|
|
void test_operation_Get();
|
|
|
|
|
void test_operation_Imaginary();
|
|
|
|
|
void test_operation_Logout();
|
|
|
|
|
void test_operation_Look();
|
|
|
|
|
void test_operation_Set();
|
|
|
|
|
void test_operation_Talk();
|
|
|
|
|
void test_operation_INVALID();
|
|
|
|
|
void test_operation_Other();
|
2012-09-09 01:33:45 +01:00
|
|
|
void test_CreateOperation_no_args();
|
2017-07-24 13:39:22 +02:00
|
|
|
void test_CreateOperation_no_parent();
|
2012-09-09 01:33:45 +01:00
|
|
|
void test_CreateOperation_good();
|
2012-09-08 14:15:13 +01:00
|
|
|
void test_GetOperation();
|
2012-09-09 18:15:37 +01:00
|
|
|
void test_ImaginaryOperation_no_args();
|
|
|
|
|
void test_ImaginaryOperation_Root_args();
|
|
|
|
|
void test_ImaginaryOperation_no_loc();
|
|
|
|
|
void test_ImaginaryOperation_loc();
|
|
|
|
|
void test_ImaginaryOperation_unconnected();
|
2012-09-13 00:02:41 +01:00
|
|
|
void test_LookOperation_no_args();
|
|
|
|
|
void test_LookOperation_unconnected();
|
|
|
|
|
void test_LookOperation_no_id();
|
|
|
|
|
void test_LookOperation_known_character();
|
|
|
|
|
void test_LookOperation_known_account();
|
|
|
|
|
void test_LookOperation_unknown();
|
|
|
|
|
void test_LookOperation_possess_invalid();
|
|
|
|
|
void test_LookOperation_possess_Entity();
|
|
|
|
|
void test_LookOperation_possess_Character();
|
2012-09-11 22:53:15 +01:00
|
|
|
void test_SetOperation_no_args();
|
|
|
|
|
void test_SetOperation_no_id();
|
|
|
|
|
void test_SetOperation_unowned_character();
|
|
|
|
|
void test_SetOperation_empty();
|
2012-09-13 19:03:05 +01:00
|
|
|
void test_TalkOperation_no_args();
|
|
|
|
|
void test_TalkOperation_non_entity();
|
|
|
|
|
void test_TalkOperation_self();
|
|
|
|
|
void test_TalkOperation_loc();
|
|
|
|
|
void test_TalkOperation_unconnected();
|
2012-09-08 14:15:13 +01:00
|
|
|
void test_OtherOperation();
|
2012-09-08 17:34:48 +01:00
|
|
|
void test_createObject_permission_error();
|
|
|
|
|
void test_createObject_add_failed();
|
|
|
|
|
void test_createObject_raw_Entity();
|
|
|
|
|
void test_createObject_Character();
|
2018-10-27 13:13:45 +02:00
|
|
|
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
static Ref<Entity> get_TestWorld_addNewEntity_ret_value();
|
|
|
|
|
static Ref<Entity> get_TeleportAuthenticator_ret_value();
|
2012-09-08 14:15:13 +01:00
|
|
|
static void append_Link_send_sent(const RootOperation &);
|
|
|
|
|
static int get_characterError_ret_value();
|
2012-09-09 18:15:37 +01:00
|
|
|
static void set_Lobby_operation_called(int class_no);
|
2013-01-17 10:17:07 +00:00
|
|
|
static void set_TestWorld_message_called(const RootOperation &,
|
|
|
|
|
LocatedEntity &);
|
2012-08-31 20:00:41 +01:00
|
|
|
};
|
|
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
Ref<Entity> Accounttest::TestWorld_addNewEntity_ret_value;
|
|
|
|
|
Ref<Entity> Accounttest::TeleportAuthenticator_ret_value;
|
2012-09-08 14:15:13 +01:00
|
|
|
OpVector Accounttest::Link_send_sent;
|
|
|
|
|
int Accounttest::characterError_ret_value;
|
2012-09-09 18:15:37 +01:00
|
|
|
int Accounttest::Lobby_operation_called;
|
2013-01-17 10:17:07 +00:00
|
|
|
std::list<std::pair<RootOperation, LocatedEntity *> >
|
|
|
|
|
Accounttest::TestWorld_message_called;
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> Accounttest::get_TestWorld_addNewEntity_ret_value()
|
2012-09-07 13:59:52 +01:00
|
|
|
{
|
|
|
|
|
return TestWorld_addNewEntity_ret_value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> Accounttest::get_TeleportAuthenticator_ret_value()
|
2012-09-13 15:16:57 +01:00
|
|
|
{
|
|
|
|
|
return TeleportAuthenticator_ret_value;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
void Accounttest::append_Link_send_sent(const RootOperation & op)
|
|
|
|
|
{
|
|
|
|
|
Link_send_sent.push_back(op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int Accounttest::get_characterError_ret_value()
|
|
|
|
|
{
|
|
|
|
|
return characterError_ret_value;
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-09 18:15:37 +01:00
|
|
|
void Accounttest::set_Lobby_operation_called(int class_no)
|
|
|
|
|
{
|
|
|
|
|
Lobby_operation_called = class_no;
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-17 10:17:07 +00:00
|
|
|
void Accounttest::set_TestWorld_message_called(const RootOperation & op,
|
|
|
|
|
LocatedEntity & entity)
|
2012-09-11 22:53:15 +01:00
|
|
|
{
|
2013-01-17 10:17:07 +00:00
|
|
|
TestWorld_message_called.push_back(std::make_pair(op, &entity));
|
2012-09-11 22:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
class TestAccount : public Account {
|
|
|
|
|
public:
|
|
|
|
|
TestAccount(Connection * conn, const std::string & username,
|
|
|
|
|
const std::string & passwd,
|
|
|
|
|
const std::string & id, long intId);
|
|
|
|
|
|
|
|
|
|
~TestAccount();
|
|
|
|
|
|
|
|
|
|
virtual int characterError(const Operation & op,
|
|
|
|
|
const Atlas::Objects::Root & ent,
|
|
|
|
|
OpVector & res) const;
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> testAddNewCharacter(const std::string & typestr,
|
2013-01-17 10:17:07 +00:00
|
|
|
const RootEntity & ent,
|
|
|
|
|
const RootEntity & arg);
|
2018-04-25 21:05:59 +02:00
|
|
|
|
|
|
|
|
void test_processExternalOperation(const Operation & op, OpVector& res) {
|
|
|
|
|
processExternalOperation(op, res);
|
|
|
|
|
}
|
2012-08-31 20:00:41 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Accounttest::Accounttest() : m_id_counter(0L),
|
|
|
|
|
m_server(0),
|
|
|
|
|
m_connection(0),
|
|
|
|
|
m_account(0)
|
|
|
|
|
{
|
|
|
|
|
ADD_TEST(Accounttest::test_null);
|
2012-09-05 22:21:21 +01:00
|
|
|
ADD_TEST(Accounttest::test_characterDestroyed);
|
|
|
|
|
ADD_TEST(Accounttest::test_characterDestroyed_invalid);
|
|
|
|
|
ADD_TEST(Accounttest::test_connectCharacter_raw_Entity);
|
2012-09-05 22:39:07 +01:00
|
|
|
ADD_TEST(Accounttest::test_addCharacter_raw_Entity);
|
2012-09-07 13:59:52 +01:00
|
|
|
ADD_TEST(Accounttest::test_addNewCharacter_fail);
|
2018-10-27 13:13:45 +02:00
|
|
|
ADD_TEST(Accounttest::test_addNewCharacter_Entity);
|
2012-09-07 13:59:52 +01:00
|
|
|
ADD_TEST(Accounttest::test_addNewCharacter_unconnected);
|
2012-09-08 14:15:13 +01:00
|
|
|
ADD_TEST(Accounttest::test_LogoutOperation_no_serialno);
|
|
|
|
|
ADD_TEST(Accounttest::test_LogoutOperation_serialno);
|
|
|
|
|
ADD_TEST(Accounttest::test_LogoutOperation_unconnected);
|
|
|
|
|
ADD_TEST(Accounttest::test_getType);
|
|
|
|
|
ADD_TEST(Accounttest::test_store);
|
|
|
|
|
ADD_TEST(Accounttest::test_addToMessage);
|
|
|
|
|
ADD_TEST(Accounttest::test_addToEntity);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Create);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Get);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Imaginary);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Logout);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Look);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Set);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Talk);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_INVALID);
|
|
|
|
|
ADD_TEST(Accounttest::test_operation_Other);
|
2012-09-09 01:33:45 +01:00
|
|
|
ADD_TEST(Accounttest::test_CreateOperation_no_args);
|
2017-07-24 13:39:22 +02:00
|
|
|
ADD_TEST(Accounttest::test_CreateOperation_no_parent);
|
2012-09-09 01:33:45 +01:00
|
|
|
ADD_TEST(Accounttest::test_CreateOperation_good);
|
2012-09-08 14:15:13 +01:00
|
|
|
ADD_TEST(Accounttest::test_GetOperation);
|
2012-09-09 18:15:37 +01:00
|
|
|
ADD_TEST(Accounttest::test_ImaginaryOperation_no_args);
|
|
|
|
|
ADD_TEST(Accounttest::test_ImaginaryOperation_Root_args);
|
|
|
|
|
ADD_TEST(Accounttest::test_ImaginaryOperation_no_loc);
|
|
|
|
|
ADD_TEST(Accounttest::test_ImaginaryOperation_loc);
|
|
|
|
|
ADD_TEST(Accounttest::test_ImaginaryOperation_unconnected);
|
2012-09-13 00:02:41 +01:00
|
|
|
ADD_TEST(Accounttest::test_LookOperation_no_args);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_unconnected);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_no_id);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_known_character);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_known_account);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_unknown);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_possess_invalid);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_possess_Entity);
|
|
|
|
|
ADD_TEST(Accounttest::test_LookOperation_possess_Character);
|
2012-09-11 22:53:15 +01:00
|
|
|
ADD_TEST(Accounttest::test_SetOperation_no_args);
|
|
|
|
|
ADD_TEST(Accounttest::test_SetOperation_no_id);
|
|
|
|
|
ADD_TEST(Accounttest::test_SetOperation_unowned_character);
|
|
|
|
|
ADD_TEST(Accounttest::test_SetOperation_empty);
|
2012-09-13 19:03:05 +01:00
|
|
|
ADD_TEST(Accounttest::test_TalkOperation_no_args);
|
|
|
|
|
ADD_TEST(Accounttest::test_TalkOperation_non_entity);
|
|
|
|
|
ADD_TEST(Accounttest::test_TalkOperation_self);
|
|
|
|
|
ADD_TEST(Accounttest::test_TalkOperation_loc);
|
|
|
|
|
ADD_TEST(Accounttest::test_TalkOperation_unconnected);
|
2012-09-08 14:15:13 +01:00
|
|
|
ADD_TEST(Accounttest::test_OtherOperation);
|
2012-09-08 17:34:48 +01:00
|
|
|
ADD_TEST(Accounttest::test_createObject_permission_error);
|
|
|
|
|
ADD_TEST(Accounttest::test_createObject_add_failed);
|
|
|
|
|
ADD_TEST(Accounttest::test_createObject_raw_Entity);
|
|
|
|
|
ADD_TEST(Accounttest::test_createObject_Character);
|
2012-08-31 20:00:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::setup()
|
|
|
|
|
{
|
2018-07-24 21:18:50 +02:00
|
|
|
|
|
|
|
|
|
2018-05-19 23:18:40 +02:00
|
|
|
m_persistence = new Persistence(m_database);
|
2018-08-04 01:12:45 +02:00
|
|
|
m_gw = new Entity(compose("%1", m_id_counter),
|
2012-08-31 20:00:41 +01:00
|
|
|
m_id_counter++);
|
2018-07-24 21:18:50 +02:00
|
|
|
TestWorld::extension.messageFn = &Accounttest::set_TestWorld_message_called;
|
2018-08-04 01:12:45 +02:00
|
|
|
TestWorld::extension.addNewEntityFn = [&](const std::string &,
|
2018-07-24 21:18:50 +02:00
|
|
|
const Atlas::Objects::Entity::RootEntity &){
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> ne = Accounttest::get_TestWorld_addNewEntity_ret_value();
|
2018-07-24 21:18:50 +02:00
|
|
|
if (ne != nullptr) {
|
2018-08-17 22:04:07 +02:00
|
|
|
ne->m_location.m_parent = m_gw;
|
2018-07-24 21:18:50 +02:00
|
|
|
ne->m_location.m_pos = Point3D(0,0,0);
|
|
|
|
|
assert(ne->m_location.isValid());
|
|
|
|
|
}
|
|
|
|
|
return ne;
|
|
|
|
|
};
|
2018-08-05 14:31:04 +02:00
|
|
|
m_world = new TestWorld(m_gw);
|
2018-10-27 13:13:45 +02:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
m_server = new ServerRouting(*m_world,
|
2012-08-31 20:00:41 +01:00
|
|
|
"5529d7a4-0158-4dc1-b4a5-b5f260cac635",
|
|
|
|
|
"bad621d4-616d-4faf-b9e6-471d12b139a9",
|
|
|
|
|
compose("%1", m_id_counter), m_id_counter++,
|
|
|
|
|
compose("%1", m_id_counter), m_id_counter++);
|
|
|
|
|
m_connection = new Connection(*(CommSocket*)0, *m_server,
|
|
|
|
|
"8d18a4e8-f14f-4a46-997e-ada120d5438f",
|
|
|
|
|
compose("%1", m_id_counter), m_id_counter++);
|
|
|
|
|
m_account = new TestAccount(m_connection,
|
|
|
|
|
"6c9f3236-5de7-4ba4-8b7a-b0222df0af38",
|
|
|
|
|
"fa1a03a2-a745-4033-85cb-bb694e921e62",
|
|
|
|
|
compose("%1", m_id_counter), m_id_counter++);
|
2018-10-27 13:13:45 +02:00
|
|
|
TestWorld_addNewEntity_ret_value = nullptr;
|
|
|
|
|
TeleportAuthenticator_ret_value = nullptr;
|
2012-08-31 20:00:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::teardown()
|
|
|
|
|
{
|
2018-08-04 01:12:45 +02:00
|
|
|
delete m_world;
|
2012-08-31 20:00:41 +01:00
|
|
|
delete m_server;
|
2012-09-05 13:45:36 +01:00
|
|
|
delete m_account;
|
2018-05-19 23:18:40 +02:00
|
|
|
delete m_persistence;
|
2012-08-31 20:00:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_null()
|
|
|
|
|
{
|
2012-09-04 22:34:35 +01:00
|
|
|
ASSERT_NOT_NULL(m_account);
|
2012-08-31 20:00:41 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-05 22:21:21 +01:00
|
|
|
void Accounttest::test_characterDestroyed()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
2018-10-27 13:13:45 +02:00
|
|
|
Ref<LocatedEntity> c = new Entity(compose("%1", cid), cid);
|
2012-09-05 22:21:21 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
m_account->m_charactersDict.insert(std::make_pair(cid, c.get()));
|
2012-09-05 22:21:21 +01:00
|
|
|
|
2012-09-05 23:54:05 +01:00
|
|
|
ASSERT_NOT_EQUAL(m_account->m_charactersDict.find(cid),
|
|
|
|
|
m_account->m_charactersDict.end());
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.find(cid)->second, c);
|
2012-09-05 23:54:05 +01:00
|
|
|
|
2012-09-05 22:21:21 +01:00
|
|
|
m_account->characterDestroyed(cid);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-05 22:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_characterDestroyed_invalid()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
|
|
|
|
m_account->characterDestroyed(cid);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.find(cid),
|
|
|
|
|
m_account->m_charactersDict.end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_connectCharacter_raw_Entity()
|
|
|
|
|
{
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
OpVector res;
|
2012-09-05 22:21:21 +01:00
|
|
|
long cid = m_id_counter++;
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2012-09-05 22:21:21 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_account->connectCharacter(c.get(), res);
|
2012-09-05 22:21:21 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
//Connecting a character doesn't mean that it's added to the account.
|
2012-09-05 22:21:21 +01:00
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-05 22:21:21 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-05 22:39:07 +01:00
|
|
|
void Accounttest::test_addCharacter_raw_Entity()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2012-09-05 22:39:07 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
m_account->addCharacter(c.get());
|
2012-09-05 22:39:07 +01:00
|
|
|
|
2012-09-05 23:54:05 +01:00
|
|
|
ASSERT_NOT_EQUAL(m_account->m_charactersDict.find(cid),
|
|
|
|
|
m_account->m_charactersDict.end());
|
2018-08-05 14:31:04 +02:00
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.find(cid)->second, c.get());
|
2012-09-05 22:39:07 +01:00
|
|
|
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-05 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-07 13:59:52 +01:00
|
|
|
void Accounttest::test_addNewCharacter_fail()
|
|
|
|
|
{
|
|
|
|
|
TestWorld_addNewEntity_ret_value = 0;
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
ASSERT_NOT_NULL(m_account->m_connection);
|
2018-10-27 13:13:45 +02:00
|
|
|
OpVector res;
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
auto te = m_account->addNewCharacter(
|
2012-09-07 13:59:52 +01:00
|
|
|
RootEntity(),
|
2018-10-27 13:13:45 +02:00
|
|
|
Root(), res);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
ASSERT_FALSE(te);
|
2012-09-07 13:59:52 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
|
|
|
|
|
void Accounttest::test_addNewCharacter_Entity()
|
2012-09-07 13:59:52 +01:00
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
TestWorld_addNewEntity_ret_value = new Entity(compose("%1", cid), cid);
|
2018-10-27 13:13:45 +02:00
|
|
|
OpVector res;
|
2012-09-07 13:59:52 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
ASSERT_NOT_NULL(m_account->m_connection);
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
{
|
|
|
|
|
auto te = m_account->addNewCharacter(
|
|
|
|
|
RootEntity(),
|
|
|
|
|
Root(), res);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_FALSE(te);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.find(cid),
|
|
|
|
|
m_account->m_charactersDict.end());
|
|
|
|
|
}
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
{
|
|
|
|
|
auto args = Root();
|
|
|
|
|
args->setAttr("spawn_name", "foo");
|
|
|
|
|
auto te = m_account->addNewCharacter(
|
|
|
|
|
RootEntity(),
|
|
|
|
|
args, res);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_TRUE(te);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_NOT_EQUAL(m_account->m_charactersDict.find(cid),
|
|
|
|
|
m_account->m_charactersDict.end());
|
|
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.find(cid)->second,
|
|
|
|
|
TestWorld_addNewEntity_ret_value.get());
|
|
|
|
|
}
|
2012-09-07 13:59:52 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
|
2012-09-07 13:59:52 +01:00
|
|
|
void Accounttest::test_addNewCharacter_unconnected()
|
|
|
|
|
{
|
|
|
|
|
// Make the account disconnected
|
|
|
|
|
delete m_account->m_connection;
|
|
|
|
|
m_account->m_connection = 0;
|
2018-10-27 13:13:45 +02:00
|
|
|
OpVector res;
|
2012-09-07 13:59:52 +01:00
|
|
|
|
|
|
|
|
long cid = m_id_counter++;
|
2018-10-27 13:13:45 +02:00
|
|
|
TestWorld_addNewEntity_ret_value = new Entity(compose("%1", cid), cid);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
ASSERT_NULL(m_account->m_connection);
|
|
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
auto te = m_account->addNewCharacter(
|
2012-09-07 13:59:52 +01:00
|
|
|
RootEntity(),
|
2018-10-27 13:13:45 +02:00
|
|
|
Root(), res);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
ASSERT_FALSE(te);
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
TestWorld_addNewEntity_ret_value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LogoutOperation_no_serialno()
|
|
|
|
|
{
|
|
|
|
|
Link_send_sent.clear();
|
|
|
|
|
|
|
|
|
|
RootOperation op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->LogoutOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Link_send_sent.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = Link_send_sent.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::INFO_NO);
|
|
|
|
|
ASSERT_TRUE(reply->isDefaultRefno());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LogoutOperation_serialno()
|
|
|
|
|
{
|
|
|
|
|
Link_send_sent.clear();
|
|
|
|
|
|
|
|
|
|
const long serno = 0x1fae73;
|
|
|
|
|
|
|
|
|
|
RootOperation op;
|
|
|
|
|
op->setSerialno(serno);
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->LogoutOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Link_send_sent.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = Link_send_sent.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::INFO_NO);
|
|
|
|
|
ASSERT_TRUE(!reply->isDefaultRefno());
|
|
|
|
|
ASSERT_EQUAL(reply->getRefno(), serno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LogoutOperation_unconnected()
|
|
|
|
|
{
|
|
|
|
|
Link_send_sent.clear();
|
|
|
|
|
|
|
|
|
|
// Make the account unconnected
|
|
|
|
|
delete m_account->m_connection;
|
|
|
|
|
m_account->m_connection = 0;
|
|
|
|
|
|
|
|
|
|
RootOperation op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->LogoutOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Link_send_sent.size(), 0u);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_getType()
|
|
|
|
|
{
|
|
|
|
|
const char * account_type = m_account->getType();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(std::string("account"), account_type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_store()
|
|
|
|
|
{
|
|
|
|
|
m_account->store();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_addToMessage()
|
|
|
|
|
{
|
2012-09-13 15:27:39 +01:00
|
|
|
long cid = m_id_counter++;
|
2018-10-27 13:13:45 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2018-08-05 20:47:09 +02:00
|
|
|
m_account->m_charactersDict.insert(std::make_pair(c->getIntId(), c.get()));
|
2012-09-13 15:27:39 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
MapType data;
|
|
|
|
|
|
|
|
|
|
m_account->m_username = "2fe6afa4-747f-490b-a292-783bf3f4520b";
|
|
|
|
|
m_account->m_password = "09a6ec9f-493c-4cca-8e4a-241d15877ab4";
|
|
|
|
|
|
|
|
|
|
m_account->addToMessage(data);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(data["username"], m_account->m_username);
|
|
|
|
|
ASSERT_EQUAL(data["name"], m_account->m_username);
|
|
|
|
|
ASSERT_EQUAL(data["password"], m_account->m_password);
|
2017-07-24 13:39:22 +02:00
|
|
|
ASSERT_EQUAL(data["parent"], "account");
|
2012-09-13 15:27:39 +01:00
|
|
|
ASSERT_EQUAL(data["characters"], ListType(1, c->getId()));
|
2012-09-08 14:15:13 +01:00
|
|
|
ASSERT_EQUAL(data["objtype"], "obj");
|
|
|
|
|
ASSERT_EQUAL(data["id"], m_account->getId());
|
2012-09-13 15:27:39 +01:00
|
|
|
|
|
|
|
|
m_account->m_charactersDict.erase(c->getIntId());
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_addToEntity()
|
|
|
|
|
{
|
2012-09-13 15:27:39 +01:00
|
|
|
long cid = m_id_counter++;
|
2018-10-27 13:13:45 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2018-08-05 20:47:09 +02:00
|
|
|
m_account->m_charactersDict.insert(std::make_pair(c->getIntId(), c.get()));
|
2012-09-13 15:27:39 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
Anonymous data;
|
|
|
|
|
|
|
|
|
|
m_account->m_username = "36b0931c-19db-4f87-8b83-591d465af9a0";
|
|
|
|
|
m_account->m_password = "980fc361-2a77-4246-8877-d57895435d6d";
|
|
|
|
|
|
|
|
|
|
m_account->addToEntity(data);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(data->getAttr("username"), m_account->m_username);
|
|
|
|
|
ASSERT_TRUE(!data->isDefaultName());
|
|
|
|
|
ASSERT_EQUAL(data->getName(), m_account->m_username);
|
|
|
|
|
ASSERT_EQUAL(data->getAttr("password"), m_account->m_password);
|
2017-07-24 13:39:22 +02:00
|
|
|
ASSERT_TRUE(!data->isDefaultParent());
|
|
|
|
|
ASSERT_EQUAL(data->getParent(), "account");
|
2012-09-13 15:27:39 +01:00
|
|
|
ASSERT_EQUAL(data->getAttr("characters"), ListType(1, c->getId()));
|
2017-07-24 13:39:22 +02:00
|
|
|
ASSERT_TRUE(!data->isDefaultParent());
|
2012-09-08 14:15:13 +01:00
|
|
|
ASSERT_EQUAL(data->getObjtype(), "obj");
|
|
|
|
|
ASSERT_EQUAL(data->getAttr("id"), m_account->getId());
|
2012-09-13 15:27:39 +01:00
|
|
|
|
|
|
|
|
m_account->m_charactersDict.erase(c->getIntId());
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Create()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-09 01:33:45 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Get()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Get op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Imaginary()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Logout()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Logout op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Look()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Set()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Set op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Talk()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_INVALID()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Generic op;
|
|
|
|
|
op->setType("3d6b8a1e-137c-40a6-9ec9-1b21591e4937", OP_INVALID);
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_operation_Other()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::RootOperation op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 01:33:45 +01:00
|
|
|
void Accounttest::test_CreateOperation_no_args()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->CreateOperation(op, res);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-24 13:39:22 +02:00
|
|
|
void Accounttest::test_CreateOperation_no_parent()
|
2012-09-09 01:33:45 +01:00
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous create_arg;
|
|
|
|
|
op->setArgs1(create_arg);
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-09 01:33:45 +01:00
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = res.front();
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_CreateOperation_good()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
|
|
|
|
|
// Set up the creation so it succeeds
|
|
|
|
|
characterError_ret_value = 0;
|
2018-10-27 13:13:45 +02:00
|
|
|
TestWorld_addNewEntity_ret_value = new Entity(compose("%1", cid), cid);
|
2012-09-09 01:33:45 +01:00
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous create_arg;
|
2017-07-24 13:39:22 +02:00
|
|
|
create_arg->setParent("foo");
|
2018-10-27 13:13:45 +02:00
|
|
|
create_arg->setAttr("spawn_name", "foo");
|
2012-09-09 01:33:45 +01:00
|
|
|
op->setArgs1(create_arg);
|
|
|
|
|
|
2018-04-25 21:05:59 +02:00
|
|
|
m_account->test_processExternalOperation(op, res);
|
2012-09-09 01:33:45 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
ASSERT_EQUAL(Atlas::Objects::Operation::SIGHT_NO, res.front()->getClassNo());
|
2012-09-11 22:53:15 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
TestWorld_addNewEntity_ret_value = 0;
|
2012-09-09 01:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
void Accounttest::test_GetOperation()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Get op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->GetOperation(op, res);
|
2012-09-09 01:35:44 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-09 18:15:37 +01:00
|
|
|
void Accounttest::test_ImaginaryOperation_no_args()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->ImaginaryOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_ImaginaryOperation_Root_args()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Root arg;
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->ImaginaryOperation(op, res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_ImaginaryOperation_no_loc()
|
|
|
|
|
{
|
|
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->ImaginaryOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called,
|
|
|
|
|
Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_ImaginaryOperation_loc()
|
|
|
|
|
{
|
|
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setLoc("foo");
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->ImaginaryOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called,
|
|
|
|
|
Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_ImaginaryOperation_unconnected()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
2012-09-09 18:15:37 +01:00
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
delete m_account->m_connection;
|
|
|
|
|
m_account->m_connection = 0;
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
Atlas::Objects::Operation::Imaginary op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2012-09-09 18:15:37 +01:00
|
|
|
Anonymous arg;
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
m_account->ImaginaryOperation(op, res);
|
2012-09-09 18:15:37 +01:00
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called, -1);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-13 00:02:41 +01:00
|
|
|
void Accounttest::test_LookOperation_no_args()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
2012-09-13 00:02:41 +01:00
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
ASSERT_EQUAL(result->getArgs().size(),
|
|
|
|
|
1u);
|
|
|
|
|
|
|
|
|
|
const Root & result_arg = result->getArgs().front();
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(!result_arg->isDefaultId());
|
|
|
|
|
ASSERT_EQUAL(result_arg->getId(),
|
|
|
|
|
m_server->m_lobby.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_unconnected()
|
|
|
|
|
{
|
|
|
|
|
delete m_account->m_connection;
|
|
|
|
|
m_account->m_connection = 0;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_no_id()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_known_character()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
2018-10-27 13:13:45 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2018-08-05 20:47:09 +02:00
|
|
|
m_account->m_charactersDict.insert(std::make_pair(c->getIntId(), c.get()));
|
2012-09-13 00:02:41 +01:00
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId(c->getId());
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
ASSERT_EQUAL(result->getArgs().size(),
|
|
|
|
|
1u);
|
|
|
|
|
|
|
|
|
|
const Root & result_arg = result->getArgs().front();
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(!result_arg->isDefaultId());
|
|
|
|
|
ASSERT_EQUAL(result_arg->getId(),
|
|
|
|
|
c->getId());
|
|
|
|
|
|
|
|
|
|
m_account->m_charactersDict.erase(c->getIntId());
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-13 00:02:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_known_account()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
Account * ac = new TestAccount(0, "","", compose("%1", cid), cid);
|
|
|
|
|
m_server->m_lobby.addAccount(ac);
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId(ac->getId());
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
ASSERT_EQUAL(result->getArgs().size(),
|
|
|
|
|
1u);
|
|
|
|
|
|
|
|
|
|
const Root & result_arg = result->getArgs().front();
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(!result_arg->isDefaultId());
|
|
|
|
|
ASSERT_EQUAL(result_arg->getId(),
|
|
|
|
|
ac->getId());
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_server->m_lobby.removeAccount(ac);
|
2012-09-13 00:02:41 +01:00
|
|
|
delete ac;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_unknown()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId("8026");
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_possess_invalid()
|
|
|
|
|
{
|
2012-09-13 15:16:57 +01:00
|
|
|
TeleportAuthenticator_ret_value = 0;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId("8026");
|
|
|
|
|
arg->setAttr("possess_key", "3efc5e84-6fc6-4c66-bd68-1eec24ba09b6");
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
|
2012-09-13 00:02:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_possess_Entity()
|
|
|
|
|
{
|
2012-09-13 15:16:57 +01:00
|
|
|
long cid = m_id_counter++;
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
2012-09-13 15:16:57 +01:00
|
|
|
TeleportAuthenticator_ret_value = c;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Look op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId(c->getId());
|
|
|
|
|
arg->setAttr("possess_key", "3efc5e84-6fc6-4c66-bd68-1eec24ba09b6");
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->LookOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & result = res.front();
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
|
|
|
|
|
m_account->m_charactersDict.erase(c->getIntId());
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-13 00:02:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_LookOperation_possess_Character()
|
|
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
// long cid = m_id_counter++;
|
|
|
|
|
// Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
|
|
|
|
// TeleportAuthenticator_ret_value = c;
|
|
|
|
|
//
|
|
|
|
|
// Atlas::Objects::Operation::Look op;
|
|
|
|
|
// OpVector res;
|
|
|
|
|
//
|
|
|
|
|
// Anonymous arg;
|
|
|
|
|
// arg->setId(c->getId());
|
|
|
|
|
// arg->setAttr("possess_key", "3efc5e84-6fc6-4c66-bd68-1eec24ba09b6");
|
|
|
|
|
// op->setArgs1(arg);
|
|
|
|
|
//
|
|
|
|
|
// m_account->LookOperation(op, res);
|
|
|
|
|
//
|
|
|
|
|
// ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
//
|
|
|
|
|
// const RootOperation & result = res.front();
|
|
|
|
|
//
|
|
|
|
|
// ASSERT_EQUAL(result->getClassNo(),
|
|
|
|
|
// Atlas::Objects::Operation::SIGHT_NO);
|
|
|
|
|
// ASSERT_EQUAL(result->getArgs().size(),
|
|
|
|
|
// 1u);
|
|
|
|
|
//
|
|
|
|
|
// const Root & result_arg = result->getArgs().front();
|
|
|
|
|
//
|
|
|
|
|
// ASSERT_TRUE(!result_arg->isDefaultId());
|
|
|
|
|
// ASSERT_EQUAL(result_arg->getId(),
|
|
|
|
|
// c->getId());
|
|
|
|
|
//
|
|
|
|
|
// m_account->m_charactersDict.erase(c->getIntId());
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
void Accounttest::test_SetOperation_no_args()
|
|
|
|
|
{
|
2013-01-17 10:17:07 +00:00
|
|
|
Accounttest::TestWorld_message_called.clear();
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Set op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->SetOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
2013-01-17 10:17:07 +00:00
|
|
|
ASSERT_TRUE(Accounttest::TestWorld_message_called.empty());
|
2012-09-11 22:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_SetOperation_no_id()
|
|
|
|
|
{
|
2013-01-17 10:17:07 +00:00
|
|
|
Accounttest::TestWorld_message_called.clear();
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Set op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->SetOperation(op, res);
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(res.size(), 0u);
|
2013-01-17 10:17:07 +00:00
|
|
|
ASSERT_TRUE(Accounttest::TestWorld_message_called.empty());
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_SetOperation_unowned_character()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
2013-01-17 10:17:07 +00:00
|
|
|
Accounttest::TestWorld_message_called.clear();
|
2012-09-11 22:53:15 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
Atlas::Objects::Operation::Set op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId("975");
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
m_account->SetOperation(op, res);
|
2012-09-11 22:53:15 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(res.size(), 0u);
|
2013-01-17 10:17:07 +00:00
|
|
|
ASSERT_TRUE(Accounttest::TestWorld_message_called.empty());
|
2012-09-11 22:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_SetOperation_empty()
|
|
|
|
|
{
|
2013-01-17 10:17:07 +00:00
|
|
|
Accounttest::TestWorld_message_called.clear();
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
Ref<Entity> c = new Entity(compose("%1", cid), cid);
|
|
|
|
|
m_account->m_charactersDict.insert(std::make_pair(c->getIntId(), c.get()));
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Set op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
arg->setId(c->getId());
|
|
|
|
|
op->setArgs1(arg);
|
|
|
|
|
|
|
|
|
|
m_account->SetOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
2013-01-17 10:17:07 +00:00
|
|
|
ASSERT_TRUE(Accounttest::TestWorld_message_called.empty());
|
2012-09-11 22:53:15 +01:00
|
|
|
|
|
|
|
|
m_account->m_charactersDict.clear();
|
2018-08-05 14:31:04 +02:00
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
|
2012-09-13 19:03:05 +01:00
|
|
|
void Accounttest::test_TalkOperation_no_args()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->TalkOperation(op, res);
|
2012-09-13 19:03:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = res.front();
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_TalkOperation_non_entity()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Root talk_arg;
|
|
|
|
|
op->setArgs1(talk_arg);
|
|
|
|
|
|
|
|
|
|
m_account->TalkOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = res.front();
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_TalkOperation_self()
|
|
|
|
|
{
|
|
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous talk_arg;
|
|
|
|
|
op->setArgs1(talk_arg);
|
|
|
|
|
|
|
|
|
|
m_account->TalkOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called, Atlas::Objects::Operation::SOUND_NO);
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-13 19:03:05 +01:00
|
|
|
void Accounttest::test_TalkOperation_loc()
|
|
|
|
|
{
|
|
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous talk_arg;
|
|
|
|
|
talk_arg->setLoc("6273");
|
|
|
|
|
op->setArgs1(talk_arg);
|
|
|
|
|
|
|
|
|
|
m_account->TalkOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called, Atlas::Objects::Operation::SOUND_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_TalkOperation_unconnected()
|
|
|
|
|
{
|
|
|
|
|
delete m_account->m_connection;
|
|
|
|
|
m_account->m_connection = 0;
|
|
|
|
|
|
|
|
|
|
Lobby_operation_called = -1;
|
|
|
|
|
|
|
|
|
|
Atlas::Objects::Operation::Talk op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
Anonymous talk_arg;
|
|
|
|
|
op->setArgs1(talk_arg);
|
|
|
|
|
|
|
|
|
|
m_account->TalkOperation(op, res);
|
|
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
|
|
|
|
|
ASSERT_EQUAL(Lobby_operation_called, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
void Accounttest::test_OtherOperation()
|
|
|
|
|
{
|
|
|
|
|
Atlas::Objects::Operation::RootOperation op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
m_account->OtherOperation(op, res);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 17:34:48 +01:00
|
|
|
void Accounttest::test_createObject_permission_error()
|
|
|
|
|
{
|
|
|
|
|
characterError_ret_value = -1;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_account->createObject(arg, op, res);
|
2012-09-08 17:34:48 +01:00
|
|
|
|
|
|
|
|
ASSERT_TRUE(res.empty());
|
|
|
|
|
|
|
|
|
|
// addNewCharacter() would have put it here if it was created
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_createObject_add_failed()
|
|
|
|
|
{
|
|
|
|
|
characterError_ret_value = 0;
|
|
|
|
|
TestWorld_addNewEntity_ret_value = 0;
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_account->createObject(arg, op, res);
|
2012-09-08 17:34:48 +01:00
|
|
|
|
2012-09-09 01:33:45 +01:00
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
|
|
|
|
|
const RootOperation & reply = res.front();
|
|
|
|
|
ASSERT_EQUAL(reply->getClassNo(), Atlas::Objects::Operation::ERROR_NO);
|
|
|
|
|
|
2012-09-08 17:34:48 +01:00
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_createObject_raw_Entity()
|
|
|
|
|
{
|
|
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
|
|
|
|
|
characterError_ret_value = 0;
|
|
|
|
|
TestWorld_addNewEntity_ret_value = new Entity(compose("%1", cid), cid);
|
|
|
|
|
|
|
|
|
|
Anonymous arg;
|
|
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_account->createObject(arg, op, res);
|
2012-09-08 17:34:48 +01:00
|
|
|
|
|
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
|
|
|
|
ASSERT_TRUE(m_account->m_charactersDict.empty());
|
2012-09-11 22:53:15 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
|
2012-09-11 22:53:15 +01:00
|
|
|
TestWorld_addNewEntity_ret_value = 0;
|
2012-09-08 17:34:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Accounttest::test_createObject_Character()
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
2012-09-08 17:34:48 +01:00
|
|
|
long cid = m_id_counter++;
|
|
|
|
|
|
|
|
|
|
characterError_ret_value = 0;
|
2018-10-27 13:13:45 +02:00
|
|
|
TestWorld_addNewEntity_ret_value = new Entity(compose("%1", cid), cid);
|
2012-09-08 17:34:48 +01:00
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
Anonymous arg;
|
2018-10-27 13:13:45 +02:00
|
|
|
arg->setAttr("spawn_name", "foo");
|
2012-09-08 14:15:13 +01:00
|
|
|
Atlas::Objects::Operation::Create op;
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
m_account->createObject(arg, op, res);
|
2012-09-08 17:34:48 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(res.size(), 1u);
|
2012-09-08 17:34:48 +01:00
|
|
|
ASSERT_EQUAL(m_account->m_charactersDict.size(), 1u);
|
2018-10-27 13:13:45 +02:00
|
|
|
ASSERT_EQUAL(Atlas::Objects::Operation::SIGHT_NO, res.front()->getClassNo());
|
2012-09-08 17:34:48 +01:00
|
|
|
|
|
|
|
|
const RootOperation & info = res.front();
|
|
|
|
|
ASSERT_EQUAL(info->getArgs().size(), 1u);
|
|
|
|
|
|
|
|
|
|
const Root & info_arg = info->getArgs().front();
|
|
|
|
|
ASSERT_TRUE(!info_arg->isDefaultId());
|
|
|
|
|
|
|
|
|
|
long info_id = integerId(info_arg->getId());
|
|
|
|
|
ASSERT_NOT_EQUAL(m_account->m_charactersDict.find(info_id),
|
|
|
|
|
m_account->m_charactersDict.end());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-07 13:59:52 +01:00
|
|
|
|
2012-08-31 20:00:41 +01:00
|
|
|
TestAccount::TestAccount(Connection * conn, const std::string & username,
|
|
|
|
|
const std::string & passwd,
|
|
|
|
|
const std::string & id, long intId) :
|
|
|
|
|
Account(conn, username, passwd, id, intId)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TestAccount::~TestAccount()
|
|
|
|
|
{
|
|
|
|
|
delete m_connection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TestAccount::characterError(const Operation & op,
|
|
|
|
|
const Atlas::Objects::Root & ent,
|
|
|
|
|
OpVector & res) const
|
2011-09-27 07:40:51 +01:00
|
|
|
{
|
2012-09-08 14:15:13 +01:00
|
|
|
return Accounttest::get_characterError_ret_value();
|
2011-09-27 07:40:51 +01:00
|
|
|
}
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> TestAccount::testAddNewCharacter(const std::string & typestr,
|
2013-01-17 10:17:07 +00:00
|
|
|
const RootEntity & ent,
|
|
|
|
|
const RootEntity & arg)
|
2012-08-31 20:00:41 +01:00
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
OpVector res;
|
|
|
|
|
return addNewCharacter(ent, arg, res);
|
2012-08-31 20:00:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
Accounttest t;
|
|
|
|
|
|
|
|
|
|
return t.run();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 18:57:57 +01:00
|
|
|
// stubs
|
|
|
|
|
|
|
|
|
|
#include "server/Connection.h"
|
2012-09-08 14:15:13 +01:00
|
|
|
#include "server/Lobby.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
#include "server/Persistence.h"
|
2013-07-26 20:14:33 +02:00
|
|
|
#include "server/PossessionAuthenticator.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
|
|
|
|
|
#include "common/globals.h"
|
|
|
|
|
#include "common/id.h"
|
|
|
|
|
#include "common/log.h"
|
|
|
|
|
|
|
|
|
|
#include <cstdlib>
|
|
|
|
|
|
2014-09-29 19:24:05 +02:00
|
|
|
#include "stubs/server/stubConnection.h"
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/server/stubConnectableRouter.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
#define STUB_ServerRouting_ServerRouting
|
2012-08-31 20:00:41 +01:00
|
|
|
ServerRouting::ServerRouting(BaseWorld & wrld,
|
|
|
|
|
const std::string & ruleset,
|
|
|
|
|
const std::string & name,
|
|
|
|
|
const std::string & id, long intId,
|
|
|
|
|
const std::string & lId, long lIntId) :
|
|
|
|
|
Router(id, intId),
|
|
|
|
|
m_svrRuleset(ruleset), m_svrName(name),
|
2012-09-08 14:15:13 +01:00
|
|
|
m_numClients(0), m_world(wrld),
|
|
|
|
|
m_lobby(*new Lobby(*this, lId, lIntId))
|
2012-08-31 20:00:41 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
#include "stubs/server/stubServerRouting.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
#define STUB_PossessionAuthenticator_authenticatePossession
|
2018-08-05 20:47:09 +02:00
|
|
|
Ref<LocatedEntity> PossessionAuthenticator::authenticatePossession(const std::string &entity_id,
|
2011-09-27 18:57:57 +01:00
|
|
|
const std::string &possess_key)
|
|
|
|
|
{
|
2018-08-05 14:31:04 +02:00
|
|
|
Ref<Entity> ne = Accounttest::get_TeleportAuthenticator_ret_value();
|
2012-09-13 15:16:57 +01:00
|
|
|
return ne;
|
2011-09-27 18:57:57 +01:00
|
|
|
}
|
2018-08-04 01:12:45 +02:00
|
|
|
#include "stubs/server/stubPossessionAuthenticator.h"
|
2018-05-19 21:47:24 +02:00
|
|
|
#include "stubs/server/stubPersistence.h"
|
2013-06-25 21:42:24 +02:00
|
|
|
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
Lobby::Lobby(ServerRouting & s, const std::string & id, long intId) :
|
|
|
|
|
Router(id, intId),
|
|
|
|
|
m_server(s)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Lobby::~Lobby()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
void Lobby::removeAccount(ConnectableRouter * ac)
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
2012-09-13 00:02:41 +01:00
|
|
|
m_accounts.erase(ac->getId());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Lobby::addToMessage(MapType & omap) const
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Lobby::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
|
|
|
|
|
{
|
2012-09-13 00:02:41 +01:00
|
|
|
ent->setId(getId());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
void Lobby::addAccount(ConnectableRouter * ac)
|
2012-09-08 14:15:13 +01:00
|
|
|
{
|
2012-09-13 00:02:41 +01:00
|
|
|
m_accounts[ac->getId()] = ac;
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2012-12-04 20:39:35 +00:00
|
|
|
void Lobby::externalOperation(const Operation & op, Link &)
|
2012-11-13 23:33:23 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-08 14:15:13 +01:00
|
|
|
void Lobby::operation(const Operation & op, OpVector & res)
|
|
|
|
|
{
|
2012-09-09 18:15:37 +01:00
|
|
|
Accounttest::set_Lobby_operation_called(op->getClassNo());
|
2012-09-08 14:15:13 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubThing.h"
|
2015-04-09 14:50:45 +02:00
|
|
|
#include "stubs/common/stubVariable.h"
|
|
|
|
|
#include "stubs/common/stubMonitors.h"
|
2017-07-05 15:24:55 +02:00
|
|
|
#include "stubs/common/stubid.h"
|
2015-04-09 14:50:45 +02:00
|
|
|
|
|
|
|
|
|
2017-07-02 19:02:42 +02:00
|
|
|
#define STUB_Entity_addToEntity
|
2011-09-27 18:57:57 +01:00
|
|
|
void Entity::addToEntity(const Atlas::Objects::Entity::RootEntity & ent) const
|
|
|
|
|
{
|
2012-09-08 17:34:48 +01:00
|
|
|
ent->setId(getId());
|
2011-09-27 18:57:57 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubEntity.h"
|
|
|
|
|
#include "stubs/rules/stubLocatedEntity.h"
|
2018-05-19 23:18:40 +02:00
|
|
|
#include "stubs/common/stubDatabase.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
#define STUB_Link_send
|
2012-08-01 19:42:36 +01:00
|
|
|
void Link::send(const Operation & op) const
|
|
|
|
|
{
|
2012-09-08 14:15:13 +01:00
|
|
|
Accounttest::append_Link_send_sent(op);
|
2012-08-01 19:42:36 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
void Link::send(const OpVector & ops) const
|
2012-08-01 19:42:36 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubLink.h"
|
|
|
|
|
#include "stubs/common/stubcustom.h"
|
|
|
|
|
#include "stubs/common/stubProperty.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/simulation/stubBaseWorld.h"
|
|
|
|
|
#include "stubs/rules/simulation/stubExternalMind.h"
|
|
|
|
|
#include "stubs/rules/simulation/stubMindsProperty.h"
|
2012-08-31 20:00:41 +01:00
|
|
|
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
#define STUB_Router_error
|
|
|
|
|
void Router::error(const Operation & op,
|
|
|
|
|
const std::string & errstring,
|
|
|
|
|
OpVector & res,
|
|
|
|
|
const std::string & to) const
|
2011-09-27 18:57:57 +01:00
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
res.push_back(Atlas::Objects::Operation::Error());
|
2011-09-27 18:57:57 +01:00
|
|
|
}
|
|
|
|
|
|
2018-10-27 13:13:45 +02:00
|
|
|
#define STUB_Router_clientError
|
|
|
|
|
void Router::clientError(const Operation & op,
|
2011-09-27 18:57:57 +01:00
|
|
|
const std::string & errstring,
|
|
|
|
|
OpVector & res,
|
|
|
|
|
const std::string & to) const
|
|
|
|
|
{
|
2012-09-09 01:33:45 +01:00
|
|
|
res.push_back(Atlas::Objects::Operation::Error());
|
2011-09-27 18:57:57 +01:00
|
|
|
}
|
2018-10-27 13:13:45 +02:00
|
|
|
#include "stubs/common/stubRouter.h"
|
2011-09-27 18:57:57 +01:00
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "stubs/rules/stubLocation.h"
|
2018-08-03 19:19:55 +02:00
|
|
|
|
2011-09-27 18:57:57 +01:00
|
|
|
|
|
|
|
|
void logEvent(LogEvent lev, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool database_flag = false;
|
2012-10-25 10:39:16 -04:00
|
|
|
|
|
|
|
|
#include <common/Shaker.h>
|
|
|
|
|
|
|
|
|
|
Shaker::Shaker()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Shaker::generateSalt(size_t length)
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|