You've already forked cpp-httplib
Replace httpbin.org with httpcan.org (#2300)
* Replace httpbin.org with httpcan.org * Fix DigestAuthTest.FromHTTPWatch_Online test
This commit is contained in:
committed by
GitHub
parent
681d388247
commit
b7097f1386
91
test/test.cc
91
test/test.cc
@@ -1371,7 +1371,7 @@ TEST_F(ChunkedEncodingTest, WithResponseHandlerAndContentReceiver) {
|
||||
|
||||
TEST(RangeTest, FromHTTPBin_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/range/32"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -1473,7 +1473,7 @@ TEST(ConnectionErrorTest, InvalidHost) {
|
||||
}
|
||||
|
||||
TEST(ConnectionErrorTest, InvalidHost2) {
|
||||
auto host = "httpbin.org/";
|
||||
auto host = "httpcan.org/";
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
SSLClient cli(host);
|
||||
@@ -1488,7 +1488,7 @@ TEST(ConnectionErrorTest, InvalidHost2) {
|
||||
}
|
||||
|
||||
TEST(ConnectionErrorTest, InvalidHostCheckResultErrorToString) {
|
||||
auto host = "httpbin.org/";
|
||||
auto host = "httpcan.org/";
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
SSLClient cli(host);
|
||||
@@ -1545,7 +1545,7 @@ TEST(ConnectionErrorTest, Timeout_Online) {
|
||||
|
||||
TEST(CancelTest, NoCancel_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/range/32"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -1569,7 +1569,7 @@ TEST(CancelTest, NoCancel_Online) {
|
||||
|
||||
TEST(CancelTest, WithCancelSmallPayload_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/range/32"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -1592,7 +1592,7 @@ TEST(CancelTest, WithCancelSmallPayload_Online) {
|
||||
|
||||
TEST(CancelTest, WithCancelLargePayload_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/range/65536"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -1941,7 +1941,7 @@ static std::string remove_whitespace(const std::string &input) {
|
||||
|
||||
TEST(BaseAuthTest, FromHTTPWatch_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/basic-auth/hello/world"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -1998,13 +1998,12 @@ TEST(BaseAuthTest, FromHTTPWatch_Online) {
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto unauth_path = std::string{"/digest-auth/auth/hello/world"};
|
||||
auto paths = std::vector<std::string>{
|
||||
"/digest-auth/auth/hello/world/MD5",
|
||||
"/digest-auth/auth/hello/world/SHA-256",
|
||||
"/digest-auth/auth/hello/world/SHA-512",
|
||||
"/digest-auth/auth-int/hello/world/MD5",
|
||||
};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -2032,8 +2031,60 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
||||
for (const auto &path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
std::string algo(path.substr(path.rfind('/') + 1));
|
||||
EXPECT_EQ(
|
||||
remove_whitespace("{\"algorithm\":\"" + algo +
|
||||
"\",\"authenticated\":true,\"user\":\"hello\"}\n"),
|
||||
remove_whitespace(res->body));
|
||||
#else
|
||||
EXPECT_EQ("{\"authenticated\":true,\"user\":\"hello\"}",
|
||||
remove_whitespace(res->body));
|
||||
#endif
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
cli.set_digest_auth("hello", "bad");
|
||||
for (const auto &path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
TEST(DigestAuthTest, FromHTTPWatch_Online_HTTPCan) {
|
||||
auto host = "httpcan.org";
|
||||
auto unauth_path = std::string{"/digest-auth/auth/hello/world"};
|
||||
auto paths = std::vector<std::string>{
|
||||
"/digest-auth/auth/hello/world/MD5",
|
||||
"/digest-auth/auth/hello/world/SHA-256",
|
||||
"/digest-auth/auth/hello/world/SHA-512",
|
||||
};
|
||||
|
||||
auto port = 443;
|
||||
SSLClient cli(host, port);
|
||||
|
||||
{
|
||||
auto res = cli.Get(unauth_path);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
cli.set_digest_auth("hello", "world");
|
||||
for (const auto &path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
std::string algo(path.substr(path.rfind('/') + 1));
|
||||
EXPECT_EQ(
|
||||
remove_whitespace("{\"algorithm\":\"" + algo +
|
||||
"\",\"authenticated\":true,\"user\":\"hello\"}\n"),
|
||||
remove_whitespace(res->body));
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
@@ -2044,18 +2095,18 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
|
||||
// NOTE: Until httpbin.org fixes issue #46, the following test is commented
|
||||
// out. Please see https://httpbin.org/digest-auth/auth/hello/world
|
||||
// cli.set_digest_auth("bad", "world");
|
||||
// for (const auto& path : paths) {
|
||||
// auto res = cli.Get(path.c_str());
|
||||
// ASSERT_TRUE(res);
|
||||
// EXPECT_EQ(StatusCode::BadRequest_400, res->status);
|
||||
// }
|
||||
cli.set_digest_auth("bad", "world");
|
||||
for (const auto &path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) {
|
||||
auto host = "google.com";
|
||||
auto another_host = "example.com";
|
||||
@@ -7924,7 +7975,7 @@ TEST(GetWithParametersTest, GetWithParameters2) {
|
||||
|
||||
TEST(ClientDefaultHeadersTest, DefaultHeaders_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/range/32"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -8440,7 +8491,7 @@ TEST(SSLClientTest, UpdateCAStore) {
|
||||
|
||||
TEST(SSLClientTest, ServerNameIndication_Online) {
|
||||
#ifdef CPPHTTPLIB_DEFAULT_HTTPBIN
|
||||
auto host = "httpbin.org";
|
||||
auto host = "httpcan.org";
|
||||
auto path = std::string{"/get"};
|
||||
#else
|
||||
auto host = "nghttp2.org";
|
||||
@@ -8684,7 +8735,7 @@ TEST(SSLClientTest, Issue2251_ClientCertFileNotMatchingKey) {
|
||||
|
||||
#if 0
|
||||
TEST(SSLClientTest, SetInterfaceWithINET6) {
|
||||
auto cli = std::make_shared<httplib::Client>("https://httpbin.org");
|
||||
auto cli = std::make_shared<httplib::Client>("https://httpcan.org");
|
||||
ASSERT_TRUE(cli != nullptr);
|
||||
|
||||
cli->set_address_family(AF_INET6);
|
||||
|
||||
@@ -153,13 +153,13 @@ template <typename T> void BaseAuthTestFromHTTPWatch(T &cli) {
|
||||
}
|
||||
|
||||
TEST(BaseAuthTest, NoSSL) {
|
||||
Client cli("httpbin.org");
|
||||
Client cli("httpcan.org");
|
||||
BaseAuthTestFromHTTPWatch(cli);
|
||||
}
|
||||
|
||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||
TEST(BaseAuthTest, SSL) {
|
||||
SSLClient cli("httpbin.org");
|
||||
SSLClient cli("httpcan.org");
|
||||
BaseAuthTestFromHTTPWatch(cli);
|
||||
}
|
||||
#endif
|
||||
@@ -182,15 +182,17 @@ template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
|
||||
"/digest-auth/auth/hello/world/MD5",
|
||||
"/digest-auth/auth/hello/world/SHA-256",
|
||||
"/digest-auth/auth/hello/world/SHA-512",
|
||||
"/digest-auth/auth-int/hello/world/MD5",
|
||||
};
|
||||
|
||||
cli.set_digest_auth("hello", "world");
|
||||
for (auto path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(normalizeJson("{\"authenticated\":true,\"user\":\"hello\"}\n"),
|
||||
normalizeJson(res->body));
|
||||
std::string algo(path.substr(path.rfind('/') + 1));
|
||||
EXPECT_EQ(
|
||||
normalizeJson("{\"algorithm\":\"" + algo +
|
||||
"\",\"authenticated\":true,\"user\":\"hello\"}\n"),
|
||||
normalizeJson(res->body));
|
||||
EXPECT_EQ(StatusCode::OK_200, res->status);
|
||||
}
|
||||
|
||||
@@ -201,24 +203,22 @@ template <typename T> void DigestAuthTestFromHTTPWatch(T &cli) {
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
|
||||
// NOTE: Until httpbin.org fixes issue #46, the following test is commented
|
||||
// out. Please see https://httpbin.org/digest-auth/auth/hello/world
|
||||
// cli.set_digest_auth("bad", "world");
|
||||
// for (auto path : paths) {
|
||||
// auto res = cli.Get(path.c_str());
|
||||
// ASSERT_TRUE(res != nullptr);
|
||||
// EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
// }
|
||||
cli.set_digest_auth("bad", "world");
|
||||
for (auto path : paths) {
|
||||
auto res = cli.Get(path.c_str());
|
||||
ASSERT_TRUE(res != nullptr);
|
||||
EXPECT_EQ(StatusCode::Unauthorized_401, res->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DigestAuthTest, SSL) {
|
||||
SSLClient cli("httpbin.org");
|
||||
SSLClient cli("httpcan.org");
|
||||
DigestAuthTestFromHTTPWatch(cli);
|
||||
}
|
||||
|
||||
TEST(DigestAuthTest, NoSSL) {
|
||||
Client cli("httpbin.org");
|
||||
Client cli("httpcan.org");
|
||||
DigestAuthTestFromHTTPWatch(cli);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user