diff --git a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp index 98584cec97..2ecc6ddacd 100644 --- a/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp +++ b/sdk/attestation/azure-security-attestation/samples/attestation/attest_sgxenclave_with_runtime_binary.cpp @@ -44,7 +44,8 @@ int main() // create client std::string endpoint(GetEnvHelper::GetEnv("ATTESTATION_AAD_URL")); - AttestationClient attestationClient(AttestationClient::Create(endpoint)); + std::shared_ptr attestationClient( + std::make_shared(AttestationClient::Create(endpoint))); std::vector const sgxEnclaveQuote = AttestationCollateral::SgxQuote(); @@ -56,7 +57,7 @@ int main() = AttestationData{AttestationCollateral::RunTimeData(), AttestationDataType::Binary}; Azure::Response> const sgxResult - = attestationClient.AttestSgxEnclave(sgxEnclaveQuote, attestOptions); + = attestationClient->AttestSgxEnclave(sgxEnclaveQuote, attestOptions); std::cout << "SGX Quote MRSIGNER is: " << Convert::Base64Encode(*sgxResult.Value.Body.SgxMrSigner) << std::endl; diff --git a/sdk/attestation/azure-security-attestation/samples/policy/get_policy.cpp b/sdk/attestation/azure-security-attestation/samples/policy/get_policy.cpp index b41ea3e005..c469e4ada6 100644 --- a/sdk/attestation/azure-security-attestation/samples/policy/get_policy.cpp +++ b/sdk/attestation/azure-security-attestation/samples/policy/get_policy.cpp @@ -40,6 +40,7 @@ int main() GetEnvHelper::GetEnv("AZURE_TENANT_ID"), GetEnvHelper::GetEnv("AZURE_CLIENT_ID"), GetEnvHelper::GetEnv("AZURE_CLIENT_SECRET")); + AttestationAdministrationClient adminClient(AttestationAdministrationClient::Create( GetEnvHelper::GetEnv("ATTESTATION_AAD_URL"), credential)); diff --git a/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp index 268fdbbdc1..1a4ff40f4f 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/attestation_test.cpp @@ -322,6 +322,17 @@ issuancerules { auto const client = AttestationClient::Create(this->m_endpoint, options); EXPECT_EQ(m_endpoint, client.Endpoint()); } + + { + std::unique_ptr client = std::make_unique( + AttestationClient::Create(this->m_endpoint, options)); + EXPECT_EQ(m_endpoint, client->Endpoint()); + } + { + std::unique_ptr client = std::make_unique( + AttestationClient::Create(this->m_endpoint, options)); + EXPECT_EQ(m_endpoint, client->Endpoint()); + } } namespace { diff --git a/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp b/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp index 34fc338827..dad0c78f55 100644 --- a/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp +++ b/sdk/attestation/azure-security-attestation/test/ut/tpmattestation_test.cpp @@ -28,7 +28,7 @@ namespace Azure { namespace Security { namespace Attestation { namespace Test { private: protected: std::shared_ptr m_credential; - + std::unique_ptr m_adminClient; // Create virtual void SetUp() override { @@ -36,9 +36,11 @@ namespace Azure { namespace Security { namespace Attestation { namespace Test { { // TPM attestation requires a policy document be set. For simplicity, we only run the // test against an AAD attestation service instance. - auto adminClient = CreateAdminClient(InstanceType::AAD); + m_adminClient = std::make_unique( + CreateAdminClient(InstanceType::AAD)); + // Set a minimal policy, which will make the TPM attestation code happy. - adminClient.SetAttestationPolicy( + m_adminClient->SetAttestationPolicy( AttestationType::Tpm, "version=1.0; authorizationrules{=> permit();}; issuancerules{};"); } @@ -46,11 +48,8 @@ namespace Azure { namespace Security { namespace Attestation { namespace Test { virtual void TearDown() override { - { - auto adminClient = CreateAdminClient(InstanceType::AAD); - // Reset the attestation policy for this instance back to the default. - adminClient.ResetAttestationPolicy(AttestationType::Tpm); - } + // Reset the attestation policy for this instance back to the default. + m_adminClient->ResetAttestationPolicy(AttestationType::Tpm); // Make sure you call the base classes TearDown method to ensure recordings are made. TestBase::TearDown();