Remove SAS and deps from tables (#6311)

* test1

* dsaf

* clangs

* remove enum_operators as they where only used for sas related operations
This commit is contained in:
gearama 2025-01-08 13:18:56 -08:00 committed by GitHub
parent 461894d526
commit c4c7e6a983
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 3 additions and 1472 deletions

View File

@ -41,27 +41,19 @@ endif()
set(
AZURE_DATA_TABLES_HEADER
inc/azure/data/tables/account_sas_builder.hpp
inc/azure/data/tables/credentials/azure_sas_credential.hpp
inc/azure/data/tables/credentials/named_key_credential.hpp
inc/azure/data/tables/dll_import_export.hpp
inc/azure/data/tables/enum_operators.hpp
inc/azure/data/tables/models.hpp
inc/azure/data/tables/rtti.hpp
inc/azure/data/tables.hpp
inc/azure/data/tables/table_client.hpp
inc/azure/data/tables/table_service_client.hpp
inc/azure/data/tables/tables_sas_builder.hpp
)
set(
AZURE_DATA_TABLES_SOURCE
src/account_sas_builder.cpp
src/cryptography/hmacsha256.cpp
src/models.cpp
src/policies/tenant_bearer_token_policy.cpp
src/policies/timeout_policy.cpp
src/private/hmacsha256.hpp
src/private/package_version.hpp
src/private/policies/service_version_policy.hpp
src/private/policies/tenant_bearer_token_policy.hpp
@ -72,7 +64,7 @@ set(
src/private/xml_wrapper.hpp
src/serializers.cpp
src/table_clients.cpp
src/tables_sas_builder.cpp
src/xml_wrapper.cpp
)

View File

@ -8,13 +8,8 @@
#pragma once
#include "azure/data/tables/account_sas_builder.hpp"
#include "azure/data/tables/credentials/azure_sas_credential.hpp"
#include "azure/data/tables/credentials/named_key_credential.hpp"
#include "azure/data/tables/dll_import_export.hpp"
#include "azure/data/tables/enum_operators.hpp"
#include "azure/data/tables/models.hpp"
#include "azure/data/tables/rtti.hpp"
#include "azure/data/tables/table_client.hpp"
#include "azure/data/tables/table_service_client.hpp"
#include "azure/data/tables/tables_sas_builder.hpp"

View File

@ -1,207 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "azure/data/tables/credentials/named_key_credential.hpp"
#include "azure/data/tables/enum_operators.hpp"
#include <azure/core/datetime.hpp>
#include <azure/core/nullable.hpp>
#include <string>
namespace Azure { namespace Data { namespace Tables { namespace Sas {
constexpr const char* HttpsAndHttp = "https,http";
constexpr const char* HttpsOnly = "https";
/**
* @brief Defines the protocols permitted for Storage requests made with a shared access
* signature.
*/
enum class SasProtocol
{
/**
* @brief Only requests issued over HTTPS or HTTP will be permitted.
*/
HttpsAndHttp,
/**
* @brief Only requests issued over HTTPS will be permitted.
*/
HttpsOnly,
};
namespace _detail {
inline std::string SasProtocolToString(SasProtocol protocol)
{
return protocol == SasProtocol::HttpsAndHttp ? HttpsAndHttp : HttpsOnly;
}
} // namespace _detail
/**
* @brief Specifies the resource types accessible from an account level shared access
* signature.
*/
enum class AccountSasResourceType
{
/**
* @brief Indicates whether service-level APIs are accessible from this shared access
* signature.
*/
Service = 1,
/**
* @brief Indicates whether container-level APIs are accessible from this shared
* access signature.
*/
Container = 2,
/**
* @brief Indicates whether object-level APIs for blobs, queue messages, and files are
* accessible from this shared access signature.
*/
Object = 4,
/**
* @brief Indicates all service-level APIs are accessible from this shared access
* signature.
*/
All = ~0,
};
/**
* @brief Specifies the services accessible from an account level shared access signature.
*/
enum class AccountSasServices
{
/**
* @brief Indicates whether Azure Table Storage resources are accessible from the shared
* access signature.
*/
Table = 1,
/**
* @brief Indicates all services are accessible from the shared
* access signature.
*/
All = ~0,
};
/**
* @brief The list of permissions that can be set for an account's access policy.
*/
enum class AccountSasPermissions
{
/**
* @brief Indicates that Read is permitted.
*/
Read = 1,
/**
* @brief Indicates that Write is permitted.
*/
Write = 2,
/**
* @brief Indicates that Delete is permitted.
*/
Delete = 4,
/**
* @brief Indicates that List is permitted.
*/
List = 8,
/**
* @brief Indicates that Add is permitted.
*/
Add = 16,
/**
* @brief Indicates that Update is permitted.
*/
Update = 32,
/**
* @brief Indicates that all permissions are set.
*/
All = ~0,
};
/**
* @brief AccountSasBuilder is used to generate an account level Shared Access Signature
* (SAS) for Azure Storage services.
*/
class AccountSasBuilder final {
public:
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.
*/
SasProtocol Protocol = SasProtocol::HttpsOnly;
/**
* @brief Optionally specify the time at which the shared access signature becomes
* valid.
*/
Azure::Nullable<Azure::DateTime> StartsOn;
/**
* @brief The time at which the shared access signature becomes invalid. This field must
* be omitted if it has been specified in an associated stored access policy.
*/
Azure::DateTime ExpiresOn;
/**
* @brief Specifies an IP address or a range of IP addresses from which to accept
* requests. If the IP address from which the request originates does not match the IP address
* or address range specified on the SAS token, the request is not authenticated. When
* specifying a range of IP addresses, note that the range is inclusive.
*/
Azure::Nullable<std::string> IPRange;
/**
* @brief The services associated with the shared access signature. The user is
* restricted to operations with the specified services.
*/
AccountSasServices Services;
/**
* The resource types associated with the shared access signature. The user is
* restricted to operations on the specified resources.
*/
AccountSasResourceType ResourceTypes;
/**
* @brief Optional encryption scope to use when sending requests authorized with this SAS url.
*/
std::string EncryptionScope;
/**
* @brief Sets the permissions for an account SAS.
*
* @param permissions The
* allowed permissions.
*/
void SetPermissions(AccountSasPermissions permissions);
/**
* @brief Sets the permissions for the SAS using a raw permissions string.
*
* @param rawPermissions Raw permissions string for the SAS.
*/
void SetPermissions(std::string rawPermissions) { Permissions = std::move(rawPermissions); }
/**
* @brief Uses the NamedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential The named key credential.
* @return The SAS query parameters used for authenticating requests.
*/
std::string GenerateSasToken(
const Azure::Data::Tables::Credentials::NamedKeyCredential& credential);
private:
std::string Permissions;
};
}}}} // namespace Azure::Data::Tables::Sas

View File

@ -1,47 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <azure/core/http/http.hpp>
#include <memory>
#include <mutex>
#include <string>
namespace Azure { namespace Data { namespace Tables { namespace Credentials {
/**
* @brief Azure Shared Access Signature (SAS) credential.
*/
class AzureSasCredential final {
private:
std::string m_signature;
mutable std::mutex m_mutex;
public:
/**
* @brief Initializes a new instance of the AzureSasCredential.
*
* @param signature The signature for the SAS token.
*/
explicit AzureSasCredential(std::string signature) : m_signature(std::move(signature)) {}
/**
* @brief Get the signature for the SAS token.
*/
std::string GetSignature() const
{
std::lock_guard<std::mutex> guard(m_mutex);
return m_signature;
}
/**
* @brief Update the signature for the SAS token.
*/
void Update(std::string signature)
{
std::lock_guard<std::mutex> guard(m_mutex);
m_signature = std::move(signature);
}
};
}}}} // namespace Azure::Data::Tables::Credentials

View File

@ -1,68 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <azure/core/http/http.hpp>
#include <memory>
#include <mutex>
#include <string>
namespace Azure { namespace Data { namespace Tables { namespace Sas {
class AccountSasBuilder;
class TablesSasBuilder;
}}}} // namespace Azure::Data::Tables::Sas
namespace Azure { namespace Data { namespace Tables { namespace Credentials {
/**
* @brief A NamedKeyCredential is a credential backed by an account's name and
* one of its access keys.
*/
class NamedKeyCredential final {
public:
/**
* @brief Initializes a new instance of the NamedKeyCredential.
*
* @param accountName Name of the account.
* @param accountKey Access key of the
* account.
*/
explicit NamedKeyCredential(std::string accountName, std::string accountKey)
: AccountName{std::move(accountName)}, m_accountKey{std::move(accountKey)}
{
}
/**
* @brief Update the account's access key. This intended to be used when you've
* regenerated your account's access keys and want to update long lived clients.
*
* @param accountKey An account access key.
*/
void Update(std::string accountKey)
{
std::lock_guard<std::mutex> guard(m_mutex);
m_accountKey = std::move(accountKey);
}
/**
* @brief The name of the Account.
*/
const std::string AccountName;
private:
friend class Azure::Data::Tables::Sas::AccountSasBuilder;
friend class Azure::Data::Tables::Sas::TablesSasBuilder;
std::string GetAccountKey() const
{
std::lock_guard<std::mutex> guard(m_mutex);
return m_accountKey;
}
mutable std::mutex m_mutex;
std::string m_accountKey;
};
}}}} // namespace Azure::Data::Tables::Credentials

View File

@ -1,85 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* @file enum_operators.hpp
* @brief Defines bitwise operators for enums.
* @details This file defines bitwise operators for enum classes. This allows the use of the
* operators |, |=, &, &=, ^, ^=, and ~ with enum classes. This is useful for flags enums.
* Example: enum class MyEnum { A = 1, B = 2, C = 4 }; MyEnum e = MyEnum::A | MyEnum::B;
* Example: enum class MyEnum { A = 1, B = 2, C = 4 }; MyEnum e = MyEnum::A; e &= MyEnum::B;
*/
#pragma once
#include <type_traits>
namespace Azure { namespace Data { namespace Tables {
/**
* @brief Bitwise OR operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E operator|(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
return static_cast<E>(static_cast<type>(lhs) | static_cast<type>(rhs));
}
/**
* @brief Bitwise OR EQUALS operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E& operator|=(E& lhs, E rhs)
{
lhs = lhs | rhs;
return lhs;
}
/**
* @brief Bitwise AND operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E operator&(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
return static_cast<E>(static_cast<type>(lhs) & static_cast<type>(rhs));
}
/**
* @brief Bitwise AND EQUALS operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E& operator&=(E& lhs, E rhs)
{
lhs = lhs & rhs;
return lhs;
}
/**
* @brief Bitwise XOR operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E operator^(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
return static_cast<E>(static_cast<type>(lhs) ^ static_cast<type>(rhs));
}
/**
* @brief Bitwise XOR EQUALS operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>>
constexpr E& operator^=(E& lhs, E rhs)
{
lhs = lhs ^ rhs;
return lhs;
}
/**
* @brief Bitwise COMPLEMENT operator for enum class.
*/
template <class E, class = std::enable_if_t<std::is_enum<E>{}>> constexpr E operator~(E rhs)
{
using type = std::underlying_type_t<E>;
return static_cast<E>(~static_cast<type>(rhs));
}
}}} // namespace Azure::Data::Tables

View File

@ -4,7 +4,6 @@
#pragma once
#include "azure/data/tables/dll_import_export.hpp"
#include "azure/data/tables/enum_operators.hpp"
#include <azure/core/datetime.hpp>
#include <azure/core/internal/extendable_enumeration.hpp>

View File

@ -3,8 +3,6 @@
#pragma once
#include "azure/data/tables/credentials/azure_sas_credential.hpp"
#include "azure/data/tables/credentials/named_key_credential.hpp"
#include "azure/data/tables/models.hpp"
#include <azure/core/credentials/credentials.hpp>
@ -88,21 +86,6 @@ namespace Azure { namespace Data { namespace Tables {
std::shared_ptr<Core::Credentials::TokenCredential> credential,
const TableClientOptions& options = {});
/**
* @brief Initializes a new instance of tableClient.
*
* @param serviceUrl The service Url
* @param credential The SAS credential used to sign requests.
* @param tableName The name of the table.
* @param options Optional client options that define the transport pipeline policies for
* authentication, retries, etc., that are applied to every request.
*/
explicit TableClient(
const std::string& serviceUrl,
std::shared_ptr<Azure::Data::Tables::Credentials::AzureSasCredential> credential,
const std::string& tableName,
const TableClientOptions& options = {});
/**
* @brief Add entity in a table.
*

View File

@ -50,20 +50,6 @@ namespace Azure { namespace Data { namespace Tables {
std::shared_ptr<Core::Credentials::TokenCredential> credential,
const TableClientOptions& options = {});
/**
* @brief Initializes a new instance of tableClient.
*
* @param serviceUrl A url referencing the table that includes the name of the account and the
* name of the table.
* @param credential The SAS credential used to sign requests.
* @param options Optional client options that define the transport pipeline policies for
* authentication, retries, etc., that are applied to every request.
*/
explicit TableServiceClient(
const std::string& serviceUrl,
std::shared_ptr<Azure::Data::Tables::Credentials::AzureSasCredential> credential,
const TableClientOptions& options = {});
/**
* @brief Creates a new table under the given account.
*

View File

@ -1,151 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "azure/data/tables/account_sas_builder.hpp"
#include "azure/data/tables/credentials/named_key_credential.hpp"
#include "azure/data/tables/enum_operators.hpp"
#include <azure/core/datetime.hpp>
#include <azure/core/nullable.hpp>
#include <string>
#include <type_traits>
namespace Azure { namespace Data { namespace Tables { namespace Sas {
/**
* @brief Contains the list of
* permissions that can be set for a table's access policy.
*/
enum class TablesSasPermissions
{
/**
* @brief Indicates that Read is permitted.
*/
Read = 1,
/**
* @brief Indicates that Add is permitted.
*/
Add = 2,
/**
* @brief Indicates that Delete is permitted.
*/
Delete = 4,
/**
* @brief Indicates that Update is permitted.
*/
Update = 8,
/**
* @brief Indicates that all permissions are set.
*/
All = ~0
};
/**
* @brief TableSasBuilder is used to generate a Shared Access Signature (SAS) for an Azure
* Storage Tables.
*/
class TablesSasBuilder final {
public:
/**
* @brief The optional signed protocol field specifies the protocol permitted for a
* request made with the SAS.
*/
SasProtocol Protocol;
/**
* @brief Optionally specify the time at which the shared access signature becomes
* valid. This timestamp will be truncated to second.
*/
Azure::Nullable<Azure::DateTime> StartsOn;
/**
* @brief The time at which the shared access signature becomes invalid. This field must
* be omitted if it has been specified in an associated stored access policy. This timestamp
* will be truncated to second.
*/
Azure::DateTime ExpiresOn;
/**
* @brief Specifies an IP address or a range of IP addresses from which to accept
* requests. If the IP address from which the request originates does not match the IP address
* or address range specified on the SAS token, the request is not authenticated. When
* specifying a range of IP addresses, note that the range is inclusive.
*/
Azure::Nullable<std::string> IPRange;
/**
* @brief An optional unique value up to 64 characters in length that correlates to an
* access policy specified for the table.
*/
std::string Identifier;
/**
* @brief The name of the table being made accessible.
*/
std::string TableName;
/**
* @brief The optional start of the partition key values range being made available.
*/
std::string PartitionKeyStart;
/**
* @brief The optional end of the partition key values range being made available.
*/
std::string PartitionKeyEnd;
/**
* @brief The optional start of the row key values range being made available.
*/
std::string RowKeyStart;
/**
* @brief The optional end of the partition key values range being made available.
*/
std::string RowKeyEnd;
/**
* @brief Sets the permissions for the table SAS.
*
* @param permissions The allowed permissions.
*/
void SetPermissions(TablesSasPermissions permissions);
/**
* @brief Sets the permissions for the SAS using a raw permissions string.
*
* @param rawPermissions Raw permissions string for the SAS.
*/
void SetPermissions(std::string rawPermissions) { Permissions = std::move(rawPermissions); }
/**
* @brief Uses the NamedKeyCredential to sign this shared access signature, to produce
* the proper SAS query parameters for authentication requests.
*
* @param credential The named key credential.
* @return The SAS query parameters used for authenticating requests.
*/
std::string GenerateSasToken(
const Azure::Data::Tables::Credentials::NamedKeyCredential& credential);
/**
* @brief Gets the canonical path for the shared access signature.
*
* @param credential The named key credential.
* @return Canonical path.
*/
std::string GetCanonicalName(
const Azure::Data::Tables::Credentials::NamedKeyCredential& credential) const
{
return Azure::Core::_internal::StringExtensions::ToLower(
"/table/" + credential.AccountName + "/" + TableName);
}
private:
std::string Permissions;
};
}}}} // namespace Azure::Data::Tables::Sas

