Skip to content

Commit

Permalink
Modify test for framework version
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Sep 4, 2024
1 parent fcae8ce commit cd32ed0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ public void TestAuthenticationExceptionThrowsExceptionAndNotRetried()
using (var conn = new MockSnowflakeDbConnection(mockRestRequester))
{
string invalidConnectionString = "host=google.com/404;"
+ "connection_timeout=0;account=testFailFast;user=testFailFast;password=testFailFast;disableretry=true;forceretryon404=true";
+ "account=account;user=user;password=password;";
conn.ConnectionString = invalidConnectionString;

Assert.AreEqual(conn.State, ConnectionState.Closed);
Expand All @@ -603,8 +603,10 @@ public void TestAuthenticationExceptionThrowsExceptionAndNotRetried()
catch (AggregateException e)
{
Assert.IsInstanceOf<HttpRequestException>(e.InnerException);
#if NET6_0_OR_GREATER
Assert.IsInstanceOf<AuthenticationException>(e.InnerException.InnerException);
Assert.IsTrue(e.InnerException.InnerException.Message.Contains("The remote certificate is invalid because of errors in the certificate chain: RevocationStatusUnknown"));
#endif
}
catch (Exception unexpected)
{
Expand Down
5 changes: 4 additions & 1 deletion Snowflake.Data/Core/HttpUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
catch (Exception e)
{
lastException = e;
Exception mostInnerException = e;
while (mostInnerException.InnerException != null) mostInnerException = mostInnerException.InnerException;

if (cancellationToken.IsCancellationRequested)
{
logger.Debug("SF rest request timeout or explicit cancel called.");
Expand All @@ -404,7 +407,7 @@ protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage
logger.Warn("Http request timeout. Retry the request");
totalRetryTime += (int)httpTimeout.TotalSeconds;
}
else if (e is HttpRequestException && e.InnerException is AuthenticationException)
else if (mostInnerException is AuthenticationException)
{
logger.Error("Non-retryable error encountered: ", e);
throw;
Expand Down

0 comments on commit cd32ed0

Please sign in to comment.