Settings API (#4210)

* skeletor

* client

* rework

* all works plus test

* sample , self pr

* tests

* clang

* Mind your language .. Sir ...

* comments

* removed preprocessor directives

* removed template class

* dll clang

* Rick PR
This commit is contained in:
George Arama 2023-01-11 10:55:15 -08:00 committed by GitHub
parent a34b8d19a5
commit efee11268e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 1372 additions and 2 deletions

View File

@ -15,3 +15,4 @@ endif()
add_subdirectory(azure-security-keyvault-keys)
add_subdirectory(azure-security-keyvault-secrets)
add_subdirectory(azure-security-keyvault-certificates)
add_subdirectory(azure-security-keyvault-administration)

View File

@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "cpp",
"TagPrefix": "cpp/keyvault",
"Tag": "cpp/keyvault_090bae9bd9"
"Tag": "cpp/keyvault_5a151033a9"
}

View File

@ -0,0 +1,5 @@
# Release History
## 4.0.0-beta.1 (Unreleased)
- initial preview

View File

@ -0,0 +1,122 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
# setting CMAKE_TOOLCHAIN_FILE must happen before creating the project
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules")
include(AzureVcpkg)
az_vcpkg_integrate()
cmake_minimum_required (VERSION 3.13)
project(azure-security-keyvault-administration LANGUAGES CXX)
# Compile Options
option(FETCH_SOURCE_DEPS "build source dependencies" OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(FETCH_SOURCE_DEPS)
set(AZ_ALL_LIBRARIES ON)
include(FolderList)
SetCompileOptions(ADMINISTRATION)
endif()
include(AzureVersion)
include(AzureCodeCoverage)
include(AzureTransportAdapters)
include(AzureDoxygen)
include(AzureGlobalCompileOptions)
include(AzureConfigRTTI)
include(AzureBuildTargetForCI)
# Add create_map_file function
include(CreateMapFile)
if(FETCH_SOURCE_DEPS)
GetFolderList(ADMINISTRATION)
foreach(oneFolder IN LISTS BUILD_FOLDERS)
message("add folder ${oneFolder}")
add_subdirectory(${oneFolder})
endforeach()
elseif(NOT AZ_ALL_LIBRARIES)
find_package(azure-core-cpp "1.5.0" CONFIG QUIET)
if(NOT azure-core-cpp_FOUND)
find_package(azure-core-cpp "1.5.0" REQUIRED)
endif()
endif()
set(
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_HEADER
inc/azure/keyvault/administration.hpp
inc/azure/keyvault/administration/dll_import_export.hpp
inc/azure/keyvault/administration/rest_client.hpp
inc/azure/keyvault/administration/rtti.hpp
inc/azure/keyvault/administration/settings_client.hpp
inc/azure/keyvault/administration/settings_client_options.hpp
src/private/keyvault_settings_common_request.hpp
src/private/administration_constants.hpp
)
set(
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_SOURCE
src/keyvault_settings_common_request.cpp
src/settings_client.cpp
)
add_library(azure-security-keyvault-administration ${AZURE_SECURITY_KEYVAULT_ADMINISTRATION_HEADER} ${AZURE_SECURITY_KEYVAULT_ADMINISTRATION_SOURCE})
add_library(Azure::azure-security-keyvault-administration ALIAS azure-security-keyvault-administration)
create_per_service_target_build(keyvault azure-security-keyvault-administration)
target_include_directories(
azure-security-keyvault-administration
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<INSTALL_INTERFACE:include>
)
# Include shared source code
# NOTE: Use shared-code only within .cpp files. DO NEVER consume the shared-code from header files.
target_include_directories(
azure-security-keyvault-administration
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../azure-security-keyvault-shared/inc>
)
target_link_libraries(azure-security-keyvault-administration PUBLIC Azure::azure-core)
# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(keyvault azure-security-keyvault-administration azure-security-keyvault-administration-test "tests?/*;samples?/*")
get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-security-keyvault-administration ${AZ_LIBRARY_VERSION})
if(BUILD_TESTING)
if (NOT AZ_ALL_LIBRARIES OR FETCH_SOURCE_DEPS)
include(AddGoogleTest)
enable_testing ()
endif()
add_subdirectory(test/ut)
endif()
if (BUILD_PERFORMANCE_TESTS)
#add_subdirectory(test/perf)
endif()
if(BUILD_SAMPLES)
add_subdirectory(test/samples)
endif()
az_vcpkg_export(
azure-security-keyvault-administration
SECURITY_KEYVAULT_ADMINISTRATION
azure/keyvault/administration/dll_import_export.hpp
)
az_rtti_setup(
azure-security-keyvault-administration
SECURITY_KEYVAULT_ADMINISTRATION
azure/keyvault/administration/rtti.hpp
)
unset(FETCH_SOURCE_DEPS CACHE)

View File

@ -0,0 +1,32 @@
azure-security-keyvault-administration
NOTICES AND INFORMATION
Do Not Translate or Localize
This software incorporates material from third parties. Microsoft makes certain
open source code available at https://3rdpartysource.microsoft.com, or you may
send a check or money order for US $5.00, including the product name, the open
source component name, and version number, to:
Source Code Compliance Team
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052
USA
Notwithstanding any other terms, you may reverse engineer this software to the
extent required to debug changes to any libraries licensed under the GNU Lesser
General Public License.
------------------------------------------------------------------------------
Azure SDK for C++ uses third-party libraries or other resources that may be
distributed under licenses different than the Azure SDK for C++ software.
In the event that we accidentally failed to list a required notice, please
bring it to our attention. Post an issue or email us:
azcppsdkhelp@microsoft.com
The attached notices are provided for information only.

