Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add HAVE_BAUTH guards to remaining files missed in initial commit
Guard basic auth references in ws_start_stop.cpp, basic.cpp,
create_test_request_test.cpp, create_test_request.hpp, and
create_test_request.cpp that would fail to compile when
libmicrohttpd lacks basic auth support.
  • Loading branch information
etr committed Feb 19, 2026
commit 507d29a92171666e8f372d7e94adfd84598a30f1
2 changes: 2 additions & 0 deletions src/create_test_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ http_request create_test_request::build() {
req.cache->querystring = std::move(_querystring);
}

#ifdef HAVE_BAUTH
req.cache->username = std::move(_user);
req.cache->password = std::move(_pass);
#endif // HAVE_BAUTH

#ifdef HAVE_DAUTH
req.cache->digested_user = std::move(_digested_user);
Expand Down
4 changes: 4 additions & 0 deletions src/httpserver/create_test_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class create_test_request {
return *this;
}

#ifdef HAVE_BAUTH
create_test_request& user(const std::string& user) {
_user = user;
return *this;
Expand All @@ -92,6 +93,7 @@ class create_test_request {
_pass = pass;
return *this;
}
#endif // HAVE_BAUTH

#ifdef HAVE_DAUTH
create_test_request& digested_user(const std::string& digested_user) {
Expand Down Expand Up @@ -129,8 +131,10 @@ class create_test_request {
http::header_map _cookies;
std::map<std::string, std::vector<std::string>, http::arg_comparator> _args;
std::string _querystring;
#ifdef HAVE_BAUTH
std::string _user;
std::string _pass;
#endif // HAVE_BAUTH
#ifdef HAVE_DAUTH
std::string _digested_user;
#endif // HAVE_DAUTH
Expand Down
4 changes: 4 additions & 0 deletions test/integ/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,7 @@ class null_value_query_resource : public http_resource {
}
};

#ifdef HAVE_BAUTH
// Resource that tests auth caching (get_user/get_pass called multiple times)
class auth_cache_resource : public http_resource {
public:
Expand All @@ -2654,7 +2655,9 @@ class auth_cache_resource : public http_resource {
return std::make_shared<string_response>(result, 200, "text/plain");
}
};
#endif // HAVE_BAUTH

#ifdef HAVE_BAUTH
LT_BEGIN_AUTO_TEST(basic_suite, auth_caching)
auth_cache_resource resource;
LT_ASSERT_EQ(true, ws->register_resource("auth_cache", &resource));
Expand All @@ -2672,6 +2675,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, auth_caching)
LT_CHECK_EQ(s, "NO_AUTH");
curl_easy_cleanup(curl);
LT_END_AUTO_TEST(auth_caching)
#endif // HAVE_BAUTH

// Test query parameters with null/empty values (e.g., ?keyonly&normal=value)
// This covers http_request.cpp lines 234 and 248 (arg_value == nullptr branches)
Expand Down
2 changes: 2 additions & 0 deletions test/integ/ws_start_stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, disable_options)
.no_ipv6()
.no_debug()
.no_pedantic()
#ifdef HAVE_BAUTH
.no_basic_auth()
#endif // HAVE_BAUTH
.no_digest_auth()
.no_deferred()
.no_regex_checking()
Expand Down
2 changes: 2 additions & 0 deletions test/unit/create_test_request_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ LT_BEGIN_AUTO_TEST(create_test_request_suite, build_content)
LT_CHECK_EQ(std::string(req.get_content()), std::string("{\"key\":\"value\"}"));
LT_END_AUTO_TEST(build_content)

#ifdef HAVE_BAUTH
// Test basic auth
LT_BEGIN_AUTO_TEST(create_test_request_suite, build_basic_auth)
auto req = create_test_request()
Expand All @@ -135,6 +136,7 @@ LT_BEGIN_AUTO_TEST(create_test_request_suite, build_basic_auth)
LT_CHECK_EQ(std::string(req.get_user()), std::string("admin"));
LT_CHECK_EQ(std::string(req.get_pass()), std::string("secret"));
LT_END_AUTO_TEST(build_basic_auth)
#endif // HAVE_BAUTH

// Test requestor
LT_BEGIN_AUTO_TEST(create_test_request_suite, build_requestor)
Expand Down
Loading