View File

@ -1,131 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "azure/data/tables/account_sas_builder.hpp"
#include "private/hmacsha256.hpp"
#include "private/url_encode.hpp"
#include <azure/core/base64.hpp>
#include <azure/core/http/http.hpp>
namespace Azure { namespace Data { namespace Tables { namespace Sas {
namespace {
constexpr const char* SasVersion = "2023-08-03";
}
void AccountSasBuilder::SetPermissions(AccountSasPermissions permissions)
{
Permissions.clear();
if ((permissions & AccountSasPermissions::Read) == AccountSasPermissions::Read)
{
Permissions += "r";
}
if ((permissions & AccountSasPermissions::Write) == AccountSasPermissions::Write)
{
Permissions += "w";
}
if ((permissions & AccountSasPermissions::Delete) == AccountSasPermissions::Delete)
{
Permissions += "d";
}
if ((permissions & AccountSasPermissions::List) == AccountSasPermissions::List)
{
Permissions += "l";
}
if ((permissions & AccountSasPermissions::Add) == AccountSasPermissions::Add)
{
Permissions += "a";
}
if ((permissions & AccountSasPermissions::Update) == AccountSasPermissions::Update)
{
Permissions += "u";
}
}
std::string AccountSasBuilder::GenerateSasToken(
const Azure::Data::Tables::Credentials::NamedKeyCredential& credential)
{
std::string protocol = _detail::SasProtocolToString(Protocol);
std::string services;
if ((Services & AccountSasServices::Table) == AccountSasServices::Table)
{
services += "t";
}
std::string resourceTypes;
if ((ResourceTypes & AccountSasResourceType::Service) == AccountSasResourceType::Service)
{
resourceTypes += "s";
}
if ((ResourceTypes & AccountSasResourceType::Container) == AccountSasResourceType::Container)
{
resourceTypes += "c";
}
if ((ResourceTypes & AccountSasResourceType::Object) == AccountSasResourceType::Object)
{
resourceTypes += "o";
}
std::string startsOnStr = StartsOn.HasValue()
? StartsOn.Value().ToString(
Azure::DateTime::DateFormat::Rfc3339, Azure::DateTime::TimeFractionFormat::Truncate)
: "";
std::string expiresOnStr = ExpiresOn.ToString(
Azure::DateTime::DateFormat::Rfc3339, Azure::DateTime::TimeFractionFormat::Truncate);
std::string stringToSign = credential.AccountName + "\n" + Permissions + "\n" + services + "\n"
+ resourceTypes + "\n" + startsOnStr + "\n" + expiresOnStr + "\n"
+ (IPRange.HasValue() ? IPRange.Value() : "") + "\n" + protocol + "\n" + SasVersion + "\n"
+ EncryptionScope + "\n";
std::string signature = Azure::Core::Convert::Base64Encode(
Azure::Data::Tables::_detail::Cryptography::HmacSha256::Compute(
std::vector<uint8_t>(stringToSign.begin(), stringToSign.end()),
Azure::Core::Convert::Base64Decode(credential.GetAccountKey())));
Azure::Core::Url builder;
builder.AppendQueryParameter(
"sv",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(SasVersion));
builder.AppendQueryParameter(
"ss",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(services));
builder.AppendQueryParameter(
"srt",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
resourceTypes));
builder.AppendQueryParameter(
"sp",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(Permissions));
if (!startsOnStr.empty())
{
builder.AppendQueryParameter("st", startsOnStr);
}
builder.AppendQueryParameter("se", expiresOnStr);
if (IPRange.HasValue())
{
builder.AppendQueryParameter(
"sip",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
IPRange.Value()));
}
builder.AppendQueryParameter(
"spr",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(protocol));
builder.AppendQueryParameter(
"sig",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(signature));
if (!EncryptionScope.empty())
{
builder.AppendQueryParameter(
"ses",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
EncryptionScope));
}
return builder.GetAbsoluteUrl();
}
}}}} // namespace Azure::Data::Tables::Sas

