mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
fix: don't send messages if not connected
This commit is contained in:
parent
55de95caf7
commit
4713ec3e93
@ -52,12 +52,15 @@ wf_impl_client_protocol_send(
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
struct wf_client_protocol * protocol = user_data;
|
struct wf_client_protocol * protocol = user_data;
|
||||||
|
|
||||||
struct wf_message * message = wf_message_create(request);
|
if (NULL != protocol->wsi)
|
||||||
if (NULL != message)
|
|
||||||
{
|
{
|
||||||
wf_slist_append(&protocol->messages, &message->item);
|
struct wf_message * message = wf_message_create(request);
|
||||||
lws_callback_on_writable(protocol->wsi);
|
if (NULL != message)
|
||||||
result = true;
|
{
|
||||||
|
wf_slist_append(&protocol->messages, &message->item);
|
||||||
|
lws_callback_on_writable(protocol->wsi);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -211,6 +211,7 @@ alltests = executable('alltests',
|
|||||||
'test/webfuse/utils/static_filesystem.c',
|
'test/webfuse/utils/static_filesystem.c',
|
||||||
'test/webfuse/utils/ws_server.cc',
|
'test/webfuse/utils/ws_server.cc',
|
||||||
'test/webfuse/utils/ws_server2.cc',
|
'test/webfuse/utils/ws_server2.cc',
|
||||||
|
'test/webfuse/utils/jansson_test_environment.cc',
|
||||||
'test/webfuse/mocks/fake_invokation_context.cc',
|
'test/webfuse/mocks/fake_invokation_context.cc',
|
||||||
'test/webfuse/mocks/mock_authenticator.cc',
|
'test/webfuse/mocks/mock_authenticator.cc',
|
||||||
'test/webfuse/mocks/mock_request.cc',
|
'test/webfuse/mocks/mock_request.cc',
|
||||||
|
@ -208,6 +208,33 @@ TEST(AdapterClient, Authenticate)
|
|||||||
wf_client_dispose(client);
|
wf_client_dispose(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(AdapterClient, AuthenticateFailedWithoutConnect)
|
||||||
|
{
|
||||||
|
TimeoutWatcher watcher(TIMEOUT);
|
||||||
|
|
||||||
|
MockAdapterClientCallback callback;
|
||||||
|
EXPECT_CALL(callback, Invoke(_, _, _)).Times(AnyNumber());
|
||||||
|
EXPECT_CALL(callback, Invoke(_, WF_CLIENT_AUTHENTICATE_GET_CREDENTIALS, _)).Times(1)
|
||||||
|
.WillOnce(Invoke(GetCredentials));
|
||||||
|
bool called = false;
|
||||||
|
EXPECT_CALL(callback, Invoke(_, WF_CLIENT_AUTHENTICATION_FAILED, nullptr)).Times(1)
|
||||||
|
.WillOnce(Invoke([&called] (wf_client *, int, void *) mutable {
|
||||||
|
called = true;
|
||||||
|
}));
|
||||||
|
|
||||||
|
wf_client * client = wf_client_create(
|
||||||
|
callback.GetCallbackFn(), callback.GetUserData());
|
||||||
|
|
||||||
|
|
||||||
|
wf_client_authenticate(client);
|
||||||
|
while (!called) {
|
||||||
|
watcher.check();
|
||||||
|
wf_client_service(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
wf_client_dispose(client);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(AdapterClient, AuthenticationFailed)
|
TEST(AdapterClient, AuthenticationFailed)
|
||||||
{
|
{
|
||||||
TimeoutWatcher watcher(TIMEOUT);
|
TimeoutWatcher watcher(TIMEOUT);
|
||||||
|
16
test/webfuse/utils/jansson_test_environment.cc
Normal file
16
test/webfuse/utils/jansson_test_environment.cc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <jansson.h>
|
||||||
|
|
||||||
|
namespace webfuse_test
|
||||||
|
{
|
||||||
|
|
||||||
|
class JanssonTestEnvironment: public ::testing::Environment
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void SetUp()
|
||||||
|
{
|
||||||
|
json_object_seed(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user