Kusto NoAuth authentication (#1161)

* Added username and password to DataSourceConnectionDetails. Refactored KustoClient>GetKustoConnectionStringBuilder to accept no username or password for no credentials authentication.

* Removed invalid Unit Test and added 2 unit tests for testing authentication type.

* Added validation for dstsAuth and AzureMFA in DataSourceFactory. Added unit test for validation.
This commit is contained in:
Justin M
2021-02-23 17:29:09 -08:00
committed by GitHub
parent 294a6f4dc2
commit 13a7d4aa2b
4 changed files with 39 additions and 22 deletions

View File

@@ -7,17 +7,19 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
{
public class KustoClientTests
{
[Test]
public void Constructor_Throws_ArgumentException_For_MissingToken()
{
var connectionDetails = new DataSourceConnectionDetails
{
UserToken = ""
};
Assert.Throws<ArgumentException>(() => new KustoClient(connectionDetails, "ownerUri"));
}
[TestCase("dstsAuth")]
[TestCase("AzureMFA")]
public void Constructor_Throws_ArgumentException_For_MissingToken(string authType)
{
var connectionDetails = new DataSourceConnectionDetails
{
UserToken = "",
AuthenticationType = authType
};
Assert.Throws<ArgumentException>(() => new KustoClient(connectionDetails, "ownerUri"));
}
[Test]
public void Constructor_Sets_ClusterName_With_DefaultDatabaseName()
{
@@ -38,6 +40,8 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
[TestCase("dstsAuth")]
[TestCase("AzureMFA")]
[TestCase("NoAuth")]
[TestCase("SqlLogin")]
public void Constructor_Creates_Client_With_Valid_AuthenticationType(string authenticationType)
{
string clusterName = "https://fake.url.com";
@@ -46,7 +50,9 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
UserToken = "UserToken",
ServerName = clusterName,
DatabaseName = "FakeDatabaseName",
AuthenticationType = authenticationType
AuthenticationType = authenticationType,
UserName = authenticationType == "SqlLogin" ? "username": null,
Password = authenticationType == "SqlLogin" ? "password": null
};
var client = new KustoClient(connectionDetails, "ownerUri");