View File

@ -1,166 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "../private/hmacsha256.hpp"
#include <azure/core/azure_assert.hpp>
#include <azure/core/cryptography/hash.hpp>
#include <azure/core/platform.hpp>
#if defined(AZ_PLATFORM_WINDOWS)
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
// Windows needs to go before bcrypt
#include <windows.h>
#include <bcrypt.h>
#elif defined(AZ_PLATFORM_POSIX)
#include <openssl/bio.h>
#include <openssl/evp.h>
#include <openssl/hmac.h>
#endif
#include <algorithm>
#include <limits>
#include <numeric>
#include <stdexcept>
#include <vector>
namespace Azure { namespace Data { namespace Tables { namespace _detail { namespace Cryptography {
#if defined(AZ_PLATFORM_WINDOWS)
enum class AlgorithmType
{
HmacSha256,
};
struct AlgorithmProviderInstance final
{
BCRYPT_ALG_HANDLE Handle;
size_t ContextSize;
size_t HashLength;
AlgorithmProviderInstance(AlgorithmType type)
{
const wchar_t* algorithmId = nullptr;
if (type == AlgorithmType::HmacSha256)
{
algorithmId = BCRYPT_SHA256_ALGORITHM;
}
else
{
throw std::runtime_error("Unknown algorithm type.");
}
unsigned long algorithmFlags = 0;
if (type == AlgorithmType::HmacSha256)
{
algorithmFlags = BCRYPT_ALG_HANDLE_HMAC_FLAG;
}
Handle = nullptr;
NTSTATUS status = BCryptOpenAlgorithmProvider(&Handle, algorithmId, nullptr, algorithmFlags);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptOpenAlgorithmProvider failed.");
}
DWORD objectLength = 0;
DWORD dataLength = 0;
status = BCryptGetProperty(
Handle,
BCRYPT_OBJECT_LENGTH,
reinterpret_cast<PBYTE>(&objectLength),
sizeof(objectLength),
&dataLength,
0);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptGetProperty failed.");
}
ContextSize = objectLength;
DWORD hashLength = 0;
status = BCryptGetProperty(
Handle,
BCRYPT_HASH_LENGTH,
reinterpret_cast<PBYTE>(&hashLength),
sizeof(hashLength),
&dataLength,
0);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptGetProperty failed.");
}
HashLength = hashLength;
}
~AlgorithmProviderInstance() { BCryptCloseAlgorithmProvider(Handle, 0); }
};
std::vector<uint8_t> HmacSha256::Compute(
const std::vector<uint8_t>& data,
const std::vector<uint8_t>& key)
{
AZURE_ASSERT_MSG(data.size() <= ULONG_MAX, "Data size is too big.");
static AlgorithmProviderInstance AlgorithmProvider(AlgorithmType::HmacSha256);
std::string context;
context.resize(AlgorithmProvider.ContextSize);
BCRYPT_HASH_HANDLE hashHandle;
NTSTATUS status = BCryptCreateHash(
AlgorithmProvider.Handle,
&hashHandle,
reinterpret_cast<PUCHAR>(&context[0]),
static_cast<ULONG>(context.size()),
reinterpret_cast<PUCHAR>(const_cast<uint8_t*>(&key[0])),
static_cast<ULONG>(key.size()),
0);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptCreateHash failed.");
}
status = BCryptHashData(
hashHandle,
reinterpret_cast<PBYTE>(const_cast<uint8_t*>(data.data())),
static_cast<ULONG>(data.size()),
0);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptHashData failed.");
}
std::vector<uint8_t> hash;
hash.resize(AlgorithmProvider.HashLength);
status = BCryptFinishHash(
hashHandle, reinterpret_cast<PUCHAR>(&hash[0]), static_cast<ULONG>(hash.size()), 0);
if (!BCRYPT_SUCCESS(status))
{
throw std::runtime_error("BCryptFinishHash failed.");
}
BCryptDestroyHash(hashHandle);
return hash;
}
#elif defined(AZ_PLATFORM_POSIX)
std::vector<uint8_t> HmacSha256::Compute(
const std::vector<uint8_t>& data,
const std::vector<uint8_t>& key)
{
uint8_t hash[EVP_MAX_MD_SIZE];
unsigned int hashLength = 0;
HMAC(
EVP_sha256(),
key.data(),
static_cast<int>(key.size()),
reinterpret_cast<const unsigned char*>(data.data()),
data.size(),
reinterpret_cast<unsigned char*>(&hash[0]),
&hashLength);
return std::vector<uint8_t>(std::begin(hash), std::begin(hash) + hashLength);
}
#endif
}}}}} // namespace Azure::Data::Tables::_detail::Cryptography

