mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-21 09:35:39 -05:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user