2020-06-16 21:39:45 +00:00
|
|
|
#include "webfuse_provider/impl/jsonrpc/request.h"
|
2020-07-11 22:39:55 +00:00
|
|
|
#include "webfuse_provider/impl/json/parser.h"
|
2020-07-10 21:27:33 +00:00
|
|
|
#include <gtest/gtest.h>
|
2019-05-19 12:33:42 +00:00
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_object_params)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-11 22:39:55 +00:00
|
|
|
char text[] = "{\"method\": \"some_method\", \"params\": { }, \"id\": 42}";
|
|
|
|
wfp_json_doc * doc = wfp_impl_json_parse(text);
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
ASSERT_TRUE(wfp_jsonrpc_is_request(wfp_impl_json_root(doc)));
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
wfp_impl_json_dispose(doc);
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_fail_missing_params)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-11 22:39:55 +00:00
|
|
|
char text[] = "{\"method\": \"some_method\", \"id\": 42}";
|
|
|
|
wfp_json_doc * doc = wfp_impl_json_parse(text);
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
ASSERT_FALSE(wfp_jsonrpc_is_request(wfp_impl_json_root(doc)));
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
wfp_impl_json_dispose(doc);
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|
|
|
|
|
2020-06-16 21:57:41 +00:00
|
|
|
TEST(wfp_jsonrpc_request, is_request_fail_params_wrong_type)
|
2020-03-22 12:36:03 +00:00
|
|
|
{
|
2020-07-11 22:39:55 +00:00
|
|
|
char text[] = "{\"method\": \"some_method\", \"params\": \"invalid_params\", \"id\": 42}";
|
|
|
|
wfp_json_doc * doc = wfp_impl_json_parse(text);
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
ASSERT_FALSE(wfp_jsonrpc_is_request(wfp_impl_json_root(doc)));
|
2020-03-22 12:36:03 +00:00
|
|
|
|
2020-07-11 22:39:55 +00:00
|
|
|
wfp_impl_json_dispose(doc);
|
2020-03-22 12:36:03 +00:00
|
|
|
}
|