View File

@ -1,21 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include <azure/core/azure_assert.hpp>
#include <memory>
#include <stdexcept>
#include <stdint.h>
#include <string>
#include <vector>
namespace Azure { namespace Data { namespace Tables { namespace _detail { namespace Cryptography {
class HmacSha256 final {
public:
static std::vector<uint8_t> Compute(
const std::vector<uint8_t>& data,
const std::vector<uint8_t>& key);
};
}}}}} // namespace Azure::Data::Tables::_detail::Cryptography

View File

@ -65,14 +65,6 @@ TableServiceClient::TableServiceClient(
std::move(perOperationPolicies));
}
TableServiceClient::TableServiceClient(
const std::string& serviceUrl,
std::shared_ptr<Azure::Data::Tables::Credentials::AzureSasCredential> credential,
const TableClientOptions& options)
: TableServiceClient(std::string{serviceUrl + credential->GetSignature()}, options)
{
}
TableClient TableServiceClient::GetTableClient(
const std::string& tableName,
TableClientOptions const& options) const
@ -291,19 +283,6 @@ TableClient::TableClient(
std::move(perOperationPolicies));
}
TableClient::TableClient(
const std::string& serviceUrl,
std::shared_ptr<Azure::Data::Tables::Credentials::AzureSasCredential> credential,
const std::string& tableName,
const TableClientOptions& options)
: TableClient(
std::string{
Azure::Core::Url(serviceUrl).GetAbsoluteUrl() + "/" + credential->GetSignature()},
tableName,
options)
{
}
Azure::Response<Models::Table> TableServiceClient::CreateTable(
std::string const& tableName,
Core::Context const& context)

