Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add retries to DisableCrlValidation test to improve reliability #5537

Merged
merged 9 commits into from
May 16, 2024
36 changes: 27 additions & 9 deletions sdk/core/azure-core/test/ut/transport_policy_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,19 +430,37 @@ namespace Azure { namespace Core { namespace Test {
TEST_F(TransportAdapterOptions, DisableCrlValidation)
{
Azure::Core::Url testUrl(AzureSdkHttpbinServer::Get());
// Azure::Core::Url testUrl("https://www.microsoft.com/");

// HTTP Connections.
auto failedCounter = 0;
for (auto i = 0; i < 3; i++)
{
Azure::Core::Http::Policies::TransportOptions transportOptions;
GTEST_LOG_(INFO) << "DisableCrlValidation test iteration " << i << ".";
try
{
Azure::Core::Http::Policies::TransportOptions transportOptions;

// Note that the default is to *disable* CRL checks, because they are disabled
// by default. So we test *enabling* CRL validation checks.
transportOptions.EnableCertificateRevocationListCheck = true;
HttpPipeline pipeline(CreateHttpPipeline(transportOptions));
// Note that the default is to *disable* CRL checks, because they are disabled
// by default. So we test *enabling* CRL validation checks.
transportOptions.EnableCertificateRevocationListCheck = true;
HttpPipeline pipeline(CreateHttpPipeline(transportOptions));

auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Get, testUrl);
auto response = pipeline.Send(request, Azure::Core::Context::ApplicationContext);
EXPECT_EQ(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok);
auto request = Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Get, testUrl);
auto response = pipeline.Send(request, Azure::Core::Context::ApplicationContext);
EXPECT_EQ(response->GetStatusCode(), Azure::Core::Http::HttpStatusCode::Ok);
}
catch (Azure::Core::Http::TransportException const& ex)
{
// CURL returns a connection error which triggers a transport exception.
GTEST_LOG_(INFO) << "DisableCrlValidation test iteration " << i
<< " failed with a TransportException.";
failedCounter++;
// We allow 1 intermittent failure, due to networking issues.
if (failedCounter > 1)
ahsonkhan marked this conversation as resolved.
Show resolved Hide resolved
{
throw;
}
}
}
#if defined(ENABLE_PROXY_TESTS)
if (IsSquidProxyRunning)
Expand Down
Loading