From 32a93ecf50a236ea654448f761371e7cce89c262 Mon Sep 17 00:00:00 2001 From: Yuval Lifshitz Date: Tue, 19 May 2020 16:29:46 +0300 Subject: [PATCH] rgw/url: fix commensts from review #34717 Signed-off-by: Yuval Lifshitz Fixes: https://tracker.ceph.com/issues/45269 --- src/rgw/rgw_url.cc | 6 +++--- src/test/rgw/rgw_multi/tests_ps.py | 2 +- src/test/rgw/test_rgw_url.cc | 11 ++++++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_url.cc b/src/rgw/rgw_url.cc index 62b003c49c298..58f7b5490538c 100644 --- a/src/rgw/rgw_url.cc +++ b/src/rgw/rgw_url.cc @@ -14,11 +14,11 @@ namespace { const std::string schema_re = "([[:alpha:]]+:\\/\\/)"; const std::string user_pass_re = "(([^:\\s]+):([^@\\s]+)@)?"; const std::string host_port_re = "([[:alnum:].:-]+)"; - const std::string vhost_re = "(/[[:print:]]+)?"; + const std::string path_re = "(/[[:print:]]+)?"; } bool parse_url_authority(const std::string& url, std::string& host, std::string& user, std::string& password) { - const std::string re = schema_re + user_pass_re + host_port_re + vhost_re; + const std::string re = schema_re + user_pass_re + host_port_re + path_re; const std::regex url_regex(re, std::regex::icase); std::smatch url_match_result; @@ -33,7 +33,7 @@ bool parse_url_authority(const std::string& url, std::string& host, std::string& } bool parse_url_userinfo(const std::string& url, std::string& user, std::string& password) { - const std::string re = schema_re + user_pass_re + host_port_re + vhost_re; + const std::string re = schema_re + user_pass_re + host_port_re + path_re; const std::regex url_regex(re); std::smatch url_match_result; diff --git a/src/test/rgw/rgw_multi/tests_ps.py b/src/test/rgw/rgw_multi/tests_ps.py index ac106cd4dc651..9f2dc27ce1e4d 100644 --- a/src/test/rgw/rgw_multi/tests_ps.py +++ b/src/test/rgw/rgw_multi/tests_ps.py @@ -839,7 +839,7 @@ def test_ps_s3_topic_on_master(): delete_all_s3_topics(master_zone, zonegroup.name) # create s3 topics - endpoint_address = 'amqp://127.0.0.1:7001' + endpoint_address = 'amqp://127.0.0.1:7001/vhost_1' endpoint_args = 'push-endpoint='+endpoint_address+'&amqp-exchange=amqp.direct&amqp-ack-level=none' topic_conf1 = PSTopicS3(master_zone.conn, topic_name+'_1', zonegroup.name, endpoint_args=endpoint_args) topic_arn = topic_conf1.set_config() diff --git a/src/test/rgw/test_rgw_url.cc b/src/test/rgw/test_rgw_url.cc index 8422bca1b409c..d38457b815d2e 100644 --- a/src/test/rgw/test_rgw_url.cc +++ b/src/test/rgw/test_rgw_url.cc @@ -48,7 +48,7 @@ TEST(TestURL, AuthorityWithUserinfo) std::string host; std::string user; std::string password; - const std::string url = "http://user:password@example.com"; + const std::string url = "https://user:password@example.com"; ASSERT_TRUE(parse_url_authority(url, host, user, password)); EXPECT_STREQ(host.c_str(), "example.com"); EXPECT_STREQ(user.c_str(), "user"); @@ -88,3 +88,12 @@ TEST(TestURL, InvalidHost) ASSERT_FALSE(parse_url_authority(url, host, user, password)); } +TEST(TestURL, WithPath) +{ + std::string host; + std::string user; + std::string password; + const std::string url = "amqps://www.example.com:1234/vhost_name"; + ASSERT_TRUE(parse_url_authority(url, host, user, password)); +} + -- 2.39.5