View File

@ -1,155 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "azure/data/tables/tables_sas_builder.hpp"
#include "private/hmacsha256.hpp"
#include "private/url_encode.hpp"
#include <azure/core/base64.hpp>
#include <azure/core/http/http.hpp>
namespace Azure { namespace Data { namespace Tables { namespace Sas {
namespace {
constexpr static const char* SasVersion = "2019-07-07";
}
void TablesSasBuilder::SetPermissions(TablesSasPermissions permissions)
{
Permissions.clear();
// The order matters
if ((permissions & TablesSasPermissions::Read) == TablesSasPermissions::Read)
{
Permissions += "r";
}
if ((permissions & TablesSasPermissions::Add) == TablesSasPermissions::Add)
{
Permissions += "a";
}
if ((permissions & TablesSasPermissions::Update) == TablesSasPermissions::Update)
{
Permissions += "u";
}
if ((permissions & TablesSasPermissions::Delete) == TablesSasPermissions::Delete)
{
Permissions += "d";
}
}
std::string TablesSasBuilder::GenerateSasToken(
const Azure::Data::Tables::Credentials::NamedKeyCredential& credential)
{
std::string canonicalName
= Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
GetCanonicalName(credential));
std::string protocol = _detail::SasProtocolToString(Protocol);
std::string startsOnStr = StartsOn.HasValue()
? StartsOn.Value().ToString(
Azure::DateTime::DateFormat::Rfc3339, Azure::DateTime::TimeFractionFormat::Truncate)
: "";
std::string expiresOnStr = ExpiresOn.ToString(
Azure::DateTime::DateFormat::Rfc3339, Azure::DateTime::TimeFractionFormat::Truncate);
// the order here matters
std::string stringToSign = Permissions + "\n" + startsOnStr + "\n" + expiresOnStr + "\n"
+ canonicalName + "\n" + Identifier + "\n" + (IPRange.HasValue() ? IPRange.Value() : "")
+ "\n" + protocol + "\n" + SasVersion + "\n" + PartitionKeyStart + "\n" + RowKeyStart + "\n"
+ PartitionKeyEnd + "\n" + RowKeyEnd;
std::string signature = Azure::Core::Convert::Base64Encode(
Azure::Data::Tables::_detail::Cryptography::HmacSha256::Compute(
std::vector<uint8_t>(stringToSign.begin(), stringToSign.end()),
Azure::Core::Convert::Base64Decode(credential.GetAccountKey())));
Azure::Core::Url builder;
builder.AppendQueryParameter(
"sv",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(SasVersion));
builder.AppendQueryParameter(
"tn",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(TableName));
builder.AppendQueryParameter(
"spr",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(protocol));
if (!startsOnStr.empty())
{
builder.AppendQueryParameter(
"st",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
startsOnStr));
}
if (!expiresOnStr.empty())
{
builder.AppendQueryParameter(
"se",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
expiresOnStr));
}
if (IPRange.HasValue())
{
builder.AppendQueryParameter(
"sip",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
IPRange.Value()));
}
if (!Identifier.empty())
{
builder.AppendQueryParameter(
"si",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
Identifier));
}
if (!Permissions.empty())
{
builder.AppendQueryParameter(
"sp",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
Permissions));
}
builder.AppendQueryParameter(
"sig",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(signature));
if (!PartitionKeyStart.empty())
{
builder.AppendQueryParameter(
"spk",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
PartitionKeyStart));
if (!PartitionKeyEnd.empty())
{
builder.AppendQueryParameter(
"epk",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
PartitionKeyEnd));
}
}
if (!RowKeyStart.empty())
{
builder.AppendQueryParameter(
"srk",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
RowKeyStart));
if (!RowKeyEnd.empty())
{
builder.AppendQueryParameter(
"erk",
Azure::Data::Tables::_detail::Cryptography::UrlUtils::UrlEncodeQueryParameter(
RowKeyEnd));
}
}
return builder.GetAbsoluteUrl();
}
}}}} // namespace Azure::Data::Tables::Sas

