From 5d6c4f1df62c34c3914977d6988e823fe9164442 Mon Sep 17 00:00:00 2001 From: Krunal Chheda Date: Wed, 19 Nov 2025 11:30:18 -0500 Subject: [PATCH] rgw/notification: add negative test case to test boost:parse:url. Signed-off-by: kchheda3 --- src/test/rgw/test_rgw_url.cc | 43 +++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/src/test/rgw/test_rgw_url.cc b/src/test/rgw/test_rgw_url.cc index 2b036c3444e..32216d30693 100644 --- a/src/test/rgw/test_rgw_url.cc +++ b/src/test/rgw/test_rgw_url.cc @@ -91,13 +91,44 @@ TEST(TestURL, DifferentSchema) EXPECT_STREQ(host.c_str(), "example.com"); } -TEST(TestURL, InvalidHost) +TEST(TestURL, InvalidUrl) { - std::string host; - std::string user; - std::string password; - const std::string url = "http://exa_mple.com"; - ASSERT_FALSE(parse_url_authority(url, host, user, password)); + std::string host, user, password; + EXPECT_FALSE(parse_url_authority("not a valid url", host, user, password)); +} + +TEST(TestURL, EmptyString) +{ + std::string host, user, password; + EXPECT_FALSE(parse_url_authority("", host, user, password)); +} + +TEST(TestURL, MalformedScheme) +{ + std::string host, user, password; + EXPECT_FALSE( + parse_url_authority("ht!tp://example.com", host, user, password)); +} + +TEST(TestURL, InvalidCharactersInHost) +{ + std::string host, user, password; + EXPECT_FALSE( + parse_url_authority("http://exa mple.com", host, user, password)); +} + +TEST(TestURL, MissingScheme) +{ + std::string host, user, password; + EXPECT_FALSE(parse_url_authority("example.com", host, user, password)); +} + +TEST(TestURL, SpecialCharactersInUserinfo) +{ + std::string host, user, password; + EXPECT_FALSE( + parse_url_authority( + "http://us er:pass@example.com", host, user, password)); } TEST(TestURL, WithPath) -- 2.47.3