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
45 lines
1.8 KiB
C#
45 lines
1.8 KiB
C#
using SQLInsight.Core.Instances;
|
|
using SQLInsight.Rules.Engine;
|
|
using static SQLInsight.Rules.Tests.TestInstances;
|
|
|
|
namespace SQLInsight.Rules.Tests;
|
|
|
|
public class ManagedInstanceTests
|
|
{
|
|
private static RuleContext ManagedInstance()
|
|
{
|
|
var info = new InstanceInfo
|
|
{
|
|
ServerName = "mi-prod.abc123.database.windows.net",
|
|
Version = SqlServerVersion.Parse("12.0.2000.8"),
|
|
Edition = "SQL Azure",
|
|
EngineEdition = EngineEdition.AzureSqlManagedInstance,
|
|
};
|
|
var context = new RuleContext(info, InstanceCapabilities.From(info), Now);
|
|
context.Data.Set(Config(("max server memory (MB)", 2147483647), ("cost threshold for parallelism", 5), ("max degree of parallelism", 0), ("xp_cmdshell", 0)));
|
|
context.Data.Set(Server(cpus: 8));
|
|
context.Data.Set(DatabaseList(Database(change: d => d with { LastFullBackup = null, LastGoodCheckDb = new DateTime(1900, 1, 1) })));
|
|
return context;
|
|
}
|
|
|
|
[Fact]
|
|
public void Azure_managed_areas_are_reported_as_handled_by_azure_not_as_findings()
|
|
{
|
|
var results = new RuleEngine(BuiltInRules.Create()).Evaluate(ManagedInstance());
|
|
|
|
foreach (var id in new[] { "SQLI-VER-001", "SQLI-VER-002", "SQLI-CFG-001", "SQLI-DB-007", "SQLI-DB-009", "SQLI-DB-015" })
|
|
{
|
|
var result = results.Single(r => r.RuleId == id);
|
|
Assert.Equal(RuleOutcome.NotMeasurable, result.Outcome);
|
|
Assert.Equal("Håndteres af Azure på Azure SQL Managed Instance.", result.Reason);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Workload_rules_still_apply()
|
|
{
|
|
var results = new RuleEngine(BuiltInRules.Create()).Evaluate(ManagedInstance());
|
|
|
|
Assert.Equal(RuleOutcome.Findings, results.Single(r => r.RuleId == "SQLI-CFG-003").Outcome); // cost threshold 5
|
|
}
|
|
}
|