Revert commits related to _azure_BUILD_FOR_TESTING and _azure_*_FOR_TESTS (#5416)
* Revert "Remove the use of ifdef for TESTING_BUILD in KeyVault clients, where (#5406)" This reverts commit2d8c940f55. * Revert "Rename the TESTING_BUILD macro to be _azure_TESTING_BUILD to highlight (#5390)" This reverts commit256c2df8b5. * Revert "Use new macros in existing surface area, so that classes marked as final don't have virtual methods. (#5389)" This reverts commit3d7eaddb9d. * Revert "For new surface area, classes marked as final should not have virtual methods. (#5331)" This reverts commitddd0f4bd07. --------- Co-authored-by: Anton Kolesnyk <antkmsft@users.noreply.github.com>
This commit is contained in:
parent
87036bc05e
commit
aad2299dcd
@ -26,14 +26,6 @@ function(generate_documentation PROJECT_NAME PROJECT_VERSION)
|
||||
# classes and enums directly into the documentation.
|
||||
set(DOXYGEN_INLINE_SOURCES NO)
|
||||
set(DOXYGEN_MARKDOWN_ID_STYLE GITHUB)
|
||||
# Used to correctly expand macros like _azure_NON_FINAL_FOR_TESTS when generating docs.
|
||||
# Using EXPAND_ONLY_PREDEF to limit macro expansion to the macros specified with the PREDEFINED tags.
|
||||
set(DOXYGEN_MACRO_EXPANSION YES)
|
||||
set(EXPAND_ONLY_PREDEF YES)
|
||||
set(DOXYGEN_PREDEFINED
|
||||
_azure_NON_FINAL_FOR_TESTS=final
|
||||
_azure_VIRTUAL_FOR_TESTS=
|
||||
)
|
||||
# Skip generating docs for json, test, samples, and private files.
|
||||
set(DOXYGEN_EXCLUDE_PATTERNS
|
||||
json.hpp
|
||||
|
||||
@ -192,7 +192,7 @@ az_rtti_setup(
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
if (NOT AZ_ALL_LIBRARIES)
|
||||
include(AddGoogleTest)
|
||||
|
||||
@ -37,7 +37,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
Jwt,
|
||||
};
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
/** @brief Implementation of AMQP 1.0 Claims-based Security (CBS) protocol.
|
||||
*
|
||||
* This class allows AMQP clients to implement the CBS protocol for authentication and
|
||||
@ -74,5 +74,5 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
private:
|
||||
std::shared_ptr<ClaimsBasedSecurityImpl> m_impl;
|
||||
};
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
}}}} // namespace Azure::Core::Amqp::_detail
|
||||
|
||||
@ -21,7 +21,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
class ConnectionFactory;
|
||||
}}}} // namespace Azure::Core::Amqp::_detail
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// Define the test classes dependant on this class here.
|
||||
namespace Azure { namespace Core { namespace Amqp { namespace Tests {
|
||||
namespace MessageTests {
|
||||
@ -44,7 +44,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Tests {
|
||||
class TestMessages_ReceiverReceiveAsync_Test;
|
||||
|
||||
}}}} // namespace Azure::Core::Amqp::Tests
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
#if defined(SAMPLES_BUILD)
|
||||
namespace LocalServerSample {
|
||||
int LocalServerSampleMain();
|
||||
@ -452,7 +452,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal {
|
||||
|
||||
std::shared_ptr<_detail::ConnectionImpl> m_impl;
|
||||
friend class _detail::ConnectionFactory;
|
||||
#if _azure_TESTING_BUILD
|
||||
#if TESTING_BUILD
|
||||
friend class Azure::Core::Amqp::Tests::MessageTests::AmqpServerMock;
|
||||
friend class Azure::Core::Amqp::Tests::MessageTests::MessageListenerEvents;
|
||||
friend class Azure::Core::Amqp::Tests::TestSocketListenerEvents;
|
||||
@ -467,7 +467,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal {
|
||||
friend class Azure::Core::Amqp::Tests::TestMessages_SenderSendAsync_Test;
|
||||
friend class Azure::Core::Amqp::Tests::TestMessages_SenderOpenClose_Test;
|
||||
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
#if SAMPLES_BUILD
|
||||
friend int LocalServerSample::LocalServerSampleMain();
|
||||
#endif // SAMPLES_BUILD
|
||||
|
||||
@ -70,7 +70,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
class LinkEvents {
|
||||
public:
|
||||
virtual Models::AmqpValue OnTransferReceived(
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
Link const& link,
|
||||
#else
|
||||
std::shared_ptr<LinkImpl> link,
|
||||
@ -80,7 +80,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
const unsigned char* payloadBytes)
|
||||
= 0;
|
||||
virtual void OnLinkStateChanged(
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
Link const& link,
|
||||
#else
|
||||
std::shared_ptr<LinkImpl> link,
|
||||
@ -89,7 +89,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
LinkState previousLinkState)
|
||||
= 0;
|
||||
virtual void OnLinkFlowOn(
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
Link const& link
|
||||
#else
|
||||
std::shared_ptr<LinkImpl> link
|
||||
@ -99,7 +99,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
virtual ~LinkEvents() = default;
|
||||
};
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
|
||||
class Link final {
|
||||
public:
|
||||
@ -172,5 +172,5 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
|
||||
std::shared_ptr<LinkImpl> m_impl;
|
||||
};
|
||||
#endif // defined(_azure_TESTING_BUILD)
|
||||
#endif // defined(TESTING_BUILD)
|
||||
}}}} // namespace Azure::Core::Amqp::_detail
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// Define the test classes dependant on this class here.
|
||||
namespace Azure { namespace Core { namespace Amqp { namespace Tests {
|
||||
namespace MessageTests {
|
||||
@ -34,7 +34,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace Tests {
|
||||
class LinkSocketListenerEvents;
|
||||
class TestMessages_SenderSendAsync_Test;
|
||||
}}}} // namespace Azure::Core::Amqp::Tests
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
#if defined(SAMPLES_BUILD)
|
||||
namespace LocalServerSample {
|
||||
class SampleEvents;
|
||||
@ -245,7 +245,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal {
|
||||
|
||||
friend class _detail::SessionFactory;
|
||||
|
||||
#if _azure_TESTING_BUILD
|
||||
#if TESTING_BUILD
|
||||
friend class Azure::Core::Amqp::Tests::MessageTests::AmqpServerMock;
|
||||
friend class Azure::Core::Amqp::Tests::MessageTests::MockServiceEndpoint;
|
||||
friend class Azure::Core::Amqp::Tests::MessageTests::MessageListenerEvents;
|
||||
@ -258,7 +258,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _internal {
|
||||
friend class Azure::Core::Amqp::Tests::TestLinks_LinkAttachDetach_Test;
|
||||
|
||||
friend class Azure::Core::Amqp::Tests::TestMessages_SenderSendAsync_Test;
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
#if SAMPLES_BUILD
|
||||
friend class LocalServerSample::SampleEvents;
|
||||
#endif // SAMPLES_BUILD
|
||||
|
||||
@ -16,7 +16,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
using namespace Azure::Core::Amqp::_internal;
|
||||
|
||||
// The non-Impl types for CBS exist only for testing purposes.
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
ClaimsBasedSecurity::ClaimsBasedSecurity(Session const& session)
|
||||
: m_impl{std::make_shared<_detail::ClaimsBasedSecurityImpl>(SessionFactory::GetImpl(session))}
|
||||
{
|
||||
@ -37,7 +37,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
return m_impl->PutToken(tokenType, audience, token, context);
|
||||
}
|
||||
|
||||
#endif // _azure_TESTING_BUILD
|
||||
#endif // TESTING_BUILD
|
||||
|
||||
ClaimsBasedSecurityImpl::ClaimsBasedSecurityImpl(std::shared_ptr<_detail::SessionImpl> session)
|
||||
: m_session{session}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
#include <azure_uamqp_c/link.h>
|
||||
|
||||
namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
Link::Link(
|
||||
_internal::Session const& session,
|
||||
std::string const& name,
|
||||
@ -475,7 +475,7 @@ namespace Azure { namespace Core { namespace Amqp { namespace _detail {
|
||||
{
|
||||
|
||||
return Models::_detail::AmqpValueFactory::ToUamqp(link->m_eventHandler->OnTransferReceived(
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
Link{link->shared_from_this()},
|
||||
#else
|
||||
link->shared_from_this(),
|
||||
|
||||
@ -96,7 +96,7 @@ endif()
|
||||
|
||||
if(BUILD_AZURE_CORE_TRACING_OPENTELEMETRY AND BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
if (NOT AZ_ALL_LIBRARIES)
|
||||
include(AddGoogleTest)
|
||||
|
||||
@ -96,7 +96,6 @@ set(
|
||||
inc/azure/core/internal/json/json_optional.hpp
|
||||
inc/azure/core/internal/json/json_serializable.hpp
|
||||
inc/azure/core/internal/strings.hpp
|
||||
inc/azure/core/internal/test_hooks.hpp
|
||||
inc/azure/core/internal/tracing/service_tracing.hpp
|
||||
inc/azure/core/internal/tracing/tracing_impl.hpp
|
||||
inc/azure/core/internal/unique_handle.hpp
|
||||
@ -205,7 +204,7 @@ az_rtti_setup(
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
if (NOT AZ_ALL_LIBRARIES)
|
||||
include(AddGoogleTest)
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// Define the class used from tests to validate retry enabled
|
||||
namespace Azure { namespace Core { namespace Test {
|
||||
class TestHttp_getters_Test;
|
||||
@ -181,7 +181,7 @@ namespace Azure { namespace Core { namespace Http {
|
||||
*/
|
||||
class Request final {
|
||||
friend class Azure::Core::Http::Policies::_internal::RetryPolicy;
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// make tests classes friends to validate set Retry
|
||||
friend class Azure::Core::Test::TestHttp_getters_Test;
|
||||
friend class Azure::Core::Test::TestHttp_query_parameter_Test;
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "azure/core/http/transport.hpp"
|
||||
#include "azure/core/internal/http/http_sanitizer.hpp"
|
||||
#include "azure/core/internal/http/user_agent.hpp"
|
||||
#include "azure/core/internal/test_hooks.hpp"
|
||||
#include "azure/core/uuid.hpp"
|
||||
|
||||
#include <atomic>
|
||||
@ -31,14 +30,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
// Define the class used from tests to validate retry policy
|
||||
namespace Azure { namespace Core { namespace Test {
|
||||
class RetryPolicyTest;
|
||||
class RetryLogic;
|
||||
}}} // namespace Azure::Core::Test
|
||||
#endif
|
||||
|
||||
/**
|
||||
* A function that should be implemented and linked to the end-user application in order to override
|
||||
* an HTTP transport implementation provided by Azure SDK with custom implementation.
|
||||
@ -372,13 +363,11 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
|
||||
/**
|
||||
* @brief HTTP retry policy.
|
||||
*/
|
||||
class RetryPolicy _azure_NON_FINAL_FOR_TESTS : public HttpPolicy {
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
friend class Azure::Core::Test::RetryPolicyTest;
|
||||
friend class Azure::Core::Test::RetryLogic;
|
||||
class RetryPolicy
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
|
||||
: public HttpPolicy {
|
||||
private:
|
||||
RetryOptions m_retryOptions;
|
||||
|
||||
@ -413,14 +402,14 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
|
||||
*/
|
||||
static int32_t GetRetryCount(Context const& context);
|
||||
|
||||
private:
|
||||
_azure_VIRTUAL_FOR_TESTS bool ShouldRetryOnTransportFailure(
|
||||
protected:
|
||||
virtual bool ShouldRetryOnTransportFailure(
|
||||
RetryOptions const& retryOptions,
|
||||
int32_t attempt,
|
||||
std::chrono::milliseconds& retryAfter,
|
||||
double jitterFactor = -1) const;
|
||||
|
||||
_azure_VIRTUAL_FOR_TESTS bool ShouldRetryOnResponse(
|
||||
virtual bool ShouldRetryOnResponse(
|
||||
RawResponse const& response,
|
||||
RetryOptions const& retryOptions,
|
||||
int32_t attempt,
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief This file is used to define internal-only macros that are used to control the behavior of
|
||||
* the Azure SDK when running tests, to allow mocking within tests.
|
||||
* The macros in this file should NOT be used by anyone outside this repo.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// When testing is enabled, we want to make sure that certain classes are not final, so that we can
|
||||
// mock it.
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
|
||||
/**
|
||||
* @brief If we are testing, we want to make sure that classes are not final, by default.
|
||||
*/
|
||||
#if !defined(_azure_NON_FINAL_FOR_TESTS)
|
||||
#define _azure_NON_FINAL_FOR_TESTS
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief If we are testing, we want to make sure methods can be made virtual, for mocking.
|
||||
*/
|
||||
#if !defined(_azure_VIRTUAL_FOR_TESTS)
|
||||
#define _azure_VIRTUAL_FOR_TESTS virtual
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* @brief If we are not testing, we want to make sure that classes are final, by default.
|
||||
*/
|
||||
#if !defined(_azure_NON_FINAL_FOR_TESTS)
|
||||
#define _azure_NON_FINAL_FOR_TESTS final
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief If we are not testing, we don't need to make methods virtual for mocking.
|
||||
*/
|
||||
#if !defined(_azure_VIRTUAL_FOR_TESTS)
|
||||
#define _azure_VIRTUAL_FOR_TESTS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -23,7 +23,7 @@
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// Define the class name that reads from ConnectionPool private members
|
||||
namespace Azure { namespace Core { namespace Test {
|
||||
class CurlConnectionPool_connectionPoolTest_Test;
|
||||
@ -43,7 +43,7 @@ namespace Azure { namespace Core { namespace Http { namespace _detail {
|
||||
* connection pool per application.
|
||||
*/
|
||||
class CurlConnectionPool final {
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// Give access to private to this tests class
|
||||
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
|
||||
friend class Azure::Core::Test::CurlConnectionPool_uniquePort_Test;
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#ifdef _azure_TESTING_BUILD
|
||||
#ifdef TESTING_BUILD
|
||||
// Define the class name that reads from ConnectionPool private members
|
||||
namespace Azure { namespace Core { namespace Test {
|
||||
class CurlConnectionPool_connectionPoolTest_Test;
|
||||
@ -40,7 +40,7 @@ namespace Azure { namespace Core { namespace Http {
|
||||
* transporter to be reusable in multiple pipelines while every call to network is unique.
|
||||
*/
|
||||
class CurlSession final : public Azure::Core::IO::BodyStream {
|
||||
#ifdef _azure_TESTING_BUILD
|
||||
#ifdef TESTING_BUILD
|
||||
// Give access to private to this tests class
|
||||
friend class Azure::Core::Test::CurlConnectionPool_connectionPoolTest_Test;
|
||||
friend class Azure::Core::Test::SdkWithLibcurl_DISABLED_globalCleanUp_Test;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -126,7 +126,7 @@ az_rtti_setup(
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
# tests
|
||||
if (NOT AZ_ALL_LIBRARIES OR FETCH_SOURCE_DEPS)
|
||||
|
||||
@ -13,18 +13,11 @@
|
||||
#include <azure/core/credentials/credentials.hpp>
|
||||
#include <azure/core/credentials/token_credential_options.hpp>
|
||||
#include <azure/core/datetime.hpp>
|
||||
#include <azure/core/internal/test_hooks.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
namespace Azure { namespace Identity { namespace Test {
|
||||
class AzureCliTestCredential;
|
||||
}}} // namespace Azure::Identity::Test
|
||||
#endif
|
||||
|
||||
namespace Azure { namespace Identity {
|
||||
/**
|
||||
* @brief Options for configuring the #Azure::Identity::AzureCliCredential.
|
||||
@ -56,12 +49,11 @@ namespace Azure { namespace Identity {
|
||||
* @brief Enables authentication to Microsoft Entra ID using Azure CLI to obtain an access
|
||||
* token.
|
||||
*/
|
||||
class AzureCliCredential _azure_NON_FINAL_FOR_TESTS : public Core::Credentials::TokenCredential {
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
friend class Azure::Identity::Test::AzureCliTestCredential;
|
||||
class AzureCliCredential
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
|
||||
: public Core::Credentials::TokenCredential {
|
||||
protected:
|
||||
/** @brief The cache for the access token. */
|
||||
_detail::TokenCache m_tokenCache;
|
||||
@ -114,12 +106,13 @@ namespace Azure { namespace Identity {
|
||||
Core::Credentials::TokenRequestContext const& tokenRequestContext,
|
||||
Core::Context const& context) const override;
|
||||
|
||||
#if !defined(TESTING_BUILD)
|
||||
private:
|
||||
_azure_VIRTUAL_FOR_TESTS std::string GetAzCommand(
|
||||
std::string const& scopes,
|
||||
std::string const& tenantId) const;
|
||||
|
||||
_azure_VIRTUAL_FOR_TESTS int GetLocalTimeToUtcDiffSeconds() const;
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
virtual std::string GetAzCommand(std::string const& scopes, std::string const& tenantId) const;
|
||||
virtual int GetLocalTimeToUtcDiffSeconds() const;
|
||||
};
|
||||
|
||||
}} // namespace Azure::Identity
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
class DefaultAzureCredential_CachingCredential_Test;
|
||||
#endif
|
||||
|
||||
@ -42,7 +42,7 @@ namespace Azure { namespace Identity {
|
||||
*/
|
||||
class DefaultAzureCredential final : public Core::Credentials::TokenCredential {
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// make tests classes friends to validate caching
|
||||
friend class ::DefaultAzureCredential_CachingCredential_Test;
|
||||
#endif
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <azure/core/credentials/credentials.hpp>
|
||||
#include <azure/core/internal/test_hooks.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@ -20,30 +19,26 @@
|
||||
#include <string>
|
||||
#include <tuple>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
// Define the class used from tests to validate retry policy
|
||||
namespace Azure { namespace Identity { namespace Test {
|
||||
class TestableTokenCache;
|
||||
}}} // namespace Azure::Identity::Test
|
||||
#endif
|
||||
|
||||
namespace Azure { namespace Identity { namespace _detail {
|
||||
/**
|
||||
* @brief Access token cache.
|
||||
*
|
||||
*/
|
||||
class TokenCache _azure_NON_FINAL_FOR_TESTS {
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
friend class Azure::Identity::Test::TestableTokenCache;
|
||||
class TokenCache
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
|
||||
{
|
||||
#if !defined(TESTING_BUILD)
|
||||
private:
|
||||
#else
|
||||
protected:
|
||||
#endif
|
||||
// A test hook that gets invoked before cache write lock gets acquired.
|
||||
_azure_VIRTUAL_FOR_TESTS void OnBeforeCacheWriteLock() const {};
|
||||
virtual void OnBeforeCacheWriteLock() const {};
|
||||
|
||||
// A test hook that gets invoked before item write lock gets acquired.
|
||||
_azure_VIRTUAL_FOR_TESTS void OnBeforeItemWriteLock() const {};
|
||||
virtual void OnBeforeItemWriteLock() const {};
|
||||
|
||||
struct CacheKey
|
||||
{
|
||||
@ -68,6 +63,7 @@ namespace Azure { namespace Identity { namespace _detail {
|
||||
mutable std::map<CacheKey, std::shared_ptr<CacheValue>, CacheKeyComparator> m_cache;
|
||||
mutable std::shared_timed_mutex m_cacheMutex;
|
||||
|
||||
private:
|
||||
TokenCache(TokenCache const&) = delete;
|
||||
TokenCache& operator=(TokenCache const&) = delete;
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
#include <limits>
|
||||
#include <mutex>
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
class DefaultAzureCredential_CachingCredential_Test;
|
||||
#endif
|
||||
|
||||
@ -17,7 +17,7 @@ namespace Azure { namespace Identity { namespace _detail {
|
||||
|
||||
class ChainedTokenCredentialImpl final {
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
// make tests classes friends to validate caching
|
||||
friend class ::DefaultAzureCredential_CachingCredential_Test;
|
||||
#endif
|
||||
|
||||
@ -39,7 +39,7 @@ std::shared_ptr<TokenCache::CacheValue> TokenCache::GetOrCreateValue(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
OnBeforeCacheWriteLock();
|
||||
#endif
|
||||
|
||||
@ -101,7 +101,7 @@ AccessToken TokenCache::GetToken(
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
OnBeforeItemWriteLock();
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
endif()
|
||||
|
||||
add_subdirectory(azure-security-keyvault-keys)
|
||||
|
||||
@ -102,7 +102,7 @@ generate_documentation(azure-security-keyvault-certificates ${AZ_LIBRARY_VERSION
|
||||
|
||||
if(BUILD_TESTING)
|
||||
# define a symbol that enables some test hooks in code
|
||||
add_compile_definitions(_azure_TESTING_BUILD)
|
||||
add_compile_definitions(TESTING_BUILD)
|
||||
|
||||
if (NOT AZ_ALL_LIBRARIES OR FETCH_SOURCE_DEPS)
|
||||
include(AddGoogleTest)
|
||||
|
||||
@ -16,14 +16,13 @@
|
||||
#include <azure/core/context.hpp>
|
||||
#include <azure/core/http/http.hpp>
|
||||
#include <azure/core/internal/http/pipeline.hpp>
|
||||
#include <azure/core/internal/test_hooks.hpp>
|
||||
#include <azure/core/response.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace Azure { namespace Security { namespace KeyVault { namespace Certificates {
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
namespace Test {
|
||||
class KeyVaultCertificateClientTest;
|
||||
}
|
||||
@ -34,10 +33,14 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
|
||||
*
|
||||
* @details The client supports retrieving KeyVaultCertificate.
|
||||
*/
|
||||
class CertificateClient final {
|
||||
class CertificateClient
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
{
|
||||
friend class CreateCertificateOperation;
|
||||
|
||||
#if defined(_azure_TESTING_BUILD)
|
||||
#if defined(TESTING_BUILD)
|
||||
friend class Test::KeyVaultCertificateClientTest;
|
||||
#endif
|
||||
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
#include <azure/core/credentials/credentials.hpp>
|
||||
#include <azure/core/http/http.hpp>
|
||||
#include <azure/core/internal/http/pipeline.hpp>
|
||||
#include <azure/core/internal/test_hooks.hpp>
|
||||
#include <azure/core/io/body_stream.hpp>
|
||||
#include <azure/core/response.hpp>
|
||||
|
||||
@ -35,7 +34,11 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Keys {
|
||||
* Vault. The client supports creating, retrieving, updating, deleting, purging, backing up,
|
||||
* restoring, and listing the KeyVaultKey.
|
||||
*/
|
||||
class KeyClient _azure_NON_FINAL_FOR_TESTS {
|
||||
class KeyClient
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
{
|
||||
protected:
|
||||
// Using a shared pipeline for a client to share it with LRO (like delete key)
|
||||
/** @brief the base URL for this keyvault instance. */
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
|
||||
#include <azure/core/http/http.hpp>
|
||||
#include <azure/core/internal/http/pipeline.hpp>
|
||||
#include <azure/core/internal/test_hooks.hpp>
|
||||
#include <azure/core/response.hpp>
|
||||
|
||||
#include <stdint.h>
|
||||
@ -43,7 +42,11 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Secrets {
|
||||
* Vault. The client supports creating, retrieving, updating, deleting, purging, backing up,
|
||||
* restoring, and listing the secret.
|
||||
*/
|
||||
class SecretClient final {
|
||||
class SecretClient
|
||||
#if !defined(TESTING_BUILD)
|
||||
final
|
||||
#endif
|
||||
{
|
||||
|
||||
private:
|
||||
// Using a shared pipeline for a client to share it with LRO (like delete key)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user