Use GetTestCredentials in eventhubs admin client; updated samples to allow sample execution to be disabled (#5799)

* Use GetTestCredentials in eventhubs admin client; updated samples to allow sample execution to be disabled

* Made sample execution optional

* re-enabled building keyvault samples

* Disabled RetrieveMultipleEvents test

* Disabled RetrieveMultipleEvents test

* Pull request feedback
This commit is contained in:
Larry Osterman 2024-07-16 10:29:54 -07:00 коммит произвёл GitHub
Родитель 7e9906f884
Коммит e19dc2371c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
29 изменённых файлов: 66 добавлений и 46 удалений

Просмотреть файл

@ -32,6 +32,20 @@ macro(create_per_service_target_build_for_sample service target)
if(CMAKE_GENERATOR MATCHES "Visual Studio.*")
SET(binary "Release/${binary}")
endif()
file(APPEND ${CMAKE_BINARY_DIR}/${service}-samples.txt "${CMAKE_CURRENT_BINARY_DIR}/${binary}\n")
set(RUN_SAMPLE TRUE)
if(${ARGC} GREATER 2)
set(extra_args "${ARGN}")
foreach(arg IN LISTS extra_args)
if (${arg} MATCHES "DISABLE_RUN")
set(RUN_SAMPLE FALSE)
message("Disabling sample execution for ${service}/${binary}")
else()
message(FATAL_ERROR "Unknown extra argument: ${arg}")
endif()
endforeach()
endif()
if (RUN_SAMPLE)
file(APPEND ${CMAKE_BINARY_DIR}/${service}-samples.txt "${CMAKE_CURRENT_BINARY_DIR}/${binary}\n")
endif()
endmacro()

Просмотреть файл

@ -15,7 +15,7 @@ add_executable (
attestation_collateral.cpp
attestation_collateral.hpp)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation get-env-helper)

Просмотреть файл

@ -12,7 +12,7 @@ add_executable (
attestation-${samplename}
${samplename}.cpp)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity get-env-helper)

Просмотреть файл

@ -14,7 +14,7 @@ add_executable (
cryptohelpers.hpp
)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation-${samplename} attestation)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation-${samplename} attestation DISABLE_RUN)
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity OpenSSL::Crypto get-env-helper)

Просмотреть файл

@ -14,7 +14,7 @@ add_executable (
cryptohelpers.hpp
)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(attestation attestation-${samplename} DISABLE_RUN)
target_link_libraries(attestation-${samplename} PRIVATE azure-security-attestation azure-identity get-env-helper)

Просмотреть файл

@ -12,7 +12,7 @@ add_executable (
eventhubs-${samplename}
${samplename}.cpp)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
endmacro()

Просмотреть файл

@ -12,7 +12,7 @@ add_executable (
eventhubs-${samplename}
${samplename}.cpp)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
endmacro()

Просмотреть файл

@ -12,7 +12,7 @@ add_executable (
eventhubs-${samplename}
${samplename}.cpp)
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename})
CREATE_PER_SERVICE_TARGET_BUILD_FOR_SAMPLE(eventhubs eventhubs-${samplename} DISABLE_RUN)
target_link_libraries(eventhubs-${samplename} PRIVATE azure-messaging-eventhubs azure-identity)
endmacro()

Просмотреть файл

@ -303,7 +303,7 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
return name;
}
TEST_P(ConsumerClientTest, RetrieveMultipleEvents)
TEST_P(ConsumerClientTest, DISABLED_RetrieveMultipleEvents)
{
// This test depends on being able to create a new eventhub instance, so skip it on the
// emulator.
@ -311,6 +311,8 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
{
GTEST_SKIP();
}
// Disabled test for now.
EventHubsManagement administrationClient;
auto eventhubNamespace{administrationClient.GetNamespace(GetEnv("EVENTHUBS_NAMESPACE"))};

Просмотреть файл

@ -9,7 +9,6 @@
#include <azure/core/internal/json/json.hpp>
#include <azure/core/platform.hpp>
#include <azure/core/response.hpp>
#include <azure/identity/default_azure_credential.hpp>
#include <memory>
#include <sstream>
@ -35,7 +34,7 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
tokenContext.Scopes = {"https://management.azure.com/.default"};
perRetrypolicies.emplace_back(
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
std::make_unique<Azure::Identity::DefaultAzureCredential>(), tokenContext));
GetTestCredential(), tokenContext));
}
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> perCallpolicies;
options.Telemetry.ApplicationId = "eventhubs.test";

Просмотреть файл