View File

@ -16,10 +16,7 @@ SetUpTestProxy("sdk/tables")
add_executable (
azure-data-tables-test
enum_operators_test.hpp
enum_operators_test.cpp
macro_guard.cpp
sas_test.cpp
serializers_test.hpp
serializers_test.cpp
table_client_test.cpp

View File

@ -1,147 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "enum_operators_test.hpp"
using namespace Azure::Data::Tables::Sas;
using namespace Azure::Data::Tables;
namespace Azure { namespace Data { namespace Test {
TEST(EnumOperator, AndTest)
{
{
constexpr auto val = TestEnum::One & TestEnum::Two;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::One & TestEnum::One;
EXPECT_EQ(val, TestEnum::One);
}
{
auto val = TestEnum::Two & TestEnum::One;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::Two & TestEnum::Two;
EXPECT_EQ(val, TestEnum::Two);
}
{
auto val = TestEnum::One;
val &= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::One;
val &= TestEnum::One;
EXPECT_EQ(val, TestEnum::One);
}
{
auto val = TestEnum::Two;
val &= TestEnum::One;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::Two;
val &= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Two);
}
}
TEST(EnumOperator, OrTest)
{
{
constexpr auto val = TestEnum::One | TestEnum::Two;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::One | TestEnum::One;
EXPECT_EQ(val, TestEnum::One);
}
{
auto val = TestEnum::Two | TestEnum::One;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::Two | TestEnum::Two;
EXPECT_EQ(val, TestEnum::Two);
}
{
auto val = TestEnum::One;
val |= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::One;
val |= TestEnum::One;
EXPECT_EQ(val, TestEnum::One);
}
{
auto val = TestEnum::Two;
val |= TestEnum::One;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::Two;
val |= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Two);
}
}
TEST(EnumOperator, XorTest)
{
{
constexpr auto val = TestEnum::One ^ TestEnum::Two;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::One ^ TestEnum::One;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::Two ^ TestEnum::One;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::Two ^ TestEnum::Two;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::One;
val ^= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::One;
val ^= TestEnum::One;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = TestEnum::Two;
val ^= TestEnum::One;
EXPECT_EQ(val, TestEnum::Three);
}
{
auto val = TestEnum::Two;
val ^= TestEnum::Two;
EXPECT_EQ(val, TestEnum::Zero);
}
}
TEST(EnumOperator, ComplementTest)
{
{
constexpr auto val = ~TestEnum::Zero;
EXPECT_EQ(val, TestEnum::All);
}
{
auto val = ~TestEnum::All;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = ~~TestEnum::Zero;
EXPECT_EQ(val, TestEnum::Zero);
}
{
auto val = ~~TestEnum::One;
EXPECT_EQ(val, TestEnum::One);
}
}
}}} // namespace Azure::Data::Test

