Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions test/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1361,6 +1361,14 @@ TEST(CancelTest, WithCancelLargePayloadDelete) {
EXPECT_EQ(Error::Canceled, res.error());
}

static std::string remove_whitespace(const std::string &input) {
std::string output;
output.reserve(input.size());
std::copy_if(input.begin(), input.end(), std::back_inserter(output),
[](unsigned char c) { return !std::isspace(c); });
return output;
}

TEST(BaseAuthTest, FromHTTPWatch_Online) {
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
auto host = "httpbin.org";
Expand Down Expand Up @@ -1388,17 +1396,17 @@ TEST(BaseAuthTest, FromHTTPWatch_Online) {
auto res =
cli.Get(path, {make_basic_authentication_header("hello", "world")});
ASSERT_TRUE(res);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
remove_whitespace(res->body));
EXPECT_EQ(StatusCode::OK_200, res->status);
}

{
cli.set_basic_auth("hello", "world");
auto res = cli.Get(path);
ASSERT_TRUE(res);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
remove_whitespace(res->body));
EXPECT_EQ(StatusCode::OK_200, res->status);
}

Expand Down Expand Up @@ -1454,8 +1462,8 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
for (const auto &path : paths) {
auto res = cli.Get(path.c_str());
ASSERT_TRUE(res);
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n",
res->body);
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
remove_whitespace(res->body));
EXPECT_EQ(StatusCode::OK_200, res->status);
}

Expand Down
Loading