Skip to content

Commit 507d29a

Browse files
committed
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.
1 parent 0908e48 commit 507d29a

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

src/create_test_request.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,10 @@ http_request create_test_request::build() {
4949
req.cache->querystring = std::move(_querystring);
5050
}
5151

52+
#ifdef HAVE_BAUTH
5253
req.cache->username = std::move(_user);
5354
req.cache->password = std::move(_pass);
55+
#endif // HAVE_BAUTH
5456

5557
#ifdef HAVE_DAUTH
5658
req.cache->digested_user = std::move(_digested_user);

src/httpserver/create_test_request.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class create_test_request {
8383
return *this;
8484
}
8585

86+
#ifdef HAVE_BAUTH
8687
create_test_request& user(const std::string& user) {
8788
_user = user;
8889
return *this;
@@ -92,6 +93,7 @@ class create_test_request {
9293
_pass = pass;
9394
return *this;
9495
}
96+
#endif // HAVE_BAUTH
9597

9698
#ifdef HAVE_DAUTH
9799
create_test_request& digested_user(const std::string& digested_user) {
@@ -129,8 +131,10 @@ class create_test_request {
129131
http::header_map _cookies;
130132
std::map<std::string, std::vector<std::string>, http::arg_comparator> _args;
131133
std::string _querystring;
134+
#ifdef HAVE_BAUTH
132135
std::string _user;
133136
std::string _pass;
137+
#endif // HAVE_BAUTH
134138
#ifdef HAVE_DAUTH
135139
std::string _digested_user;
136140
#endif // HAVE_DAUTH

test/integ/basic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,6 +2640,7 @@ class null_value_query_resource : public http_resource {
26402640
}
26412641
};
26422642

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

2660+
#ifdef HAVE_BAUTH
26582661
LT_BEGIN_AUTO_TEST(basic_suite, auth_caching)
26592662
auth_cache_resource resource;
26602663
LT_ASSERT_EQ(true, ws->register_resource("auth_cache", &resource));
@@ -2672,6 +2675,7 @@ LT_BEGIN_AUTO_TEST(basic_suite, auth_caching)
26722675
LT_CHECK_EQ(s, "NO_AUTH");
26732676
curl_easy_cleanup(curl);
26742677
LT_END_AUTO_TEST(auth_caching)
2678+
#endif // HAVE_BAUTH
26752679

26762680
// Test query parameters with null/empty values (e.g., ?keyonly&normal=value)
26772681
// This covers http_request.cpp lines 234 and 248 (arg_value == nullptr branches)

test/integ/ws_start_stop.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,9 @@ LT_BEGIN_AUTO_TEST(ws_start_stop_suite, disable_options)
279279
.no_ipv6()
280280
.no_debug()
281281
.no_pedantic()
282+
#ifdef HAVE_BAUTH
282283
.no_basic_auth()
284+
#endif // HAVE_BAUTH
283285
.no_digest_auth()
284286
.no_deferred()
285287
.no_regex_checking()

test/unit/create_test_request_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ LT_BEGIN_AUTO_TEST(create_test_request_suite, build_content)
126126
LT_CHECK_EQ(std::string(req.get_content()), std::string("{\"key\":\"value\"}"));
127127
LT_END_AUTO_TEST(build_content)
128128

129+
#ifdef HAVE_BAUTH
129130
// Test basic auth
130131
LT_BEGIN_AUTO_TEST(create_test_request_suite, build_basic_auth)
131132
auto req = create_test_request()
@@ -135,6 +136,7 @@ LT_BEGIN_AUTO_TEST(create_test_request_suite, build_basic_auth)
135136
LT_CHECK_EQ(std::string(req.get_user()), std::string("admin"));
136137
LT_CHECK_EQ(std::string(req.get_pass()), std::string("secret"));
137138
LT_END_AUTO_TEST(build_basic_auth)
139+
#endif // HAVE_BAUTH
138140

139141
// Test requestor
140142
LT_BEGIN_AUTO_TEST(create_test_request_suite, build_requestor)

0 commit comments

Comments
 (0)