View File

@ -0,0 +1,50 @@
# Azure Security KeyVault Administration client library for C++
Azure Security Keyvault Administration Package client library for C++ (`azure-security-keyvault-administration`) matches necessary patterns that the development team has established to create a unified SDK written in the C++ programming language. These libraries follow the Azure SDK Design Guidelines for C++.
The library allows client libraries to expose common functionality in a consistent fashion. Once you learn how to use these APIs in one client library, you will know how to use them in other client libraries.
[Source code][administration_client_src] | [API reference documentation][api_reference] | [Product documentation][keyvault_docs]
## Contributing
For details on contributing to this repository, see the [contributing guide][azure_sdk_for_cpp_contributing].
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit the [Contributor License Agreement](https://cla.microsoft.com).
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
### Additional Helpful Links for Contributors
Many people all over the world have helped make this project better. You'll want to check out:
* [What are some good first issues for new contributors to the repo?](https://github.com/azure/azure-sdk-for-cpp/issues?q=is%3Aopen+is%3Aissue+label%3A%22up+for+grabs%22)
* [How to build and test your change][azure_sdk_for_cpp_contributing_developer_guide]
* [How you can make a change happen!][azure_sdk_for_cpp_contributing_pull_requests]
* Frequently Asked Questions (FAQ) and Conceptual Topics in the detailed [Azure SDK for C++ wiki](https://github.com/azure/azure-sdk-for-cpp/wiki).
<!-- ### Community-->
### Reporting security issues and security bugs
Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) <secure@microsoft.com>. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://www.microsoft.com/msrc/faqs-report-an-issue).
### License
Azure SDK for C++ is licensed under the [MIT](https://github.com/Azure/azure-sdk-for-cpp/blob/main/LICENSE.txt) license.
<!-- LINKS -->
[azure_sdk_for_cpp_contributing]: https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md
[azure_sdk_for_cpp_contributing_developer_guide]: https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#developer-guide
[azure_sdk_for_cpp_contributing_pull_requests]: https://github.com/Azure/azure-sdk-for-cpp/blob/main/CONTRIBUTING.md#pull-requests
[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[api_reference]: https://azure.github.io/azure-sdk-for-cpp/keyvault.html
[administration_client_src]: https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-administration
[keyvault_docs]: https://docs.microsoft.com/azure/key-vault/

View File

@ -0,0 +1,37 @@
{
"$schema": "https://json.schemastore.org/component-detection-manifest.json",
"Registrations": [
{
"Component": {
"Type": "git",
"git": {
"RepositoryUrl": "https://github.com/google/googletest",
"CommitHash": "703bd9caab50b139428cea1aaff9974ebee5742e"
}
},
"DevelopmentDependency": true
},
{
"Component": {
"Type": "other",
"Other": {
"Name": "clang-format",
"Version": "9.0.0-2",
"DownloadUrl": "https://ubuntu.pkgs.org/18.04/ubuntu-updates-universe-amd64/clang-format-9_9-2~ubuntu18.04.2_amd64.deb.html"
}
},
"DevelopmentDependency": true
},
{
"Component": {
"Type": "other",
"Other": {
"Name": "doxygen",
"Version": "1.8.20",
"DownloadUrl": "http://doxygen.nl/files/doxygen-1.8.20-setup.exe"
}
},
"DevelopmentDependency": true
}
]
}

View File

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief Includes all public headers from Azure Security KeyVault Administration SDK library.
*
*/
#pragma once
#include "azure/keyvault/administration/dll_import_export.hpp"
#include "azure/keyvault/administration/rest_client.hpp"
#include "azure/keyvault/administration/rtti.hpp"
#include "azure/keyvault/administration/settings_client.hpp"
#include "azure/keyvault/administration/settings_client_options.hpp"

View File

@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief DLL export macro.
*/
// For explanation, see the comment in azure/core/dll_import_export.hpp
#pragma once
/**
* @def AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT
* @brief Applies DLL export attribute, when applicable.
* @note See https://docs.microsoft.com/cpp/cpp/dllexport-dllimport?view=msvc-160.
*/
#if defined(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLL) \
|| (0 /*@AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLL_INSTALLED_AS_PACKAGE@*/)
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL 1
#else
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL 0
#endif
#if AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL
#if defined(_MSC_VER)
#if defined(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BEING_BUILT)
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT __declspec(dllexport)
#else // !defined(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BEING_BUILT)
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT __declspec(dllimport)
#endif // AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BEING_BUILT
#else // !defined(_MSC_VER)
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT
#endif // _MSC_VER
#else // !AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT
#endif // AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_BUILT_AS_DLL

View File

@ -0,0 +1,92 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
//
// Code generated by Microsoft (R) AutoRest C++ Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
#pragma once
#include <azure/core/context.hpp>
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/nullable.hpp>
#include <azure/core/response.hpp>
#include <azure/core/url.hpp>
#include <azure/keyvault/administration/dll_import_export.hpp>
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
/**
* @brief The type specifier of the value.
*/
class SettingTypeEnum final {
public:
/**
* @brief Default constructor
*/
SettingTypeEnum() = default;
/**
* @brief Constructor
* @param value Setting Value
*/
explicit SettingTypeEnum(std::string value) : m_value(std::move(value)) {}
bool operator==(const SettingTypeEnum& other) const { return m_value == other.m_value; }
bool operator!=(const SettingTypeEnum& other) const { return !(*this == other); }
/**
* @brief Returns value as string
*
* @returns String value
*/
const std::string& ToString() const { return m_value; }
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_DLLEXPORT const static SettingTypeEnum Boolean;
private:
std::string m_value;
};
/**
* @brief Update Settings Options
*/
struct UpdateSettingOptions final
{
/**
* The value of the pool setting.
*/
std::string Value;
};
/**
* @brief Setting struct
*/
struct Setting final
{
/**
* The account setting to be updated.
*/
std::string Name;
/**
* The value of the pool setting.
*/
std::string Value;
/**
* The type specifier of the value.
*/
Azure::Nullable<SettingTypeEnum> Type;
};
/**
* @brief The settings list result.
*/
struct SettingsListResult final
{
/**
* A response message containing a list of account settings with their
* associated value.
*/
std::vector<Setting> Value;
};
}}}} // namespace Azure::Security::KeyVault::Administration

