2012-11-12 20:25:19 -05:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
|
|
|
|
// Copyright (C) 2012 Anthony Pesce
|
|
|
|
|
//
|
|
|
|
|
// 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
|
|
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../TestBase.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
|
|
|
|
#include "server/Connection.h"
|
|
|
|
|
#include "server/ServerRouting.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/simulation/ExternalMind.h"
|
2012-11-23 11:05:59 +00:00
|
|
|
#include "common/CommSocket.h"
|
2012-11-16 22:23:35 +00:00
|
|
|
#include "common/Shaker.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
#include "common/PropertyManager.h"
|
|
|
|
|
#include "common/globals.h"
|
|
|
|
|
#include "common/log.h"
|
2012-11-16 22:23:35 +00:00
|
|
|
#include "common/const.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
|
|
using Atlas::Message::Element;
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
using Atlas::Message::MapType;
|
2012-11-16 22:23:35 +00:00
|
|
|
using String::compose;
|
2012-11-12 20:25:19 -05:00
|
|
|
|
|
|
|
|
bool database_flag = false;
|
|
|
|
|
|
2012-11-27 12:43:40 -05:00
|
|
|
int salt_length = -1;
|
|
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
class ConnectionShakerintegration : public Cyphesis::TestBase
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
long m_id_counter;
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
ServerRouting * m_server;
|
|
|
|
|
Connection * m_connection;
|
|
|
|
|
public:
|
|
|
|
|
ConnectionShakerintegration();
|
|
|
|
|
void setup();
|
|
|
|
|
void teardown();
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void testShaker();
|
|
|
|
|
};
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
ConnectionShakerintegration::ConnectionShakerintegration() : m_id_counter(0L),
|
|
|
|
|
m_server(0),
|
|
|
|
|
m_connection(0)
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
ADD_TEST(ConnectionShakerintegration::testShaker);
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void ConnectionShakerintegration::testShaker()
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
ASSERT_NOT_NULL(m_connection);
|
2012-12-04 22:44:10 +00:00
|
|
|
m_connection->addNewAccount("player",
|
|
|
|
|
"testuser",
|
|
|
|
|
"testpassword");
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-12-04 22:44:10 +00:00
|
|
|
ASSERT_EQUAL(salt_length, 16);
|
2012-11-16 22:23:35 +00:00
|
|
|
}
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void ConnectionShakerintegration::setup()
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
m_server = new ServerRouting(*(BaseWorld*)0,
|
2021-08-01 23:17:40 +02:00
|
|
|
*(Persistence*)nullptr,
|
2012-11-16 22:23:35 +00:00
|
|
|
"b88aa6d3-44b4-40bd-bfa9-8db00045bdc0",
|
|
|
|
|
"0f1fc7cb-5ab1-45c1-b0d3-ae49205ea437",
|
2023-10-19 23:04:04 +02:00
|
|
|
m_id_counter++,
|
|
|
|
|
AssetsHandler({}));
|
2012-11-16 22:23:35 +00:00
|
|
|
m_connection = new Connection(*(CommSocket*)0,
|
|
|
|
|
*m_server,
|
|
|
|
|
"test_addr",
|
2022-07-04 15:37:51 +02:00
|
|
|
m_id_counter++);
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void ConnectionShakerintegration::teardown()
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
delete m_connection;
|
2019-01-01 20:03:26 +01:00
|
|
|
delete m_server;
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
int main()
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
ConnectionShakerintegration t;
|
|
|
|
|
return t.run();
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
2012-11-16 22:23:35 +00:00
|
|
|
|
|
|
|
|
// Stubs
|
|
|
|
|
|
|
|
|
|
#include "server/Lobby.h"
|
|
|
|
|
#include "server/Player.h"
|
|
|
|
|
|
|
|
|
|
#include "common/Inheritance.h"
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/common/stubLink.h"
|
2023-10-19 23:04:04 +02:00
|
|
|
#include "../stubs/common/stubAssetsHandler.h"
|
2012-11-16 22:23:35 +00:00
|
|
|
|
|
|
|
|
using Atlas::Objects::Root;
|
|
|
|
|
|
|
|
|
|
bool restricted_flag;
|
|
|
|
|
|
|
|
|
|
namespace Atlas { namespace Objects { namespace Operation {
|
|
|
|
|
int UPDATE_NO = -1;
|
|
|
|
|
} } }
|
|
|
|
|
|
|
|
|
|
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
int CommSocket::flush()
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
return 0;
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/server/stubPlayer.h"
|
|
|
|
|
#include "../stubs/server/stubAccount.h"
|
|
|
|
|
#include "../stubs/server/stubServerRouting.h"
|
|
|
|
|
#include "../stubs/server/stubLobby.h"
|
2021-08-01 23:17:40 +02:00
|
|
|
#include "../stubs/server/stubPersistence.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2018-10-01 23:22:28 +02:00
|
|
|
#define STUB_ExternalMind_connectionId
|
2012-11-12 20:25:19 -05:00
|
|
|
const std::string & ExternalMind::connectionId()
|
|
|
|
|
{
|
2018-02-08 21:46:49 +01:00
|
|
|
assert(m_link != 0);
|
|
|
|
|
return m_link->getId();
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2018-10-01 23:22:28 +02:00
|
|
|
#define STUB_ExternalMind_linkUp
|
2012-11-12 20:25:19 -05:00
|
|
|
void ExternalMind::linkUp(Link * c)
|
|
|
|
|
{
|
2018-02-08 21:46:49 +01:00
|
|
|
m_link = c;
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/rules/simulation/stubExternalMind.h"
|
|
|
|
|
#include "../stubs/rules/simulation/stubThing.h"
|
|
|
|
|
#include "../stubs/rules/simulation/stubEntity.h"
|
|
|
|
|
#include "../stubs/rules/stubLocatedEntity.h"
|
|
|
|
|
#include "../stubs/server/stubExternalMindsManager.h"
|
|
|
|
|
#include "../stubs/server/stubExternalMindsConnection.h"
|
|
|
|
|
#include "../stubs/common/stubOperationsDispatcher.h"
|
|
|
|
|
#include "../stubs/common/stubTypeNode.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/common/stubRouter.h"
|
|
|
|
|
#include "../stubs/rules/stubLocation.h"
|
|
|
|
|
#include "../stubs/common/stubProperty.h"
|
2013-01-03 23:17:51 +00:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#ifndef STUB_Inheritance_getClass
|
|
|
|
|
#define STUB_Inheritance_getClass
|
2019-08-11 01:38:28 +02:00
|
|
|
const Atlas::Objects::Root& Inheritance::getClass(const std::string & parent, Visibility) const
|
2012-11-16 22:23:35 +00:00
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
return noClass;
|
|
|
|
|
}
|
2018-04-25 20:09:14 +02:00
|
|
|
#endif //STUB_Inheritance_getClass
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2018-04-25 20:09:14 +02:00
|
|
|
#ifndef STUB_Inheritance_getType
|
|
|
|
|
#define STUB_Inheritance_getType
|
2018-10-27 13:13:45 +02:00
|
|
|
const TypeNode* Inheritance::getType(const std::string & parent) const
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2018-10-27 13:13:45 +02:00
|
|
|
auto I = atlasObjects.find(parent);
|
2012-11-16 22:23:35 +00:00
|
|
|
if (I == atlasObjects.end()) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2019-11-17 18:43:43 +01:00
|
|
|
return I->second.get();
|
2018-10-27 13:13:45 +02:00
|
|
|
}
|
2018-04-25 20:09:14 +02:00
|
|
|
#endif //STUB_Inheritance_getType
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/common/stubInheritance.h"
|
|
|
|
|
#include "../stubs/common/stublog.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void hash_password(const std::string & pwd, const std::string & salt,
|
|
|
|
|
std::string & hash )
|
|
|
|
|
{
|
2012-11-27 12:43:40 -05:00
|
|
|
salt_length=salt.length();
|
2012-11-16 22:23:35 +00:00
|
|
|
}
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2020-01-20 23:17:55 +01:00
|
|
|
#include "../stubs/common/stubid.h"
|
2012-11-12 20:25:19 -05:00
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
void addToEntity(const Vector3D & v, std::vector<double> & vd)
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
vd.resize(3);
|
|
|
|
|
vd[0] = v[0];
|
|
|
|
|
vd[1] = v[1];
|
|
|
|
|
vd[2] = v[2];
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|
|
|
|
|
|
2012-11-16 22:23:35 +00:00
|
|
|
int check_password(const std::string & pwd, const std::string & hash)
|
2012-11-12 20:25:19 -05:00
|
|
|
{
|
2012-11-16 22:23:35 +00:00
|
|
|
return 0;
|
2012-11-12 20:25:19 -05:00
|
|
|
}
|