]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/url: fix commensts from review #34717 35384/head
authorYuval Lifshitz <ylifshit@redhat.com>
Tue, 19 May 2020 13:29:46 +0000 (16:29 +0300)
committerNathan Cutler <ncutler@suse.com>
Thu, 4 Jun 2020 12:40:57 +0000 (14:40 +0200)
Signed-off-by: Yuval Lifshitz <ylifshit@redhat.com>
Fixes: https://tracker.ceph.com/issues/45269
(cherry picked from commit 32a93ecf50a236ea654448f761371e7cce89c262)

src/rgw/rgw_url.cc
src/test/rgw/rgw_multi/tests_ps.py
src/test/rgw/test_rgw_url.cc

index 62b003c49c2987c2ae9229304323f31779aadadc..58f7b5490538c36b26764047fdf606fe2a241c77 100644 (file)
@@ -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;
 
index 086f5d9f4abb24d29e3cb3a46439a34c8a295342..38e786d9b814be10d884ee5d2d249d3be45cad9f 100644 (file)
@@ -845,7 +845,7 @@ def test_ps_s3_topic_on_master():
     delete_all_s3_topics(zones[0], 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(zones[0].conn, topic_name+'_1', zonegroup.name, endpoint_args=endpoint_args)
     topic_arn = topic_conf1.set_config()
index 8422bca1b409c0862558dbaafe68fd86ee7f366b..d38457b815d2ea24ce7676d4e94dbf77389ad281 100644 (file)
@@ -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));
+}
+