Some checks are pending
CI / Integration (mcr.microsoft.com/mssql/server:2017-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2019-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2022-latest) (push) Blocked by required conditions
CI / Integration (mcr.microsoft.com/mssql/server:2025-latest) (push) Blocked by required conditions
CI / Build og unit tests (push) Waiting to run
- Managed Instance reports 12.0.2000.8 but is evergreen: treated as the newest engine with all capabilities; new SelfManagedInfrastructure capability so backup, CHECKDB, files, tempdb, memory, patch level and lifecycle rules report 'handled by Azure' instead of false findings - Microsoft Entra ID login (managed identity, service principal, default credential chain) via SqlConnection.AccessTokenCallback - Least-privilege script recognizes Managed Instance; deadlock collector falls back to the ring buffer when event files cannot be read - Web UI shows the right release for Managed Instance - README and installation docs: notifications and Managed Instance - Catalog test: 61 rules with unique, well-formed ids Integration suite green on SQL Server 2017 and 2022. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E3EExwndy8Z22EK2Qpt6BK
75 lines
3.2 KiB
C#
75 lines
3.2 KiB
C#
namespace SQLInsight.Connectivity.Tests;
|
|
|
|
public class ConnectionStringsTests
|
|
{
|
|
[Fact]
|
|
public void SqlClient_defaults_to_mandatory_encryption_with_certificate_validation()
|
|
{
|
|
var cs = ConnectionStrings.ForSqlClient(new ConnectionTarget { Server = "sql01" });
|
|
|
|
Assert.Contains("Encrypt=True", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.DoesNotContain("Trust Server Certificate=True", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.Contains("Integrated Security=True", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.Contains("Application Name=\"SQLInsight Pro\"", cs, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Fact]
|
|
public void Odbc_uses_configured_driver_and_sql_login()
|
|
{
|
|
var cs = ConnectionStrings.ForOdbc(new ConnectionTarget
|
|
{
|
|
Server = "legacy01",
|
|
Authentication = AuthenticationMode.SqlLogin,
|
|
UserName = "sqlinsight",
|
|
Password = "secret",
|
|
Encryption = EncryptionMode.Optional,
|
|
OdbcDriver = "SQL Server",
|
|
});
|
|
|
|
Assert.Contains("Driver={SQL Server}", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.Contains("UID=sqlinsight", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.Contains("Encrypt=no", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.DoesNotContain("Trusted_Connection", cs, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Fact]
|
|
public void Sql_login_without_user_name_is_rejected()
|
|
{
|
|
var target = new ConnectionTarget { Server = "sql01", Authentication = AuthenticationMode.SqlLogin };
|
|
|
|
Assert.Throws<ArgumentException>(() => ConnectionStrings.ForSqlClient(target));
|
|
}
|
|
}
|
|
|
|
public class EntraTests
|
|
{
|
|
[Fact]
|
|
public void Entra_connection_string_carries_no_credentials()
|
|
{
|
|
var cs = ConnectionStrings.ForSqlClient(new ConnectionTarget { Server = "mi.abc.database.windows.net", Authentication = AuthenticationMode.EntraManagedIdentity });
|
|
|
|
Assert.DoesNotContain("Integrated Security=True", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.DoesNotContain("User ID", cs, StringComparison.OrdinalIgnoreCase);
|
|
Assert.DoesNotContain("Password", cs, StringComparison.OrdinalIgnoreCase);
|
|
}
|
|
|
|
[Fact]
|
|
public void Entra_is_not_offered_over_odbc()
|
|
{
|
|
Assert.Throws<NotSupportedException>(() => ConnectionStrings.ForOdbc(new ConnectionTarget { Server = "x", Authentication = AuthenticationMode.EntraDefault }));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(AuthenticationMode.EntraManagedIdentity, "Azure.Identity.ManagedIdentityCredential")]
|
|
[InlineData(AuthenticationMode.EntraDefault, "Azure.Identity.DefaultAzureCredential")]
|
|
public void Credential_type_follows_the_mode(AuthenticationMode mode, string type)
|
|
{
|
|
Assert.Equal(type, EntraCredentials.For(new ConnectionTarget { Server = "x", Authentication = mode }).GetType().FullName);
|
|
}
|
|
|
|
[Fact]
|
|
public void Service_principal_needs_tenant_client_and_secret()
|
|
{
|
|
Assert.Throws<ArgumentException>(() => EntraCredentials.For(new ConnectionTarget { Server = "x", Authentication = AuthenticationMode.EntraServicePrincipal, UserName = "client" }));
|
|
}
|
|
}
|