Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ TEST_F(KeyVaultCertificateClientTest, CreateCertificate)

{
auto response = client.StartDeleteCertificate(certificateName);
// double polling should not have an impact on the result
auto result = response.PollUntilDone(m_defaultWait);
result = response.PollUntilDone(m_defaultWait);
EXPECT_EQ(result.Value.Name(), certificateName);
EXPECT_EQ(result.Value.Properties.Enabled.Value(), true);
EXPECT_NE(result.Value.RecoveryIdUrl.length(), size_t(0));
Expand Down Expand Up @@ -64,8 +66,9 @@ TEST_F(KeyVaultCertificateClientTest, CreateCertificateResumeToken)

auto fromToken
= CreateCertificateOperation::CreateFromResumeToken(response.GetResumeToken(), client);

// double polling should not have an impact on the result
auto result = fromToken.PollUntilDone(m_defaultWait);
result = fromToken.PollUntilDone(m_defaultWait);

auto cert = client.GetCertificate(certificateName);
EXPECT_EQ(cert.Value.Name(), options.Properties.Name);
Expand Down Expand Up @@ -192,7 +195,9 @@ TEST_F(KeyVaultCertificateClientTest, GetDeletedCertificate)
}
{
auto response = client.StartRecoverDeletedCertificate(certificateName);
// double polling should not have an impact on the result
auto result = response.PollUntilDone(m_defaultWait);
result = response.PollUntilDone(m_defaultWait);
EXPECT_EQ(result.Value.Name(), certificateName);
}
{
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,36 @@ Azure::Security::KeyVault::Keys::DeleteKeyOperation::PollInternal(
Azure::Core::Context const& context)
{
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse;
if (!IsDone())

try
{
try
{
rawResponse = m_keyClient->GetDeletedKey(m_value.Name(), context).RawResponse;
}
catch (Azure::Core::RequestFailedException& error)
{
rawResponse = std::move(error.RawResponse);
}
rawResponse = m_keyClient->GetDeletedKey(m_value.Name(), context).RawResponse;
}
catch (Azure::Core::RequestFailedException& error)
{
rawResponse = std::move(error.RawResponse);
}

switch (rawResponse->GetStatusCode())
switch (rawResponse->GetStatusCode())
{
case Azure::Core::Http::HttpStatusCode::Ok:
case Azure::Core::Http::HttpStatusCode::Forbidden: // Access denied but proof the key was
// deleted.
{
case Azure::Core::Http::HttpStatusCode::Ok:
case Azure::Core::Http::HttpStatusCode::Forbidden: // Access denied but proof the key was
// deleted.
{
m_status = Azure::Core::OperationStatus::Succeeded;
break;
}
case Azure::Core::Http::HttpStatusCode::NotFound: {
m_status = Azure::Core::OperationStatus::Running;
break;
}
default:
throw Azure::Core::RequestFailedException(rawResponse);
m_status = Azure::Core::OperationStatus::Succeeded;
break;
}

if (m_status == Azure::Core::OperationStatus::Succeeded)
{
m_value = _detail::DeletedKeySerializer::DeletedKeyDeserialize(m_value.Name(), *rawResponse);
case Azure::Core::Http::HttpStatusCode::NotFound: {
m_status = Azure::Core::OperationStatus::Running;
break;
}
default:
throw Azure::Core::RequestFailedException(rawResponse);
}

if (m_status == Azure::Core::OperationStatus::Succeeded)
{
m_value = _detail::DeletedKeySerializer::DeletedKeyDeserialize(m_value.Name(), *rawResponse);
}

// To ensure the success of calling Poll multiple times, even after operation is completed, a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,34 @@ Azure::Security::KeyVault::Keys::RecoverDeletedKeyOperation::PollInternal(
Azure::Core::Context const& context)
{
std::unique_ptr<Azure::Core::Http::RawResponse> rawResponse;
if (!IsDone())

try
{
try
{
rawResponse = m_keyClient->GetKey(m_value.Name(), {}, context).RawResponse;
}
catch (Azure::Core::RequestFailedException& error)
{
rawResponse = std::move(error.RawResponse);
}
rawResponse = m_keyClient->GetKey(m_value.Name(), {}, context).RawResponse;
}
catch (Azure::Core::RequestFailedException& error)
{
rawResponse = std::move(error.RawResponse);
}

switch (rawResponse->GetStatusCode())
{
case Azure::Core::Http::HttpStatusCode::Ok:
// Access denied but proof the key was deleted.
case Azure::Core::Http::HttpStatusCode::Forbidden: {
m_status = Azure::Core::OperationStatus::Succeeded;
break;
}
case Azure::Core::Http::HttpStatusCode::NotFound: {
m_status = Azure::Core::OperationStatus::Running;
break;
}
default:
throw Azure::Core::RequestFailedException(rawResponse);
switch (rawResponse->GetStatusCode())
{
case Azure::Core::Http::HttpStatusCode::Ok:
// Access denied but proof the key was deleted.
case Azure::Core::Http::HttpStatusCode::Forbidden: {
m_status = Azure::Core::OperationStatus::Succeeded;
break;
}
if (m_status == Azure::Core::OperationStatus::Succeeded)
{
m_value
= _detail::KeyVaultKeySerializer::KeyVaultKeyDeserialize(m_value.Name(), *rawResponse);
case Azure::Core::Http::HttpStatusCode::NotFound: {
m_status = Azure::Core::OperationStatus::Running;
break;
}
default:
throw Azure::Core::RequestFailedException(rawResponse);
}
if (m_status == Azure::Core::OperationStatus::Succeeded)
{
m_value = _detail::KeyVaultKeySerializer::KeyVaultKeyDeserialize(m_value.Name(), *rawResponse);
}

// To ensure the success of calling Poll multiple times, even after operation is completed, a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ TEST_F(KeyVaultKeyClient, DeleteKey)
EXPECT_EQ(keyResponseLRO.GetResumeToken(), expectedStatusToken);
// poll each second until key is soft-deleted
// Will throw and fail test if test takes more than 3 minutes (token cancelled)
// double polling should not interfere with the outcome
auto keyResponse = keyResponseLRO.PollUntilDone(m_testPollingIntervalMs, cancelToken);
keyResponse = keyResponseLRO.PollUntilDone(m_testPollingIntervalMs, cancelToken);
}
}

Expand Down Expand Up @@ -353,6 +355,8 @@ TEST_F(KeyVaultKeyClient, RecoverOperationResumeToken)
auto resumeOperation
= Azure::Security::KeyVault::Keys::DeleteKeyOperation::CreateFromResumeToken(
resumeToken, client);
// double polling should have no impact on the result
resumeOperation.PollUntilDone(m_testPollingIntervalMs);
resumeOperation.PollUntilDone(m_testPollingIntervalMs);
}
{
Expand All @@ -365,7 +369,9 @@ TEST_F(KeyVaultKeyClient, RecoverOperationResumeToken)
auto resumeRecoveryOp
= Azure::Security::KeyVault::Keys::RecoverDeletedKeyOperation::CreateFromResumeToken(
resumeToken, client);
// double polling should have no impact on the result
auto keyResponse = resumeRecoveryOp.PollUntilDone(m_testPollingIntervalMs);
keyResponse = resumeRecoveryOp.PollUntilDone(m_testPollingIntervalMs);
auto key = keyResponse.Value;
}
}
Loading