summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNan Zhou <nanzhoumails@gmail.com>2022-06-14 20:18:06 +0300
committerEd Tanous <ed@tanous.net>2022-06-14 22:51:12 +0300
commit69d28257b0b8aef694e3239af893c0876c400e9a (patch)
treece8a6acbafb2c83431745376295e4e342a93f3f0
parentc7a6d66054deb891a224aac5c4ae0e66ddeb6769 (diff)
downloadbmcweb-69d28257b0b8aef694e3239af893c0876c400e9a.tar.xz
kvm_websocket_test: delete the test
This test is not enabled and referenced anywhere. Per Discord discussion, this test is obsolete and can be deleted now. https://discord.com/channels/775381525260664832/855566794994221117/985996960840429568 """ bmcweb used to have the full RFB (VNC) server in it, and access the linux device directly, that's what that unit test was checking, but that code is long gone in lieu of what we have now (unix socket to the rfbserver) which is better. """ Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: If42801c15009f8b33ea5d15749a067dccda935e9
-rw-r--r--src/kvm_websocket_test.cpp114
1 files changed, 0 insertions, 114 deletions
diff --git a/src/kvm_websocket_test.cpp b/src/kvm_websocket_test.cpp
deleted file mode 100644
index c01b7e5582..0000000000
--- a/src/kvm_websocket_test.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-#include "crow.h"
-
-#include "gzip_helper.hpp"
-#include "web_kvm.hpp"
-
-#include <iostream>
-#include <sstream>
-#include <vector>
-
-#include <gmock/gmock.h>
-#include <gtest/gtest.h>
-
-using namespace crow;
-using namespace testing;
-
-// Tests static files are loaded correctly
-TEST(Kvm, BasicRfb)
-{
- return; // TODO(ed) Make the code below work again
- SimpleApp app;
-
- crow::kvm::requestRoutes(app);
- app.bindaddr("127.0.0.1").port(45451);
- BMCWEB_ROUTE(app, "/")([]() { return boost::beast::http::status::ok; });
- auto _ = async(std::launch::async, [&] { app.run(); });
- auto routes = app.getRoutes();
- asio::io_context is;
-
- {
- // Retry a couple of times waiting for the server to come up
- // TODO(ed) This is really unfortunate, and should use some form of
- // mock
- asio::ip::tcp::socket c(is);
- for (int i = 0; i < 200; i++)
- {
- try
- {
- c.connect(asio::ip::tcp::endpoint(
- asio::ip::address::from_string("127.0.0.1"), 45451));
- c.close();
- break;
- }
- catch (const std::exception& e)
- {
- // do nothing. We expect this to fail while the server is
- // starting up
- }
- }
- }
-
- // Get the websocket
- std::string sendmsg = ("GET /kvmws HTTP/1.1\r\n"
- "Host: localhost:45451\r\n"
- "Connection: Upgrade\r\n"
- "Upgrade: websocket\r\n"
- "Sec-WebSocket-Version: 13\r\n"
- "Sec-WebSocket-Key: aLeGkmLPZmdv5tTyEpJ3jQ==\r\n"
- "Sec-WebSocket-Extensions: permessage-deflate; "
- "client_max_window_bits\r\n"
- "Sec-WebSocket-Protocol: binary\r\n"
- "\r\n");
-
- asio::ip::tcp::socket socket(is);
- socket.connect(asio::ip::tcp::endpoint(
- 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
- // 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.
- 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.
- boost::asio::read_until(socket, response, "\r\n\r\n");
-
- // Process the Response headers.
- std::string header;
- std::vector<std::string> headers;
- while (std::getline(response_stream, header) && header != "\r")
- {
- headers.push_back(header);
- }
-
- EXPECT_THAT(headers, Contains("Upgrade: websocket\r"));
- EXPECT_THAT(headers, Contains("Connection: Upgrade\r"));
- EXPECT_THAT(headers, Contains("Sec-WebSocket-Protocol: binary\r"));
- // TODO(ed) This is the result that it gives today. Need to check websocket
- // docs and make
- // sure that this calclution is actually being done to spec
- EXPECT_THAT(
- headers,
- Contains("Sec-WebSocket-Accept: /CnDM3l79rIxniLNyxMryXbtLEU=\r"));
- std::array<char, 13> rfb_open_string;
-
- //
- // socket.receive(rfb_open_string.data(), rfb_open_string.size());
- boost::asio::read(socket, boost::asio::buffer(rfb_open_string));
- auto open_string =
- std::string(std::begin(rfb_open_string), std::end(rfb_open_string));
- // Todo(ed) find out what the two characters at the end of the websocket
- // stream are
- open_string = open_string.substr(2);
- EXPECT_EQ(open_string, "RFB 003.008");
-
- app.stop();
-}