Introduce AAD interactive auth mode (#1860)

This commit is contained in:
Cheena Malhotra
2023-03-02 09:39:54 -08:00
committed by GitHub
parent 98e50c98fe
commit 187b6ecc14
47 changed files with 918 additions and 151 deletions

View File

@@ -12,14 +12,15 @@ using Microsoft.Kusto.ServiceLayer.DataSource;
using Microsoft.Kusto.ServiceLayer.DataSource.Intellisense;
using Microsoft.Kusto.ServiceLayer.LanguageServices;
using Microsoft.Kusto.ServiceLayer.Workspace.Contracts;
using static Microsoft.SqlTools.Shared.Utility.Constants;
using NUnit.Framework;
namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
{
public class DataSourceFactoryTests
{
[TestCase(typeof(ArgumentException), "ConnectionString", "", "AzureMFA")]
[TestCase(typeof(ArgumentException), "ConnectionString", "", "dstsAuth")]
[TestCase(typeof(ArgumentException), "ConnectionString", "", AzureMFA)]
[TestCase(typeof(ArgumentException), "ConnectionString", "", dstsAuth)]
public void Create_Throws_Exceptions_For_InvalidAzureAccountToken(Type exceptionType, string connectionString, string azureAccountToken, string authType)
{
Program.ServiceName = "Kusto";

View File

@@ -8,14 +8,15 @@
using System;
using Microsoft.Kusto.ServiceLayer.DataSource.Contracts;
using Microsoft.Kusto.ServiceLayer.DataSource.Kusto;
using static Microsoft.SqlTools.Shared.Utility.Constants;
using NUnit.Framework;
namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
{
public class KustoClientTests
{
[TestCase("dstsAuth")]
[TestCase("AzureMFA")]
[TestCase(dstsAuth)]
[TestCase(AzureMFA)]
public void Constructor_Throws_ArgumentException_For_MissingToken(string authType)
{
var connectionDetails = new DataSourceConnectionDetails
@@ -37,7 +38,7 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
UserToken = "UserToken",
ServerName = clusterName,
DatabaseName = "",
AuthenticationType = "AzureMFA"
AuthenticationType = AzureMFA
};
var client = new KustoClient(connectionDetails, "ownerUri");
@@ -46,10 +47,10 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
Assert.AreEqual("NetDefaultDB", client.DatabaseName);
}
[TestCase("dstsAuth")]
[TestCase("AzureMFA")]
[TestCase(dstsAuth)]
[TestCase(AzureMFA)]
[TestCase("NoAuth")]
[TestCase("SqlLogin")]
[TestCase(SqlLogin)]
public void Constructor_Creates_Client_With_Valid_AuthenticationType(string authenticationType)
{
string clusterName = "https://fake.url.com";
@@ -59,8 +60,8 @@ namespace Microsoft.Kusto.ServiceLayer.UnitTests.DataSource
ServerName = clusterName,
DatabaseName = "FakeDatabaseName",
AuthenticationType = authenticationType,
UserName = authenticationType == "SqlLogin" ? "username": null,
Password = authenticationType == "SqlLogin" ? "password": null
UserName = authenticationType == SqlLogin ? "username": null,
Password = authenticationType == SqlLogin ? "password": null
};
var client = new KustoClient(connectionDetails, "ownerUri");