View File

@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Run-time type info enable or disable.
*
* @details Checks whenever RTTI is enabled and exports the symbol
* `AZ_SECURITY_KEYVAULT_ADMINISTRATION_RTTI`. When the macro is not defined, RTTI is disabled.
*
* @details Each library has this header file. These headers are being configured by
* `az_rtti_setup()` CMake macro. CMake install will patch this file during installation, depending
* on the build flags.
*/
#pragma once
/**
* @def AZ_SECURITY_KEYVAULT_ADMINISTRATION_RTTI
* @brief A macro indicating whether the code is built with RTTI or not.
*
* @details `AZ_RTTI` could be defined while building the Azure SDK with CMake, however, after
* the build is completed, that information is not preserved for the code that consumes Azure SDK
* headers, unless the code that consumes the SDK is the part of the same build process. To address
* this issue, CMake install would patch the header it places in the installation directory, so that
* condition:
* `#if defined(AZ_RTTI) || (0)`
* becomes, effectively,
* `#if defined(AZ_RTTI) || (0 + 1)`
* when the library was built with RTTI support, and will make no changes to the
* condition when it was not.
*/
#if defined(AZ_RTTI) || (0 /*@AZ_SECURITY_KEYVAULT_ADMINISTRATION_RTTI@*/)
#define AZ_SECURITY_KEYVAULT_ADMINISTRATION_RTTI
#endif

View File

@ -0,0 +1,107 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Defines the Key Vault Administration client.
*
*/
#pragma once
#include <azure/core/context.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/response.hpp>
#include <azure/keyvault/administration/rest_client.hpp>
#include <azure/keyvault/administration/settings_client_options.hpp>
#include <memory>
#include <string>
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
/**
* @brief Settings Client class.
*/
class SettingsClient final {
private:
Azure::Core::Url m_vaultUrl;
std::string m_apiVersion;
// Using a shared pipeline for a client to share it with LRO (like delete key).
std::shared_ptr<Azure::Core::Http::_internal::HttpPipeline> m_pipeline;
public:
/**
* @brief Destructor.
*
*/
virtual ~SettingsClient() = default;
/**
* @brief Construct a new settings client object.
*
* @param vaultUrl The URL address where the client will send the requests to.
* @param credential The authentication method to use.
* @param options The options to customize the client behavior.
*/
explicit SettingsClient(
std::string const& vaultUrl,
std::shared_ptr<Core::Credentials::TokenCredential const> credential,
SettingsClientOptions options = SettingsClientOptions());
/**
* @brief Construct a new settings client object from another settings client.
*
* @param settingsClient An existing key vault settings client.
*/
explicit SettingsClient(SettingsClient const& settingsClient) = default;
public:
/**
* @brief Update a setting.
*
* @param settingName Name of the setting to update.
* @param options Options for updating the setting.
* @param context Operation Context.
*
* @returns Response containing the new updated setting.
*/
Azure::Response<Setting> UpdateSetting(
std::string const& settingName,
UpdateSettingOptions const& options,
const Azure::Core::Context& context = Azure::Core::Context{}) const;
/**
* @brief Gets an existing setting.
*
* @param settingName Name of setting to get.
* @param context Operation context.
*
* @returns response containing the setting.
*/
Azure::Response<Setting> GetSetting(
std::string const& settingName,
const Azure::Core::Context& context = Azure::Core::Context{}) const;
/**
* @brief Gets all settings.
*
* @param context Operation context.
*
* @returns Response containing a list of settings.
*/
Azure::Response<SettingsListResult> GetSettings(
const Azure::Core::Context& context = Azure::Core::Context{}) const;
private:
Setting ParseSetting(std::vector<uint8_t> const& responseBody) const;
std::unique_ptr<Azure::Core::Http::RawResponse> SendRequest(
Azure::Core::Http::Request& request,
Azure::Core::Context const& context) const;
Azure::Core::Http::Request CreateRequest(
Azure::Core::Http::HttpMethod method,
std::vector<std::string> const& path = {},
Azure::Core::IO::BodyStream* content = nullptr) const;
};
}}}} // namespace Azure::Security::KeyVault::Administration

