summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-12-14 06:20:27 +0300
committerEd Tanous <ed@tanous.net>2021-12-17 21:55:59 +0300
commitd7de0bd2548a12b39a799d0c6eae0f4d9be1075d (patch)
tree5cc7975c78b27b0a963e67385086a90ac518d9ed /src
parent1b7e696bb97d12125117f71c9d710cd482a54c85 (diff)
downloadbmcweb-d7de0bd2548a12b39a799d0c6eae0f4d9be1075d.tar.xz
Remove unused file
As much as I dislike removing tests, this one has been broken for a very... very long time, and as written can't really pass given that we no longer include the webui in the bmcweb repo. Tested: no-op. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: If486fc45547203339b3e39ffbb28c2926c1247a2
Diffstat (limited to 'src')
-rw-r--r--src/webassets_test.cpp145
1 files changed, 0 insertions, 145 deletions
diff --git a/src/webassets_test.cpp b/src/webassets_test.cpp
deleted file mode 100644
index b182f46bd4..0000000000
--- a/src/webassets_test.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <app.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/lexical_cast.hpp>
-#include <gzip_helper.hpp>
-#include <webassets.hpp>
-
-#include <sstream>
-
-#include "gtest/gtest.h"
-#include <gmock/gmock.h>
-
-using namespace crow;
-using namespace std;
-using namespace testing;
-
-// Tests static files are loaded correctly
-TEST(Webassets, StaticFilesFixedRoutes)
-{
- std::array<char, 2048> buf;
- SimpleApp app;
- webassets::requestRoutes(app);
- Server<SimpleApp> server(&app, "127.0.0.1", 45451);
- auto _ = async(launch::async, [&] { server.run(); });
-
- // get the homepage
- std::string sendmsg = "GET /\r\n\r\n";
-
- asio::io_context is;
-
- asio::ip::tcp::socket c(is);
- c.connect(asio::ip::tcp::endpoint(
- asio::ip::address::from_string("127.0.0.1"), 45451));
-
- c.send(asio::buffer(sendmsg));
-
- c.receive(asio::buffer(buf, 2048));
- c.close();
-
- std::string response(std::begin(buf), std::end(buf));
- // This is a routine to split strings until a newline is hit
- // TODO(ed) this should really use the HTTP parser
- std::vector<std::string> headers;
- std::string::size_type pos = 0;
- std::string::size_type prev = 0;
- int content_length = 0;
- std::string content_encoding("");
- 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;
- }
-
- if (boost::starts_with(this_string, "Content-Length: "))
- {
- content_length = boost::lexical_cast<int>(this_string.substr(16));
- // TODO(ed) This is an unfortunate test, but it's all we have at
- // this point Realistically, the index.html will be more than 500
- // bytes. This test will need to be improved at some point
- EXPECT_GT(content_length, 500);
- }
- if (boost::starts_with(this_string, "Content-Encoding: "))
- {
- content_encoding = this_string.substr(18);
- }
-
- headers.push_back(this_string);
- prev = pos + 2;
- }
-
- auto http_content = response.substr(prev);
- // TODO(ed) ideally the server should support non-compressed gzip assets.
- // Once this occurs, this line will be obsolete
- std::string ungziped_content = http_content;
- if (content_encoding == "gzip")
- {
- EXPECT_TRUE(gzipInflate(http_content, ungziped_content));
- }
-
- EXPECT_EQ(headers[0], "HTTP/1.1 200 OK");
- EXPECT_THAT(headers,
- ::testing::Contains("Content-Type: text/html;charset=UTF-8"));
-
- EXPECT_EQ(ungziped_content.substr(0, 21), "<!DOCTYPE html>\n<html");
-
- server.stop();
-}
-
-// Tests static files are loaded correctly
-TEST(Webassets, EtagIsSane)
-{
- std::array<char, 2048> buf;
- SimpleApp app;
- webassets::requestRoutes(app);
- Server<SimpleApp> server(&app, "127.0.0.1", 45451);
- auto _ = async(launch::async, [&] { server.run(); });
-
- // get the homepage
- std::string sendmsg = "GET /\r\n\r\n";
-
- asio::io_context is;
-
- asio::ip::tcp::socket c(is);
- c.connect(asio::ip::tcp::endpoint(
- asio::ip::address::from_string("127.0.0.1"), 45451));
-
- c.send(asio::buffer(sendmsg));
-
- c.receive(asio::buffer(buf, 2048));
- c.close();
-
- std::string response(std::begin(buf), std::end(buf));
- // This is a routine to split strings until a newline is hit
- // TODO(ed) this should really use the HTTP parser
- std::vector<std::string> headers;
- std::string::size_type pos = 0;
- std::string::size_type prev = 0;
- int content_length = 0;
- std::string content_encoding("");
- while ((pos = response.find("\r\n", prev)) != std::string::npos)
- {
- auto this_string = response.substr(prev, pos - prev);
- if (this_string == "")
- {
- break;
- }
-
- if (boost::starts_with(this_string, "ETag: "))
- {
- auto etag = this_string.substr(6);
- // ETAG should not be blank
- EXPECT_NE(etag, "");
- // SHa1 is 20 characters long
- EXPECT_EQ(etag.size(), 40);
- EXPECT_THAT(etag, MatchesRegex("^[a-f0-9]+$"));
- }
-
- headers.push_back(this_string);
- prev = pos + 2;
- }
-
- server.stop();
-}