From: Krunal Chheda Date: Wed, 19 Nov 2025 16:30:18 +0000 (-0500) Subject: rgw/notification: add negative test case to test boost:parse:url. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d6c4f1df62c34c3914977d6988e823fe9164442;p=ceph.git rgw/notification: add negative test case to test boost:parse:url. Signed-off-by: kchheda3 --- 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)