View File

@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Defines the supported options to create a Key Vault Administration client.
*
*/
#pragma once
#include <azure/core/internal/client_options.hpp>
#include <azure/keyvault/administration/dll_import_export.hpp>
#include <memory>
#include <string>
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
/**
* @brief Define the options to create a Keyvault Administration client.
*
*/
struct SettingsClientOptions final : public Azure::Core::_internal::ClientOptions
{
/**
* @brief Service Version used.
*
*/
const std::string ApiVersion{"7.4-preview.1"};
};
}}}} // namespace Azure::Security::KeyVault::Administration

View File

@ -0,0 +1,14 @@
---
page_type: sample
languages:
- c++ 14
products:
- azure
- azure-key-vault
name: Azure Security KeyVault Administration samples for C++
description: Samples for the azure-security-keyVault-administration client library.
---
# Azure.Security.KeyVault.Secrets Samples
- Get Settings, Get Setting , Update setting value

View File

@ -0,0 +1,63 @@
# Getting, updating, settings
This sample demonstrates how to get one or more settings and update a setting in Azure Key Vault.
To get started, you'll need a URI to an Azure Key Vault HSM.
## Creating a SettingsClient
To create a new `SettingsClient` to access settings, you need the endpoint to an Azure Key Vault HSM and credentials.
Key Vault Settings client for C++ currently supports the `ClientSecretCredential` for authenticating.
In the sample below, you can create a credential by setting the Tenant ID, Client ID and Client Secret as environment variables.
```cpp Snippet:SampleAdministration1CreateCredential
auto tenantId = std::getenv("AZURE_TENANT_ID");
auto clientId = std::getenv("AZURE_CLIENT_ID");
auto clientSecret = std::getenv("AZURE_CLIENT_SECRET");
auto credential
= std::make_shared<Azure::Identity::ClientSecretCredential>(tenantId, clientId, clientSecret);
```
Then, in the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
```cpp Snippet:SampleAdministration2SettingsClient
// create client
SettingsClient settingsClient(std::getenv("AZURE_KEYVAULT_HSM_URL"), credential);
```
## Get Settings
Call GetSettings get a list of all keyvault settings stored in the HSM.
```cpp Snippet:SampleAdministration3GetSettings
// Get all settings
SettingsListResult settingsList = settingsClient.GetSettings().Value;
std::cout << "Number of settings found : " << settingsList.Value.size();
```
## Getting a setting by name
Call GetSetting to retrieve a setting from HSM by passing the setting name as parameter. In this example we use a name from the list obtained previously.
```cpp Snippet:SampleAdministration4GetSetting
Setting setting = settingsClient.GetSetting(settingsList.Value[0].Name).Value;
std::cout << "Retrieved setting with name " << setting.Name << ", with value " << setting.Value;
```
## Updating a setting
Call UpdateSetting to modify an existing setting. Create an options object and initialize its Value field with the new value. In this example we do not change the actual value in order to not affect the keyvault long term.
```cpp Snippet:SampleAdministration5UpdateSetting
UpdateSettingOptions options;
options.Value = setting.Value;
Setting updatedSetting = settingsClient.UpdateSetting(settingsList.Value[0].Name,options).Value;
std::cout << "Retrieved updated setting with name " << updatedSetting.Name << ", with value " << updatedSetting.Value;
```
## Source
To see the full example source, see:
[Source Code](https://github.com/gearama/azure-sdk-for-cpp/tree/settings/sdk/keyvault/azure-security-keyvault-administration/test/samples/sample1-basic-operations)

View File

@ -0,0 +1,59 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "private/keyvault_settings_common_request.hpp"
#include "private/administration_constants.hpp"
#include <azure/core/exception.hpp>
#include <azure/core/http/http.hpp>
#include <memory>
using namespace Azure::Security::KeyVault;
using namespace Azure::Core::Http::_internal;
using namespace Azure::Security::KeyVault::Administration::_detail;
std::unique_ptr<Azure::Core::Http::RawResponse> KeyVaultSettingsCommonRequest::SendRequest(
Azure::Core::Http::_internal::HttpPipeline const& pipeline,
Azure::Core::Http::Request& request,
Azure::Core::Context const& context)
{
auto response = pipeline.Send(request, context);
auto responseCode = response->GetStatusCode();
switch (responseCode)
{
// 200, 201, 202, 204 are accepted responses
case Azure::Core::Http::HttpStatusCode::Ok:
case Azure::Core::Http::HttpStatusCode::Created:
case Azure::Core::Http::HttpStatusCode::Accepted:
case Azure::Core::Http::HttpStatusCode::NoContent:
break;
default:
throw Azure::Core::RequestFailedException(response);
}
return response;
}
Azure::Core::Http::Request KeyVaultSettingsCommonRequest::CreateRequest(
Azure::Core::Url url,
std::string const& apiVersion,
Azure::Core::Http::HttpMethod method,
std::vector<std::string> const& path,
Azure::Core::IO::BodyStream* content)
{
using namespace Azure::Core::Http;
Request request = content == nullptr ? Request(method, url) : Request(method, url, content);
request.SetHeader(ContentHeaderName, ApplicationJsonValue);
request.GetUrl().AppendQueryParameter(ApiVersionQueryParamName, apiVersion);
for (std::string const& p : path)
{
if (!p.empty())
{
request.GetUrl().AppendPath(p);
}
}
return request;
}

View File

@ -0,0 +1,28 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Centralize the string constants used by Key Vault Administration Client.
*
*/
#pragma once
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
namespace _detail {
/***************** Administration moniker *****************/
constexpr static const char KeyVaultServicePackageName[] = "keyvault-administration";
/***************** Request components *****************/
constexpr static const char ContentHeaderName[] = "content-type";
constexpr static const char ApplicationJsonValue[] = "application/json";
constexpr static const char ApiVersionQueryParamName[] = "api-version";
constexpr static const char SettingPathName[] = "settings";
/***************** JSON components *****************/
constexpr static const char SettingNodeName[] = "settings";
constexpr static const char ValueField[] = "value";
constexpr static const char NameField[] = "name";
constexpr static const char TypeField[] = "type";
}}}}} // namespace Azure::Security::KeyVault::Administration::_detail

