Skip to content

Commit

Permalink
Fixed test for mfa
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmartinezramirez committed Sep 4, 2024
1 parent f133cfe commit e36f8ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Snowflake.Data.Tests.UnitTests
using Snowflake.Data.Core.Tools;
using Snowflake.Data.Tests.Util;

[TestFixture]
[TestFixture, NonParallelizable]
class ConnectionPoolManagerMFATest
{
private readonly ConnectionPoolManager _connectionPoolManager = new ConnectionPoolManager();
Expand Down Expand Up @@ -100,12 +100,12 @@ public void TestPoolManagerShouldOnlyUsePasscodeAsArgumentForFirstSessionWhenNot
{
authResponseSessionInfo = new SessionInfo()
});

// Act
var session = _connectionPoolManager.GetSession(ConnectionStringMFABasicWithoutPasscode, null, SecureStringHelper.Encode(TestPasscode));
Thread.Sleep(5000);
_connectionPoolManager.GetSession(ConnectionStringMFABasicWithoutPasscode, null, SecureStringHelper.Encode(TestPasscode));
Thread.Sleep(8000);

// Assert

Assert.AreEqual(3, s_restRequester.LoginRequests.Count);
var request = s_restRequester.LoginRequests.ToList();
Assert.AreEqual(1, request.Count(r => r.data.extAuthnDuoMethod == "passcode" && r.data.passcode == TestPasscode));
Expand Down
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/Session/SessionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal SFSession GetSession(string connStr, SecureString password, SecureStrin
if (!GetPooling())
return NewNonPoolingSession(connStr, password, passcode);
var isMfaAuthentication = sessionProperties.TryGetValue(SFSessionProperty.AUTHENTICATOR, out var authenticator) && authenticator == MFACacheAuthenticator.AUTH_NAME;
var sessionOrCreateTokens = GetIdleSession(connStr, isMfaAuthentication ? 1 : Int32.MaxValue);
var sessionOrCreateTokens = GetIdleSession(connStr, isMfaAuthentication ? 1 : int.MaxValue);
if (sessionOrCreateTokens.Session != null)
{
_sessionPoolEventHandler.OnSessionProvided(this);
Expand Down

0 comments on commit e36f8ed

Please sign in to comment.