Api review changes (#2994)

* operator !=

* moved download , make protected private

* structs and classes

* comments

* change std::vector into struct

* optional structs

* get version

* api signature changes

* remove the options structs where not necessary , they are extremelly ugly

* fix issue

* small sample readme update
This commit is contained in:
George Arama 2021-10-27 10:26:30 -07:00 committed by GitHub
parent 1055ff8c14
commit 30f62eb3aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 191 additions and 163 deletions

View File

@ -21,7 +21,11 @@
#include <string>
namespace Azure { namespace Security { namespace KeyVault { namespace Certificates {
#if defined(TESTING_BUILD)
namespace Test {
class KeyVaultCertificateClientTest;
}
#endif
/**
* @brief The CertificateClient provides synchronous methods to manage KeyVaultCertificate in
* Azure Key Vault.
@ -35,7 +39,11 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
{
friend class CreateCertificateOperation;
protected:
#if defined(TESTING_BUILD)
friend class Test::KeyVaultCertificateClientTest;
#endif
private:
// Using a shared pipeline for a client to share it with LRO (like delete key)
Azure::Core::Url m_vaultUrl;
std::string m_apiVersion;
@ -90,14 +98,14 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @remark This operation requires the certificates/get permission.
*
* @param name The name of the certificate.
* @param options Optional parameters for this operation.
* @param version The version of the certificate.
* @param context The context for the operation can be used for request cancellation.
* @return A response containing the certificate and policy as a KeyVaultCertificateWithPolicy
* instance.
*/
Azure::Response<KeyVaultCertificateWithPolicy> GetCertificateVersion(
std::string const& name,
GetCertificateVersionOptions const& options = GetCertificateVersionOptions(),
std::string const& version,
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
@ -124,11 +132,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
*
* @remark This operation requires the certificates/setissuers permission.
*
* @param name The certificate issuer name.
* @param issuer The certificate issuer.
* @param context The context for the operation can be used for request cancellation.
* @return CertificateIssuer instance used to determine create status.
*/
Azure::Response<CertificateIssuer> CreateIssuer(
std::string const& name,
CertificateIssuer const& issuer,
Azure::Core::Context const& context = Azure::Core::Context()) const;
@ -189,7 +199,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @param context The context for the operation can be used for request cancellation.
* @return The contacts list for the key vault certificate.
*/
Azure::Response<std::vector<CertificateContact>> GetContacts(
Azure::Response<CertificateContactsResult> GetContacts(
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
@ -202,7 +212,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @param context The context for the operation can be used for request cancellation.
* @return The contacts for the key vault certificate.
*/
Azure::Response<std::vector<CertificateContact>> DeleteContacts(
Azure::Response<CertificateContactsResult> DeleteContacts(
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
@ -216,7 +226,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @param context The context for the operation can be used for request cancellation.
* @return The contacts for the key vault certificate.
*/
Azure::Response<std::vector<CertificateContact>> SetContacts(
Azure::Response<CertificateContactsResult> SetContacts(
std::vector<CertificateContact> const& contacts,
Azure::Core::Context const& context = Azure::Core::Context()) const;
@ -423,22 +433,6 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
GetDeletedCertificatesOptions const& options = GetDeletedCertificatesOptions(),
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
* @brief Downloads a copy of a certificate.
*
* @details The Download Certificate operation attempts to download the managed secret which
* contains the full certificate
*
* @param name The name of the certificate.
* @param options The options for the request.
* @param context The context for the operation can be used for request cancellation.
* @return Downloaded certificate.
*/
Azure::Response<DownloadCertificateResult> DownloadCertificate(
std::string const& name,
DownloadCertificateOptions const& options = DownloadCertificateOptions(),
Azure::Core::Context const& context = Azure::Core::Context()) const;
/**
* @brief Imports a certificate into a specified key vault.
*
@ -484,11 +478,15 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
*
* @remark This operation requires the certificates/update permission.
*
* @param name The certificate name.
* @param version The certificate version.
* @param options The options for the request.
* @param context The context for the operation can be used for request cancellation.
* @return The updated certificate.
*/
Azure::Response<KeyVaultCertificateWithPolicy> UpdateCertificateProperties(
std::string const& name,
std::string const& version,
CertificateUpdateOptions const& options,
Azure::Core::Context const& context = Azure::Core::Context()) const;

View File

@ -231,6 +231,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
return m_value == other.m_value;
}
/**
* @brief Enables using the not equal operator for JWT.
*
* @param other A JWT to be compared.
*/
bool operator!=(const CertificateKeyType& other) const noexcept { return !operator==(other); }
/**
* @brief Return the JSON Web Token (JWT) as a string.
*
@ -303,6 +310,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
return m_value == other.m_value;
}
/**
* @brief Enables using the not equal operator for JWT.
*
* @param other A JWT to be compared.
*/
bool operator!=(const CertificateKeyCurveName& other) const noexcept
{
return !operator==(other);
}
/**
* @brief Get the string value of the key curve.
*
@ -415,6 +432,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
return m_value == other.m_value;
}
/**
* @brief Enables using the not equal operator for JWT.
*
* @param other A JWT to be compared.
*/
bool operator!=(const CertificateContentType& other) const noexcept
{
return !operator==(other);
}
/**
* @brief Get the string value of the key curve.
*
@ -481,6 +508,13 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
return m_value == other.m_value;
}
/**
* @brief Enables using the not equal operator for JWT.
*
* @param other A JWT to be compared.
*/
bool operator!=(const CertificateKeyUsage& other) const noexcept { return !operator==(other); }
/**
* @brief Get the string value of the key curve.
*
@ -590,6 +624,16 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
return m_value == other.m_value;
}
/**
* @brief Enables using the not equal operator for JWT.
*
* @param other A JWT to be compared.
*/
bool operator!=(const CertificatePolicyAction& other) const noexcept
{
return !operator==(other);
}
/**
* @brief Get the string value of the key curve.
*
@ -774,8 +818,8 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @brief A KeyVaultCertificate along with its CertificatePolicy.
*
*/
struct KeyVaultCertificateWithPolicy : public KeyVaultCertificate
{
class KeyVaultCertificateWithPolicy : public KeyVaultCertificate {
public:
/**
* @brief Gets the current policy for the certificate.
*
@ -800,38 +844,12 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
KeyVaultCertificateWithPolicy() = default;
};
/**
* @brief The options for calling GetCertificate.
*
*/
struct GetCertificateVersionOptions final
{
/**
* @brief Certificate Version.
*
*/
std::string Version;
};
/**
* @brief The options for calling DownloadCertificate.
*
*/
struct DownloadCertificateOptions final
{
/**
* @brief Certificate Version.
*
*/
Azure::Nullable<std::string> Version;
};
/**
* @brief Parameters for StartCreateCertificate.
*
*/
struct CertificateCreateParameters final
{
class CertificateCreateParameters final {
public:
/**
* @brief Certificate policy.
*
@ -1037,8 +1055,8 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @brief Key vault server error
*
*/
struct ServerError final
{
class ServerError final {
public:
~ServerError() = default;
/**
* @brief Error Code
@ -1063,8 +1081,8 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
* @brief A certificate operation.
*
*/
struct CertificateOperationProperties final
{
class CertificateOperationProperties final {
public:
/**
* @brief The certificate id.
*
@ -1149,8 +1167,8 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
~CertificateOperationProperties() = default;
};
struct DeletedCertificate final : public KeyVaultCertificateWithPolicy
{
class DeletedCertificate final : public KeyVaultCertificateWithPolicy {
public:
/**
* @brief Gets the identifier of the deleted certificate.
*
@ -1267,25 +1285,6 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
std::string Provider;
};
/**
* @brief A certificate downloaded X509 data.
*
*/
struct DownloadCertificateResult final
{
/**
* @brief Certificate data.
*
*/
std::string Certificate;
/**
* @brief Content Type.
*
*/
CertificateContentType ContentType;
};
/**
* @brief Define a single page to list the certificates from the Key Vault.
*
@ -1509,4 +1508,18 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
*/
std::unordered_map<std::string, std::string> Tags;
};
/**
* @brief The certificate contacts API result.
*
*/
struct CertificateContactsResult
{
/**
* @brief The certificate contacts list.
*
*/
std::vector<CertificateContact> Contacts;
};
}}}} // namespace Azure::Security::KeyVault::Certificates

View File

@ -3,7 +3,7 @@
/**
* @file
* @brief Defines the supported options to create a Key Vault Keys client.
* @brief Defines the supported options to create a Key Vault Certificate client.
*
*/
@ -30,7 +30,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
/**
* @brief Construct a new Service Version object
*
* @param version The string version for the Key Vault keys service.
* @param version The string version for the Key Vault Certificate service.
*/
ServiceVersion(std::string version) : m_version(std::move(version)) {}
@ -55,7 +55,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
};
/**
* @brief Define the options to create an SDK Keys client.
* @brief Define the options to create an SDK Certificate client.
*
*/
struct CertificateClientOptions final : public Azure::Core::_internal::ClientOptions
@ -63,7 +63,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
ServiceVersion Version;
/**
* @brief Construct a new Key Client Options object.
* @brief Construct a new Certificate Client Options object.
*
* @param version Optional version for the client.
*/

View File

@ -26,14 +26,14 @@ CertificateClient certificateClient(std::getenv("AZURE_KEYVAULT_URL"), credentia
## Importing a PEM certificate
You will need the certificate content in PEM format to perform this operation. One sample is provided in certificate-ImportCertificate.hpp as the pemCertificate string.
You will need the certificate content in PEM format to perform this operation. One sample is provided in certificate-ImportCertificate.hpp as the GetPemCertificate() string.
Once the import parameters are setup we can call Import certificate and get back the newly imported certificate.
```cpp Snippet:CertificateSample3ImportPEM
// prepare the parameters
ImportCertificateOptions params;
params.Value = pemCertificate;
params.Value = GetPemCertificate();
params.Policy.Enabled = true;
params.Policy.KeyType = CertificateKeyType::Rsa;
@ -48,14 +48,14 @@ std::cout << "Imported pem certificate with name " << imported.Name();
## Importing a PKCS certificate
You will need the certificate content in PKCS format to perform this operation. One sample is provided in certificate-ImportCertificate.hpp as the pkcsBase64 string.
You will need the certificate content in PKCS format to perform this operation. One sample is provided in certificate-ImportCertificate.hpp as the GetPkcsCertificate() string.
Once the import parameters are setup we can call Import certificate and get back the newly imported certificate
```cpp Snippet:CertificateSample3ImportPKCS
// prepare the parameters
ImportCertificateOptions params;
params.Value = pkcsBase64;
params.Value = GetPemCertificate();
params.Policy.Enabled = true;
params.Policy.KeyType = CertificateKeyType::Rsa;

View File

@ -88,7 +88,11 @@ int main()
updateOptions.Properties = certificate.Properties;
updateOptions.Properties.Enabled = false;
auto updatedCertificate = certificateClient.UpdateCertificateProperties(updateOptions).Value;
auto updatedCertificate
= certificateClient
.UpdateCertificateProperties(
updateOptions.Properties.Name, updateOptions.Properties.Version, updateOptions)
.Value;
std::cout << "After update certificate is enabled : "
<< (updatedCertificate.Properties.Enabled.Value() ? "true" : "false");

View File

@ -102,15 +102,11 @@ Response<KeyVaultCertificateWithPolicy> CertificateClient::GetCertificate(
Response<KeyVaultCertificateWithPolicy> CertificateClient::GetCertificateVersion(
std::string const& name,
GetCertificateVersionOptions const& options,
std::string const& version,
Context const& context) const
{
// Request with no payload
std::vector<std::string> path{{CertificatesPath, name}};
if (!options.Version.empty())
{
path.emplace_back(options.Version);
}
std::vector<std::string> path{{CertificatesPath, name, version}};
auto request = CreateRequest(HttpMethod::Get, std::move(path));
@ -175,10 +171,10 @@ Azure::Response<CertificateIssuer> CertificateClient::DeleteIssuer(
}
Azure::Response<CertificateIssuer> CertificateClient::CreateIssuer(
std::string const& name,
CertificateIssuer const& issuer,
Azure::Core::Context const& context) const
{
std::string name = issuer.Name;
auto payload = CertificateIssuerSerializer::Serialize(issuer);
Azure::Core::IO::MemoryBodyStream payloadStream(
reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
@ -208,7 +204,7 @@ Azure::Response<CertificateIssuer> CertificateClient::UpdateIssuer(
return Azure::Response<CertificateIssuer>(std::move(value), std::move(rawResponse));
}
Response<std::vector<CertificateContact>> CertificateClient::GetContacts(
Response<CertificateContactsResult> CertificateClient::GetContacts(
Azure::Core::Context const& context) const
{
auto request = CreateRequest(HttpMethod::Get, {CertificatesPath, ContactsPath});
@ -216,10 +212,10 @@ Response<std::vector<CertificateContact>> CertificateClient::GetContacts(
// Send and parse respone
auto rawResponse = SendRequest(request, context);
auto value = CertificateContactsSerializer::Deserialize(*rawResponse);
return Azure::Response<std::vector<CertificateContact>>(std::move(value), std::move(rawResponse));
return Azure::Response<CertificateContactsResult>(std::move(value), std::move(rawResponse));
}
Response<std::vector<CertificateContact>> CertificateClient::DeleteContacts(
Response<CertificateContactsResult> CertificateClient::DeleteContacts(
Azure::Core::Context const& context) const
{
auto request = CreateRequest(HttpMethod::Delete, {CertificatesPath, ContactsPath});
@ -227,10 +223,10 @@ Response<std::vector<CertificateContact>> CertificateClient::DeleteContacts(
// Send and parse respone
auto rawResponse = SendRequest(request, context);
auto value = CertificateContactsSerializer::Deserialize(*rawResponse);
return Azure::Response<std::vector<CertificateContact>>(std::move(value), std::move(rawResponse));
return Azure::Response<CertificateContactsResult>(std::move(value), std::move(rawResponse));
}
Response<std::vector<CertificateContact>> CertificateClient::SetContacts(
Response<CertificateContactsResult> CertificateClient::SetContacts(
std::vector<CertificateContact> const& contacts,
Azure::Core::Context const& context) const
{
@ -242,7 +238,7 @@ Response<std::vector<CertificateContact>> CertificateClient::SetContacts(
auto rawResponse = SendRequest(request, context);
auto value = CertificateContactsSerializer::Deserialize(*rawResponse);
return Azure::Response<std::vector<CertificateContact>>(std::move(value), std::move(rawResponse));
return Azure::Response<CertificateContactsResult>(std::move(value), std::move(rawResponse));
}
Azure::Response<CertificateOperationProperties> CertificateClient::GetPendingCertificateOperation(
@ -383,6 +379,7 @@ CertificatePropertiesPagedResponse CertificateClient::GetPropertiesOfCertificate
GetPropertiesOfCertificatesOptions const& options,
Azure::Core::Context const& context) const
{
(void)options;
// Request and settings
auto request = ContinuationTokenRequest({CertificatesPath}, options.NextPageToken);
if (options.IncludePending)
@ -441,34 +438,6 @@ DeletedCertificatesPagedResponse CertificateClient::GetDeletedCertificates(
std::move(value), std::move(rawResponse), std::make_unique<CertificateClient>(*this));
}
Azure::Response<DownloadCertificateResult> CertificateClient::DownloadCertificate(
std::string const& name,
DownloadCertificateOptions const& options,
Azure::Core::Context const& context) const
{
KeyVaultCertificateWithPolicy certificate;
if (options.Version)
{
GetCertificateVersionOptions getVersionOptions{options.Version.Value()};
auto response = GetCertificateVersion(name, getVersionOptions, context);
certificate = response.Value;
}
else
{
auto response = GetCertificate(name, context);
certificate = response.Value;
}
Azure::Core::Url url(certificate.SecretId);
auto secretRequest = CreateRequest(HttpMethod::Get, {url.GetPath()});
auto secretResponse = SendRequest(secretRequest, context);
auto secret = KeyVaultSecretSerializer::Deserialize(*secretResponse);
DownloadCertificateResult result{secret.Value, secret.ContentType.Value()};
return Azure::Response<DownloadCertificateResult>(std::move(result), std::move(secretResponse));
}
Azure::Response<KeyVaultCertificateWithPolicy> CertificateClient::ImportCertificate(
std::string const& name,
ImportCertificateOptions const& options,
@ -504,6 +473,8 @@ Azure::Response<KeyVaultCertificateWithPolicy> CertificateClient::MergeCertifica
}
Azure::Response<KeyVaultCertificateWithPolicy> CertificateClient::UpdateCertificateProperties(
std::string const& name,
std::string const& version,
CertificateUpdateOptions const& options,
Azure::Core::Context const& context) const
{
@ -511,10 +482,8 @@ Azure::Response<KeyVaultCertificateWithPolicy> CertificateClient::UpdateCertific
Azure::Core::IO::MemoryBodyStream payloadStream(
reinterpret_cast<const uint8_t*>(payload.data()), payload.size());
auto request = CreateRequest(
HttpMethod::Patch,
{CertificatesPath, options.Properties.Name, options.Properties.Version},
&payloadStream);
auto request
= CreateRequest(HttpMethod::Patch, {CertificatesPath, name, version}, &payloadStream);
auto rawResponse = SendRequest(request, context);
auto value = KeyVaultCertificateSerializer::Deserialize(options.Properties.Name, *rawResponse);

View File

@ -547,10 +547,10 @@ std::string CertificateContactsSerializer::Serialize(
return payload.dump();
}
std::vector<CertificateContact> CertificateContactsSerializer::Deserialize(
CertificateContactsResult CertificateContactsSerializer::Deserialize(
Azure::Core::Http::RawResponse const& rawResponse)
{
std::vector<CertificateContact> response;
CertificateContactsResult response;
auto const& body = rawResponse.GetBody();
auto jsonResponse = json::parse(body);
@ -565,7 +565,7 @@ std::vector<CertificateContact> CertificateContactsSerializer::Deserialize(
JsonOptional::SetIfExists(contact.Name, contactJson, NamePropertyName);
JsonOptional::SetIfExists(contact.Phone, contactJson, PhonePropertyName);
response.emplace_back(contact);
response.Contacts.emplace_back(contact);
}
}

View File

@ -135,7 +135,7 @@ namespace Azure { namespace Security { namespace KeyVault { namespace Certificat
public:
static std::string Serialize(std::vector<CertificateContact> const& constacts);
static std::vector<CertificateContact> Deserialize(
static CertificateContactsResult Deserialize(
Azure::Core::Http::RawResponse const& rawResponse);
};

View File

@ -8,10 +8,10 @@
*/
#include <gtest/gtest.h>
#include "../src/private/certificate_serializers.hpp"
#include <azure/core/test/test_base.hpp>
#include <azure/identity/client_secret_credential.hpp>
#include <azure/keyvault/keyvault_certificates.hpp>
#include <thread>
using namespace std::chrono_literals;
@ -21,9 +21,28 @@ namespace Azure {
namespace KeyVault {
namespace Certificates {
namespace Test {
/**
* @brief Client Certificate Credential authenticates with the Azure services using a Tenant ID,
* Client ID and a client secret.
* @brief A certificate downloaded X509 data.
*
*/
struct DownloadCertificateResult final
{
/**
* @brief Certificate data.
*
*/
std::string Certificate;
/**
* @brief Content Type.
*
*/
CertificateContentType ContentType;
};
/**
* @brief Client Certificate Credential authenticates with the Azure services using a
* Tenant ID, Client ID and a client secret.
*
*/
class TestClientSecretCredential final : public Core::Credentials::TokenCredential {
@ -134,9 +153,9 @@ namespace Azure {
m_defaultWait = 10s;
}
// When running live tests, service can return 429 error response if the client is sending
// multiple requests per second. This can happen if the network is fast and tests are running
// without any delay between them.
// When running live tests, service can return 429 error response if the client is
// sending multiple requests per second. This can happen if the network is fast and
// tests are running without any delay between them.
auto avoidTestThrottled = GetEnv("AZURE_KEYVAULT_AVOID_THROTTLED", "0");
if (avoidTestThrottled != "0")
@ -266,6 +285,28 @@ namespace Azure {
return cert.Value;
}
};
Azure::Response<DownloadCertificateResult> DownloadCertificate(
std::string const& name,
CertificateClient const& client,
Azure::Core::Context const& context = Azure::Core::Context()) const
{
{
KeyVaultCertificateWithPolicy certificate;
auto response = client.GetCertificate(name, context);
certificate = response.Value;
Azure::Core::Url url(certificate.SecretId);
auto secretRequest
= client.CreateRequest(Azure::Core::Http::HttpMethod::Get, {url.GetPath()});
auto secretResponse = client.SendRequest(secretRequest, context);
auto secret = _detail::KeyVaultSecretSerializer::Deserialize(*secretResponse);
DownloadCertificateResult result{secret.Value, secret.ContentType.Value()};
return Azure::Response<DownloadCertificateResult>(
std::move(result), std::move(secretResponse));
}
}
};
}}}}} // namespace Azure::Security::KeyVault::Certificates::Test

View File

@ -173,11 +173,10 @@ TEST_F(KeyVaultCertificateClientTest, GetCertificateVersion)
auto const& client
= GetClientForTest(::testing::UnitTest::GetInstance()->current_test_info()->name());
GetCertificateVersionOptions options;
options.Version = CreateCertificate(certificateName, client, m_defaultWait).Properties.Version;
std::string version
= CreateCertificate(certificateName, client, m_defaultWait).Properties.Version;
{
auto response = client.GetCertificateVersion(certificateName, options);
auto response = client.GetCertificateVersion(certificateName, version);
CheckValidResponse(response);
auto cert = response.Value;
EXPECT_EQ(cert.Name(), cert.Properties.Name);
@ -305,7 +304,7 @@ TEST_F(KeyVaultCertificateClientTest, CreateGetIssuer)
issuer.Organization.AdminDetails.emplace_back(admin);
{
auto result = client.CreateIssuer(issuer);
auto result = client.CreateIssuer(issuer.Name, issuer);
CheckIssuers(result.Value, issuer);
}
@ -341,7 +340,7 @@ TEST_F(KeyVaultCertificateClientTest, UpdateIssuer)
issuer.Organization.AdminDetails.emplace_back(admin);
{
auto result = client.CreateIssuer(issuer);
auto result = client.CreateIssuer(issuer.Name, issuer);
CheckIssuers(result.Value, issuer);
}
@ -380,11 +379,11 @@ TEST_F(KeyVaultCertificateClientTest, SetContacts)
auto response = client.SetContacts(contacts);
CheckContactsCollections(contacts, response.Value);
CheckContactsCollections(contacts, response.Value.Contacts);
auto response2 = client.DeleteContacts();
CheckContactsCollections(contacts, response2.Value);
CheckContactsCollections(contacts, response2.Value.Contacts);
}
TEST_F(KeyVaultCertificateClientTest, GetContacts)
@ -411,11 +410,11 @@ TEST_F(KeyVaultCertificateClientTest, GetContacts)
client.SetContacts(contacts);
auto response = client.GetContacts();
CheckContactsCollections(contacts, response.Value);
CheckContactsCollections(contacts, response.Value.Contacts);
auto response2 = client.DeleteContacts();
CheckContactsCollections(contacts, response2.Value);
CheckContactsCollections(contacts, response2.Value.Contacts);
}
TEST_F(KeyVaultCertificateClientTest, GetContactsPartial)
@ -444,11 +443,11 @@ TEST_F(KeyVaultCertificateClientTest, GetContactsPartial)
client.SetContacts(contacts);
auto response = client.GetContacts();
CheckContactsCollections(contacts, response.Value);
CheckContactsCollections(contacts, response.Value.Contacts);
auto response2 = client.DeleteContacts();
CheckContactsCollections(contacts, response2.Value);
CheckContactsCollections(contacts, response2.Value.Contacts);
}
TEST_F(KeyVaultCertificateClientTest, GetContactsDuplicateEmail)
@ -477,11 +476,11 @@ TEST_F(KeyVaultCertificateClientTest, GetContactsDuplicateEmail)
client.SetContacts(contacts);
auto response = client.GetContacts();
CheckContactsCollections(contacts, response.Value);
CheckContactsCollections(contacts, response.Value.Contacts);
auto response2 = client.DeleteContacts();
CheckContactsCollections(contacts, response2.Value);
CheckContactsCollections(contacts, response2.Value.Contacts);
}
TEST_F(KeyVaultCertificateClientTest, GetCertificatePolicy)
@ -783,11 +782,11 @@ TEST_F(KeyVaultCertificateClientTest, GetPropertiesOfIssuers)
issuer2.Organization.AdminDetails.emplace_back(admin);
{
auto result = client.CreateIssuer(issuer);
auto result = client.CreateIssuer(issuer.Name, issuer);
CheckIssuers(result.Value, issuer);
}
{
auto result = client.CreateIssuer(issuer2);
auto result = client.CreateIssuer(issuer2.Name, issuer2);
CheckIssuers(result.Value, issuer2);
}
{
@ -862,7 +861,7 @@ TEST_F(KeyVaultCertificateClientTest, DownloadImportPkcs)
= CreateCertificate(pkcs, client, m_defaultWait, "CN=xyz", CertificateContentType::Pkcs12);
{
auto result = client.DownloadCertificate(pkcs);
auto result = DownloadCertificate(pkcs, client);
auto params = ImportCertificateOptions();
params.Value = result.Value.Certificate;
@ -911,7 +910,7 @@ TEST_F(KeyVaultCertificateClientTest, DownloadImportPem)
= CreateCertificate(pem, client, m_defaultWait, "CN=xyz", CertificateContentType::Pem);
{
auto result = client.DownloadCertificate(pem);
auto result = DownloadCertificate(pem, client);
auto params = ImportCertificateOptions();
params.Value = result.Value.Certificate;
@ -957,7 +956,11 @@ TEST_F(KeyVaultCertificateClientTest, UpdateCertificate)
certificate.Properties.Enabled = false;
CertificateUpdateOptions updateOptions;
updateOptions.Properties = certificate.Properties;
auto updatedCert = client.UpdateCertificateProperties(updateOptions).Value;
auto updatedCert
= client
.UpdateCertificateProperties(
certificate.Properties.Name, certificate.Properties.Version, updateOptions)
.Value;
EXPECT_FALSE(updatedCert.Properties.Enabled.Value());
}
{
@ -991,7 +994,7 @@ TEST_F(KeyVaultCertificateClientTest, DISABLED_MergeCertificate)
{
auto certificate = CreateCertificate(pkcsToMerge, client, 1s, "CN=bbb");
auto result = client.DownloadCertificate(pkcsToMerge);
auto result = DownloadCertificate(pkcsToMerge, client);
// mergeParams.Certificates.emplace_back(Azure::Core::Convert::Base64Encode(certificate.Cer));
}
{