View File

@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief Provides a wrapper class for the Azure Core Pipeline for all Key Vault services where
* common functionality is set up.
*
*/
#pragma once
#include <azure/core/context.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/internal/http/pipeline.hpp>
#include <azure/core/internal/json/json.hpp>
#include <azure/core/internal/json/json_serializable.hpp>
#include <azure/core/response.hpp>
#include <memory>
#include <string>
#include <vector>
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
namespace _detail {
struct KeyVaultSettingsCommonRequest final
{
static Azure::Core::Http::Request CreateRequest(
Azure::Core::Url url,
std::string const& apiVersion,
Azure::Core::Http::HttpMethod method,
std::vector<std::string> const& path,
Azure::Core::IO::BodyStream* content);
static std::unique_ptr<Azure::Core::Http::RawResponse> SendRequest(
Azure::Core::Http::_internal::HttpPipeline const& pipeline,
Azure::Core::Http::Request& request,
Azure::Core::Context const& context);
};
}}}}} // namespace Azure::Security::KeyVault::Administration::_detail

View File

@ -0,0 +1,71 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief Provides version information.
*/
#pragma once
#include <cstdint>
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MAJOR 4
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MINOR 0
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PATCH 0
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PRERELEASE "beta.1"
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA_HELPER(i) #i
#define AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(i) \
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA_HELPER(i)
namespace Azure { namespace Security { namespace KeyVault { namespace Administration {
namespace _detail {
/**
* @brief Provides version information.
*/
class PackageVersion final {
public:
/**
* @brief Major numeric identifier.
*/
static constexpr int32_t Major = AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MAJOR;
/**
* @brief Minor numeric identifier.
*/
static constexpr int32_t Minor = AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MINOR;
/**
* @brief Patch numeric identifier.
*/
static constexpr int32_t Patch = AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PATCH;
/**
* @brief Indicates whether the SDK is in a pre-release state.
*/
static constexpr bool IsPreRelease
= sizeof(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PRERELEASE) != sizeof("");
/**
* @brief The version in string format used for telemetry following the `semver.org` standard
* (https://semver.org).
*/
static constexpr const char* ToString()
{
return IsPreRelease
? AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PATCH) "-" AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PRERELEASE
: AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MAJOR) "." AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(
AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MINOR) "." AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA(AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PATCH);
}
};
}}}}} // namespace Azure::Security::KeyVault::Administration::_detail
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA_HELPER
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_ITOA
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MAJOR
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_MINOR
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PATCH
#undef AZURE_SECURITY_KEYVAULT_ADMINISTRATION_VERSION_PRERELEASE

View File

