Merge pull request #11165 from ClickHouse/fix-test-s3

Merging #11036
This commit is contained in:
alexey-milovidov 2020-05-24 22:18:35 +03:00 committed by GitHub
commit 9b09cfc611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -111,7 +111,7 @@ namespace S3
if (!client_configuration.endpointOverride.empty())
{
static const RE2 region_pattern(R"(s3[.\-]([a-z0-9\-]+)\.amazonaws\.)");
static const RE2 region_pattern(R"(^s3[.\-]([a-z0-9\-]+)\.amazonaws\.)");
Poco::URI uri(client_configuration.endpointOverride);
if (uri.getScheme() == "http")
client_configuration.scheme = Aws::Http::Scheme::HTTP;
@ -138,6 +138,7 @@ namespace S3
/// E.g. (https://bucket-name.s3.Region.amazonaws.com/key)
/// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#virtual-hosted-style-access
static const RE2 virtual_hosted_style_pattern(R"((.+)\.(s3[.\-][a-z0-9\-.:]+))");
/// Case when bucket name and key represented in path of S3 URL.
/// E.g. (https://s3.Region.amazonaws.com/bucket-name/key)
/// https://docs.aws.amazon.com/AmazonS3/latest/dev/VirtualHosting.html#path-style-access

View File

@ -17,7 +17,7 @@ TEST(S3UriTest, validPatterns)
{
{
S3::URI uri(Poco::URI("https://jokserfn.s3.yandexcloud.net/data"));
ASSERT_EQ("https://jokserfn.s3.yandexcloud.net", uri.endpoint);
ASSERT_EQ("https://s3.yandexcloud.net", uri.endpoint);
ASSERT_EQ("jokserfn", uri.bucket);
ASSERT_EQ("data", uri.key);
}
@ -27,6 +27,12 @@ TEST(S3UriTest, validPatterns)
ASSERT_EQ("jokserfn", uri.bucket);
ASSERT_EQ("data", uri.key);
}
{
S3::URI uri(Poco::URI("https://s3.us-east-2.amazonaws.com/bucketname/data"));
ASSERT_EQ("https://s3.us-east-2.amazonaws.com", uri.endpoint);
ASSERT_EQ("bucketname", uri.bucket);
ASSERT_EQ("data", uri.key);
}
}
TEST_P(S3UriTest, invalidPatterns)