mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
switched prefix to wfp for old wf stuff
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_TEST_INTEGRATION_FILE_HPP
|
||||
#define WF_TEST_INTEGRATION_FILE_HPP
|
||||
#ifndef WFP_TEST_INTEGRATION_FILE_HPP
|
||||
#define WFP_TEST_INTEGRATION_FILE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_TEST_INTEGRATION_PROVIDER
|
||||
#define WF_TEST_INTEGRATION_PROVIDER
|
||||
#ifndef WFP_TEST_INTEGRATION_PROVIDER
|
||||
#define WFP_TEST_INTEGRATION_PROVIDER
|
||||
|
||||
namespace webfuse_test
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "webfuse_adapter.h"
|
||||
#include "webfuse/adapter/impl/server.h"
|
||||
|
||||
#define WF_PATH_MAX (100)
|
||||
#define WFP_PATH_MAX (100)
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -22,17 +22,17 @@ static void webfuse_test_server_cleanup_mountpoint(
|
||||
free(path);
|
||||
}
|
||||
|
||||
static struct wf_mountpoint *
|
||||
static struct wfp_mountpoint *
|
||||
webfuse_test_server_create_mountpoint(
|
||||
char const * filesystem,
|
||||
void * user_data)
|
||||
{
|
||||
char const * base_dir = reinterpret_cast<char const*>(user_data);
|
||||
char path[WF_PATH_MAX];
|
||||
snprintf(path, WF_PATH_MAX, "%s/%s", base_dir, filesystem);
|
||||
char path[WFP_PATH_MAX];
|
||||
snprintf(path, WFP_PATH_MAX, "%s/%s", base_dir, filesystem);
|
||||
mkdir(path, 0755);
|
||||
struct wf_mountpoint * mountpoint = wf_mountpoint_create(path);
|
||||
wf_mountpoint_set_userdata(
|
||||
struct wfp_mountpoint * mountpoint = wfp_mountpoint_create(path);
|
||||
wfp_mountpoint_set_userdata(
|
||||
mountpoint,
|
||||
reinterpret_cast<void*>(strdup(path)),
|
||||
&webfuse_test_server_cleanup_mountpoint);
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
Private()
|
||||
: is_shutdown_requested(false)
|
||||
{
|
||||
snprintf(base_dir, WF_PATH_MAX, "%s", "/tmp/webfuse_test_integration_XXXXXX");
|
||||
snprintf(base_dir, WFP_PATH_MAX, "%s", "/tmp/webfuse_test_integration_XXXXXX");
|
||||
char const * result = mkdtemp(base_dir);
|
||||
if (NULL == result)
|
||||
{
|
||||
@@ -59,19 +59,19 @@ public:
|
||||
}
|
||||
|
||||
|
||||
config = wf_server_config_create();
|
||||
wf_server_config_set_port(config, 0);
|
||||
wf_server_config_set_mountpoint_factory(config,
|
||||
config = wfp_server_config_create();
|
||||
wfp_server_config_set_port(config, 0);
|
||||
wfp_server_config_set_mountpoint_factory(config,
|
||||
&webfuse_test_server_create_mountpoint,
|
||||
reinterpret_cast<void*>(base_dir));
|
||||
wf_server_config_set_keypath(config, "server-key.pem");
|
||||
wf_server_config_set_certpath(config, "server-cert.pem");
|
||||
wfp_server_config_set_keypath(config, "server-key.pem");
|
||||
wfp_server_config_set_certpath(config, "server-cert.pem");
|
||||
|
||||
server = wf_server_create(config);
|
||||
server = wfp_server_create(config);
|
||||
|
||||
while (!wf_impl_server_is_operational(server))
|
||||
while (!wfp_impl_server_is_operational(server))
|
||||
{
|
||||
wf_server_service(server);
|
||||
wfp_server_service(server);
|
||||
}
|
||||
|
||||
thread = std::thread(Run, this);
|
||||
@@ -83,8 +83,8 @@ public:
|
||||
RequestShutdown();
|
||||
thread.join();
|
||||
rmdir(base_dir);
|
||||
wf_server_dispose(server);
|
||||
wf_server_config_dispose(config);
|
||||
wfp_server_dispose(server);
|
||||
wfp_server_config_dispose(config);
|
||||
}
|
||||
|
||||
bool IsShutdownRequested()
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
|
||||
std::string GetUrl(void) const
|
||||
{
|
||||
int const port = wf_server_get_port(server);
|
||||
int const port = wfp_server_get_port(server);
|
||||
std::ostringstream stream;
|
||||
stream << "wss://localhost:" << port << "/";
|
||||
return stream.str();
|
||||
@@ -106,14 +106,14 @@ private:
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(shutdown_lock);
|
||||
is_shutdown_requested = true;
|
||||
wf_server_interrupt(server);
|
||||
wfp_server_interrupt(server);
|
||||
}
|
||||
|
||||
static void Run(Server::Private * context)
|
||||
{
|
||||
while (!context->IsShutdownRequested())
|
||||
{
|
||||
wf_server_service(context->server);
|
||||
wfp_server_service(context->server);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,9 +124,9 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
char base_dir[WF_PATH_MAX];
|
||||
wf_server_config * config;
|
||||
wf_server * server;
|
||||
char base_dir[WFP_PATH_MAX];
|
||||
wfp_server_config * config;
|
||||
wfp_server * server;
|
||||
};
|
||||
|
||||
Server::Server()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef WF_TEST_INTEGRATION_SERVER_HPP
|
||||
#define WF_TEST_INTEGRATION_SERVER_HPP
|
||||
#ifndef WFP_TEST_INTEGRATION_SERVER_HPP
|
||||
#define WFP_TEST_INTEGRATION_SERVER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace
|
||||
, provider(nullptr)
|
||||
{
|
||||
json_object_seed(0);
|
||||
wf_lwslog_disable();
|
||||
wfp_lwslog_disable();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -11,16 +11,16 @@ using ::webfuse_test::TempDir;
|
||||
extern "C"
|
||||
{
|
||||
|
||||
wf_mountpoint *
|
||||
wf_test_integration_lowlevel_create_mountpoint(
|
||||
wfp_mountpoint *
|
||||
wfp_test_integration_lowlevel_create_mountpoint(
|
||||
char const *, void * user_data)
|
||||
{
|
||||
auto * tempDir = reinterpret_cast<TempDir*>(user_data);
|
||||
return wf_mountpoint_create(tempDir->path());
|
||||
return wfp_mountpoint_create(tempDir->path());
|
||||
}
|
||||
|
||||
void
|
||||
wf_test_integration_lowlevel_on_connected(
|
||||
wfp_test_integration_lowlevel_on_connected(
|
||||
void * user_data)
|
||||
{
|
||||
int * state = reinterpret_cast<int*>(user_data);
|
||||
@@ -28,7 +28,7 @@ wf_test_integration_lowlevel_on_connected(
|
||||
}
|
||||
|
||||
void
|
||||
wf_test_integration_lowlevel_on_disconnected(
|
||||
wfp_test_integration_lowlevel_on_disconnected(
|
||||
void * user_data)
|
||||
{
|
||||
int * state = reinterpret_cast<int*>(user_data);
|
||||
@@ -36,18 +36,18 @@ wf_test_integration_lowlevel_on_disconnected(
|
||||
}
|
||||
|
||||
bool
|
||||
wf_test_integration_lowlevel_authenticate(
|
||||
struct wf_credentials const * credentials,
|
||||
wfp_test_integration_lowlevel_authenticate(
|
||||
struct wfp_credentials const * credentials,
|
||||
void * )
|
||||
{
|
||||
char const * username = wf_credentials_get(credentials, "username");
|
||||
char const * password = wf_credentials_get(credentials, "password");
|
||||
char const * username = wfp_credentials_get(credentials, "username");
|
||||
char const * password = wfp_credentials_get(credentials, "password");
|
||||
|
||||
return ((0 == strcmp(username, "bob")) && (0 == strcmp(password, "secret")));
|
||||
}
|
||||
|
||||
void
|
||||
wf_test_integration_lowlevel_get_credentials(
|
||||
wfp_test_integration_lowlevel_get_credentials(
|
||||
struct wfp_credentials * credentials,
|
||||
void * )
|
||||
{
|
||||
@@ -60,29 +60,29 @@ wf_test_integration_lowlevel_get_credentials(
|
||||
|
||||
TEST(integration, lowlevel)
|
||||
{
|
||||
TempDir dir("wf_test");
|
||||
TempDir dir("wfp_test");
|
||||
|
||||
wf_server_protocol * server_protocol = wf_server_protocol_create(
|
||||
&wf_test_integration_lowlevel_create_mountpoint,
|
||||
wfp_server_protocol * server_protocol = wfp_server_protocol_create(
|
||||
&wfp_test_integration_lowlevel_create_mountpoint,
|
||||
reinterpret_cast<void*>(&dir));
|
||||
ASSERT_NE(nullptr, server_protocol);
|
||||
wf_server_protocol_add_authenticator(server_protocol, "username",
|
||||
&wf_test_integration_lowlevel_authenticate, nullptr);
|
||||
wfp_server_protocol_add_authenticator(server_protocol, "username",
|
||||
&wfp_test_integration_lowlevel_authenticate, nullptr);
|
||||
|
||||
int state = 0;
|
||||
wfp_client_config * client_config = wfp_client_config_create();
|
||||
ASSERT_NE(nullptr, client_config);
|
||||
wfp_client_config_set_userdata(client_config, reinterpret_cast<void*>(&state));
|
||||
wfp_client_config_set_onconnected(client_config, &wf_test_integration_lowlevel_on_connected);
|
||||
wfp_client_config_set_ondisconnected(client_config, &wf_test_integration_lowlevel_on_disconnected);
|
||||
wfp_client_config_enable_authentication(client_config, &wf_test_integration_lowlevel_get_credentials);
|
||||
wfp_client_config_set_onconnected(client_config, &wfp_test_integration_lowlevel_on_connected);
|
||||
wfp_client_config_set_ondisconnected(client_config, &wfp_test_integration_lowlevel_on_disconnected);
|
||||
wfp_client_config_enable_authentication(client_config, &wfp_test_integration_lowlevel_get_credentials);
|
||||
|
||||
wfp_client_protocol * client_protocol = wfp_client_protocol_create(client_config);
|
||||
ASSERT_NE(nullptr, client_protocol);
|
||||
|
||||
lws_protocols protocols[3];
|
||||
memset(protocols, 0, 3 * sizeof(lws_protocols));
|
||||
wf_server_protocol_init_lws(server_protocol, &protocols[0]);
|
||||
wfp_server_protocol_init_lws(server_protocol, &protocols[0]);
|
||||
wfp_client_protocol_init_lws(client_protocol, &protocols[1]);
|
||||
|
||||
lws_context_creation_info info;
|
||||
@@ -108,5 +108,5 @@ TEST(integration, lowlevel)
|
||||
|
||||
wfp_client_protocol_dispose(client_protocol);
|
||||
wfp_client_config_dispose(client_config);
|
||||
wf_server_protocol_dispose(server_protocol);
|
||||
wfp_server_protocol_dispose(server_protocol);
|
||||
}
|
||||
Reference in New Issue
Block a user