Skip to content

Commit 8aedbf4

Browse files
committed
Add a unit test
1 parent cde2936 commit 8aedbf4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8366,6 +8366,19 @@ TEST(SSLClientTest, Issue2004_Online) {
83668366
EXPECT_EQ(body.substr(0, 15), "<!doctype html>");
83678367
}
83688368

8369+
TEST(SSLClientTest, ErrorReportingWhenInvalid) {
8370+
// Create SSLClient with invalid cert/key to make is_valid() return false
8371+
SSLClient cli("localhost", 8080, "nonexistent_cert.pem",
8372+
"nonexistent_key.pem");
8373+
8374+
// is_valid() should be false due to cert loading failure
8375+
ASSERT_FALSE(cli.is_valid());
8376+
8377+
auto res = cli.Get("/");
8378+
ASSERT_FALSE(res);
8379+
EXPECT_EQ(Error::SSLConnection, res.error());
8380+
}
8381+
83698382
#if 0
83708383
TEST(SSLClientTest, SetInterfaceWithINET6) {
83718384
auto cli = std::make_shared<httplib::Client>("https://httpbin.org");

0 commit comments

Comments
 (0)