mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
refactor: made jsonrpc an independent library
This commit is contained in:
@@ -167,6 +167,22 @@ static void webfuse_test_iproviderclient_onread(
|
||||
delete[] data;
|
||||
}
|
||||
|
||||
static void webfuse_test_iproviderclient_get_credentials(
|
||||
wfp_credentials * credentials,
|
||||
void * user_data)
|
||||
{
|
||||
auto * self = reinterpret_cast<IProviderClient*>(user_data);
|
||||
|
||||
try
|
||||
{
|
||||
self->GetCredentials(credentials);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// swallow
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace webfuse_test
|
||||
@@ -185,7 +201,7 @@ wf_status ProviderClientException::GetErrorCode()
|
||||
}
|
||||
|
||||
|
||||
void IProviderClient::AttachTo(wfp_client_config * config)
|
||||
void IProviderClient::AttachTo(wfp_client_config * config, bool enableAuthentication)
|
||||
{
|
||||
void * self = reinterpret_cast<void *>(this);
|
||||
wfp_client_config_set_userdata(config, self);
|
||||
@@ -199,6 +215,11 @@ void IProviderClient::AttachTo(wfp_client_config * config)
|
||||
wfp_client_config_set_onopen(config, &webfuse_test_iproviderclient_onopen);
|
||||
wfp_client_config_set_onclose(config, &webfuse_test_iproviderclient_onclose);
|
||||
wfp_client_config_set_onread(config, &webfuse_test_iproviderclient_onread);
|
||||
|
||||
if (enableAuthentication)
|
||||
{
|
||||
wfp_client_config_enable_authentication(config, &webfuse_test_iproviderclient_get_credentials);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,8 +16,6 @@ namespace webfuse_test
|
||||
private:
|
||||
wf_status error_code_;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class IProviderClient
|
||||
{
|
||||
@@ -32,8 +30,9 @@ namespace webfuse_test
|
||||
virtual void Open(ino_t inode, int flags, uint32_t * handle) = 0;
|
||||
virtual void Close(ino_t inode, uint32_t handle, int flags) = 0;
|
||||
virtual void Read(ino_t inode, uint32_t handle, size_t offset, size_t length, char * buffer, size_t * bytes_read) = 0;
|
||||
virtual void GetCredentials(wfp_credentials * credentials) = 0;
|
||||
|
||||
void AttachTo(wfp_client_config * config);
|
||||
void AttachTo(wfp_client_config * config, bool enableAuthentication = false);
|
||||
};
|
||||
|
||||
class MockProviderClient: public IProviderClient
|
||||
@@ -49,6 +48,7 @@ namespace webfuse_test
|
||||
MOCK_METHOD3( Open, void(ino_t inode, int flags, uint32_t * handle));
|
||||
MOCK_METHOD3( Close, void(ino_t inode, uint32_t handle, int flags));
|
||||
MOCK_METHOD6( Read, void(ino_t inode, uint32_t handle, size_t offset, size_t length, char * buffer, size_t * bytes_read));
|
||||
MOCK_METHOD1( GetCredentials, void (wfp_credentials * credentials));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/request.h"
|
||||
|
||||
TEST(jsonrpc_is_request, request_with_object_params)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("method"));
|
||||
json_object_set_new(request, "params", json_object());
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_TRUE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, request_with_array_params)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("method"));
|
||||
json_object_set_new(request, "params", json_array());
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_TRUE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, null_request)
|
||||
{
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(nullptr));
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request)
|
||||
{
|
||||
json_t * request = json_array();
|
||||
json_array_append_new(request, json_string("method"));
|
||||
json_array_append_new(request, json_object());
|
||||
json_array_append_new(request, json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_without_id)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("method"));
|
||||
json_object_set_new(request, "params", json_object());
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_due_to_invalid_id)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("method"));
|
||||
json_object_set_new(request, "params", json_object());
|
||||
json_object_set_new(request, "id", json_string("42"));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_without_method)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "params", json_object());
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_due_to_invalid_method)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_integer(42));
|
||||
json_object_set_new(request, "params", json_object());
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_without_params)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("method"));
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_request, invalid_request_due_to_invalid_params)
|
||||
{
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "methdo", json_string("method"));
|
||||
json_object_set_new(request, "params", json_string("params"));
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_request(request));
|
||||
|
||||
json_decref(request);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||
|
||||
TEST(jsonrpc_is_response, valid_result)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "result", json_object());
|
||||
json_object_set_new(message, "id", json_integer(42));
|
||||
|
||||
ASSERT_TRUE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, valid_result_string)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "result", json_string("also valid"));
|
||||
json_object_set_new(message, "id", json_integer(42));
|
||||
|
||||
ASSERT_TRUE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, valid_error)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "error", json_object());
|
||||
json_object_set_new(message, "id", json_integer(42));
|
||||
|
||||
ASSERT_TRUE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_null)
|
||||
{
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(nullptr));
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_message)
|
||||
{
|
||||
json_t * message = json_array();
|
||||
json_array_append_new(message, json_object());
|
||||
json_array_append_new(message, json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_missing_id)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "result", json_object());
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_id_wrong_type)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "result", json_object());
|
||||
json_object_set_new(message, "id", json_string("42"));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_missing_result_and_error)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_is_response, invalid_error_wrong_type)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "error", json_array());
|
||||
json_object_set_new(message, "id", json_integer(42));
|
||||
|
||||
ASSERT_FALSE(wf_impl_jsonrpc_is_response(message));
|
||||
|
||||
json_decref(message);
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
|
||||
#include "webfuse/adapter/impl/time/timeout_manager.h"
|
||||
#include "webfuse/utils/msleep.hpp"
|
||||
|
||||
using webfuse_test::msleep;
|
||||
|
||||
#define WF_DEFAULT_TIMEOUT (10 * 1000)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
struct SendContext
|
||||
{
|
||||
json_t * response;
|
||||
bool result;
|
||||
bool is_called;
|
||||
|
||||
explicit SendContext(bool result_ = true)
|
||||
: response(nullptr)
|
||||
, result(result_)
|
||||
, is_called(false)
|
||||
{
|
||||
}
|
||||
|
||||
~SendContext()
|
||||
{
|
||||
if (nullptr != response)
|
||||
{
|
||||
json_decref(response);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bool jsonrpc_send(
|
||||
json_t * request,
|
||||
void * user_data)
|
||||
{
|
||||
SendContext * context = reinterpret_cast<SendContext*>(user_data);
|
||||
context->is_called = true;
|
||||
context->response = request;
|
||||
json_incref(request);
|
||||
|
||||
return context->result;
|
||||
}
|
||||
|
||||
struct FinishedContext
|
||||
{
|
||||
bool is_called;
|
||||
wf_status status;
|
||||
json_t * result;
|
||||
|
||||
FinishedContext()
|
||||
: is_called(false)
|
||||
, status(WF_BAD)
|
||||
, result(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
~FinishedContext()
|
||||
{
|
||||
if (nullptr != result)
|
||||
{
|
||||
json_decref(result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void jsonrpc_finished(
|
||||
void * user_data,
|
||||
wf_status status,
|
||||
struct json_t const * result)
|
||||
{
|
||||
FinishedContext * context = reinterpret_cast<FinishedContext*>(user_data);
|
||||
context->is_called = true;
|
||||
context->status = status;
|
||||
context->result = json_deep_copy(result);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, init)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext context;
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, user_data);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
|
||||
ASSERT_FALSE(context.is_called);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, invoke)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
json_t * method = json_object_get(send_context.response, "method");
|
||||
ASSERT_TRUE(json_is_string(method));
|
||||
ASSERT_STREQ("foo", json_string_value(method));
|
||||
|
||||
json_t * params = json_object_get(send_context.response, "params");
|
||||
ASSERT_TRUE(json_is_array(params));
|
||||
ASSERT_EQ(2, json_array_size(params));
|
||||
ASSERT_TRUE(json_is_string(json_array_get(params, 0)));
|
||||
ASSERT_STREQ("bar", json_string_value(json_array_get(params, 0)));
|
||||
ASSERT_TRUE(json_is_integer(json_array_get(params, 1)));
|
||||
ASSERT_EQ(42, json_integer_value(json_array_get(params, 1)));
|
||||
|
||||
json_t * id = json_object_get(send_context.response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
|
||||
ASSERT_FALSE(finished_context.is_called);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_FALSE(WF_GOOD == finished_context.status);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, invoke_calls_finish_if_send_fails)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context(false);
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_FALSE(WF_GOOD == finished_context.status);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, invoke_fails_if_another_request_is_pending)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
FinishedContext finished_context2;
|
||||
void * finished_data2 = reinterpret_cast<void*>(&finished_context2);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data2, "foo", "");
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
ASSERT_FALSE(finished_context.is_called);
|
||||
|
||||
ASSERT_TRUE(finished_context2.is_called);
|
||||
ASSERT_EQ(WF_BAD_BUSY, finished_context2.status);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, invoke_fails_if_request_is_invalid)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "?", "error");
|
||||
|
||||
ASSERT_FALSE(send_context.is_called);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_EQ(WF_BAD, finished_context.status);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, on_result)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
json_t * id = json_object_get(send_context.response, "id");
|
||||
ASSERT_TRUE(json_is_number(id));
|
||||
|
||||
json_t * response = json_object();
|
||||
json_object_set_new(response, "result", json_string("okay"));
|
||||
json_object_set(response, "id", id);
|
||||
|
||||
wf_impl_jsonrpc_proxy_onresult(&proxy, response);
|
||||
json_decref(response);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_EQ(WF_GOOD, finished_context.status);
|
||||
ASSERT_TRUE(json_is_string(finished_context.result));
|
||||
ASSERT_STREQ("okay", json_string_value(finished_context.result));
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, on_result_reject_response_with_unknown_id)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
json_t * id = json_object_get(send_context.response, "id");
|
||||
ASSERT_TRUE(json_is_number(id));
|
||||
|
||||
json_t * response = json_object();
|
||||
json_object_set_new(response, "result", json_string("okay"));
|
||||
json_object_set_new(response, "id", json_integer(1 + json_integer_value(id)));
|
||||
|
||||
wf_impl_jsonrpc_proxy_onresult(&proxy, response);
|
||||
json_decref(response);
|
||||
|
||||
ASSERT_FALSE(finished_context.is_called);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, timeout)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, 0, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
msleep(10);
|
||||
wf_impl_timeout_manager_check(&timeout_manager);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_EQ(WF_BAD_TIMEOUT, finished_context.status);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, cleanup_pending_request)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, 10, &jsonrpc_send, send_data);
|
||||
|
||||
FinishedContext finished_context;
|
||||
void * finished_data = reinterpret_cast<void*>(&finished_context);
|
||||
wf_impl_jsonrpc_proxy_invoke(&proxy, &jsonrpc_finished, finished_data, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
ASSERT_FALSE(finished_context.is_called);
|
||||
ASSERT_NE(nullptr, timeout_manager.timers);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
|
||||
ASSERT_TRUE(finished_context.is_called);
|
||||
ASSERT_EQ(nullptr, timeout_manager.timers);
|
||||
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TEST(jsonrpc_proxy, notify)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
wf_impl_jsonrpc_proxy_notify(&proxy, "foo", "si", "bar", 42);
|
||||
|
||||
ASSERT_TRUE(send_context.is_called);
|
||||
ASSERT_TRUE(json_is_object(send_context.response));
|
||||
|
||||
json_t * method = json_object_get(send_context.response, "method");
|
||||
ASSERT_TRUE(json_is_string(method));
|
||||
ASSERT_STREQ("foo", json_string_value(method));
|
||||
|
||||
json_t * params = json_object_get(send_context.response, "params");
|
||||
ASSERT_TRUE(json_is_array(params));
|
||||
ASSERT_EQ(2, json_array_size(params));
|
||||
ASSERT_TRUE(json_is_string(json_array_get(params, 0)));
|
||||
ASSERT_STREQ("bar", json_string_value(json_array_get(params, 0)));
|
||||
ASSERT_TRUE(json_is_integer(json_array_get(params, 1)));
|
||||
ASSERT_EQ(42, json_integer_value(json_array_get(params, 1)));
|
||||
|
||||
json_t * id = json_object_get(send_context.response, "id");
|
||||
ASSERT_EQ(nullptr, id);
|
||||
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_proxy, notify_dont_send_invalid_request)
|
||||
{
|
||||
struct wf_impl_timeout_manager timeout_manager;
|
||||
wf_impl_timeout_manager_init(&timeout_manager);
|
||||
|
||||
SendContext send_context;
|
||||
void * send_data = reinterpret_cast<void*>(&send_context);
|
||||
struct wf_impl_jsonrpc_proxy proxy;
|
||||
wf_impl_jsonrpc_proxy_init(&proxy, &timeout_manager, WF_DEFAULT_TIMEOUT, &jsonrpc_send, send_data);
|
||||
|
||||
wf_impl_jsonrpc_proxy_notify(&proxy, "foo", "?");
|
||||
|
||||
ASSERT_FALSE(send_context.is_called);
|
||||
|
||||
wf_impl_jsonrpc_proxy_cleanup(&proxy);
|
||||
wf_impl_timeout_manager_cleanup(&timeout_manager);
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/request.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
struct Context
|
||||
{
|
||||
json_t * response;
|
||||
};
|
||||
|
||||
bool jsonrpc_send(
|
||||
json_t * request,
|
||||
void * user_data)
|
||||
{
|
||||
Context * context = reinterpret_cast<Context*>(user_data);
|
||||
context->response = request;
|
||||
json_incref(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(jsonrpc_request, create_dispose)
|
||||
{
|
||||
Context context{nullptr};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
|
||||
struct wf_impl_jsonrpc_request * request =
|
||||
wf_impl_jsonrpc_request_create(42, &jsonrpc_send, user_data);
|
||||
|
||||
ASSERT_NE(nullptr, request);
|
||||
ASSERT_EQ(user_data, wf_impl_jsonrpc_request_get_userdata(request));
|
||||
|
||||
wf_impl_jsonrpc_request_dispose(request);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_request, respond)
|
||||
{
|
||||
Context context{nullptr};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
|
||||
struct wf_impl_jsonrpc_request * request =
|
||||
wf_impl_jsonrpc_request_create(42, &jsonrpc_send, user_data);
|
||||
|
||||
wf_impl_jsonrpc_respond(request, json_string("okay"));
|
||||
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
|
||||
|
||||
json_t * response = reinterpret_cast<json_t*>(context.response);
|
||||
ASSERT_TRUE(json_is_object(response));
|
||||
|
||||
json_t * id = json_object_get(response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(42, json_integer_value(id));
|
||||
|
||||
json_t * result = json_object_get(response, "result");
|
||||
ASSERT_TRUE(json_is_string(result));
|
||||
ASSERT_STREQ("okay", json_string_value(result));
|
||||
|
||||
ASSERT_EQ(nullptr, json_object_get(response, "error"));
|
||||
|
||||
json_decref(response);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_request, respond_error)
|
||||
{
|
||||
Context context{nullptr};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
|
||||
struct wf_impl_jsonrpc_request * request =
|
||||
wf_impl_jsonrpc_request_create(42, &jsonrpc_send, user_data);
|
||||
|
||||
wf_impl_jsonrpc_respond_error(request, WF_BAD);
|
||||
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
|
||||
|
||||
json_t * response = reinterpret_cast<json_t*>(context.response);
|
||||
ASSERT_TRUE(json_is_object(response));
|
||||
|
||||
json_t * id = json_object_get(response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(42, json_integer_value(id));
|
||||
|
||||
ASSERT_EQ(nullptr, json_object_get(response, "result"));
|
||||
|
||||
json_t * err = json_object_get(response, "error");
|
||||
ASSERT_TRUE(json_is_object(err));
|
||||
|
||||
json_t * err_code = json_object_get(err, "code");
|
||||
ASSERT_TRUE(json_is_integer(err_code));
|
||||
ASSERT_EQ(WF_BAD, json_integer_value(err_code));
|
||||
|
||||
json_t * err_message = json_object_get(err, "message");
|
||||
ASSERT_TRUE(json_is_string(err_message));
|
||||
ASSERT_STREQ("Bad", json_string_value(err_message));
|
||||
|
||||
json_decref(response);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||
|
||||
TEST(json_response, init_result)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "result", json_integer(47));
|
||||
json_object_set_new(message, "id", json_integer(11));
|
||||
|
||||
struct wf_impl_jsonrpc_response response;
|
||||
wf_impl_jsonrpc_response_init(&response, message);
|
||||
|
||||
ASSERT_EQ(WF_GOOD, response.status);
|
||||
ASSERT_TRUE(json_is_integer(response.result));
|
||||
ASSERT_EQ(47, json_integer_value(response.result));
|
||||
ASSERT_EQ(11, response.id);
|
||||
|
||||
wf_impl_jsonrpc_response_cleanup(&response);
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(json_response, init_error)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_t * err = json_object();
|
||||
json_object_set_new(err, "code", json_integer(WF_BAD_ACCESS_DENIED));
|
||||
json_object_set_new(err, "message", json_string("access denied"));
|
||||
json_object_set_new(message, "error", err);
|
||||
json_object_set_new(message, "id", json_integer(23));
|
||||
|
||||
struct wf_impl_jsonrpc_response response;
|
||||
wf_impl_jsonrpc_response_init(&response, message);
|
||||
|
||||
ASSERT_EQ(WF_BAD_ACCESS_DENIED, response.status);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
ASSERT_EQ(23, response.id);
|
||||
|
||||
wf_impl_jsonrpc_response_cleanup(&response);
|
||||
json_decref(message);
|
||||
}
|
||||
|
||||
TEST(json_response, init_format_error)
|
||||
{
|
||||
json_t * message = json_object();
|
||||
json_object_set_new(message, "id", json_integer(12));
|
||||
|
||||
struct wf_impl_jsonrpc_response response;
|
||||
wf_impl_jsonrpc_response_init(&response, message);
|
||||
|
||||
ASSERT_EQ(WF_BAD_FORMAT, response.status);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
ASSERT_EQ(12, response.id);
|
||||
|
||||
wf_impl_jsonrpc_response_cleanup(&response);
|
||||
json_decref(message);
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
|
||||
#include "webfuse/adapter/impl/jsonrpc/request.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct Context
|
||||
{
|
||||
json_t * response;
|
||||
bool is_called;
|
||||
};
|
||||
|
||||
bool jsonrpc_send(
|
||||
json_t * request,
|
||||
void * user_data)
|
||||
{
|
||||
Context * context = reinterpret_cast<Context*>(user_data);
|
||||
context->is_called = true;
|
||||
context->response = request;
|
||||
json_incref(request);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void sayHello(
|
||||
struct wf_impl_jsonrpc_request * request,
|
||||
char const * method_name,
|
||||
json_t * params,
|
||||
void * user_data)
|
||||
{
|
||||
(void) method_name;
|
||||
(void) params;
|
||||
(void) user_data;
|
||||
|
||||
json_t * result = json_string("Hello");
|
||||
wf_impl_jsonrpc_respond(request, result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(jsonrpc_server, process_request)
|
||||
{
|
||||
struct wf_impl_jsonrpc_server server;
|
||||
wf_impl_jsonrpc_server_init(&server);
|
||||
wf_impl_jsonrpc_server_add(&server, "sayHello", &sayHello, nullptr);
|
||||
|
||||
Context context{nullptr, false};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("sayHello"));
|
||||
json_object_set_new(request, "params", json_array());
|
||||
json_object_set_new(request, "id", json_integer(23));
|
||||
wf_impl_jsonrpc_server_process(&server, request, &jsonrpc_send, user_data);
|
||||
|
||||
ASSERT_TRUE(context.is_called);
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
ASSERT_TRUE(json_is_object(context.response));
|
||||
|
||||
json_t * id = json_object_get(context.response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(23, json_integer_value(id));
|
||||
|
||||
json_t * result = json_object_get(context.response, "result");
|
||||
ASSERT_TRUE(json_is_string(result));
|
||||
ASSERT_STREQ("Hello", json_string_value(result));
|
||||
|
||||
json_decref(context.response);
|
||||
json_decref(request);
|
||||
wf_impl_jsonrpc_server_cleanup(&server);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_server, invoke_unknown_method)
|
||||
{
|
||||
struct wf_impl_jsonrpc_server server;
|
||||
wf_impl_jsonrpc_server_init(&server);
|
||||
wf_impl_jsonrpc_server_add(&server, "sayHello", &sayHello, nullptr);
|
||||
|
||||
Context context{nullptr, false};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("greet"));
|
||||
json_object_set_new(request, "params", json_array());
|
||||
json_object_set_new(request, "id", json_integer(42));
|
||||
wf_impl_jsonrpc_server_process(&server, request, &jsonrpc_send, user_data);
|
||||
|
||||
ASSERT_TRUE(context.is_called);
|
||||
ASSERT_NE(nullptr, context.response);
|
||||
ASSERT_TRUE(json_is_object(context.response));
|
||||
|
||||
json_t * id = json_object_get(context.response, "id");
|
||||
ASSERT_TRUE(json_is_integer(id));
|
||||
ASSERT_EQ(42, json_integer_value(id));
|
||||
|
||||
json_t * err = json_object_get(context.response, "error");
|
||||
ASSERT_TRUE(json_is_object(err));
|
||||
|
||||
json_t * err_code = json_object_get(err, "code");
|
||||
ASSERT_TRUE(json_is_integer(err_code));
|
||||
ASSERT_EQ(WF_BAD_NOTIMPLEMENTED, json_integer_value(err_code));
|
||||
|
||||
json_t * err_message = json_object_get(err, "message");
|
||||
ASSERT_TRUE(json_is_string(err_message));
|
||||
|
||||
json_decref(context.response);
|
||||
json_decref(request);
|
||||
wf_impl_jsonrpc_server_cleanup(&server);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_server, skip_invalid_request)
|
||||
{
|
||||
struct wf_impl_jsonrpc_server server;
|
||||
wf_impl_jsonrpc_server_init(&server);
|
||||
|
||||
Context context{nullptr, false};
|
||||
void * user_data = reinterpret_cast<void*>(&context);
|
||||
json_t * request = json_object();
|
||||
json_object_set_new(request, "method", json_string("sayHello"));
|
||||
json_object_set_new(request, "params", json_array());
|
||||
wf_impl_jsonrpc_server_process(&server, request, &jsonrpc_send, user_data);
|
||||
|
||||
ASSERT_FALSE(context.is_called);
|
||||
|
||||
json_decref(request);
|
||||
wf_impl_jsonrpc_server_cleanup(&server);
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include "webfuse/adapter/impl/jsonrpc/util.h"
|
||||
|
||||
TEST(jsonrpc_util, get_int)
|
||||
{
|
||||
json_t * object = json_object();
|
||||
json_object_set_new(object, "key", json_integer(23));
|
||||
int value = wf_impl_json_get_int(object, "key", 42);
|
||||
ASSERT_EQ(23, value);
|
||||
|
||||
json_decref(object);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_util, failed_to_get_null_object)
|
||||
{
|
||||
int value = wf_impl_json_get_int(nullptr, "key", 42);
|
||||
|
||||
ASSERT_EQ(42, value);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_util, failed_to_get_not_object)
|
||||
{
|
||||
json_t * object = json_array();
|
||||
int value = wf_impl_json_get_int(nullptr, "key", 42);
|
||||
ASSERT_EQ(42, value);
|
||||
|
||||
json_decref(object);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_util, failed_to_get_invalid_key)
|
||||
{
|
||||
json_t * object = json_object();
|
||||
int value = wf_impl_json_get_int(object, "key", 42);
|
||||
ASSERT_EQ(42, value);
|
||||
|
||||
json_decref(object);
|
||||
}
|
||||
|
||||
TEST(jsonrpc_util, failed_to_get_invalid_value_type)
|
||||
{
|
||||
json_t * object = json_object();
|
||||
json_object_set_new(object, "key", json_string("42"));
|
||||
int value = wf_impl_json_get_int(object, "key", 42);
|
||||
ASSERT_EQ(42, value);
|
||||
|
||||
json_decref(object);
|
||||
}
|
||||
@@ -1,54 +1,59 @@
|
||||
#include <string>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
|
||||
#include "jsonrpc/response.h"
|
||||
#include "webfuse/core/json_util.h"
|
||||
|
||||
|
||||
static void response_parse_str(
|
||||
std::string const & buffer,
|
||||
struct wf_impl_jsonrpc_response * response)
|
||||
struct jsonrpc_response * response)
|
||||
{
|
||||
json_t * message = json_loadb(buffer.c_str(), buffer.size(), 0, nullptr);
|
||||
if (nullptr != message)
|
||||
{
|
||||
wf_impl_jsonrpc_response_init(response, message);
|
||||
jsonrpc_response_init(response, message);
|
||||
json_decref(message);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(response_parser, test)
|
||||
{
|
||||
struct wf_impl_jsonrpc_response response;
|
||||
struct jsonrpc_response response;
|
||||
|
||||
// no object
|
||||
response_parse_str("[]", &response);
|
||||
ASSERT_NE(WF_GOOD, response.status);
|
||||
ASSERT_NE(nullptr, response.error);
|
||||
ASSERT_EQ(-1, response.id);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
jsonrpc_response_cleanup(&response);
|
||||
|
||||
// empty
|
||||
response_parse_str("{}", &response);
|
||||
ASSERT_NE(WF_GOOD, response.status);
|
||||
ASSERT_NE(nullptr, response.error);
|
||||
ASSERT_EQ(-1, response.id);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
jsonrpc_response_cleanup(&response);
|
||||
|
||||
// no data
|
||||
response_parse_str("{\"id\":42}", &response);
|
||||
ASSERT_NE(WF_GOOD, response.status);
|
||||
ASSERT_NE(nullptr, response.error);
|
||||
ASSERT_EQ(42, response.id);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
jsonrpc_response_cleanup(&response);
|
||||
|
||||
// custom error code
|
||||
response_parse_str("{\"error\":{\"code\": 42}, \"id\": 42}", &response);
|
||||
ASSERT_NE(WF_GOOD, response.status);
|
||||
ASSERT_EQ(42, response.status);
|
||||
ASSERT_NE(nullptr, response.error);
|
||||
ASSERT_EQ(42, json_integer_value(json_object_get(response.error, "code")));
|
||||
ASSERT_EQ(42, response.id);
|
||||
ASSERT_EQ(nullptr, response.result);
|
||||
jsonrpc_response_cleanup(&response);
|
||||
|
||||
// valid response
|
||||
response_parse_str("{\"result\": true, \"id\": 42}", &response);
|
||||
ASSERT_EQ(WF_GOOD, response.status);
|
||||
ASSERT_EQ(WF_GOOD, response.error);
|
||||
ASSERT_EQ(42, response.id);
|
||||
ASSERT_NE(nullptr, response.result);
|
||||
json_decref(response.result);
|
||||
jsonrpc_response_cleanup(&response);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ using webfuse_test::MockProviderClient;
|
||||
using webfuse_test::IProviderClient;
|
||||
using testing::_;
|
||||
using testing::AtMost;
|
||||
using testing::Invoke;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -24,10 +25,10 @@ class ClientProtocolFixture
|
||||
ClientProtocolFixture(ClientProtocolFixture const &) = delete;
|
||||
ClientProtocolFixture& operator=(ClientProtocolFixture const &) = delete;
|
||||
public:
|
||||
explicit ClientProtocolFixture(IProviderClient& client)
|
||||
explicit ClientProtocolFixture(IProviderClient& client, bool enableAuthentication = false)
|
||||
{
|
||||
config = wfp_client_config_create();
|
||||
client.AttachTo(config);
|
||||
client.AttachTo(config, enableAuthentication);
|
||||
|
||||
protocol = wfp_client_protocol_create(config);
|
||||
|
||||
@@ -140,6 +141,13 @@ private:
|
||||
wfp_client_protocol * protocol;
|
||||
};
|
||||
|
||||
void GetCredentials(wfp_credentials * credentials)
|
||||
{
|
||||
wfp_credentials_set_type(credentials, "username");
|
||||
wfp_credentials_add(credentials, "username", "bob");
|
||||
wfp_credentials_add(credentials, "password", "secret");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TEST(client_protocol, connect)
|
||||
@@ -161,11 +169,11 @@ TEST(client_protocol, connect)
|
||||
TEST(client_protocol, connect_with_username_authentication)
|
||||
{
|
||||
MockProviderClient provider;
|
||||
ClientProtocolFixture fixture(provider);
|
||||
// ToDo: enable authentication
|
||||
ClientProtocolFixture fixture(provider, true);
|
||||
|
||||
EXPECT_CALL(provider, OnConnected()).Times(AtMost(1));
|
||||
EXPECT_CALL(provider, OnDisconnected()).Times(1);
|
||||
EXPECT_CALL(provider, GetCredentials(_)).WillOnce(Invoke(GetCredentials)).Times(1);
|
||||
|
||||
fixture.Connect();
|
||||
if (HasFatalFailure()) { return; }
|
||||
|
||||
Reference in New Issue
Block a user