Merge pull request #1475

81702b54 Fixes for google test < 1.8 (Lee Clagett)
This commit is contained in:
Riccardo Spagni 2016-12-20 17:48:25 +02:00
commit c7f9d0d971
No known key found for this signature in database
GPG key ID: 55432DF31CCD4FCD

View file

@ -219,21 +219,21 @@ TEST(HTTP_Auth, NotRequired)
TEST(HTTP_Auth, MissingAuth) TEST(HTTP_Auth, MissingAuth)
{ {
epee::net_utils::http::http_auth auth{{"foo", "bar"}}; epee::net_utils::http::http_auth auth{{"foo", "bar"}};
EXPECT_TRUE(auth.get_response(epee::net_utils::http::http_request_info{})); EXPECT_TRUE(bool(auth.get_response(epee::net_utils::http::http_request_info{})));
{ {
epee::net_utils::http::http_request_info request{}; epee::net_utils::http::http_request_info request{};
request.m_header_info.m_etc_fields.push_back({"\xFF", "\xFF"}); request.m_header_info.m_etc_fields.push_back({"\xFF", "\xFF"});
EXPECT_TRUE(auth.get_response(request)); EXPECT_TRUE(bool(auth.get_response(request)));
} }
} }
TEST(HTTP_Auth, BadSyntax) TEST(HTTP_Auth, BadSyntax)
{ {
epee::net_utils::http::http_auth auth{{"foo", "bar"}}; epee::net_utils::http::http_auth auth{{"foo", "bar"}};
EXPECT_TRUE(auth.get_response(make_request({{u8"algorithm", "fo\xFF"}}))); EXPECT_TRUE(bool(auth.get_response(make_request({{u8"algorithm", "fo\xFF"}}))));
EXPECT_TRUE(auth.get_response(make_request({{u8"cnonce", "\"000\xFF\""}}))); EXPECT_TRUE(bool(auth.get_response(make_request({{u8"cnonce", "\"000\xFF\""}}))));
EXPECT_TRUE(auth.get_response(make_request({{u8"cnonce \xFF =", "\"000\xFF\""}}))); EXPECT_TRUE(bool(auth.get_response(make_request({{u8"cnonce \xFF =", "\"000\xFF\""}}))));
EXPECT_TRUE(auth.get_response(make_request({{u8" \xFF cnonce", "\"000\xFF\""}}))); EXPECT_TRUE(bool(auth.get_response(make_request({{u8" \xFF cnonce", "\"000\xFF\""}}))));
} }
TEST(HTTP_Auth, MD5) TEST(HTTP_Auth, MD5)
@ -242,7 +242,7 @@ TEST(HTTP_Auth, MD5)
epee::net_utils::http::http_auth auth{user}; epee::net_utils::http::http_auth auth{user};
const auto response = auth.get_response(make_request({})); const auto response = auth.get_response(make_request({}));
ASSERT_TRUE(response); ASSERT_TRUE(bool(response));
EXPECT_TRUE(is_unauthorized(*response)); EXPECT_TRUE(is_unauthorized(*response));
const auto fields = parse_response(*response); const auto fields = parse_response(*response);
@ -269,10 +269,10 @@ TEST(HTTP_Auth, MD5)
{u8"username", quoted(user.username)} {u8"username", quoted(user.username)}
}); });
EXPECT_FALSE(auth.get_response(request)); EXPECT_FALSE(bool(auth.get_response(request)));
const auto response2 = auth.get_response(request); const auto response2 = auth.get_response(request);
ASSERT_TRUE(response2); ASSERT_TRUE(bool(response2));
EXPECT_TRUE(is_unauthorized(*response2)); EXPECT_TRUE(is_unauthorized(*response2));
const auto fields2 = parse_response(*response2); const auto fields2 = parse_response(*response2);
@ -291,7 +291,7 @@ TEST(HTTP_Auth, MD5_sess)
epee::net_utils::http::http_auth auth{user}; epee::net_utils::http::http_auth auth{user};
const auto response = auth.get_response(make_request({})); const auto response = auth.get_response(make_request({}));
ASSERT_TRUE(response); ASSERT_TRUE(bool(response));
EXPECT_TRUE(is_unauthorized(*response)); EXPECT_TRUE(is_unauthorized(*response));
const auto fields = parse_response(*response); const auto fields = parse_response(*response);
@ -320,10 +320,10 @@ TEST(HTTP_Auth, MD5_sess)
{u8"username", quoted(user.username)} {u8"username", quoted(user.username)}
}); });
EXPECT_FALSE(auth.get_response(request)); EXPECT_FALSE(bool(auth.get_response(request)));
const auto response2 = auth.get_response(request); const auto response2 = auth.get_response(request);
ASSERT_TRUE(response2); ASSERT_TRUE(bool(response2));
EXPECT_TRUE(is_unauthorized(*response2)); EXPECT_TRUE(is_unauthorized(*response2));
const auto fields2 = parse_response(*response2); const auto fields2 = parse_response(*response2);
@ -343,7 +343,7 @@ TEST(HTTP_Auth, MD5_auth)
epee::net_utils::http::http_auth auth{user}; epee::net_utils::http::http_auth auth{user};
const auto response = auth.get_response(make_request({})); const auto response = auth.get_response(make_request({}));
ASSERT_TRUE(response); ASSERT_TRUE(bool(response));
EXPECT_TRUE(is_unauthorized(*response)); EXPECT_TRUE(is_unauthorized(*response));
const auto parsed = parse_response(*response); const auto parsed = parse_response(*response);
@ -380,7 +380,7 @@ TEST(HTTP_Auth, MD5_auth)
}; };
const auto request = make_request(args); const auto request = make_request(args);
EXPECT_FALSE(auth.get_response(request)); EXPECT_FALSE(bool(auth.get_response(request)));
for (unsigned i = 2; i < 20; ++i) for (unsigned i = 2; i < 20; ++i)
{ {
@ -391,7 +391,7 @@ TEST(HTTP_Auth, MD5_auth)
} }
const auto replay = auth.get_response(request); const auto replay = auth.get_response(request);
ASSERT_TRUE(replay); ASSERT_TRUE(bool(replay));
EXPECT_TRUE(is_unauthorized(*replay)); EXPECT_TRUE(is_unauthorized(*replay));
const auto parsed_replay = parse_response(*replay); const auto parsed_replay = parse_response(*replay);
@ -411,7 +411,7 @@ TEST(HTTP_Auth, MD5_sess_auth)
epee::net_utils::http::http_auth auth{user}; epee::net_utils::http::http_auth auth{user};
const auto response = auth.get_response(make_request({})); const auto response = auth.get_response(make_request({}));
ASSERT_TRUE(response); ASSERT_TRUE(bool(response));
EXPECT_TRUE(is_unauthorized(*response)); EXPECT_TRUE(is_unauthorized(*response));
const auto parsed = parse_response(*response); const auto parsed = parse_response(*response);
@ -448,7 +448,7 @@ TEST(HTTP_Auth, MD5_sess_auth)
}; };
const auto request = make_request(args); const auto request = make_request(args);
EXPECT_FALSE(auth.get_response(request)); EXPECT_FALSE(bool(auth.get_response(request)));
for (unsigned i = 2; i < 20; ++i) for (unsigned i = 2; i < 20; ++i)
{ {
@ -459,7 +459,7 @@ TEST(HTTP_Auth, MD5_sess_auth)
} }
const auto replay = auth.get_response(request); const auto replay = auth.get_response(request);
ASSERT_TRUE(replay); ASSERT_TRUE(bool(replay));
EXPECT_TRUE(is_unauthorized(*replay)); EXPECT_TRUE(is_unauthorized(*replay));
const auto parsed_replay = parse_response(*replay); const auto parsed_replay = parse_response(*replay);