diff options
| author | Ed Tanous <ed.tanous@intel.com> | 2017-04-05 13:04:39 -0700 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2017-04-05 13:17:36 -0700 |
| commit | 7d3dba40b6576ece9850c7156a481436b5f5ef02 (patch) | |
| tree | 5042fa6df66620b82706f25d3eb19e1a4c14d364 /src | |
| parent | b4a7bfad0a3ded7a813bdb44a46383316dc49b24 (diff) | |
| download | bmcweb-7d3dba40b6576ece9850c7156a481436b5f5ef02.tar.gz bmcweb-7d3dba40b6576ece9850c7156a481436b5f5ef02.zip | |
Make app middlewares not require specific instances of app
Diffstat (limited to 'src')
| -rw-r--r-- | src/g3log/generated_definitions.hpp | 13 | ||||
| -rw-r--r-- | src/getvideo_main.cpp | 11 | ||||
| -rw-r--r-- | src/security_headers_middleware_test.cpp | 4 | ||||
| -rw-r--r-- | src/token_authorization_middleware_test.cpp | 10 | ||||
| -rw-r--r-- | src/udpclient.cpp | 2 | ||||
| -rw-r--r-- | src/webassets_test.cpp | 1 | ||||
| -rw-r--r-- | src/webserver_main.cpp | 14 |
7 files changed, 33 insertions, 22 deletions
diff --git a/src/g3log/generated_definitions.hpp b/src/g3log/generated_definitions.hpp new file mode 100644 index 0000000..18433bb --- /dev/null +++ b/src/g3log/generated_definitions.hpp @@ -0,0 +1,13 @@ +// AUTO GENERATED MACRO DEFINITIONS FOR G3LOG + +/** ========================================================================== +* 2015 by KjellKod.cc. This is PUBLIC DOMAIN to use at your own risk and comes +* with no warranties. This code is yours to share, use and modify with no +* strings attached and no restrictions or obligations. +* +* For more information see g3log/LICENSE or refer refer to http://unlicense.org +* ============================================================================*/ +#pragma once + +// CMake induced definitions below. See g3log/Options.cmake for details. + diff --git a/src/getvideo_main.cpp b/src/getvideo_main.cpp index 2259b8c..182e8ad 100644 --- a/src/getvideo_main.cpp +++ b/src/getvideo_main.cpp @@ -39,14 +39,14 @@ class VideoPuller { std::cout << "Writing\n"; int status; - /* + status = write(video_fd, reinterpret_cast<char*>(&image_info), sizeof(image_info)); if (status != 0) { std::cout << "Write failed. Return: " << status <<"\n"; perror("perror output:"); } - */ + std::cout << "Write done\n"; //std::this_thread::sleep_for(std::chrono::milliseconds(2000)); @@ -64,8 +64,9 @@ class VideoPuller { std::cout << std::hex << std::setfill('0') << std::setw(2) << int(*(pt + i)) << " "; } - std::cout << "\n"; - /* + + std::cout << "\nprinting buffer\n"; + for(int i = 0; i < 1024; i++){ if (i % 16 == 0){ std::cout << "\n"; @@ -73,7 +74,7 @@ class VideoPuller { std::cout << std::hex << std::setfill('0') << std::setw(2) << int(buffer[i]) << " "; } - */ + buffer.resize(image_info.len); std::ofstream f("/tmp/screen.jpg",std::ios::out | std::ios::binary); diff --git a/src/security_headers_middleware_test.cpp b/src/security_headers_middleware_test.cpp index 2364ab5..fc183e9 100644 --- a/src/security_headers_middleware_test.cpp +++ b/src/security_headers_middleware_test.cpp @@ -40,13 +40,13 @@ TEST(SecurityHeaders, TestHeadersExist) { c.connect(asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"), 45451)); c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf)); + c.receive(asio::buffer(buf)); c.close(); auto return_code = std::string(&buf[9], &buf[12]); EXPECT_EQ("200", return_code); std::string response(std::begin(buf), std::end(buf)); - // This is a routine to split strings until a newline is hit + // This is a routine to split strings until a blank is hit // TODO(ed) this should really use the HTTP parser std::vector<std::string> headers; std::string::size_type pos = 0; diff --git a/src/token_authorization_middleware_test.cpp b/src/token_authorization_middleware_test.cpp index 68efe8f..00eed2f 100644 --- a/src/token_authorization_middleware_test.cpp +++ b/src/token_authorization_middleware_test.cpp @@ -24,7 +24,7 @@ TEST(TokenAuthentication, TestBasicReject) { c.connect(asio::ip::tcp::endpoint( asio::ip::address::from_string("127.0.0.1"), 45451)); c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf, 2048)); + c.receive(asio::buffer(buf, 2048)); c.close(); EXPECT_EQ("200", std::string(buf + 9, buf + 12)); } @@ -66,7 +66,7 @@ TEST(TokenAuthentication, TestRejectedResource) { } } c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf, 2048)); + c.receive(asio::buffer(buf, 2048)); c.close(); EXPECT_EQ("401", std::string(buf + 9, buf + 12)); @@ -95,7 +95,7 @@ TEST(TokenAuthentication, TestGetLoginUrl) { } } c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf, 2048)); + c.receive(asio::buffer(buf, 2048)); c.close(); EXPECT_EQ("401", std::string(buf + 9, buf + 12)); @@ -118,7 +118,7 @@ TEST(TokenAuthentication, TestPostBadLoginUrl) { c.connect(asio::ip::tcp::endpoint( asio::ip::address::from_string("127.0.0.1"), 45451)); c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf)); + c.receive(asio::buffer(buf)); c.close(); }; @@ -193,7 +193,7 @@ TEST(TokenAuthentication, TestSuccessfulLogin) { c.connect(asio::ip::tcp::endpoint( asio::ip::address::from_string("127.0.0.1"), 45451)); c.send(asio::buffer(sendmsg)); - auto received_count = c.receive(asio::buffer(buf)); + c.receive(asio::buffer(buf)); c.close(); }; diff --git a/src/udpclient.cpp b/src/udpclient.cpp index 772739b..cf9f3d1 100644 --- a/src/udpclient.cpp +++ b/src/udpclient.cpp @@ -85,7 +85,7 @@ int main(int argc, char* argv[]) { udp::endpoint sender_endpoint; size_t len = socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint); - + std::cout << len; for (auto character : recv_buf) { std::cout << std::hex << static_cast<unsigned>(character) << " "; } diff --git a/src/webassets_test.cpp b/src/webassets_test.cpp index 2157f03..8d0cfef 100644 --- a/src/webassets_test.cpp +++ b/src/webassets_test.cpp @@ -186,7 +186,6 @@ TEST(Webassets, EtagIsSane) { while ((pos = response.find("\r\n", prev)) != std::string::npos) { auto this_string = response.substr(prev, pos - prev); if (this_string == "") { - prev = pos + 2; break; } diff --git a/src/webserver_main.cpp b/src/webserver_main.cpp index cf8500f..949bdc1 100644 --- a/src/webserver_main.cpp +++ b/src/webserver_main.cpp @@ -1,9 +1,7 @@ -#include <webassets.hpp> #include <web_kvm.hpp> +#include <webassets.hpp> #include "ssl_key_handler.hpp" -#include <crow/bmc_app_type.hpp> - #include "crow/app.h" #include "crow/ci_map.h" #include "crow/common.h" @@ -26,15 +24,15 @@ #include "crow/utility.h" #include "crow/websocket.h" - #include "color_cout_g3_sink.hpp" #include "webassets.hpp" +#include "security_headers_middleware.hpp" +#include "token_authorization_middleware.hpp" #include <boost/asio.hpp> #include <boost/endian/arithmetic.hpp> - #include <iostream> #include <memory> #include <string> @@ -52,13 +50,13 @@ int main(int argc, char** argv) { std::string ssl_pem_file("server.pem"); ensuressl::ensure_openssl_key_present_and_valid(ssl_pem_file); - BmcAppType app; + crow::App<crow::TokenAuthorizationMiddleware, crow::SecurityHeadersMiddleware> + app; crow::webassets::request_routes(app); crow::kvm::request_routes(app); crow::logger::setLogLevel(crow::LogLevel::INFO); - app.debug_print(); CROW_ROUTE(app, "/systeminfo") ([]() { @@ -112,7 +110,7 @@ int main(int argc, char** argv) { size_t len = socket.receive_from(boost::asio::buffer(recv_buf), sender_endpoint); // TODO(ed) THis is ugly. Find a way to not make a copy (ie, use - // std::string::data() to + // std::string::data() to std::string str(std::begin(recv_buf), std::end(recv_buf)); LOG(DEBUG) << "Got " << str << "back \n"; conn.send_binary(str); |

