|
@@ -2055,56 +2055,6 @@ TEST(DigestAuthTest, FromHTTPWatch_Online) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#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);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- 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
|
|
#endif
|
|
|
|
|
|
|
|
TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) {
|
|
TEST(SpecifyServerIPAddressTest, AnotherHostname_Online) {
|