@ -5,13 +5,16 @@
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/internal/json/json.hpp>
#include <azure/core/operation.hpp>
#include <azure/core/test/test_base.hpp>
#include <string>
#include <vector>
namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
class EventHubsManagement {
// Derived from Azure::Core::Test::TestBase to get access to GetTestCredential, which has logic to
// add the pipeline credential when run in CI.
class EventHubsManagement : Azure::Core::Test::TestBase {
public:
enum class EventHubsPricingTier
{
@ -259,6 +262,8 @@ namespace Azure { namespace Messaging { namespace EventHubs { namespace Test {
Azure::Core::Context const& context = {});
private:
// Dummy test body to satisfy Azure::Core::Test::TestBase.
void TestBody() {}
std::string m_resourceGroup;
std::string m_location;
std::string m_subscriptionId;

Просмотреть файл

@ -31,22 +31,22 @@ target_link_libraries(workload_identity_credential_sample PRIVATE azure-identity
target_include_directories(workload_identity_credential_sample PRIVATE .)
create_per_service_target_build_for_sample(identity workload_identity_credential_sample)
#add_executable(client_secret_credential_sample client_secret_credential.cpp)
#target_link_libraries(client_secret_credential_sample PRIVATE azure-identity service get-env-helper)
#target_include_directories(client_secret_credential_sample PRIVATE .)
#create_per_service_target_build_for_sample(identity client_secret_credential_sample)
add_executable(client_secret_credential_sample client_secret_credential.cpp)
target_link_libraries(client_secret_credential_sample PRIVATE azure-identity service get-env-helper)
target_include_directories(client_secret_credential_sample PRIVATE .)
create_per_service_target_build_for_sample(identity client_secret_credential_sample DISABLE_RUN)
#add_executable(default_azure_credential_sample default_azure_credential.cpp)
#target_link_libraries(default_azure_credential_sample PRIVATE azure-identity service)
#target_include_directories(default_azure_credential_sample PRIVATE .)
#create_per_service_target_build_for_sample(identity default_azure_credential_sample)
add_executable(default_azure_credential_sample default_azure_credential.cpp)
target_link_libraries(default_azure_credential_sample PRIVATE azure-identity service)
target_include_directories(default_azure_credential_sample PRIVATE .)
create_per_service_target_build_for_sample(identity default_azure_credential_sample DISABLE_RUN)
#add_executable(environment_credential_sample environment_credential.cpp)
#target_link_libraries(environment_credential_sample PRIVATE azure-identity service)
#target_include_directories(environment_credential_sample PRIVATE .)
#create_per_service_target_build_for_sample(identity environment_credential_sample)
add_executable(environment_credential_sample environment_credential.cpp)
target_link_libraries(environment_credential_sample PRIVATE azure-identity service)
target_include_directories(environment_credential_sample PRIVATE .)
create_per_service_target_build_for_sample(identity environment_credential_sample DISABLE_RUN)
#add_executable(managed_identity_credential_sample managed_identity_credential.cpp)
#target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity service)
#target_include_directories(managed_identity_credential_sample PRIVATE .)
#create_per_service_target_build_for_sample(identity managed_identity_credential_sample)
add_executable(managed_identity_credential_sample managed_identity_credential.cpp)
target_link_libraries(managed_identity_credential_sample PRIVATE azure-identity service)
target_include_directories(managed_identity_credential_sample PRIVATE .)
create_per_service_target_build_for_sample(identity managed_identity_credential_sample DISABLE_RUN)

Просмотреть файл

@ -117,7 +117,7 @@ if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()
if(BUILD_SAMPLES_DISABLED)
if(BUILD_SAMPLES)
add_subdirectory(samples)
endif()

Просмотреть файл

@ -12,6 +12,6 @@ add_executable (
certificate_basic_operations.cpp
)
create_per_service_target_build_for_sample(keyvault certificate-basic-operations)
create_per_service_target_build_for_sample(keyvault certificate-basic-operations DISABLE_RUN)
target_link_libraries(certificate-basic-operations PRIVATE azure-security-keyvault-certificates azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
certificate-get-certificates
certificate_get_certificates.cpp
)
create_per_service_target_build_for_sample(keyvault certificate-get-certificates)
create_per_service_target_build_for_sample(keyvault certificate-get-certificates DISABLE_RUN)
target_link_libraries(certificate-get-certificates PRIVATE azure-security-keyvault-certificates azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
certificate-import-certificate
certificate_import_certificate.cpp
)
create_per_service_target_build_for_sample(keyvault certificate-import-certificate)
create_per_service_target_build_for_sample(keyvault certificate-import-certificate DISABLE_RUN)
target_link_libraries(certificate-import-certificate PRIVATE azure-security-keyvault-certificates azure-identity get-env-helper)

Просмотреть файл

@ -154,7 +154,7 @@ if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()
if(BUILD_SAMPLES_DISABLED)
if(BUILD_SAMPLES)
add_subdirectory(samples)
endif()

Просмотреть файл

@ -12,6 +12,6 @@ add_executable (
sample1_hello_world.cpp
)
create_per_service_target_build_for_sample(keyvault sample1-hello-world)
create_per_service_target_build_for_sample(keyvault sample1-hello-world DISABLE_RUN)
target_link_libraries(sample1-hello-world PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample2-backup-and-restore
sample2_backup_and_restore.cpp
)
create_per_service_target_build_for_sample(keyvault sample2-backup-and-restore)
create_per_service_target_build_for_sample(keyvault sample2-backup-and-restore DISABLE_RUN)
target_link_libraries(sample2-backup-and-restore PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample3-get-keys
sample3_get_keys.cpp
)
create_per_service_target_build_for_sample(keyvault sample3-get-keys)
create_per_service_target_build_for_sample(keyvault sample3-get-keys DISABLE_RUN)
target_link_libraries(sample3-get-keys PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample4-encrypt-decrypt
sample4_encrypt_decrypt.cpp
)
create_per_service_target_build_for_sample(keyvault sample4-encrypt-decrypt)
create_per_service_target_build_for_sample(keyvault sample4-encrypt-decrypt DISABLE_RUN)
target_link_libraries(sample4-encrypt-decrypt PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample5-sign-verify
sample5_sign_verify.cpp
)
create_per_service_target_build_for_sample(keyvault sample5-sign-verify)
create_per_service_target_build_for_sample(keyvault sample5-sign-verify DISABLE_RUN)
target_link_libraries(sample5-sign-verify PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample6-wrap-unwrap
sample6_wrap_unwrap.cpp
)
create_per_service_target_build_for_sample(keyvault sample6-wrap-unwrap)
create_per_service_target_build_for_sample(keyvault sample6-wrap-unwrap DISABLE_RUN)
target_link_libraries(sample6-wrap-unwrap PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample7-key-rotation
sample7_key_rotation.cpp
)
create_per_service_target_build_for_sample(keyvault sample7-key-rotation)
create_per_service_target_build_for_sample(keyvault sample7-key-rotation DISABLE_RUN)
target_link_libraries(sample7-key-rotation PRIVATE azure-security-keyvault-keys azure-identity get-env-helper)

Просмотреть файл

@ -117,7 +117,7 @@ if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(test/perf)
endif()
if(BUILD_SAMPLES_DISABLED)
if(BUILD_SAMPLES)
add_subdirectory(samples)
endif()

Просмотреть файл

@ -11,6 +11,6 @@ add_executable (
sample1-basic-operations
sample1_basic_operations.cpp
)
create_per_service_target_build_for_sample(keyvault sample1-basic-operations)
create_per_service_target_build_for_sample(keyvault sample1-basic-operations DISABLE_RUN)
target_link_libraries(sample1-basic-operations PRIVATE azure-security-keyvault-secrets azure-identity get-env-helper)

Просмотреть файл

@ -12,6 +12,6 @@ add_executable (
sample2_backup_restore.cpp
)
create_per_service_target_build_for_sample(keyvault sample2-backup-restore)
create_per_service_target_build_for_sample(keyvault sample2-backup-restore DISABLE_RUN)
target_link_libraries(sample2-backup-restore PRIVATE azure-security-keyvault-secrets azure-identity get-env-helper)

Просмотреть файл

@ -12,6 +12,6 @@ add_executable (
sample3_delete_recover.cpp
)
create_per_service_target_build_for_sample(keyvault sample3-delete-recover)
create_per_service_target_build_for_sample(keyvault sample3-delete-recover DISABLE_RUN)
target_link_libraries(sample3-delete-recover PRIVATE azure-security-keyvault-secrets azure-identity get-env-helper)

Просмотреть файл

@ -12,6 +12,6 @@ add_executable (
sample4_get_secrets_deleted.cpp
)
create_per_service_target_build_for_sample(keyvault sample4-get-secrets-deleted)
create_per_service_target_build_for_sample(keyvault sample4-get-secrets-deleted DISABLE_RUN)
target_link_libraries(sample4-get-secrets-deleted PRIVATE azure-security-keyvault-secrets azure-identity get-env-helper)