Move to clang-format-16 (#908)

Fixes #848
This commit is contained in:
Alex Kremer
2023-10-19 16:55:04 +01:00
committed by GitHub
parent 5de87b9ef8
commit 1aab2b94b1
265 changed files with 3950 additions and 4743 deletions

View File

@@ -26,8 +26,7 @@
namespace http = boost::beast::http;
class IPAdminVerificationStrategyTest : public NoLoggerFixture
{
class IPAdminVerificationStrategyTest : public NoLoggerFixture {
protected:
web::detail::IPAdminVerificationStrategy strat_;
http::request<http::string_body> request_ = {};
@@ -42,8 +41,7 @@ TEST_F(IPAdminVerificationStrategyTest, IsAdminOnlyForIP_127_0_0_1)
EXPECT_FALSE(strat_.isAdmin(request_, "localhost"));
}
class PasswordAdminVerificationStrategyTest : public NoLoggerFixture
{
class PasswordAdminVerificationStrategyTest : public NoLoggerFixture {
protected:
const std::string password_ = "secret";
web::detail::PasswordAdminVerificationStrategy strat_{password_};
@@ -75,12 +73,12 @@ TEST_F(PasswordAdminVerificationStrategyTest, IsAdminReturnsTrueOnlyForValidPass
EXPECT_FALSE(strat_.isAdmin(makeRequest(password_, http::field::authentication_info), ""));
}
struct MakeAdminVerificationStrategyTestParams
{
struct MakeAdminVerificationStrategyTestParams {
MakeAdminVerificationStrategyTestParams(
std::optional<std::string> passwordOpt,
bool expectIpStrategy,
bool expectPasswordStrategy)
bool expectPasswordStrategy
)
: passwordOpt(std::move(passwordOpt))
, expectIpStrategy(expectIpStrategy)
, expectPasswordStrategy(expectPasswordStrategy)
@@ -91,9 +89,7 @@ struct MakeAdminVerificationStrategyTestParams
bool expectPasswordStrategy;
};
class MakeAdminVerificationStrategyTest : public testing::TestWithParam<MakeAdminVerificationStrategyTestParams>
{
};
class MakeAdminVerificationStrategyTest : public testing::TestWithParam<MakeAdminVerificationStrategyTestParams> {};
TEST_P(MakeAdminVerificationStrategyTest, ChoosesStrategyCorrectly)
{
@@ -110,4 +106,6 @@ INSTANTIATE_TEST_CASE_P(
testing::Values(
MakeAdminVerificationStrategyTestParams(std::nullopt, true, false),
MakeAdminVerificationStrategyTestParams("p", false, true),
MakeAdminVerificationStrategyTestParams("", false, true)));
MakeAdminVerificationStrategyTestParams("", false, true)
)
);

View File

@@ -31,8 +31,7 @@ using namespace web;
constexpr static auto MINSEQ = 10;
constexpr static auto MAXSEQ = 30;
struct MockWsBase : public web::ConnectionBase
{
struct MockWsBase : public web::ConnectionBase {
std::string message;
boost::beast::http::status lastStatus = boost::beast::http::status::unknown;
@@ -55,8 +54,7 @@ struct MockWsBase : public web::ConnectionBase
}
};
class WebRPCServerHandlerTest : public MockBackendTest
{
class WebRPCServerHandlerTest : public MockBackendTest {
protected:
void
SetUp() override
@@ -69,7 +67,8 @@ protected:
subManager = std::make_shared<SubscriptionManager>(cfg, mockBackendPtr);
session = std::make_shared<MockWsBase>(*tagFactory);
handler = std::make_shared<RPCServerHandler<MockAsyncRPCEngine, MockETLService>>(
cfg, mockBackendPtr, rpcEngine, etl, subManager);
cfg, mockBackendPtr, rpcEngine, etl, subManager
);
}
void
@@ -712,7 +711,8 @@ TEST_F(WebRPCServerHandlerTest, WsTooBusy)
auto localRpcEngine = std::make_shared<MockRPCEngine>();
auto localHandler = std::make_shared<RPCServerHandler<MockRPCEngine, MockETLService>>(
cfg, mockBackendPtr, localRpcEngine, etl, subManager);
cfg, mockBackendPtr, localRpcEngine, etl, subManager
);
static auto constexpr request = R"({
"command": "server_info",
"id": 99
@@ -741,7 +741,8 @@ TEST_F(WebRPCServerHandlerTest, HTTPTooBusy)
{
auto localRpcEngine = std::make_shared<MockRPCEngine>();
auto localHandler = std::make_shared<RPCServerHandler<MockRPCEngine, MockETLService>>(
cfg, mockBackendPtr, localRpcEngine, etl, subManager);
cfg, mockBackendPtr, localRpcEngine, etl, subManager
);
static auto constexpr request = R"({
"method": "server_info",
"params": [{}]

View File

@@ -122,8 +122,7 @@ PAMNb1i80cMsjK98xXDdr+7Uvy5M4COMwA5XHmMZDEW8Jw==
return ctx;
}
class WebServerTest : public NoLoggerFixture
{
class WebServerTest : public NoLoggerFixture {
public:
~WebServerTest() override
{
@@ -165,8 +164,7 @@ private:
std::optional<std::thread> runner;
};
class EchoExecutor
{
class EchoExecutor {
public:
void
operator()(std::string const& reqStr, std::shared_ptr<web::ConnectionBase> const& ws)
@@ -180,8 +178,7 @@ public:
}
};
class ExceptionExecutor
{
class ExceptionExecutor {
public:
void
operator()(std::string const& /* req */, std::shared_ptr<web::ConnectionBase> const& /* ws */)
@@ -204,7 +201,8 @@ makeServerSync(
boost::asio::io_context& ioc,
std::optional<std::reference_wrapper<boost::asio::ssl::context>> const& sslCtx,
web::DOSGuard& dosGuard,
std::shared_ptr<Executor> const& handler)
std::shared_ptr<Executor> const& handler
)
{
auto server = std::shared_ptr<web::HttpServer<Executor>>();
std::mutex m;
@@ -253,7 +251,8 @@ TEST_F(WebServerTest, HttpInternalError)
auto const res = HttpSyncClient::syncPost("localhost", "8888", R"({})");
EXPECT_EQ(
res,
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response"})");
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response"})"
);
}
TEST_F(WebServerTest, WsInternalError)
@@ -266,7 +265,8 @@ TEST_F(WebServerTest, WsInternalError)
wsClient.disconnect();
EXPECT_EQ(
res,
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response","id":"id1","request":{"id":"id1"}})");
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response","id":"id1","request":{"id":"id1"}})"
);
}
TEST_F(WebServerTest, WsInternalErrorNotJson)
@@ -279,7 +279,8 @@ TEST_F(WebServerTest, WsInternalErrorNotJson)
wsClient.disconnect();
EXPECT_EQ(
res,
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response","request":"not json"})");
R"({"error":"internal","error_code":73,"error_message":"Internal error.","status":"error","type":"response","request":"not json"})"
);
}
TEST_F(WebServerTest, Https)
@@ -315,7 +316,8 @@ TEST_F(WebServerTest, HttpRequestOverload)
res = HttpSyncClient::syncPost("localhost", "8888", R"({})");
EXPECT_EQ(
res,
R"({"error":"slowDown","error_code":10,"error_message":"You are placing too much load on the server.","status":"error","type":"response"})");
R"({"error":"slowDown","error_code":10,"error_message":"You are placing too much load on the server.","status":"error","type":"response"})"
);
}
TEST_F(WebServerTest, WsRequestOverload)
@@ -333,7 +335,8 @@ TEST_F(WebServerTest, WsRequestOverload)
wsClient2.disconnect();
EXPECT_EQ(
res,
R"({"error":"slowDown","error_code":10,"error_message":"You are placing too much load on the server.","status":"error","type":"response","request":{}})");
R"({"error":"slowDown","error_code":10,"error_message":"You are placing too much load on the server.","status":"error","type":"response","request":{}})"
);
}
TEST_F(WebServerTest, HttpPayloadOverload)
@@ -344,7 +347,8 @@ TEST_F(WebServerTest, HttpPayloadOverload)
auto const res = HttpSyncClient::syncPost("localhost", "8888", fmt::format(R"({{"payload":"{}"}})", s100));
EXPECT_EQ(
res,
R"({"payload":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","warning":"load","warnings":[{"id":2003,"message":"You are about to be rate limited"}]})");
R"({"payload":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","warning":"load","warnings":[{"id":2003,"message":"You are about to be rate limited"}]})"
);
}
TEST_F(WebServerTest, WsPayloadOverload)
@@ -358,7 +362,8 @@ TEST_F(WebServerTest, WsPayloadOverload)
wsClient.disconnect();
EXPECT_EQ(
res,
R"({"payload":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","warning":"load","warnings":[{"id":2003,"message":"You are about to be rate limited"}]})");
R"({"payload":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","warning":"load","warnings":[{"id":2003,"message":"You are about to be rate limited"}]})"
);
}
TEST_F(WebServerTest, WsTooManyConnection)
@@ -371,13 +376,10 @@ TEST_F(WebServerTest, WsTooManyConnection)
WebSocketSyncClient wsClient2;
wsClient2.connect("localhost", "8888");
bool exceptionThrown = false;
try
{
try {
WebSocketSyncClient wsClient3;
wsClient3.connect("localhost", "8888");
}
catch (boost::system::system_error const& ex)
{
} catch (boost::system::system_error const& ex) {
exceptionThrown = true;
EXPECT_EQ(ex.code(), boost::beast::websocket::error::upgrade_declined);
}
@@ -396,8 +398,7 @@ static auto constexpr JSONServerConfigWithAdminPassword = R"JSON(
}
)JSON";
class AdminCheckExecutor
{
class AdminCheckExecutor {
public:
void
operator()(std::string const& reqStr, std::shared_ptr<web::ConnectionBase> const& ws)
@@ -412,15 +413,12 @@ public:
}
};
struct WebServerAdminTestParams
{
struct WebServerAdminTestParams {
std::vector<WebHeader> headers;
std::string expectedResponse;
};
class WebServerAdminTest : public WebServerTest, public ::testing::WithParamInterface<WebServerAdminTestParams>
{
};
class WebServerAdminTest : public WebServerTest, public ::testing::WithParamInterface<WebServerAdminTestParams> {};
TEST_P(WebServerAdminTest, WsAdminCheck)
{
@@ -457,4 +455,6 @@ INSTANTIATE_TEST_CASE_P(
.expectedResponse = "admin"},
WebServerAdminTestParams{
.headers = {WebHeader(http::field::authentication_info, "secret")},
.expectedResponse = "user"}));
.expectedResponse = "user"}
)
);

View File

@@ -40,8 +40,7 @@ constexpr static auto JSONData = R"JSON(
}
)JSON";
class DOSGuardIntervalSweepHandlerTest : public SyncAsioContextTest
{
class DOSGuardIntervalSweepHandlerTest : public SyncAsioContextTest {
protected:
Config cfg{boost::json::parse(JSONData)};
IntervalSweepHandler sweepHandler{cfg, ctx};

View File

@@ -49,9 +49,7 @@ constexpr static auto JSONDataIPV6 = R"JSON(
}
)JSON";
class WhitelistHandlerTest : public NoLoggerFixture
{
};
class WhitelistHandlerTest : public NoLoggerFixture {};
TEST_F(WhitelistHandlerTest, TestWhiteListIPV4)
{