View File

@ -1,21 +0,0 @@
#pragma once
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// clang-format off
#include "azure/data/tables/account_sas_builder.hpp"
#include "azure/data/tables/tables_sas_builder.hpp"
#include "test/ut/test_base.hpp"
namespace Azure { namespace Data { namespace Test {
enum class TestEnum
{
Zero = 0,
One = 1,
Two = 2,
Three = 3,
All = ~0
};
class EnumOperator : public Azure::Core::Test::TestBase {};
}}} // namespace Azure::Data::Test

View File

@ -1,133 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "sas_test.hpp"
#include <chrono>
#include <sstream>
#include <string>
#include <thread>
using namespace Azure::Data::Tables::Sas;
// cspell: words rwdlau raud bqft
namespace Azure { namespace Data { namespace Test {
TEST(SasTest, TableSasBuilderTestAllSet)
{
TablesSasBuilder sasBuilder;
sasBuilder.SetPermissions(TablesSasPermissions::All);
sasBuilder.Protocol = SasProtocol::HttpsAndHttp;
sasBuilder.StartsOn
= Azure::DateTime::Parse("2020-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
sasBuilder.ExpiresOn
= Azure::DateTime::Parse("2022-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
sasBuilder.Identifier = "myIdentifier";
sasBuilder.IPRange = "iprange";
sasBuilder.TableName = "myTableName";
sasBuilder.RowKeyEnd = "myRowKeyEnd";
sasBuilder.RowKeyStart = "myRowKeyStart";
sasBuilder.PartitionKeyStart = "myStartPartitionKey";
sasBuilder.PartitionKeyEnd = "myEndPartitionKey";
std::string key = "accountKey";
Azure::Data::Tables::Credentials::NamedKeyCredential cred(
"accountName",
Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(key.begin(), key.end())));
auto sasToken = sasBuilder.GenerateSasToken(cred);
auto sasParts = SasTest::ParseQueryParameters(sasToken);
EXPECT_EQ(sasParts.at("si"), "myIdentifier");
EXPECT_EQ(sasParts.at("sp"), "raud");
EXPECT_EQ(sasParts.at("st"), "2020-08-18T00:00:00Z");
EXPECT_EQ(sasParts.at("se"), "2022-08-18T00:00:00Z");
EXPECT_EQ(sasParts.at("sip"), "iprange");
EXPECT_EQ(sasParts.at("spr"), "https,http");
EXPECT_FALSE(sasParts.at("sig").empty());
EXPECT_EQ(sasParts.at("srk"), "myRowKeyStart");
EXPECT_EQ(sasParts.at("erk"), "myRowKeyEnd");
EXPECT_EQ(sasParts.at("spk"), "myStartPartitionKey");
EXPECT_EQ(sasParts.at("?epk"), "myEndPartitionKey");
}
TEST(SasTest, TableSasBuilderTestSomeSet)
{
TablesSasBuilder sasBuilder;
sasBuilder.Protocol = SasProtocol::HttpsAndHttp;
sasBuilder.ExpiresOn
= Azure::DateTime::Parse("2022-03-11T11:13:52Z", Azure::DateTime::DateFormat::Rfc3339);
sasBuilder.SetPermissions(TablesSasPermissions::Add);
sasBuilder.TableName = "someTableName";
std::string key = "*";
Azure::Data::Tables::Credentials::NamedKeyCredential cred(
"someaccount",
Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(key.begin(), key.end())));
auto sasToken = sasBuilder.GenerateSasToken(cred);
auto sasParts = SasTest::ParseQueryParameters(sasToken);
EXPECT_EQ(sasParts.at("?se"), "2022-03-11T11:13:52Z");
EXPECT_EQ(sasParts.at("sp"), "a");
EXPECT_EQ(sasParts.at("spr"), "https,http");
EXPECT_EQ(sasParts.at("tn"), "someTableName");
}
TEST(SasTest, TableSasBuilderTestMin)
{
TablesSasBuilder sasBuilder;
sasBuilder.ExpiresOn
= Azure::DateTime::Parse("2022-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
std::string key = "accountKey";
Azure::Data::Tables::Credentials::NamedKeyCredential cred(
"accountName",
Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(key.begin(), key.end())));
auto sasToken = sasBuilder.GenerateSasToken(cred);
auto sasParts = SasTest::ParseQueryParameters(sasToken);
EXPECT_FALSE(sasParts.at("sig").empty());
}
TEST(SasTest, AccountSasBuilderTestAllSet)
{
AccountSasBuilder sasBuilder;
sasBuilder.SetPermissions(AccountSasPermissions::All);
sasBuilder.Protocol = SasProtocol::HttpsAndHttp;
sasBuilder.StartsOn
= Azure::DateTime::Parse("2020-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
sasBuilder.ExpiresOn
= Azure::DateTime::Parse("2022-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
sasBuilder.IPRange = "iprange";
sasBuilder.EncryptionScope = "myScope";
sasBuilder.ResourceTypes = AccountSasResourceType::All;
sasBuilder.Services = AccountSasServices::All;
std::string key = "accountKey";
Azure::Data::Tables::Credentials::NamedKeyCredential cred(
"accountName",
Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(key.begin(), key.end())));
auto sasToken = sasBuilder.GenerateSasToken(cred);
auto sasParts = SasTest::ParseQueryParameters(sasToken);
EXPECT_EQ(sasParts.at("?se"), "2022-08-18T00:00:00Z");
EXPECT_EQ(sasParts.at("ses"), "myScope");
EXPECT_FALSE(sasParts.at("sig").empty());
EXPECT_EQ(sasParts.at("sip"), "iprange");
EXPECT_EQ(sasParts.at("sp"), "rwdlau");
EXPECT_EQ(sasParts.at("spr"), "https,http");
EXPECT_EQ(sasParts.at("srt"), "sco");
EXPECT_EQ(sasParts.at("ss"), "t");
EXPECT_EQ(sasParts.at("st"), "2020-08-18T00:00:00Z");
EXPECT_EQ(sasParts.at("sv"), "2023-08-03");
}
TEST(SasTest, AccountSasBuilderTestMin)
{
AccountSasBuilder sasBuilder;
sasBuilder.SetPermissions(AccountSasPermissions::All);
sasBuilder.ExpiresOn
= Azure::DateTime::Parse("2022-08-18T00:00:00Z", Azure::DateTime::DateFormat::Rfc3339);
std::string key = "accountKey";
Azure::Data::Tables::Credentials::NamedKeyCredential cred(
"accountName",
Azure::Core::Convert::Base64Encode(std::vector<uint8_t>(key.begin(), key.end())));
auto sasToken = sasBuilder.GenerateSasToken(cred);
auto sasParts = SasTest::ParseQueryParameters(sasToken);
EXPECT_FALSE(sasParts.at("sig").empty());
}
}}} // namespace Azure::Data::Test

View File

@ -1,30 +0,0 @@
#pragma once
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "azure/data/tables/account_sas_builder.hpp"
#include "azure/data/tables/tables_sas_builder.hpp"
#include "test/ut/test_base.hpp"
namespace Azure { namespace Data { namespace Test {
class SasTest : public Azure::Core::Test::TestBase {
public:
static std::map<std::string, std::string> ParseQueryParameters(const std::string& query)
{
std::map<std::string, std::string> result;
auto parameters = Azure::Core::_internal::StringExtensions::Split(query, '&');
for (const auto& p : parameters)
{
auto keyValue = Azure::Core::_internal::StringExtensions::Split(p, '=');
if (keyValue.size() == 2)
{
result[keyValue[0]] = keyValue[1];
}
}
return result;
}
};
}}} // namespace Azure::Data::Test

View File

@ -3,9 +3,6 @@
#include "table_client_test.hpp"
#include "azure/data/tables/account_sas_builder.hpp"
#include "azure/data/tables/tables_sas_builder.hpp"
#include <azure/core/internal/strings.hpp>
#include <chrono>
@ -64,33 +61,6 @@ namespace Azure { namespace Data { namespace Test {
m_credential,
tableClientOptions));
break;
case AuthType::SAS:
auto creds = std::make_shared<Azure::Data::Tables::Credentials::NamedKeyCredential>(
GetAccountName(), GetAccountKey());
Azure::Data::Tables::Sas::AccountSasBuilder sasBuilder;
sasBuilder.ExpiresOn = std::chrono::system_clock::now() + std::chrono::minutes(60);
sasBuilder.ResourceTypes = Azure::Data::Tables::Sas::AccountSasResourceType::All;
sasBuilder.Services = Azure::Data::Tables::Sas::AccountSasServices::All;
sasBuilder.Protocol = Azure::Data::Tables::Sas::SasProtocol::HttpsOnly;
sasBuilder.SetPermissions(Azure::Data::Tables::Sas::AccountSasPermissions::All);
std::string serviceUrl = "https://" + GetAccountName() + ".table.core.windows.net/";
auto sasCreds = std::make_shared<Azure::Data::Tables::Credentials::AzureSasCredential>(
sasBuilder.GenerateSasToken(*creds));
m_tableServiceClient = std::make_shared<Tables::TableServiceClient>(
Tables::TableServiceClient(serviceUrl, sasCreds, clientOptions));
Azure::Data::Tables::Sas::TablesSasBuilder tableSasBuilder;
tableSasBuilder.Protocol = Azure::Data::Tables::Sas::SasProtocol::HttpsOnly;
tableSasBuilder.StartsOn = std::chrono::system_clock::now() - std::chrono::minutes(5);
tableSasBuilder.ExpiresOn = std::chrono::system_clock::now() + std::chrono::minutes(60);
tableSasBuilder.SetPermissions(Azure::Data::Tables::Sas::TablesSasPermissions::All);
tableSasBuilder.TableName = m_tableName;
auto tableSasCreds
= std::make_shared<Azure::Data::Tables::Credentials::AzureSasCredential>(
tableSasBuilder.GenerateSasToken(*creds));
m_tableClient = std::make_shared<Tables::TableClient>(
Tables::TableClient(serviceUrl, tableSasCreds, m_tableName, tableClientOptions));
break;
}
}
}
@ -674,9 +644,6 @@ namespace Azure { namespace Data { namespace Test {
case AuthType::Key:
stringValue = "key";
break;
case AuthType::SAS:
stringValue = "sas_LIVEONLY_";
break;
default:
stringValue = "key";
break;
@ -684,9 +651,5 @@ namespace Azure { namespace Data { namespace Test {
return stringValue;
}
} // namespace
INSTANTIATE_TEST_SUITE_P(
Tables,
TablesClientTest,
::testing::Values(AuthType::Key, AuthType::SAS),
GetSuffix);
INSTANTIATE_TEST_SUITE_P(Tables, TablesClientTest, ::testing::Values(AuthType::Key), GetSuffix);
}}} // namespace Azure::Data::Test

View File

@ -10,8 +10,7 @@
namespace Azure { namespace Data { namespace Test {
enum class AuthType
{
Key = 0x0,
SAS = 0x1,
Key = 0x0
};
class TablesClientTest : public Azure::Storage::Test::StorageTest,