@ -0,0 +1,147 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include "private/administration_constants.hpp"
#include "private/keyvault_settings_common_request.hpp"
#include "private/package_version.hpp"
#include <azure/core/exception.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/internal/json/json.hpp>
#include <azure/core/internal/json/json_optional.hpp>
#include <azure/core/internal/json/json_serializable.hpp>
#include <azure/keyvault/administration/settings_client.hpp>
#include <azure/keyvault/shared/keyvault_shared.hpp>
#include <memory>
using namespace Azure::Core::Http;
using namespace Azure::Core::Http::Policies;
using namespace Azure::Core::Http::Policies::_internal;
using namespace Azure::Core::Json::_internal;
using namespace Azure::Security::KeyVault::Administration;
using namespace Azure::Security::KeyVault::Administration::_detail;
std::unique_ptr<Azure::Core::Http::RawResponse> SettingsClient::SendRequest(
Azure::Core::Http::Request& request,
Azure::Core::Context const& context) const
{
return Azure::Security::KeyVault::Administration::_detail::KeyVaultSettingsCommonRequest::
SendRequest(*m_pipeline, request, context);
}
Azure::Core::Http::Request SettingsClient::CreateRequest(
Azure::Core::Http::HttpMethod method,
std::vector<std::string> const& path,
Azure::Core::IO::BodyStream* content) const
{
return Azure::Security::KeyVault::Administration::_detail::KeyVaultSettingsCommonRequest::
CreateRequest(m_vaultUrl, m_apiVersion, method, path, content);
}
SettingsClient::SettingsClient(
std::string const& vaultUrl,
std::shared_ptr<Core::Credentials::TokenCredential const> credential,
SettingsClientOptions options)
: m_vaultUrl(vaultUrl), m_apiVersion(options.ApiVersion)
{
auto apiVersion = options.ApiVersion;
std::vector<std::unique_ptr<HttpPolicy>> perRetrypolicies;
{
Azure::Core::Credentials::TokenRequestContext tokenContext;
tokenContext.Scopes = {_internal::UrlScope::GetScopeFromUrl(m_vaultUrl)};
perRetrypolicies.emplace_back(
std::make_unique<BearerTokenAuthenticationPolicy>(credential, std::move(tokenContext)));
}
std::vector<std::unique_ptr<HttpPolicy>> perCallpolicies;
m_pipeline = std::make_shared<Azure::Core::Http::_internal::HttpPipeline>(
options,
_detail::KeyVaultServicePackageName,
_detail::PackageVersion::ToString(),
std::move(perRetrypolicies),
std::move(perCallpolicies));
}
Azure::Response<Setting> SettingsClient::UpdateSetting(
std::string const& settingName,
UpdateSettingOptions const& options,
const Azure::Core::Context& context) const
{
std::string jsonBody;
{
auto jsonRoot = Azure::Core::Json::_internal::json::object();
jsonRoot[ValueField] = options.Value;
jsonBody = jsonRoot.dump();
}
Azure::Core::IO::MemoryBodyStream requestBody(
reinterpret_cast<const uint8_t*>(jsonBody.data()), jsonBody.length());
auto request = CreateRequest(HttpMethod::Patch, {SettingPathName, settingName}, &requestBody);
auto pRawResponse = m_pipeline->Send(request, context);
auto httpStatusCode = pRawResponse->GetStatusCode();
if (httpStatusCode != Azure::Core::Http::HttpStatusCode::Ok)
{
throw Azure::Core::RequestFailedException(pRawResponse);
}
Setting response = ParseSetting(pRawResponse->GetBody());
return Azure::Response<Setting>(std::move(response), std::move(pRawResponse));
}
Azure::Response<Setting> SettingsClient::GetSetting(
std::string const& settingName,
const Azure::Core::Context& context) const
{
auto request = CreateRequest(HttpMethod::Get, {SettingPathName, settingName});
auto pRawResponse = m_pipeline->Send(request, context);
auto httpStatusCode = pRawResponse->GetStatusCode();
if (httpStatusCode != Azure::Core::Http::HttpStatusCode::Ok)
{
throw Azure::Core::RequestFailedException(pRawResponse);
}
Setting response = ParseSetting(pRawResponse->GetBody());
return Azure::Response<Setting>(std::move(response), std::move(pRawResponse));
}
Azure::Response<SettingsListResult> SettingsClient::GetSettings(
const Azure::Core::Context& context) const
{
auto request = CreateRequest(Azure::Core::Http::HttpMethod::Get, {SettingPathName});
auto pRawResponse = m_pipeline->Send(request, context);
auto httpStatusCode = pRawResponse->GetStatusCode();
if (httpStatusCode != Azure::Core::Http::HttpStatusCode::Ok)
{
throw Azure::Core::RequestFailedException(pRawResponse);
}
SettingsListResult response;
{
const auto& responseBody = pRawResponse->GetBody();
auto jsonRoot = json::parse(responseBody);
auto settingsArray = jsonRoot[SettingNodeName];
for (const auto& setting : settingsArray)
{
auto const settingString = setting.dump();
Setting parsedSetting
= ParseSetting(std::vector<uint8_t>(settingString.begin(), settingString.end()));
response.Value.emplace_back(std::move(parsedSetting));
}
}
return Azure::Response<SettingsListResult>(std::move(response), std::move(pRawResponse));
}
Setting SettingsClient::ParseSetting(std::vector<uint8_t> const& responseBody) const
{
Setting response;
{
auto jsonRoot
= Azure::Core::Json::_internal::json::parse(responseBody.begin(), responseBody.end());
response.Name = jsonRoot[NameField].get<std::string>();
response.Value = jsonRoot[ValueField].get<std::string>();
if (jsonRoot.count(TypeField) != 0)
{
response.Type = SettingTypeEnum(jsonRoot[TypeField].get<std::string>());
}
}
return response;
}

View File

@ -0,0 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.13)
add_subdirectory(sample1-basic-operations)

View File

