Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show headers and query parameters in storage CI pipeline #4379

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ namespace Azure { namespace Storage { namespace Test {
auto blobClient = GetAppendBlobClientForTest(RandomString());

auto blobClientWithoutAuth = Azure::Storage::Blobs::AppendBlobClient(
blobClient.GetUrl(), InitClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
blobClient.GetUrl(), InitStorageClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
EXPECT_THROW(blobClientWithoutAuth.CreateIfNotExists(), StorageException);
{
auto response = blobClient.CreateIfNotExists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace Azure { namespace Storage { namespace Test {
auto serviceClient = *m_blobServiceClient;
GetBlobContainerClientForTest(containerName).CreateIfNotExists();
Blobs::BlobClientOptions clientOptions;
InitClientOptions(clientOptions);
InitStorageClientOptions(clientOptions);
auto containerClient = Blobs::BlobContainerClient(
serviceClient.GetBlobContainerClient(containerName).GetUrl() + containerSasToken,
clientOptions);
Expand Down Expand Up @@ -135,7 +135,7 @@ namespace Azure { namespace Storage { namespace Test {
= std::make_shared<Azure::Identity::ClientSecretCredential>(
AadTenantId(), AadClientId(), AadClientSecret());
Blobs::BlobClientOptions clientOptions;
InitClientOptions(clientOptions);
InitStorageClientOptions(clientOptions);

auto serviceClient
= Blobs::BlobServiceClient(m_blobServiceClient->GetUrl(), credential, clientOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Test {
const std::string& containerName,
Blobs::BlobClientOptions clientOptions)
{
InitClientOptions(clientOptions);
InitStorageClientOptions(clientOptions);
auto blobContainerClient = Blobs::BlobContainerClient::CreateFromConnectionString(
StandardStorageConnectionString(), containerName, clientOptions);
m_resourceCleanupFunctions.push_back(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ namespace Azure { namespace Storage { namespace Test {
auto secondaryServiceClient = Blobs::BlobServiceClient(
InferSecondaryUrl(serviceClient.GetUrl()),
keyCredential,
InitClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
InitStorageClientOptions<Azure::Storage::Blobs::BlobClientOptions>());

auto serviceStatistics = secondaryServiceClient.GetStatistics().Value;
EXPECT_FALSE(serviceStatistics.GeoReplication.Status.ToString().empty());
Expand Down Expand Up @@ -448,7 +448,7 @@ namespace Azure { namespace Storage { namespace Test {
= std::make_shared<Azure::Identity::ClientSecretCredential>(
AadTenantId(), AadClientId(), AadClientSecret());
Blobs::BlobClientOptions options;
InitClientOptions(options);
InitStorageClientOptions(options);

auto blobServiceClient1 = Blobs::BlobServiceClient(serviceClient.GetUrl(), credential, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Azure { namespace Storage { namespace Test {
{
StorageTest::SetUp();

auto options = InitClientOptions<Blobs::BlobClientOptions>();
auto options = InitStorageClientOptions<Blobs::BlobClientOptions>();
m_blobServiceClient = std::make_shared<Blobs::BlobServiceClient>(
Blobs::BlobServiceClient::CreateFromConnectionString(
StandardStorageConnectionString(), options));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ namespace Azure { namespace Storage { namespace Test {
auto blobClient = GetBlockBlobClientForTest(RandomString());

auto blobClientWithoutAuth = Azure::Storage::Blobs::BlockBlobClient(
blobClient.GetUrl(), InitClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
blobClient.GetUrl(), InitStorageClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
{
auto response = blobClient.DeleteIfExists();
EXPECT_FALSE(response.Value.Deleted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ namespace Azure { namespace Storage { namespace Test {
auto pageBlobClient = GetPageBlobClientTestForTest(RandomString());

auto blobClientWithoutAuth = Azure::Storage::Blobs::PageBlobClient(
pageBlobClient.GetUrl(), InitClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
pageBlobClient.GetUrl(),
InitStorageClientOptions<Azure::Storage::Blobs::BlobClientOptions>());
EXPECT_THROW(blobClientWithoutAuth.CreateIfNotExists(m_blobContent.size()), StorageException);
{
auto response = pageBlobClient.CreateIfNotExists(m_blobContent.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Azure { namespace Storage { namespace Test {
m_testContext.RenameTest(GetTestName());

auto peekPolicyPtr = std::make_unique<PeekHttpRequestPolicy>(callback);
Blobs::BlobClientOptions clientOptions = InitClientOptions<Blobs::BlobClientOptions>();
Blobs::BlobClientOptions clientOptions = InitStorageClientOptions<Blobs::BlobClientOptions>();
clientOptions.PerRetryPolicies.emplace_back(std::move(peekPolicyPtr));
auto containerClient = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString(
StandardStorageConnectionString(), GetTestNameLowerCase(), clientOptions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace Azure { namespace Storage { namespace Test {
AadTenantId(),
AadClientId(),
AadClientSecret(),
InitClientOptions<Core::Credentials::TokenCredentialOptions>());
InitStorageClientOptions<Core::Credentials::TokenCredentialOptions>());
containerClient = Blobs::BlobContainerClient(
containerClient.GetUrl(), credential, InitClientOptions<Blobs::BlobClientOptions>());
containerClient.GetUrl(), credential, InitStorageClientOptions<Blobs::BlobClientOptions>());

EXPECT_NO_THROW(containerClient.Create());
EXPECT_NO_THROW(containerClient.Delete());
Expand Down
183 changes: 183 additions & 0 deletions sdk/storage/azure-storage-common/test/ut/test_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,189 @@ namespace Azure { namespace Storage { namespace Test {
return secondaryUri.GetAbsoluteUrl();
}

void StorageTest::InitLoggingOptions(Azure::Core::_internal::ClientOptions& options)
{
const std::set<std::string> allowedHttpHeaders = {
"x-ms-version",
"x-ms-write",
"x-ms-version-id",
"x-ms-type",
"x-ms-time-next-visible",
"x-ms-tags",
"x-ms-tag-count",
"x-ms-source-range",
"x-ms-source-lease-id",
"x-ms-source-if-unmodified-since",
"x-ms-source-if-tags",
"x-ms-source-if-none-match-crc64",
"x-ms-source-if-none-match",
"x-ms-source-if-modified-since",
"x-ms-source-if-match-crc64",
"x-ms-source-if-match",
"x-ms-source-content-md5",
"x-ms-source-content-crc64",
"x-ms-snapshot",
"x-ms-sku-name",
"x-ms-share-quota",
"x-ms-request-server-encrypted",
"x-ms-requires-sync",
"x-ms-resource-type",
"x-ms-root-squash",
"x-ms-seal-blob",
"x-ms-sequence-number-action",
"x-ms-server-encrypted",
"x-ms-share-next-allowed-quota-downgrade-time",
"x-ms-share-provisioned-bandwidth-mibps",
"x-ms-share-provisioned-egress-mbps",
"x-ms-share-provisioned-ingress-mbps",
"x-ms-share-provisioned-iops",
"x-ms-page-write",
"x-ms-permissions",
"x-ms-popreceipt",
"x-ms-properties",
"x-ms-proposed-lease-id",
"x-ms-range",
"x-ms-range-get-content-crc64",
"x-ms-range-get-content-md5",
"x-ms-rehydrate-priority",
"x-ms-meta-*",
"x-ms-namespace-enabled",
"x-ms-number-of-handles-closed",
"x-ms-number-of-handles-failed",
"x-ms-has-immutability-policy",
"x-ms-has-legal-hold",
"x-ms-if-sequence-number-eq",
"x-ms-if-sequence-number-le",
"x-ms-if-sequence-number-lt",
"x-ms-if-tags",
"x-ms-immutable-storage-with-versioning-enabled",
"x-ms-incremental-copy",
"x-ms-is-current-version",
"x-ms-is-hns-enabled",
"x-ms-is-soft-deleted",
"x-ms-lease-action",
"x-ms-lease-break-period",
"x-ms-lease-duration",
"x-ms-lease-id",
"x-ms-lease-renewed",
"x-ms-lease-state",
"x-ms-lease-status",
"x-ms-lease-time",
"accept-ranges",
"content-disposition",
"content-encoding",
"content-language",
"content-md5",
"content-range",
"x-ms-access-tier",
"x-ms-access-tier-change-time",
"x-ms-access-tier-inferred",
"x-ms-account-kind",
"x-ms-approximate-messages-count",
"x-ms-archive-status",
"x-ms-blob-append-offset",
"x-ms-blob-cache-control",
"x-ms-blob-committed-block-count",
"x-ms-blob-condition-appendpos",
"x-ms-blob-condition-maxsize",
"x-ms-blob-content-disposition",
"x-ms-blob-content-encoding",
"x-ms-blob-content-language",
"x-ms-blob-content-length",
"x-ms-blob-content-md5",
"x-ms-blob-content-type",
"x-ms-blob-public-access",
"x-ms-blob-sealed",
"x-ms-blob-sequence-number",
"x-ms-blob-type",
"x-ms-cache-control",
"x-ms-content-crc64",
"x-ms-content-disposition",
"x-ms-content-encoding",
"x-ms-content-language",
"x-ms-content-length",
"x-ms-content-type",
"x-ms-copy-completion-time",
"x-ms-copy-destination-snapshot",
"x-ms-copy-id",
"x-ms-copy-progress",
"x-ms-copy-source-blob-properties",
"x-ms-copy-source-tag-option",
"x-ms-copy-status",
"x-ms-creation-time",
"x-ms-date",
"x-ms-delete-snapshots",
"x-ms-delete-type-permanent",
"x-ms-deleted-container-name",
"x-ms-deleted-container-version",
"x-ms-deletion-id",
"x-ms-deny-encryption-scope-override",
"x-ms-destination-lease-id",
"x-ms-enabled-protocols",
"x-ms-encryption-algorithm",
"x-ms-error-code",
"x-ms-existing-resource-type",
"x-ms-expiry-option",
"x-ms-expiry-time",
"x-ms-file-attributes",
"x-ms-file-change-time",
"x-ms-file-creation-time",
"x-ms-file-last-write-time",
"x-ms-file-permission-copy-mode",
"x-ms-file-rename-ignore-readonly",
"x-ms-file-rename-replace-if-exists",
};
const std::set<std::string> allowedQueryParameters = {
"comp",
"blockid",
"restype",
"versionid",
"snapshot",
"sv",
"sr",
"sp",
"spr",
"se",
"where",
"prefix",
"maxresults",
"delimiter",
"include",
"blocklisttype",
"ss",
"st",
"srt",
"popreceipt",
"visibilitytimeout",
"peekonly",
"numofmessages",
"messagettl",
"rscc",
"rscd",
"rsce",
"rscl",
"rsct",
"resource",
"action",
"recursive",
"timeout",
"position",
"mode",
"showonly",
"flush",
"maxResults",
"ske",
"sks",
"skv",
"skt",
"sdd",
"directory",
};
options.Log.AllowedHttpHeaders.insert(allowedHttpHeaders.begin(), allowedHttpHeaders.end());
options.Log.AllowedHttpQueryParameters.insert(
allowedQueryParameters.begin(), allowedQueryParameters.end());
}

const Azure::ETag StorageTest::DummyETag("0x8D83B58BDF51D75");
const Azure::ETag StorageTest::DummyETag2("0x8D812645BFB0CDE");

Expand Down
16 changes: 16 additions & 0 deletions sdk/storage/azure-storage-common/test/ut/test_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,25 @@ namespace Azure { namespace Storage {
return Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(text.begin(), text.end()));
}

template <class T> T InitStorageClientOptions()
{
T options;
InitStorageClientOptions(options);
return options;
}
template <class T> void InitStorageClientOptions(T& options)
{
InitClientOptions(options);
InitLoggingOptions(options);
}

protected:
std::vector<std::function<void()>> m_resourceCleanupFunctions;

private:
void InitLoggingOptions(Azure::Core::_internal::ClientOptions& options);
using TestBase::InitClientOptions;

private:
std::mt19937_64 m_randomGenerator;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ namespace Azure { namespace Storage { namespace Test {

Files::DataLake::DataLakeDirectoryClient directoryClientSas(
Files::DataLake::_detail::GetDfsUrlFromUrl(baseDirectoryClient.GetUrl()) + GetSas(),
InitClientOptions<Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Files::DataLake::DataLakeClientOptions>());
directoryClientSas.RenameFile(sourceFilename, destinationFilename);
EXPECT_THROW(
baseDirectoryClient.GetFileClient(sourceFilename).GetProperties(), StorageException);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace Azure { namespace Storage { namespace Test {
const std::string& fileSystemName,
Files::DataLake::DataLakeClientOptions clientOptions)
{
InitClientOptions(clientOptions);
InitStorageClientOptions(clientOptions);
auto fsClient = Files::DataLake::DataLakeFileSystemClient::CreateFromConnectionString(
AdlsGen2ConnectionString(), fileSystemName, clientOptions);
m_resourceCleanupFunctions.push_back([fsClient]() { fsClient.DeleteIfExists(); });
Expand Down Expand Up @@ -278,7 +278,7 @@ namespace Azure { namespace Storage { namespace Test {
= Azure::Storage::Files::DataLake::DataLakeFileSystemClient::CreateFromConnectionString(
AdlsGen2ConnectionString(),
fileSystemName,
InitClientOptions<Azure::Storage::Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Azure::Storage::Files::DataLake::DataLakeClientOptions>());
EXPECT_NO_THROW(connectionStringClient.Create());
EXPECT_NO_THROW(connectionStringClient.Delete());
}
Expand Down Expand Up @@ -711,7 +711,7 @@ namespace Azure { namespace Storage { namespace Test {
fileClient.CreateIfNotExists();

Files::DataLake::DataLakeClientOptions options;
InitClientOptions(options);
InitStorageClientOptions(options);
Files::DataLake::DataLakeFileSystemClient fileSystemClientSas(
Files::DataLake::_detail::GetDfsUrlFromUrl(m_fileSystemClient->GetUrl()) + GetSas(),
options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ namespace Azure { namespace Storage { namespace Test {
AdlsGen2ConnectionString(),
m_fileSystemName,
baseName + "1",
InitClientOptions<Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Files::DataLake::DataLakeClientOptions>());
pathClient.Create(Files::DataLake::Models::PathResourceType::File);
std::string pathPermissions = "rwxrw-rw-";
EXPECT_NO_THROW(pathClient.SetPermissions(pathPermissions));
Expand All @@ -353,7 +353,7 @@ namespace Azure { namespace Storage { namespace Test {
AdlsGen2ConnectionString(),
m_fileSystemName,
baseName + "2",
InitClientOptions<Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Files::DataLake::DataLakeClientOptions>());
auto response = pathClient.Create(Files::DataLake::Models::PathResourceType::File);
Files::DataLake::SetPathPermissionsOptions options1, options2;
options1.AccessConditions.IfUnmodifiedSince = response.Value.LastModified;
Expand All @@ -368,7 +368,7 @@ namespace Azure { namespace Storage { namespace Test {
AdlsGen2ConnectionString(),
m_fileSystemName,
baseName + "3",
InitClientOptions<Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Files::DataLake::DataLakeClientOptions>());
auto response = pathClient.Create(Files::DataLake::Models::PathResourceType::File);
Files::DataLake::SetPathPermissionsOptions options1, options2;
options1.AccessConditions.IfMatch = response.Value.ETag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ namespace Azure { namespace Storage { namespace Test {
.GetUrl();
auto datalakeServiceClient = Azure::Storage::Files::DataLake::DataLakeServiceClient(
datalakeServiceUrl + sasToken,
InitClientOptions<Azure::Storage::Files::DataLake::DataLakeClientOptions>());
InitStorageClientOptions<Azure::Storage::Files::DataLake::DataLakeClientOptions>());
EXPECT_NO_THROW(datalakeServiceClient.ListFileSystems());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Azure { namespace Storage { namespace Test {
void SetUp() override
{
StorageTest::SetUp();
auto options = InitClientOptions<Files::DataLake::DataLakeClientOptions>();
auto options = InitStorageClientOptions<Files::DataLake::DataLakeClientOptions>();
m_dataLakeServiceClient = std::make_shared<Files::DataLake::DataLakeServiceClient>(
Files::DataLake::DataLakeServiceClient::CreateFromConnectionString(
AdlsGen2ConnectionString(), options));
Expand Down
Loading