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

SNOW-723810: Add coverage for RestRequest #784

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions Snowflake.Data.Tests/UnitTests/SFOktaTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,62 @@ public void TestWrongPostbackUrl()
Assert.AreEqual(SFError.IDP_SAML_POSTBACK_INVALID.GetAttribute<SFErrorAttr>().errorCode, e.ErrorCode);
}
}

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

LoginRequestClientEnv loginRequestClientEnv = new LoginRequestClientEnv();

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

// Assert
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()
{
// Arrange
string expectedOktaAccount = "mockOktaAccount";

// Act
AuthenticatorRequest authenticatorRequest = new AuthenticatorRequest()
{
Data = new AuthenticatorRequestData()
{
AccountName = expectedOktaAccount,
}
};

// Assert
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