]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/rgw/test_rgw_url.cc
8422bca1b409c0862558dbaafe68fd86ee7f366b
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #include "rgw/rgw_url.h"
6 #include <gtest/gtest.h>
10 TEST(TestURL
, SimpleAuthority
)
15 const std::string url
= "http://example.com";
16 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
17 ASSERT_TRUE(user
.empty());
18 ASSERT_TRUE(password
.empty());
19 EXPECT_STREQ(host
.c_str(), "example.com");
22 TEST(TestURL
, IPAuthority
)
27 const std::string url
= "http://1.2.3.4";
28 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
29 ASSERT_TRUE(user
.empty());
30 ASSERT_TRUE(password
.empty());
31 EXPECT_STREQ(host
.c_str(), "1.2.3.4");
34 TEST(TestURL
, IPv6Authority
)
39 const std::string url
= "http://FE80:CD00:0000:0CDE:1257:0000:211E:729C";
40 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
41 ASSERT_TRUE(user
.empty());
42 ASSERT_TRUE(password
.empty());
43 EXPECT_STREQ(host
.c_str(), "FE80:CD00:0000:0CDE:1257:0000:211E:729C");
46 TEST(TestURL
, AuthorityWithUserinfo
)
51 const std::string url
= "http://user:password@example.com";
52 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
53 EXPECT_STREQ(host
.c_str(), "example.com");
54 EXPECT_STREQ(user
.c_str(), "user");
55 EXPECT_STREQ(password
.c_str(), "password");
58 TEST(TestURL
, AuthorityWithPort
)
63 const std::string url
= "http://user:password@example.com:1234";
64 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
65 EXPECT_STREQ(host
.c_str(), "example.com:1234");
66 EXPECT_STREQ(user
.c_str(), "user");
67 EXPECT_STREQ(password
.c_str(), "password");
70 TEST(TestURL
, DifferentSchema
)
75 const std::string url
= "kafka://example.com";
76 ASSERT_TRUE(parse_url_authority(url
, host
, user
, password
));
77 ASSERT_TRUE(user
.empty());
78 ASSERT_TRUE(password
.empty());
79 EXPECT_STREQ(host
.c_str(), "example.com");
82 TEST(TestURL
, InvalidHost
)
87 const std::string url
= "http://exa_mple.com";
88 ASSERT_FALSE(parse_url_authority(url
, host
, user
, password
));