summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEd Tanous <ed.tanous@intel.com>2018-05-23 01:27:24 +0300
committerEd Tanous <ed.tanous@intel.com>2018-07-27 01:54:37 +0300
commit55c7b7a2e58779580f33046d2dd8649243776700 (patch)
treeeed2d032dff3e18c4a8d4778e8f52ae5864620ee /src
parent1752c9657b56a6e1950d8725f44f4298c9872c63 (diff)
downloadbmcweb-55c7b7a2e58779580f33046d2dd8649243776700.tar.xz
Move over to upstream c++ style
This patchset moves bmcweb over to the upstream style naming conventions for variables, classes, and functions, as well as imposes the latest clang-format file. This changeset was mostly built automatically by the included .clang-tidy file, which has the ability to autoformat and auto rename variables. At some point in the future I would like to see this in greater use, but for now, we will impose it on bmcweb, and see how it goes. Tested: Code still compiles, and appears to run, although other issues are possible and likely. Change-Id: If422a2e36df924e897736b3feffa89f411d9dac1 Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'src')
-rw-r--r--src/ast_jpeg_decoder_test.cpp106
-rw-r--r--src/ast_video_puller_test.cpp18
-rw-r--r--src/base64.cpp6
-rw-r--r--src/crow_getroutes_test.cpp32
-rw-r--r--src/crow_test.cpp340
-rw-r--r--src/getvideo_main.cpp26
-rw-r--r--src/gtest_main.cpp2
-rw-r--r--src/kvm_websocket_test.cpp14
-rw-r--r--src/security_headers_middleware_test.cpp4
-rw-r--r--src/token_authorization_middleware_test.cpp20
-rw-r--r--src/webassets_test.cpp10
-rw-r--r--src/webserver_main.cpp50
12 files changed, 315 insertions, 313 deletions
diff --git a/src/ast_jpeg_decoder_test.cpp b/src/ast_jpeg_decoder_test.cpp
index b8faa29330..277ba2cc8b 100644
--- a/src/ast_jpeg_decoder_test.cpp
+++ b/src/ast_jpeg_decoder_test.cpp
@@ -15,7 +15,7 @@ MATCHER_P2(IsBetween, a, b,
};
TEST(AstJpegDecoder, AllBlue) {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
// This binary blog was created on the aspeed hardware using a blue screen
// consisting of the color 0x8EFFFA in a web browser window
@@ -28,33 +28,33 @@ TEST(AstJpegDecoder, AllBlue) {
ASSERT_GT(bufferlen, 0);
- out.y_selector = 0;
- out.uv_selector = 0;
- out.mode = AstVideo::YuvMode::YUV444;
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
int tolerance = 16;
// All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
// compression artifacts and quanitization)
for (int i = 0; i < out.width * out.height; i++) {
- AstVideo::RGB &pixel = d.OutBuffer[i];
- EXPECT_GT(pixel.R, 0x8E - tolerance);
- EXPECT_LT(pixel.R, 0x8E + tolerance);
- EXPECT_GT(pixel.G, 0xFF - tolerance);
- EXPECT_LT(pixel.G, 0xFF + tolerance);
- EXPECT_GT(pixel.B, 0xF1 - tolerance);
- EXPECT_LT(pixel.B, 0xF1 + tolerance);
+ ast_video::RGB &pixel = d.outBuffer[i];
+ EXPECT_GT(pixel.r, 0x8E - tolerance);
+ EXPECT_LT(pixel.r, 0x8E + tolerance);
+ EXPECT_GT(pixel.g, 0xFF - tolerance);
+ EXPECT_LT(pixel.g, 0xFF + tolerance);
+ EXPECT_GT(pixel.b, 0xF1 - tolerance);
+ EXPECT_LT(pixel.b, 0xF1 + tolerance);
}
}
TEST(AstJpegDecoder, AllBlack) {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
// This binary blog was created on the aspeed hardware using a black screen
FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
@@ -65,30 +65,30 @@ TEST(AstJpegDecoder, AllBlack) {
ASSERT_GT(bufferlen, 0);
- out.y_selector = 0;
- out.uv_selector = 0;
- out.mode = AstVideo::YuvMode::YUV444;
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
// All pixels should be blue (0x8EFFFA) to within a tolerance (due to jpeg
// compression artifacts and quanitization)
for (int x = 0; x < out.width; x++) {
for (int y = 0; y < out.height; y++) {
- AstVideo::RGB pixel = d.OutBuffer[x + (y * out.width)];
- ASSERT_EQ(pixel.R, 0x00) << "X:" << x << " Y: " << y;
- ASSERT_EQ(pixel.G, 0x00) << "X:" << x << " Y: " << y;
- ASSERT_EQ(pixel.B, 0x00) << "X:" << x << " Y: " << y;
+ ast_video::RGB pixel = d.outBuffer[x + (y * out.width)];
+ ASSERT_EQ(pixel.r, 0x00) << "X:" << x << " Y: " << y;
+ ASSERT_EQ(pixel.g, 0x00) << "X:" << x << " Y: " << y;
+ ASSERT_EQ(pixel.b, 0x00) << "X:" << x << " Y: " << y;
}
}
}
TEST(AstJpegDecoder, TestColors) {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
// This binary blog was created on the aspeed hardware using a blue screen
// consisting of the color 0x8EFFFA in a web browser window
@@ -100,33 +100,33 @@ TEST(AstJpegDecoder, TestColors) {
ASSERT_GT(bufferlen, 0);
- out.y_selector = 0;
- out.uv_selector = 0;
- out.mode = AstVideo::YuvMode::YUV444;
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
int tolerance = 16;
/*
for (int i = 0; i < out.width * out.height; i++) {
- AstVideo::RGB &pixel = d.OutBuffer[i];
- EXPECT_GT(pixel.R, 0x8E - tolerance);
- EXPECT_LT(pixel.R, 0x8E + tolerance);
- EXPECT_GT(pixel.G, 0xFF - tolerance);
- EXPECT_LT(pixel.G, 0xFF + tolerance);
- EXPECT_GT(pixel.B, 0xF1 - tolerance);
- EXPECT_LT(pixel.B, 0xF1 + tolerance);
+ ast_video::RGB &pixel = d.outBuffer[i];
+ EXPECT_GT(pixel.r, 0x8E - tolerance);
+ EXPECT_LT(pixel.r, 0x8E + tolerance);
+ EXPECT_GT(pixel.g, 0xFF - tolerance);
+ EXPECT_LT(pixel.g, 0xFF + tolerance);
+ EXPECT_GT(pixel.b, 0xF1 - tolerance);
+ EXPECT_LT(pixel.b, 0xF1 + tolerance);
}
*/
}
// Tests the buffers around the screen aren't written to
TEST(AstJpegDecoder, BufferLimits) {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
// This binary blog was created on the aspeed hardware using a black screen
FILE *fp = fopen("test_resources/aspeedblackscreen.bin", "rb");
@@ -137,23 +137,23 @@ TEST(AstJpegDecoder, BufferLimits) {
ASSERT_GT(bufferlen, 0);
- out.y_selector = 0;
- out.uv_selector = 0;
- out.mode = AstVideo::YuvMode::YUV444;
+ out.ySelector = 0;
+ out.uvSelector = 0;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
- // Reserved pixel should be default value
- for (auto &pixel : d.OutBuffer) {
- EXPECT_EQ(pixel.Reserved, 0xAA);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
+ // reserved pixel should be default value
+ for (auto &pixel : d.outBuffer) {
+ EXPECT_EQ(pixel.reserved, 0xAA);
}
// All pixels beyond the buffer should be zero
- for (int i = out.width * out.height; i < d.OutBuffer.size(); i++) {
- EXPECT_EQ(d.OutBuffer[i].R, 0x00) << "index:" << i;
- EXPECT_EQ(d.OutBuffer[i].B, 0x00) << "index:" << i;
- EXPECT_EQ(d.OutBuffer[i].G, 0x00) << "index:" << i;
+ for (int i = out.width * out.height; i < d.outBuffer.size(); i++) {
+ EXPECT_EQ(d.outBuffer[i].r, 0x00) << "index:" << i;
+ EXPECT_EQ(d.outBuffer[i].b, 0x00) << "index:" << i;
+ EXPECT_EQ(d.outBuffer[i].g, 0x00) << "index:" << i;
}
} \ No newline at end of file
diff --git a/src/ast_video_puller_test.cpp b/src/ast_video_puller_test.cpp
index b1f94e7579..58adda9697 100644
--- a/src/ast_video_puller_test.cpp
+++ b/src/ast_video_puller_test.cpp
@@ -14,12 +14,12 @@
#include <gtest/gtest.h>
TEST(AstvideoPuller, BasicRead) {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
bool have_hardware = false;
if (access("/dev/video", F_OK) != -1) {
- AstVideo::SimpleVideoPuller p;
+ ast_video::SimpleVideoPuller p;
p.initialize();
- out = p.read_video();
+ out = p.readVideo();
} else {
FILE *fp = fopen("test_resources/ubuntu_444_800x600_0chrom_0lum.bin", "rb");
if (fp) {
@@ -30,18 +30,18 @@ TEST(AstvideoPuller, BasicRead) {
}
fclose(fp);
out.buffer.resize(newLen);
- out.mode = AstVideo::YuvMode::YUV444;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- out.y_selector = 0;
- out.uv_selector = 0;
+ out.ySelector = 0;
+ out.uvSelector = 0;
}
}
FILE *fp = fopen("/tmp/screendata.bin", "wb");
fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
}
diff --git a/src/base64.cpp b/src/base64.cpp
index 54a60084cf..0013c28ac3 100644
--- a/src/base64.cpp
+++ b/src/base64.cpp
@@ -109,7 +109,8 @@ bool base64_decode(const std::string &input, std::string &output) {
if (base64code1 == nop) { // non base64 character
return false;
}
- output += static_cast<char>((base64code0 << 2) | ((base64code1 >> 4) & 0x3));
+ output +=
+ static_cast<char>((base64code0 << 2) | ((base64code1 >> 4) & 0x3));
if (++i < input_length) {
char c = input[i];
@@ -120,7 +121,8 @@ bool base64_decode(const std::string &input, std::string &output) {
if (base64code2 == nop) { // non base64 character
return false;
}
- output += static_cast<char>(((base64code1 << 4) & 0xf0) | ((base64code2 >> 2) & 0x0f));
+ output += static_cast<char>(((base64code1 << 4) & 0xf0) |
+ ((base64code2 >> 2) & 0x0f));
}
if (++i < input_length) {
diff --git a/src/crow_getroutes_test.cpp b/src/crow_getroutes_test.cpp
index 4b705b0bdf..29052a9a21 100644
--- a/src/crow_getroutes_test.cpp
+++ b/src/crow_getroutes_test.cpp
@@ -9,16 +9,16 @@ TEST(GetRoutes, TestEmptyRoutes) {
SimpleApp app;
decltype(app)::server_t server(&app, "127.0.0.1", 45451);
- EXPECT_THAT(app.get_routes(), testing::IsEmpty());
+ EXPECT_THAT(app.getRoutes(), testing::IsEmpty());
}
// Tests that static urls are correctly passed
TEST(GetRoutes, TestOneRoute) {
SimpleApp app;
decltype(app)::server_t server(&app, "127.0.0.1", 45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
- EXPECT_THAT(app.get_routes(),
+ EXPECT_THAT(app.getRoutes(),
testing::ElementsAre(testing::Pointee(std::string("/"))));
}
@@ -26,18 +26,18 @@ TEST(GetRoutes, TestOneRoute) {
TEST(GetRoutes, TestlotsOfRoutes) {
SimpleApp app;
decltype(app)::server_t server(&app, "127.0.0.1", 45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
- CROW_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; });
- CROW_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; });
- CROW_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; });
- CROW_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; });
- CROW_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/foo")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/bar")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/baz")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/boo")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/moo")([]() { return boost::beast::http::status::ok; });
- EXPECT_THAT(app.get_routes(), testing::UnorderedElementsAre(
- testing::Pointee(std::string("/")),
- testing::Pointee(std::string("/foo")),
- testing::Pointee(std::string("/bar")),
- testing::Pointee(std::string("/baz")),
- testing::Pointee(std::string("/boo")),
- testing::Pointee(std::string("/moo"))));
+ EXPECT_THAT(app.getRoutes(), testing::UnorderedElementsAre(
+ testing::Pointee(std::string("/")),
+ testing::Pointee(std::string("/foo")),
+ testing::Pointee(std::string("/bar")),
+ testing::Pointee(std::string("/baz")),
+ testing::Pointee(std::string("/boo")),
+ testing::Pointee(std::string("/moo"))));
} \ No newline at end of file
diff --git a/src/crow_test.cpp b/src/crow_test.cpp
index 20a946dab6..cd668171db 100644
--- a/src/crow_test.cpp
+++ b/src/crow_test.cpp
@@ -3,8 +3,8 @@
#include <sstream>
#include <vector>
#include "gtest/gtest.h"
-#undef CROW_LOG_LEVEL
-#define CROW_LOG_LEVEL 0
+#undef BMCWEB_LOG_LEVEL
+#define BMCWEB_LOG_LEVEL 0
using namespace std;
using namespace crow;
@@ -62,16 +62,16 @@ TEST(Crow, Rule) {
r.validate();
- response res;
+ Response res;
// executing handler
ASSERT_EQUAL(0, x);
boost::beast::http::request<boost::beast::http::string_body> req{};
- r.handle(request(req), res, routing_params());
+ r.handle(Request(req), res, RoutingParams());
ASSERT_EQUAL(1, x);
- // registering handler with request argument
- r([&x](const crow::request&) {
+ // registering handler with Request argument
+ r([&x](const crow::Request&) {
x = 2;
return "";
});
@@ -80,14 +80,14 @@ TEST(Crow, Rule) {
// executing handler
ASSERT_EQUAL(1, x);
- r.handle(request(req), res, routing_params());
+ r.handle(Request(req), res, RoutingParams());
ASSERT_EQUAL(2, x);
}
TEST(Crow, ParameterTagging) {
- static_assert(black_magic::is_valid("<int><int><int>"), "valid url");
- static_assert(!black_magic::is_valid("<int><int<<int>"), "invalid url");
- static_assert(!black_magic::is_valid("nt>"), "invalid url");
+ static_assert(black_magic::isValid("<int><int><int>"), "valid url");
+ static_assert(!black_magic::isValid("<int><int<<int>"), "invalid url");
+ static_assert(!black_magic::isValid("nt>"), "invalid url");
ASSERT_EQUAL(1, black_magic::get_parameter_tag("<int>"));
ASSERT_EQUAL(2, black_magic::get_parameter_tag("<uint>"));
ASSERT_EQUAL(3, black_magic::get_parameter_tag("<float>"));
@@ -106,96 +106,96 @@ TEST(Crow, ParameterTagging) {
// to template argument
static_assert(
std::is_same<black_magic::S<uint64_t, double, int64_t>,
- black_magic::arguments<6 * 6 + 6 * 3 + 2>::type>::value,
+ black_magic::Arguments<6 * 6 + 6 * 3 + 2>::type>::value,
"tag to type container");
}
TEST(Crow, PathRouting) {
SimpleApp app;
- CROW_ROUTE(app, "/file")
+ BMCWEB_ROUTE(app, "/file")
([] { return "file"; });
- CROW_ROUTE(app, "/path/")
+ BMCWEB_ROUTE(app, "/path/")
([] { return "path"; });
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/file";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/file/";
app.handle(req, res);
- ASSERT_EQUAL(404, res.result_int());
+ ASSERT_EQUAL(404, res.resultInt());
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/path";
app.handle(req, res);
- ASSERT_NOTEQUAL(404, res.result_int());
+ ASSERT_NOTEQUAL(404, res.resultInt());
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/path/";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
}
}
TEST(Crow, RoutingTest) {
SimpleApp app;
int A{};
- uint32_t B{};
+ uint32_t b{};
double C{};
string D{};
string E{};
- CROW_ROUTE(app, "/0/<uint>")
+ BMCWEB_ROUTE(app, "/0/<uint>")
([&](uint32_t b) {
- B = b;
+ b = b;
return "OK";
});
- CROW_ROUTE(app, "/1/<int>/<uint>")
+ BMCWEB_ROUTE(app, "/1/<int>/<uint>")
([&](int a, uint32_t b) {
A = a;
- B = b;
+ b = b;
return "OK";
});
- CROW_ROUTE(app, "/4/<int>/<uint>/<double>/<string>")
+ BMCWEB_ROUTE(app, "/4/<int>/<uint>/<double>/<string>")
([&](int a, uint32_t b, double c, string d) {
A = a;
- B = b;
+ b = b;
C = c;
D = d;
return "OK";
});
- CROW_ROUTE(app, "/5/<int>/<uint>/<double>/<string>/<path>")
+ BMCWEB_ROUTE(app, "/5/<int>/<uint>/<double>/<string>/<path>")
([&](int a, uint32_t b, double c, string d, string e) {
A = a;
- B = b;
+ b = b;
C = c;
D = d;
E = e;
@@ -203,96 +203,96 @@ TEST(Crow, RoutingTest) {
});
app.validate();
- // app.debug_print();
+ // app.debugPrint();
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/-1";
app.handle(req, res);
- ASSERT_EQUAL(404, res.result_int());
+ ASSERT_EQUAL(404, res.resultInt());
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/0/1001999";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
- ASSERT_EQUAL(1001999, B);
+ ASSERT_EQUAL(1001999, b);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/1/-100/1999";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
ASSERT_EQUAL(-100, A);
- ASSERT_EQUAL(1999, B);
+ ASSERT_EQUAL(1999, b);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/4/5000/3/-2.71828/hellhere";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
ASSERT_EQUAL(5000, A);
- ASSERT_EQUAL(3, B);
+ ASSERT_EQUAL(3, b);
ASSERT_EQUAL(-2.71828, C);
ASSERT_EQUAL("hellhere", D);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/5/-5/999/3.141592/hello_there/a/b/c/d";
app.handle(req, res);
- ASSERT_EQUAL(200, res.result_int());
+ ASSERT_EQUAL(200, res.resultInt());
ASSERT_EQUAL(-5, A);
- ASSERT_EQUAL(999, B);
+ ASSERT_EQUAL(999, b);
ASSERT_EQUAL(3.141592, C);
ASSERT_EQUAL("hello_there", D);
ASSERT_EQUAL("a/b/c/d", E);
}
}
-TEST(Crow, simple_response_routing_params) {
+TEST(Crow, simple_response_RoutingParams) {
ASSERT_EQUAL(100,
- response(boost::beast::http::status::continue_).result_int());
- ASSERT_EQUAL(200, response("Hello there").result_int());
- ASSERT_EQUAL(500, response(boost::beast::http::status::internal_server_error,
+ Response(boost::beast::http::status::continue_).resultInt());
+ ASSERT_EQUAL(200, Response("Hello there").resultInt());
+ ASSERT_EQUAL(500, Response(boost::beast::http::status::internal_server_error,
"Internal Error?")
- .result_int());
-
- routing_params rp;
- rp.int_params.push_back(1);
- rp.int_params.push_back(5);
- rp.uint_params.push_back(2);
- rp.double_params.push_back(3);
- rp.string_params.push_back("hello");
+ .resultInt());
+
+ RoutingParams rp;
+ rp.intParams.push_back(1);
+ rp.intParams.push_back(5);
+ rp.uintParams.push_back(2);
+ rp.doubleParams.push_back(3);
+ rp.stringParams.push_back("hello");
ASSERT_EQUAL(1, rp.get<int64_t>(0));
ASSERT_EQUAL(5, rp.get<int64_t>(1));
ASSERT_EQUAL(2, rp.get<uint64_t>(0));
@@ -302,34 +302,34 @@ TEST(Crow, simple_response_routing_params) {
TEST(Crow, handler_with_response) {
SimpleApp app;
- CROW_ROUTE(app, "/")([](const crow::request&, crow::response&) {});
+ BMCWEB_ROUTE(app, "/")([](const crow::Request&, crow::Response&) {});
}
TEST(Crow, http_method) {
SimpleApp app;
- CROW_ROUTE(app, "/").methods("POST"_method,
- "GET"_method)([](const request& req) {
+ BMCWEB_ROUTE(app, "/").methods("POST"_method,
+ "GET"_method)([](const Request& req) {
if (req.method() == "GET"_method)
return "2";
else
return "1";
});
- CROW_ROUTE(app, "/get_only")
- .methods("GET"_method)([](const request& /*req*/) { return "get"; });
- CROW_ROUTE(app, "/post_only")
- .methods("POST"_method)([](const request& /*req*/) { return "post"; });
+ BMCWEB_ROUTE(app, "/get_only")
+ .methods("GET"_method)([](const Request& /*req*/) { return "get"; });
+ BMCWEB_ROUTE(app, "/post_only")
+ .methods("POST"_method)([](const Request& /*req*/) { return "post"; });
// cannot have multiple handlers for the same url
- // CROW_ROUTE(app, "/")
+ // BMCWEB_ROUTE(app, "/")
//.methods("GET"_method)
//([]{ return "2"; });
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/";
app.handle(req, res);
@@ -338,8 +338,8 @@ TEST(Crow, http_method) {
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/";
r.method("POST"_method);
@@ -350,8 +350,8 @@ TEST(Crow, http_method) {
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/get_only";
app.handle(req, res);
@@ -361,8 +361,8 @@ TEST(Crow, http_method) {
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/get_only";
r.method("POST"_method);
@@ -375,7 +375,7 @@ TEST(Crow, http_method) {
TEST(Crow, server_handling_error_request) {
static char buf[2048];
SimpleApp app;
- CROW_ROUTE(app, "/")([] { return "A"; });
+ BMCWEB_ROUTE(app, "/")([] { return "A"; });
Server<SimpleApp> server(&app, LOCALHOST_ADDRESS, 45451);
auto _ = async(launch::async, [&] { server.run(); });
std::string sendmsg = "POX";
@@ -400,10 +400,10 @@ TEST(Crow, server_handling_error_request) {
TEST(Crow, multi_server) {
static char buf[2048];
SimpleApp app1, app2;
- CROW_ROUTE(app1, "/").methods("GET"_method,
- "POST"_method)([] { return "A"; });
- CROW_ROUTE(app2, "/").methods("GET"_method,
- "POST"_method)([] { return "B"; });
+ BMCWEB_ROUTE(app1, "/").methods("GET"_method,
+ "POST"_method)([] { return "A"; });
+ BMCWEB_ROUTE(app2, "/").methods("GET"_method,
+ "POST"_method)([] { return "B"; });
Server<SimpleApp> server1(&app1, LOCALHOST_ADDRESS, 45451);
Server<SimpleApp> server2(&app2, LOCALHOST_ADDRESS, 45452);
@@ -412,7 +412,7 @@ TEST(Crow, multi_server) {
auto _2 = async(launch::async, [&] { server2.run(); });
std::string sendmsg =
- "POST /\r\nContent-Length:3\r\nX-HeaderTest: 123\r\n\r\nA=B\r\n";
+ "POST /\r\nContent-Length:3\r\nX-HeaderTest: 123\r\n\r\nA=b\r\n";
asio::io_service is;
{
asio::ip::tcp::socket c(is);
@@ -436,7 +436,7 @@ TEST(Crow, multi_server) {
}
size_t recved = c.receive(asio::buffer(buf, 2048));
- ASSERT_EQUAL('B', buf[recved - 1]);
+ ASSERT_EQUAL('b', buf[recved - 1]);
}
server1.stop();
@@ -446,58 +446,59 @@ TEST(Crow, multi_server) {
TEST(Crow, black_magic) {
using namespace black_magic;
static_assert(
- std::is_same<void, last_element_type<int, char, void>::type>::value,
- "last_element_type");
- static_assert(std::is_same<char, pop_back<int, char, void>::rebind<
- last_element_type>::type>::value,
- "pop_back");
+ std::is_same<void, LastElementType<int, char, void>::type>::value,
+ "LastElementType");
static_assert(
- std::is_same<int, pop_back<int, char, void>::rebind<pop_back>::rebind<
- last_element_type>::type>::value,
+ std::is_same<
+ char, PopBack<int, char, void>::rebind<LastElementType>::type>::value,
+ "pop_back");
+ static_assert(
+ std::is_same<int, PopBack<int, char, void>::rebind<PopBack>::rebind<
+ LastElementType>::type>::value,
"pop_back");
}
struct NullMiddleware {
- struct context {};
+ struct Context {};
template <typename AllContext>
- void before_handle(request&, response&, context&, AllContext&) {}
+ void beforeHandle(Request&, Response&, Context&, AllContext&) {}
template <typename AllContext>
- void after_handle(request&, response&, context&, AllContext&) {}
+ void afterHandle(Request&, Response&, Context&, AllContext&) {}
};
struct NullSimpleMiddleware {
- struct context {};
+ struct Context {};
- void before_handle(request& /*req*/, response& /*res*/, context& /*ctx*/) {}
+ void beforeHandle(Request& /*req*/, Response& /*res*/, Context& /*ctx*/) {}
- void after_handle(request& /*req*/, response& /*res*/, context& /*ctx*/) {}
+ void afterHandle(Request& /*req*/, Response& /*res*/, Context& /*ctx*/) {}
};
TEST(Crow, middleware_simple) {
App<NullMiddleware, NullSimpleMiddleware> app;
decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
- CROW_ROUTE(app, "/")
- ([&](const crow::request& req) {
- app.get_context<NullMiddleware>(req);
- app.get_context<NullSimpleMiddleware>(req);
+ BMCWEB_ROUTE(app, "/")
+ ([&](const crow::Request& req) {
+ app.getContext<NullMiddleware>(req);
+ app.getContext<NullSimpleMiddleware>(req);
return "";
});
}
struct IntSettingMiddleware {
- struct context {
+ struct Context {
int val;
};
template <typename AllContext>
- void before_handle(request&, response&, context& ctx, AllContext&) {
+ void beforeHandle(Request&, Response&, Context& ctx, AllContext&) {
ctx.val = 1;
}
template <typename AllContext>
- void after_handle(request&, response&, context& ctx, AllContext&) {
+ void afterHandle(Request&, Response&, Context& ctx, AllContext&) {
ctx.val = 2;
}
};
@@ -505,49 +506,49 @@ struct IntSettingMiddleware {
std::vector<std::string> test_middleware_context_vector;
struct FirstMW {
- struct context {
+ struct Context {
std::vector<string> v;
};
- void before_handle(request& /*req*/, response& /*res*/, context& ctx) {
+ void beforeHandle(Request& /*req*/, Response& /*res*/, Context& ctx) {
ctx.v.push_back("1 before");
}
- void after_handle(request& /*req*/, response& /*res*/, context& ctx) {
+ void afterHandle(Request& /*req*/, Response& /*res*/, Context& ctx) {
ctx.v.push_back("1 after");
test_middleware_context_vector = ctx.v;
}
};
struct SecondMW {
- struct context {};
+ struct Context {};
template <typename AllContext>
- void before_handle(request& req, response& res, context&,
- AllContext& all_ctx) {
+ void beforeHandle(Request& req, Response& res, Context&,
+ AllContext& all_ctx) {
all_ctx.template get<FirstMW>().v.push_back("2 before");
if (req.url == "/break") res.end();
}
template <typename AllContext>
- void after_handle(request&, response&, context&, AllContext& all_ctx) {
+ void afterHandle(Request&, Response&, Context&, AllContext& all_ctx) {
all_ctx.template get<FirstMW>().v.push_back("2 after");
}
};
struct ThirdMW {
- struct context {};
+ struct Context {};
template <typename AllContext>
- void before_handle(request&, response&, context&, AllContext& all_ctx) {
+ void beforeHandle(Request&, Response&, Context&, AllContext& all_ctx) {
all_ctx.template get<FirstMW>().v.push_back("3 before");
}
template <typename AllContext>
- void after_handle(request&, response&, context&, AllContext& all_ctx) {
+ void afterHandle(Request&, Response&, Context&, AllContext& all_ctx) {
all_ctx.template get<FirstMW>().v.push_back("3 after");
}
};
-TEST(Crow, middleware_context) {
+TEST(Crow, middlewareContext) {
static char buf[2048];
// SecondMW depends on FirstMW (it uses all_ctx.get<FirstMW>)
// so it leads to compile error if we remove FirstMW from definition
@@ -558,23 +559,23 @@ TEST(Crow, middleware_context) {
App<IntSettingMiddleware, FirstMW, SecondMW, ThirdMW> app;
int x{};
- CROW_ROUTE(app, "/")
- ([&](const request& req) {
+ BMCWEB_ROUTE(app, "/")
+ ([&](const Request& req) {
{
- auto& ctx = app.get_context<IntSettingMiddleware>(req);
+ auto& ctx = app.getContext<IntSettingMiddleware>(req);
x = ctx.val;
}
{
- auto& ctx = app.get_context<FirstMW>(req);
+ auto& ctx = app.getContext<FirstMW>(req);
ctx.v.push_back("handle");
}
return "";
});
- CROW_ROUTE(app, "/break")
- ([&](const request& req) {
+ BMCWEB_ROUTE(app, "/break")
+ ([&](const Request& req) {
{
- auto& ctx = app.get_context<FirstMW>(req);
+ auto& ctx = app.getContext<FirstMW>(req);
ctx.v.push_back("handle");
}
@@ -634,7 +635,7 @@ TEST(Crow, bug_quick_repeated_request) {
SimpleApp app;
- CROW_ROUTE(app, "/")([&] { return "hello"; });
+ BMCWEB_ROUTE(app, "/")([&] { return "hello"; });
decltype(app)::server_t server(&app, LOCALHOST_ADDRESS, 45451);
auto _ = async(launch::async, [&] { server.run(); });
@@ -667,11 +668,11 @@ TEST(Crow, simple_url_params) {
SimpleApp app;
- query_string last_url_params;
+ QueryString lastUrlParams;
- CROW_ROUTE(app, "/params")
- ([&last_url_params](const crow::request& req) {
- last_url_params = std::move(req.url_params);
+ BMCWEB_ROUTE(app, "/params")
+ ([&lastUrlParams](const crow::Request& req) {
+ lastUrlParams = std::move(req.urlParams);
return "OK";
});
@@ -693,7 +694,7 @@ TEST(Crow, simple_url_params) {
c.close();
stringstream ss;
- ss << last_url_params;
+ ss << lastUrlParams;
ASSERT_EQUAL("[ ]", ss.str());
}
@@ -707,9 +708,9 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_TRUE(last_url_params.get("missing") == nullptr);
- ASSERT_TRUE(last_url_params.get("foobar") != nullptr);
- ASSERT_TRUE(last_url_params.get_list("missing").empty());
+ ASSERT_TRUE(lastUrlParams.get("missing") == nullptr);
+ ASSERT_TRUE(lastUrlParams.get("foobar") != nullptr);
+ ASSERT_TRUE(lastUrlParams.getList("missing").empty());
}
// check multiple presence
sendmsg = "GET /params?foo&bar&baz\r\n\r\n";
@@ -721,10 +722,10 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_TRUE(last_url_params.get("missing") == nullptr);
- ASSERT_TRUE(last_url_params.get("foo") != nullptr);
- ASSERT_TRUE(last_url_params.get("bar") != nullptr);
- ASSERT_TRUE(last_url_params.get("baz") != nullptr);
+ ASSERT_TRUE(lastUrlParams.get("missing") == nullptr);
+ ASSERT_TRUE(lastUrlParams.get("foo") != nullptr);
+ ASSERT_TRUE(lastUrlParams.get("bar") != nullptr);
+ ASSERT_TRUE(lastUrlParams.get("baz") != nullptr);
}
// check single value
sendmsg = "GET /params?hello=world\r\n\r\n";
@@ -736,7 +737,7 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_EQUAL(string(last_url_params.get("hello")), "world");
+ ASSERT_EQUAL(string(lastUrlParams.get("hello")), "world");
}
// check multiple value
sendmsg = "GET /params?hello=world&left=right&up=down\r\n\r\n";
@@ -748,9 +749,9 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_EQUAL(string(last_url_params.get("hello")), "world");
- ASSERT_EQUAL(string(last_url_params.get("left")), "right");
- ASSERT_EQUAL(string(last_url_params.get("up")), "down");
+ ASSERT_EQUAL(string(lastUrlParams.get("hello")), "world");
+ ASSERT_EQUAL(string(lastUrlParams.get("left")), "right");
+ ASSERT_EQUAL(string(lastUrlParams.get("up")), "down");
}
// check multiple value, multiple types
sendmsg = "GET /params?int=100&double=123.45&boolean=1\r\n\r\n";
@@ -762,11 +763,10 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_EQUAL(boost::lexical_cast<int>(last_url_params.get("int")), 100);
- ASSERT_EQUAL(boost::lexical_cast<double>(last_url_params.get("double")),
+ ASSERT_EQUAL(boost::lexical_cast<int>(lastUrlParams.get("int")), 100);
+ ASSERT_EQUAL(boost::lexical_cast<double>(lastUrlParams.get("double")),
123.45);
- ASSERT_EQUAL(boost::lexical_cast<bool>(last_url_params.get("boolean")),
- true);
+ ASSERT_EQUAL(boost::lexical_cast<bool>(lastUrlParams.get("boolean")), true);
}
// check single array value
sendmsg = "GET /params?tmnt[]=leonardo\r\n\r\n";
@@ -779,9 +779,9 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_TRUE(last_url_params.get("tmnt") == nullptr);
- ASSERT_EQUAL(last_url_params.get_list("tmnt").size(), 1);
- ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[0]), "leonardo");
+ ASSERT_TRUE(lastUrlParams.get("tmnt") == nullptr);
+ ASSERT_EQUAL(lastUrlParams.getList("tmnt").size(), 1);
+ ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[0]), "leonardo");
}
// check multiple array value
sendmsg =
@@ -795,43 +795,43 @@ TEST(Crow, simple_url_params) {
c.receive(asio::buffer(buf, 2048));
c.close();
- ASSERT_EQUAL(last_url_params.get_list("tmnt").size(), 3);
- ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[0]), "leonardo");
- ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[1]), "donatello");
- ASSERT_EQUAL(string(last_url_params.get_list("tmnt")[2]), "raphael");
+ ASSERT_EQUAL(lastUrlParams.getList("tmnt").size(), 3);
+ ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[0]), "leonardo");
+ ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[1]), "donatello");
+ ASSERT_EQUAL(string(lastUrlParams.getList("tmnt")[2]), "raphael");
}
server.stop();
}
-TEST(Crow, route_dynamic) {
+TEST(Crow, routeDynamic) {
SimpleApp app;
int x = 1;
- app.route_dynamic("/")([&] {
+ app.routeDynamic("/")([&] {
x = 2;
return "";
});
- app.route_dynamic("/set4")([&](const request&) {
+ app.routeDynamic("/set4")([&](const Request&) {
x = 4;
return "";
});
- app.route_dynamic("/set5")([&](const request&, response& res) {
+ app.routeDynamic("/set5")([&](const Request&, Response& res) {
x = 5;
res.end();
});
- app.route_dynamic("/set_int/<int>")([&](int y) {
+ app.routeDynamic("/set_int/<int>")([&](int y) {
x = y;
return "";
});
try {
- app.route_dynamic("/invalid_test/<double>/<path>")([]() { return ""; });
+ app.routeDynamic("/invalid_test/<double>/<path>")([]() { return ""; });
fail();
} catch (std::exception&) {
}
- // app is in an invalid state when route_dynamic throws an exception.
+ // app is in an invalid state when routeDynamic throws an exception.
try {
app.validate();
fail();
@@ -840,32 +840,32 @@ TEST(Crow, route_dynamic) {
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/";
app.handle(req, res);
ASSERT_EQUAL(x, 2);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/set_int/42";
app.handle(req, res);
ASSERT_EQUAL(x, 42);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/set5";
app.handle(req, res);
ASSERT_EQUAL(x, 5);
}
{
boost::beast::http::request<boost::beast::http::string_body> r{};
- request req{r};
- response res;
+ Request req{r};
+ Response res;
req.url = "/set4";
app.handle(req, res);
ASSERT_EQUAL(x, 4);
diff --git a/src/getvideo_main.cpp b/src/getvideo_main.cpp
index bc4d75b1a4..7055d35dfc 100644
--- a/src/getvideo_main.cpp
+++ b/src/getvideo_main.cpp
@@ -20,12 +20,12 @@
#include <ast_video_puller.hpp>
int main() {
- AstVideo::RawVideoBuffer out;
+ ast_video::RawVideoBuffer out;
bool have_hardware = false;
if (access("/dev/video", F_OK) != -1) {
- AstVideo::SimpleVideoPuller p;
+ ast_video::SimpleVideoPuller p;
p.initialize();
- out = p.read_video();
+ out = p.readVideo();
} else {
FILE *fp = fopen("/home/ed/screendata.bin", "rb");
if (fp != nullptr) {
@@ -36,29 +36,29 @@ int main() {
}
fclose(fp);
out.buffer.resize(newLen);
- out.mode = AstVideo::YuvMode::YUV444;
+ out.mode = ast_video::YuvMode::YUV444;
out.width = 800;
out.height = 600;
- out.y_selector = 0;
- out.uv_selector = 0;
+ out.ySelector = 0;
+ out.uvSelector = 0;
}
}
FILE *fp = fopen("/tmp/screendata.bin", "wb");
fwrite(out.buffer.data(), sizeof(char), out.buffer.size(), fp);
- AstVideo::AstJpegDecoder d;
- d.decode(out.buffer, out.width, out.height, out.mode, out.y_selector,
- out.uv_selector);
+ ast_video::AstJpegDecoder d;
+ d.decode(out.buffer, out.width, out.height, out.mode, out.ySelector,
+ out.uvSelector);
#ifdef BUILD_CIMG
cimg_library::CImg<unsigned char> image(out.width, out.height, 1,
3 /*numchannels*/);
for (int y = 0; y < out.height; y++) {
for (int x = 0; x < out.width; x++) {
- auto pixel = d.OutBuffer[x + (y * out.width)];
- image(x, y, 0) = pixel.R;
- image(x, y, 1) = pixel.G;
- image(x, y, 2) = pixel.B;
+ auto pixel = d.outBuffer[x + (y * out.width)];
+ image(x, y, 0) = pixel.r;
+ image(x, y, 1) = pixel.g;
+ image(x, y, 2) = pixel.b;
}
}
image.save("/tmp/file2.bmp");
diff --git a/src/gtest_main.cpp b/src/gtest_main.cpp
index d70149853d..eec00675a3 100644
--- a/src/gtest_main.cpp
+++ b/src/gtest_main.cpp
@@ -1,5 +1,5 @@
-#include "gtest/gtest.h"
#include "gmock/gmock.h"
+#include "gtest/gtest.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
diff --git a/src/kvm_websocket_test.cpp b/src/kvm_websocket_test.cpp
index 94a9ffc7b5..b5e1bdcffd 100644
--- a/src/kvm_websocket_test.cpp
+++ b/src/kvm_websocket_test.cpp
@@ -15,11 +15,11 @@ TEST(Kvm, BasicRfb) {
return; // TODO(ed) Make hte code below work again
SimpleApp app;
- crow::kvm::request_routes(app);
+ crow::kvm::requestRoutes(app);
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(std::launch::async, [&] { app.run(); });
- auto routes = app.get_routes();
+ auto routes = app.getRoutes();
asio::io_service is;
{
@@ -56,23 +56,23 @@ TEST(Kvm, BasicRfb) {
asio::ip::address::from_string("127.0.0.1"), 45451));
socket.send(asio::buffer(sendmsg));
- // Read the response status line. The response streambuf will automatically
+ // Read the Response status line. The Response streambuf will automatically
// grow to accommodate the entire line. The growth may be limited by passing
// a maximum size to the streambuf constructor.
boost::asio::streambuf response;
boost::asio::read_until(socket, response, "\r\n");
- // Check that response is OK.
+ // Check that Response is OK.
std::istream response_stream(&response);
std::string http_response;
std::getline(response_stream, http_response);
EXPECT_EQ(http_response, "HTTP/1.1 101 Switching Protocols\r");
- // Read the response headers, which are terminated by a blank line.
+ // Read the Response headers, which are terminated by a blank line.
boost::asio::read_until(socket, response, "\r\n\r\n");
- // Process the response headers.
+ // Process the Response headers.
std::string header;
std::vector<std::string> headers;
while (std::getline(response_stream, header) && header != "\r") {
diff --git a/src/security_headers_middleware_test.cpp b/src/security_headers_middleware_test.cpp
index c435921e50..e7008cb165 100644
--- a/src/security_headers_middleware_test.cpp
+++ b/src/security_headers_middleware_test.cpp
@@ -1,7 +1,7 @@
#include <security_headers_middleware.hpp>
#include <crow/app.h>
-#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
using namespace crow;
using namespace std;
@@ -10,7 +10,7 @@ using namespace std;
TEST(SecurityHeaders, TestHeadersExist) {
App<SecurityHeadersMiddleware> app;
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(launch::async, [&] { app.run(); });
asio::io_service is;
diff --git a/src/token_authorization_middleware_test.cpp b/src/token_authorization_middleware_test.cpp
index 47acc857fd..ab735b3a52 100644
--- a/src/token_authorization_middleware_test.cpp
+++ b/src/token_authorization_middleware_test.cpp
@@ -23,8 +23,8 @@ class TokenAuth : public ::testing::Test {
TEST_F(TokenAuth, SpecialResourcesAreAcceptedWithoutAuth) {
CrowApp app(io);
- crow::TokenAuthorization::request_routes(app);
- CROW_ROUTE(app, "/redfish/v1")
+ crow::token_authorization::requestRoutes(app);
+ BMCWEB_ROUTE(app, "/redfish/v1")
([]() { return boost::beast::http::status::ok; });
auto _ = std::async(std::launch::async, [&] {
app.port(testPort).run();
@@ -66,10 +66,10 @@ TEST_F(TokenAuth, SpecialResourcesAreAcceptedWithoutAuth) {
// Tests that Base64 basic strings work
TEST(TokenAuthentication, TestRejectedResource) {
- App<crow::PersistentData::Middleware, crow::TokenAuthorization::Middleware>
+ App<crow::persistent_data::Middleware, crow::token_authorization::Middleware>
app;
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(std::launch::async, [&] { app.run(); });
asio::io_service is;
@@ -96,10 +96,10 @@ TEST(TokenAuthentication, TestRejectedResource) {
// Tests that Base64 basic strings work
TEST(TokenAuthentication, TestGetLoginUrl) {
- App<crow::PersistentData::Middleware, crow::TokenAuthorization::Middleware>
+ App<crow::persistent_data::Middleware, crow::token_authorization::Middleware>
app;
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(std::launch::async, [&] { app.run(); });
asio::io_service is;
@@ -126,10 +126,10 @@ TEST(TokenAuthentication, TestGetLoginUrl) {
// Tests boundary conditions on login
TEST(TokenAuthentication, TestPostBadLoginUrl) {
- App<crow::PersistentData::Middleware, crow::TokenAuthorization::Middleware>
+ App<crow::persistent_data::Middleware, crow::token_authorization::Middleware>
app;
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(std::launch::async, [&] { app.run(); });
asio::io_service is;
@@ -210,10 +210,10 @@ class KnownLoginAuthenticator {
};
TEST(TokenAuthentication, TestSuccessfulLogin) {
- App<crow::PersistentData::Middleware, crow::TokenAuthorization::Middleware>
+ App<crow::persistent_data::Middleware, crow::token_authorization::Middleware>
app;
app.bindaddr("127.0.0.1").port(45451);
- CROW_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
+ BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
auto _ = async(std::launch::async, [&] { app.run(); });
asio::io_service is;
diff --git a/src/webassets_test.cpp b/src/webassets_test.cpp
index 4f0844bc6f..2633c9b65b 100644
--- a/src/webassets_test.cpp
+++ b/src/webassets_test.cpp
@@ -16,11 +16,11 @@ using namespace testing;
TEST(Webassets, StaticFilesFixedRoutes) {
std::array<char, 2048> buf;
SimpleApp app;
- webassets::request_routes(app);
+ webassets::requestRoutes(app);
Server<SimpleApp> server(&app, "127.0.0.1", 45451);
auto _ = async(launch::async, [&] { server.run(); });
- // Get the homepage
+ // get the homepage
std::string sendmsg = "GET /\r\n\r\n";
asio::io_service is;
@@ -70,7 +70,7 @@ TEST(Webassets, StaticFilesFixedRoutes) {
// Once this occurs, this line will be obsolete
std::string ungziped_content = http_content;
if (content_encoding == "gzip") {
- EXPECT_TRUE(gzip_inflate(http_content, ungziped_content));
+ EXPECT_TRUE(gzipInflate(http_content, ungziped_content));
}
EXPECT_EQ(headers[0], "HTTP/1.1 200 OK");
@@ -86,11 +86,11 @@ TEST(Webassets, StaticFilesFixedRoutes) {
TEST(Webassets, EtagIsSane) {
std::array<char, 2048> buf;
SimpleApp app;
- webassets::request_routes(app);
+ webassets::requestRoutes(app);
Server<SimpleApp> server(&app, "127.0.0.1", 45451);
auto _ = async(launch::async, [&] { server.run(); });
- // Get the homepage
+ // get the homepage
std::string sendmsg = "GET /\r\n\r\n";
asio::io_service is;
diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp
index 55152d6033..e2a776a7e4 100644
--- a/src/webserver_main.cpp
+++ b/src/webserver_main.cpp
@@ -24,21 +24,21 @@
constexpr int defaultPort = 18080;
template <typename... Middlewares>
-void setup_socket(crow::Crow<Middlewares...>& app) {
- int listen_fd = sd_listen_fds(0);
- if (1 == listen_fd) {
- CROW_LOG_INFO << "attempting systemd socket activation";
+void setupSocket(crow::Crow<Middlewares...>& app) {
+ int listenFd = sd_listen_fds(0);
+ if (1 == listenFd) {
+ BMCWEB_LOG_INFO << "attempting systemd socket activation";
if (sd_is_socket_inet(SD_LISTEN_FDS_START, AF_UNSPEC, SOCK_STREAM, 1, 0)) {
- CROW_LOG_INFO << "Starting webserver on socket handle "
- << SD_LISTEN_FDS_START;
+ BMCWEB_LOG_INFO << "Starting webserver on socket handle "
+ << SD_LISTEN_FDS_START;
app.socket(SD_LISTEN_FDS_START);
} else {
- CROW_LOG_INFO << "bad incoming socket, starting webserver on port "
- << defaultPort;
+ BMCWEB_LOG_INFO << "bad incoming socket, starting webserver on port "
+ << defaultPort;
app.port(defaultPort);
}
} else {
- CROW_LOG_INFO << "Starting webserver on port " << defaultPort;
+ BMCWEB_LOG_INFO << "Starting webserver on port " << defaultPort;
app.port(defaultPort);
}
}
@@ -49,47 +49,47 @@ int main(int argc, char** argv) {
auto io = std::make_shared<boost::asio::io_service>();
CrowApp app(io);
-#ifdef CROW_ENABLE_SSL
- std::string ssl_pem_file("server.pem");
- std::cout << "Building SSL context\n";
+#ifdef BMCWEB_ENABLE_SSL
+ std::string sslPemFile("server.pem");
+ std::cout << "Building SSL Context\n";
- ensuressl::ensure_openssl_key_present_and_valid(ssl_pem_file);
+ ensuressl::ensureOpensslKeyPresentAndValid(sslPemFile);
std::cout << "SSL Enabled\n";
- auto ssl_context = ensuressl::get_ssl_context(ssl_pem_file);
- app.ssl(std::move(ssl_context));
+ auto sslContext = ensuressl::getSslContext(sslPemFile);
+ app.ssl(std::move(sslContext));
#endif
// Static assets need to be initialized before Authorization, because auth
// needs to build the whitelist from the static routes
#ifdef BMCWEB_ENABLE_PHOSPHOR_WEBUI
- crow::webassets::request_routes(app);
+ crow::webassets::requestRoutes(app);
#endif
#ifdef BMCWEB_ENABLE_KVM
- crow::kvm::request_routes(app);
+ crow::kvm::requestRoutes(app);
#endif
#ifdef BMCWEB_ENABLE_REDFISH
- crow::redfish::request_routes(app);
+ crow::redfish::requestRoutes(app);
#endif
#ifdef BMCWEB_ENABLE_DBUS_REST
- crow::dbus_monitor::request_routes(app);
+ crow::dbus_monitor::requestRoutes(app);
crow::image_upload::requestRoutes(app);
- crow::openbmc_mapper::request_routes(app);
+ crow::openbmc_mapper::requestRoutes(app);
#endif
- crow::TokenAuthorization::request_routes(app);
+ crow::token_authorization::requestRoutes(app);
- CROW_LOG_INFO << "bmcweb (" << __DATE__ << ": " << __TIME__ << ')';
- setup_socket(app);
+ BMCWEB_LOG_INFO << "bmcweb (" << __DATE__ << ": " << __TIME__ << ')';
+ setupSocket(app);
- crow::connections::system_bus =
+ crow::connections::systemBus =
std::make_shared<sdbusplus::asio::connection>(*io);
redfish::RedfishService redfish(app);
app.run();
io->run();
- crow::connections::system_bus.reset();
+ crow::connections::systemBus.reset();
}