diff --git a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs index 9eaebe377..6f3c87291 100644 --- a/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFConnectionIT.cs @@ -839,7 +839,7 @@ public void TestOktaConnectionUntilMaxTimeout() { TokenUrl = $"{oktaUrl}/api/v1/sessions?additionalFields=cookieToken", SSOUrl = $"{oktaUrl}/app/testaccount/sso/saml", - ResponseContent = new StringContent(" GetAsync(IRestRequest request, CancellationToken cancellationT public Task GetAsync(IRestRequest request, CancellationToken cancellationToken) { var response = new HttpResponseMessage(System.Net.HttpStatusCode.OK); - response.Content = ResponseContent; + response.Content = new StringContent(ResponseContent); response.Content.Headers.Add(OktaAuthenticator.RetryCountHeader, MaxRetryCount.ToString()); response.Content.Headers.Add(OktaAuthenticator.TimeoutElapsedHeader, MaxRetryTimeout.ToString()); return Task.FromResult(response); diff --git a/Snowflake.Data.Tests/UnitTests/SFOktaTest.cs b/Snowflake.Data.Tests/UnitTests/SFOktaTest.cs index f6a8835fa..97b48068c 100644 --- a/Snowflake.Data.Tests/UnitTests/SFOktaTest.cs +++ b/Snowflake.Data.Tests/UnitTests/SFOktaTest.cs @@ -10,9 +10,9 @@ namespace Snowflake.Data.Tests.UnitTests [TestFixture] class SFOktaTest { - StringContent wrongPostbackContent = new StringContent(" < !DOCTYPE html >< html lang =\"en\">\n\n\n\n\n\n\n\n\n\n\n\nSnowflake - Signing in...\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n \n\n
\n
\n
\n
\n \"Please\"Please\"Okta\"
\n
\n

Signing in to TESTACCOUNT (regression)

\n
\n
\n
\n\n \n
\n \n \n
\n\n
\n\n\n\n"); - StringContent noPostbackContent = new StringContent(" < !DOCTYPE html >< html lang =\"en\">\n\n\n\n\n\n\n\n\n\n\n\nSnowflake - Signing in...\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n \n\n
\n
\n
\n
\n \"Please\"Please\"Okta\"
\n
\n

Signing in to TESTACCOUNT (regression)

\n
\n
\n
\n\n \n
\n \n \n
\n\n
\n\n\n\n"); - StringContent correctPostbackContent = new StringContent("
\n\n\n\n\n\n\n\n\n\n\n\nSnowflake - Signing in...\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n \n\n
\n
\n
\n
\n \"Please\"Please\"Okta\"
\n
\n

Signing in to TESTACCOUNT (regression)

\n
\n
\n
\n\n \n \n \n \n\n\n
\n\n\n\n"; + const string NoPostbackContent = " < !DOCTYPE html >< html lang =\"en\">\n\n\n\n\n\n\n\n\n\n\n\nSnowflake - Signing in...\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n \n\n
\n
\n
\n
\n \"Please\"Please\"Okta\"
\n
\n

Signing in to TESTACCOUNT (regression)

\n
\n
\n
\n\n \n
\n \n \n
\n\n
\n\n\n\n"; + const string CorrectPostbackContent = "
(idpTokenRestRequest); + var idpResponse = session.restRequester.Post(idpTokenRestRequest); string onetimeToken = idpResponse.SessionToken ?? idpResponse.CookieToken; s_logger.Debug("step 4: Get SAML response from SSO"); @@ -159,11 +164,16 @@ void IAuthenticator.Authenticate() Login(); return; } - catch(Exception ex) + catch (Exception ex) { lastRetryException = ex; HandleAuthenticatorException(ex, samlRawResponse, ref retryCount, ref timeoutElapsed); } + finally + { + samlRawResponse?.Dispose(); + samlRawResponse = null; + } } // while retry // Throw exception if max retry count or max timeout has been reached