Skip to content

Commit

Permalink
SNOW-723810: Add coverage for RestRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-lf committed Oct 6, 2023
1 parent 6feb3cb commit ad92e98
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
49 changes: 49 additions & 0 deletions Snowflake.Data.Tests/UnitTests/SFOktaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,54 @@ public void TestWrongPostbackUrl()
Assert.AreEqual(SFError.IDP_SAML_POSTBACK_INVALID.GetAttribute<SFErrorAttr>().errorCode, e.ErrorCode);
}
}

[Test]
public void TestLoginRequestToString()
{
string expectedOktaAccount = "mockOktaAccount";
string expectedOktaUser = "mockOktaUser";
string expectedOktaUrl = "mockOktaUrl";

LoginRequestClientEnv loginRequestClientEnv = new LoginRequestClientEnv();
LoginRequest loginRequest = new LoginRequest()
{
data = new LoginRequestData()
{
loginName = expectedOktaUser,
accountName = expectedOktaAccount,
clientAppVersion = SFEnvironment.DriverVersion,
clientEnv = loginRequestClientEnv,
Authenticator = expectedOktaUrl,
}
};

Assert.AreEqual($"LoginRequest {{data: LoginRequestData {{ClientAppVersion: {SFEnvironment.DriverVersion},\n " +
$"AccountName: {expectedOktaAccount},\n " +
$"loginName: {expectedOktaUser},\n " +
$"ClientEnv: {{ " +
$"APPLICATION: , " +
$"OS_VERSION: , " +
$"NET_RUNTIME: , " +
$"NET_VERSION: , " +
$"INSECURE_MODE: }},\n " +
$"authenticator: {expectedOktaUrl} }} }}",
loginRequest.ToString());
}

[Test]
public void TestAuthenticatorRequestToString()
{
string expectedOktaAccount = "mockOktaAccount";
AuthenticatorRequest authenticatorRequest = new AuthenticatorRequest()
{
Data = new AuthenticatorRequestData()
{
AccountName = expectedOktaAccount,
}
};

Assert.AreEqual($"AuthenticatorRequest {{data: AuthenticatorRequestData {{ACCOUNT_NAME: {expectedOktaAccount} }} }}",
authenticatorRequest.ToString());
}
}
}
2 changes: 1 addition & 1 deletion Snowflake.Data/Core/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class AuthenticatorRequestData

public override string ToString()
{
return String.Format("AuthenticatorRequestData {{ACCOUNT_NANM: {0} }}",
return String.Format("AuthenticatorRequestData {{ACCOUNT_NAME: {0} }}",
AccountName.ToString());
}
}
Expand Down

0 comments on commit ad92e98

Please sign in to comment.