Skip to content

Commit 526e997

Browse files
committed
asio basic auth support: test case
1 parent a3b7165 commit 526e997

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Release/tests/functional/http/client/authentication_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,37 @@ TEST_FIXTURE(uri_address, failed_authentication_attempt, "Ignore:Linux", "89", "
620620

621621
#if !defined(_WIN32)
622622

623+
// http_server does not support auth
624+
void auth_test_impl(bool fail)
625+
{
626+
std::string user("user1"), password("user1");
627+
auto return_code = status_codes::NotFound; // return 404 if successful auth
628+
629+
if (fail)
630+
{
631+
password = "invalid";
632+
return_code = status_codes::Unauthorized;
633+
}
634+
635+
http_client_config client_config;
636+
web::credentials cred(U(user), U(password));
637+
client_config.set_credentials(cred);
638+
http_client client(U("http://test.webdav.org/auth-basic/"), client_config);
639+
640+
http_response response = client.request(methods::GET).get();
641+
VERIFY_ARE_EQUAL(return_code, response.status_code());
642+
}
643+
644+
TEST(auth_no_data)
645+
{
646+
auth_test_impl(false);
647+
}
648+
649+
TEST(unsuccessful_auth_with_basic_cred)
650+
{
651+
auth_test_impl(true);
652+
}
653+
623654
TEST_FIXTURE(uri_address, set_user_options_asio_http)
624655
{
625656
test_http_server::scoped_server scoped(m_uri);

0 commit comments

Comments
 (0)