0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00
openvpn3/test/unittests/test_headredact.cpp
David Sommerseth dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00

60 lines
2.7 KiB
C++

#include "test_common.h"
// #define OPENVPN_HTTP_HEADERS_NO_REDACT
#include <openvpn/http/headredact.hpp>
using namespace openvpn;
static const std::string in1 = "HEADERS: POST /pg HTTP/1.1\r\n"
" Host: 3.91.106.178\r\n"
" User-Agent: japicli\r\n"
" Authorization: Basic cGc6cHJqN1hKQUpuRkRsZ2V5MXZLaVlVcGhL\r\n"
" Content-Type: application/json\r\n"
" Content-Length: 49\r\n"
" Accept-Encoding: lz4\r\n"
" Accept: */*\r\n"
" \r\n";
static const std::string out1 = "HEADERS: POST /pg HTTP/1.1\r\n"
" Host: 3.91.106.178\r\n"
" User-Agent: japicli\r\n"
" Authorization: Basic [REDACTED]\r\n"
" Content-Type: application/json\r\n"
" Content-Length: 49\r\n"
" Accept-Encoding: lz4\r\n"
" Accept: */*\r\n"
" \r\n";
static const std::string in2 = "HEADERS: POST /pg HTTP/1.1\r\n"
" Host: 3.91.106.178\r\n"
" User-Agent: japicli\r\n"
" authorization=basic cGc6cHJqN1hKQUpuRkRsZ2V5MXZLaVlVcGhL\r\n"
" Content-Type: application/json\r\n"
" Content-Length: 49\r\n"
" Accept-Encoding: lz4\r\n"
" Accept: */*\r\n"
" \r\n";
static const std::string out2 = "HEADERS: POST /pg HTTP/1.1\r\n"
" Host: 3.91.106.178\r\n"
" User-Agent: japicli\r\n"
" authorization=basic [REDACTED]\r\n"
" Content-Type: application/json\r\n"
" Content-Length: 49\r\n"
" Accept-Encoding: lz4\r\n"
" Accept: */*\r\n"
" \r\n";
TEST(http, headredact1)
{
const std::string out = HTTP::headers_redact(in1);
ASSERT_EQ(out, out1);
}
TEST(http, headredact2)
{
const std::string out = HTTP::headers_redact(in2);
ASSERT_EQ(out, out2);
}