2020-03-15 20:48:45 +00:00
|
|
|
#include "mock_config_builder.hpp"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
using webfused_test::IConfigBuilder;
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
static IConfigBuilder * wfd_MockConfigBuilder = nullptr;
|
|
|
|
|
|
|
|
extern struct wfd_config *
|
|
|
|
__real_wfd_config_create(void);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_dispose(
|
|
|
|
struct wfd_config * config);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_server_vhostname(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * vhost_name);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_server_port(
|
|
|
|
struct wfd_config * config,
|
|
|
|
int port);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_server_key(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * key_path);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_server_cert(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * cert_path);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_server_document_root(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * document_root);
|
|
|
|
|
|
|
|
extern bool
|
|
|
|
__real_wfd_config_add_auth_provider(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * provider,
|
|
|
|
struct wfd_settings * settings);
|
|
|
|
|
|
|
|
extern bool
|
|
|
|
__real_wfd_config_add_filesystem(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * name,
|
|
|
|
char const * mount_point);
|
|
|
|
|
|
|
|
extern bool
|
|
|
|
__real_wfd_config_set_logger(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * provider,
|
|
|
|
int level,
|
|
|
|
struct wfd_settings * settings);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
__real_wfd_config_set_user(
|
|
|
|
struct wfd_config * config,
|
|
|
|
char const * user,
|
|
|
|
char const * group);
|
|
|
|
|
|
|
|
struct wfd_config *
|
|
|
|
__wrap_wfd_config_create(void)
|
|
|
|
{
|
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
return __real_wfd_config_create();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wfd_MockConfigBuilder->create();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__wrap_wfd_config_dispose(
|
|
|
|
struct wfd_config * config)
|
|
|
|
{
|
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_dispose(config);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->dispose(config);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_server_vhostname(
|
|
|
|
struct wfd_config * config,
|
2020-03-15 20:48:45 +00:00
|
|
|
char const * vhost_name)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_server_vhostname(config, vhost_name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setServerVhostname(vhost_name);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_server_port(
|
|
|
|
struct wfd_config * config,
|
2020-03-15 20:48:45 +00:00
|
|
|
int port)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_server_port(config, port);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setServerPort(port);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_server_key(
|
|
|
|
struct wfd_config * config,
|
2020-03-15 20:48:45 +00:00
|
|
|
char const * key_path)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_server_key(config, key_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setServerKey(key_path);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_server_cert(
|
|
|
|
struct wfd_config * config,
|
2020-03-15 20:48:45 +00:00
|
|
|
char const * cert_path)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_server_cert(config, cert_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setServerCert(cert_path);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_server_document_root(
|
|
|
|
struct wfd_config * config,
|
2020-03-15 20:48:45 +00:00
|
|
|
char const * document_root)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_server_document_root(config, document_root);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setServerDocumentRoot(document_root);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
bool
|
|
|
|
__wrap_wfd_config_add_auth_provider(
|
|
|
|
struct wfd_config * config,
|
2020-03-18 09:17:17 +00:00
|
|
|
char const * provider,
|
|
|
|
struct wfd_settings * settings)
|
2020-03-16 20:50:31 +00:00
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
return __real_wfd_config_add_auth_provider(config, provider, settings);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wfd_MockConfigBuilder->addAuthProvider(provider, settings);
|
|
|
|
}
|
2020-03-17 20:51:04 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
bool
|
|
|
|
__wrap_wfd_config_add_filesystem(
|
|
|
|
struct wfd_config * config,
|
2020-03-17 20:51:04 +00:00
|
|
|
char const * name,
|
2020-03-19 16:25:26 +00:00
|
|
|
char const * mount_point)
|
2020-03-17 20:51:04 +00:00
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
return __real_wfd_config_add_filesystem(config, name, mount_point);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wfd_MockConfigBuilder->addFilesystem(name, mount_point);
|
|
|
|
}
|
2020-03-16 20:50:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
bool
|
|
|
|
__wrap_wfd_config_set_logger(
|
|
|
|
struct wfd_config * config,
|
2020-03-18 16:33:31 +00:00
|
|
|
char const * provider,
|
|
|
|
int level,
|
|
|
|
struct wfd_settings * settings)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
return __real_wfd_config_set_logger(config, provider, level, settings);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return wfd_MockConfigBuilder->setLogger(provider, level, settings);
|
|
|
|
}
|
2020-03-18 16:33:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
void
|
|
|
|
__wrap_wfd_config_set_user(
|
|
|
|
struct wfd_config * config,
|
2020-03-19 11:42:47 +00:00
|
|
|
char const * user,
|
|
|
|
char const * group)
|
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
if (nullptr == wfd_MockConfigBuilder)
|
|
|
|
{
|
|
|
|
__real_wfd_config_set_user(config, user, group);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder->setUser(user, group);
|
|
|
|
}
|
2020-03-19 11:42:47 +00:00
|
|
|
}
|
2020-03-16 20:50:31 +00:00
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace webfused_test
|
2020-03-15 20:48:45 +00:00
|
|
|
{
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
MockConfigBuilder::MockConfigBuilder()
|
|
|
|
{
|
|
|
|
wfd_MockConfigBuilder = this;
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
MockConfigBuilder::~MockConfigBuilder()
|
2020-03-15 20:48:45 +00:00
|
|
|
{
|
2020-03-19 16:25:26 +00:00
|
|
|
wfd_MockConfigBuilder = nullptr;
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
struct wfd_config * MockConfigBuilder::getBuilder()
|
|
|
|
{
|
|
|
|
IConfigBuilder * config_builder = this;
|
2020-03-15 20:48:45 +00:00
|
|
|
|
2020-03-19 16:25:26 +00:00
|
|
|
return reinterpret_cast<wfd_config *>(config_builder);
|
|
|
|
}
|
2020-03-15 20:48:45 +00:00
|
|
|
}
|