@ -0,0 +1,16 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.13)
project (sample1-administration LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_executable (
sample1-administration
sample1_administration.cpp
)
create_per_service_target_build_for_sample(keyvault sample1-administration)
target_link_libraries(sample1-administration PRIVATE azure-security-keyvault-administration azure-identity get-env-helper)

View File

@ -0,0 +1,71 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief This sample provides the code implementation to use the Key Vault Settings SDK client for
* C++ to get one or more settings, and update a setting value.
*
* @remark The following environment variables must be set before running the sample.
* - AZURE_KEYVAULT_HSM_URL: To the Key Vault HSM URL.
* - AZURE_TENANT_ID: Tenant ID for the Azure account.
* - AZURE_CLIENT_ID: The Client ID to authenticate the request.
* - AZURE_CLIENT_SECRET: The client secret.
*
*/
#include "get_env.hpp"
#include <azure/identity.hpp>
#include <azure/keyvault/administration.hpp>
#include <chrono>
#include <iostream>
using namespace Azure::Security::KeyVault::Administration;
using namespace std::chrono_literals;
int main()
{
auto tenantId = std::getenv("AZURE_TENANT_ID");
auto clientId = std::getenv("AZURE_CLIENT_ID");
auto clientSecret = std::getenv("AZURE_CLIENT_SECRET");
auto credential
= std::make_shared<Azure::Identity::ClientSecretCredential>(tenantId, clientId, clientSecret);
// create client
SettingsClient settingsClient(std::getenv("AZURE_KEYVAULT_HSM_URL"), credential);
try
{
// Get all settings
SettingsListResult settingsList = settingsClient.GetSettings().Value;
std::cout << "Number of settings found : " << settingsList.Value.size();
Setting setting = settingsClient.GetSetting(settingsList.Value[0].Name).Value;
std::cout << "Retrieved setting with name " << setting.Name << ", with value " << setting.Value;
UpdateSettingOptions options;
options.Value = setting.Value;
Setting updatedSetting
= settingsClient.UpdateSetting(settingsList.Value[0].Name, options).Value;
std::cout << "Retrieved updated setting with name " << updatedSetting.Name << ", with value "
<< updatedSetting.Value;
}
catch (Azure::Core::Credentials::AuthenticationException const& e)
{
std::cout << "Authentication Exception happened:" << std::endl << e.what() << std::endl;
return 1;
}
catch (Azure::Core::RequestFailedException const& e)
{
std::cout << "Key Vault Settings Client Exception happened:" << std::endl
<< e.Message << std::endl;
return 1;
}
return 0;
}

View File

@ -0,0 +1,40 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
cmake_minimum_required (VERSION 3.13)
project (azure-security-keyvault-administration-test LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(GoogleTest)
# Export the test folder for recordings access.
add_compile_definitions(AZURE_TEST_RECORDING_DIR="${CMAKE_CURRENT_LIST_DIR}")
add_executable (
azure-security-keyvault-administration-test
macro_guard.cpp
settings_client_test.cpp
settings_client_base_test.hpp)
create_per_service_target_build(keyvault azure-security-keyvault-administration-test)
create_map_file(azure-security-keyvault-administration-test azure-security-keyvault-administration-test.map)
if (MSVC)
target_compile_options(azure-security-keyvault-administration-test PUBLIC /wd6326 /wd26495 /wd26812 /wd4389)
endif()
target_link_libraries(azure-security-keyvault-administration-test PRIVATE azure-security-keyvault-administration azure-identity azure-core-test-fw gtest gtest_main gmock)
# Adding private headers so we can test the private APIs with no relative paths include.
target_include_directories (azure-security-keyvault-administration-test PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../src>)
# gtest_add_tests will scan the test from azure-core-test and call add_test
# for each test to ctest. This enables `ctest -r` to run specific tests directly.
gtest_discover_tests(azure-security-keyvault-administration-test
TEST_PREFIX azure-security-keyvault-administration.
NO_PRETTY_TYPES
NO_PRETTY_VALUES
DISCOVERY_TIMEOUT 600)

View File

@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
// Define `min` and `max` as function-like macros before including all public
// headers to ensure that uses of those identifiers are defended against
// expansion as function-like macros. Define `small` as an object-like macro to
// ensure that identifier isn't used at all. Windows.h is badly behaved and
// defines similar macros with these names and we want to ensure the SDK headers
// function even when a naive user includes Windows.h first.
//
#define small FAIL><TO][COMPILE)(VERY{{{LOUDLY!!!
#define max(x, y) small
#define min(x, y) small
#include "azure/keyvault/administration.hpp"

View File

@ -0,0 +1,83 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @file
* @brief The base class to construct and init a Key Vault client.
*
*/
#include <gtest/gtest.h>
#include <azure/core/test/test_base.hpp>
#include <azure/identity/client_secret_credential.hpp>
#include <azure/keyvault/administration.hpp>
#include <chrono>
#include <thread>
namespace Azure {
namespace Security {
namespace KeyVault {
namespace Administration {
namespace Test {
class SettingsClientTest : public Azure::Core::Test::TestBase,
public ::testing::WithParamInterface<int> {
private:
std::unique_ptr<Azure::Security::KeyVault::Administration::SettingsClient> m_client;
protected:
std::shared_ptr<Core::Credentials::TokenCredential> m_credential;
std::string m_keyVaultUrl;
std::string m_keyVaultHsmUrl;
std::chrono::milliseconds m_defaultWait = 20s;
// Required to rename the test propertly once the test is started.
// We can only know the test instance name until the test instance is run.
Azure::Security::KeyVault::Administration::SettingsClient const& GetClientForTest(
std::string const& testName)
{
// set the interceptor for the current test
m_testContext.RenameTest(testName);
return *m_client;
}
void CreateHSMClientForTest(std::string hsmUrl = "")
{
SettingsClientOptions options;
m_client = InitTestClient<
Azure::Security::KeyVault::Administration::SettingsClient,
Azure::Security::KeyVault::Administration::SettingsClientOptions>(
hsmUrl.length() == 0 ? m_keyVaultHsmUrl : hsmUrl, m_credential, options);
}
// Runs before every test.
virtual void SetUp() override
{
Azure::Core::Test::TestBase::SetUpTestBase(AZURE_TEST_RECORDING_DIR);
m_keyVaultUrl = GetEnv("AZURE_KEYVAULT_URL");
m_keyVaultHsmUrl = GetEnv("AZURE_KEYVAULT_HSM_URL");
// Options and credential for the client
SettingsClientOptions options;
m_credential = std::make_shared<Azure::Identity::ClientSecretCredential>(
GetEnv("AZURE_TENANT_ID"), GetEnv("AZURE_CLIENT_ID"), GetEnv("AZURE_CLIENT_SECRET"));
// `InitTestClient` takes care of setting up Record&Playback.
m_client = InitTestClient<
Azure::Security::KeyVault::Administration::SettingsClient,
Azure::Security::KeyVault::Administration::SettingsClientOptions>(
m_keyVaultUrl, m_credential, options);
// Update default time depending on test mode.
UpdateWaitingTime(m_defaultWait);
}
public:
// Reads the current test instance name.
// Name gets also sanitized (special chars are removed) to avoid issues when recording or
// creating. This also return the name with suffix if the "AZURE_LIVE_TEST_SUFFIX" exists.
std::string GetTestName(bool sanitize = true)
{
return Azure::Core::Test::TestBase::GetTestNameSuffix(sanitize);
}
};
}}}}} // namespace Azure::Security::KeyVault::Administration::Test

View File

@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/identity/client_secret_credential.hpp>
#include "azure/keyvault/administration/settings_client.hpp"
#include "settings_client_base_test.hpp"
#include <azure/core/base64.hpp>
#include <azure/keyvault/administration/rest_client.hpp>
#include <cstddef>
#include <gtest/gtest.h>
#include <string>
#include <thread>
using namespace std::chrono_literals;
using namespace Azure::Security::KeyVault::Administration;
using namespace Azure::Security::KeyVault::Administration::Test;
using namespace std::chrono_literals;
TEST_F(SettingsClientTest, GetSettings)
{
auto testName = ::testing::UnitTest::GetInstance()->current_test_info()->name();
EXPECT_EQ(testName, testName);
CreateHSMClientForTest();
// create certificate method contains all the checks
auto const& client = GetClientForTest(testName);
auto result = client.GetSettings();
EXPECT_EQ(result.Value.Value.size(), 1);
auto setting = result.Value.Value[0];
EXPECT_EQ(setting.Name, "AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(setting.Value, "false");
}
TEST_F(SettingsClientTest, GetSetting)
{
auto testName = ::testing::UnitTest::GetInstance()->current_test_info()->name();
CreateHSMClientForTest();
// create certificate method contains all the checks
auto const& client = GetClientForTest(testName);
auto result = client.GetSetting("AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(result.Value.Name, "AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(result.Value.Value, "false");
}
TEST_F(SettingsClientTest, UpdateSetting)
{
auto testName = ::testing::UnitTest::GetInstance()->current_test_info()->name();
CreateHSMClientForTest();
// create certificate method contains all the checks
auto const& client = GetClientForTest(testName);
{
UpdateSettingOptions options;
options.Value = "false";
auto result = client.UpdateSetting("AllowKeyManagementOperationsThroughARM", options);
EXPECT_EQ(result.Value.Name, "AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(result.Value.Value, "false");
}
{
UpdateSettingOptions options;
options.Value = "true";
auto result = client.UpdateSetting("AllowKeyManagementOperationsThroughARM", options);
EXPECT_EQ(result.Value.Name, "AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(result.Value.Value, "true");
}
{
UpdateSettingOptions options;
options.Value = "false";
auto result = client.UpdateSetting("AllowKeyManagementOperationsThroughARM", options);
EXPECT_EQ(result.Value.Name, "AllowKeyManagementOperationsThroughARM");
EXPECT_EQ(result.Value.Value, "false");
}
}

View File

@ -0,0 +1,10 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
{
"name": "azure-security-keyvault-administration",
"version-string": "1.0.0",
"dependencies": [
"azure-core-cpp"
]
}

View File

@ -0,0 +1,11 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(azure-core-cpp "1.5.0")
include("${CMAKE_CURRENT_LIST_DIR}/azure-security-keyvault-administration-cppTargets.cmake")
check_required_components("azure-security-keyvault-administration-cpp")

View File

@ -0,0 +1,21 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Azure/azure-sdk-for-cpp
REF azure-security-keyvault-administration_@AZ_LIBRARY_VERSION@
SHA512 0
)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}/sdk/keyvault/azure-security-keyvault-administration/
OPTIONS
-DWARNINGS_AS_ERRORS=OFF
)
vcpkg_cmake_install()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_cmake_config_fixup()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
vcpkg_copy_pdbs()

View File

@ -0,0 +1,28 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
{
"name": "azure-security-keyvault-administration-cpp",
"version-semver": "@AZ_LIBRARY_VERSION@",
"description": [
"Microsoft Azure Key Vault Administration SDK for C++",
"This library provides Azure Key Vault Administration SDK."
],
"homepage": "https://github.com/Azure/azure-sdk-for-cpp/tree/main/sdk/keyvault/azure-security-keyvault-administration",
"license": "MIT",
"dependencies": [
{
"name": "azure-core-cpp",
"default-features": false,
"version>=": "1.5.0"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -81,7 +81,7 @@ TEST_F(KeyVaultKeyClient, GetKeyRotationPolicy)
}
}
TEST_F(KeyVaultKeyClient, GetRandomBytes_LIVEONLY_)
TEST_F(KeyVaultKeyClient, GetRandomBytes)
{
if (m_keyVaultUrl.compare(m_keyVaultHsmUrl) != 0)
{