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
59 lines
2.1 KiB
C#
59 lines
2.1 KiB
C#
using SQLInsight.Core.Findings;
|
|
using SQLInsight.Core.Instances;
|
|
using SQLInsight.Rules.Engine;
|
|
using SQLInsight.Rules.Lifecycle;
|
|
using static SQLInsight.Rules.Tests.TestInstances;
|
|
|
|
namespace SQLInsight.Rules.Tests;
|
|
|
|
public class PatchLevelRuleTests
|
|
{
|
|
private static readonly PatchLevelRule Rule = new(BuildCatalog.LoadEmbedded(), SupportLifecycleCatalog.LoadEmbedded());
|
|
|
|
[Fact]
|
|
public void Catalog_has_a_build_for_every_known_release()
|
|
{
|
|
var catalog = BuildCatalog.LoadEmbedded();
|
|
|
|
foreach (var release in Enum.GetValues<SqlServerRelease>().Where(r => r is not (SqlServerRelease.Unknown or SqlServerRelease.AzureSqlManagedInstance)))
|
|
{
|
|
var latest = catalog.Latest(release);
|
|
Assert.NotNull(latest);
|
|
Assert.Equal(release, latest.Build.Release);
|
|
}
|
|
}
|
|
|
|
[Fact]
|
|
public void Current_build_passes()
|
|
{
|
|
Assert.Equal(RuleOutcome.Passed, Rule.Evaluate(Context("16.0.4295.3")).Outcome);
|
|
Assert.Equal(RuleOutcome.Passed, Rule.Evaluate(Context("16.0.4300.1")).Outcome); // newer than the catalog
|
|
}
|
|
|
|
[Fact]
|
|
public void Old_cu_on_supported_release_is_high()
|
|
{
|
|
var finding = Assert.Single(Rule.Evaluate(Context("15.0.4430.1")).Findings); // 2019 CU32 without 2026 security updates
|
|
|
|
Assert.Equal(Severity.High, finding.Severity);
|
|
Assert.Contains("KB5122772", finding.Recommendation, StringComparison.Ordinal);
|
|
Assert.Contains("sikkerhedsopdatering", finding.Explanation, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void Missing_service_pack_on_unsupported_release_is_medium()
|
|
{
|
|
var finding = Assert.Single(Rule.Evaluate(Context("10.50.4000.0")).Findings); // 2008 R2 SP2
|
|
|
|
Assert.Equal(Severity.Medium, finding.Severity);
|
|
Assert.Contains("SP3", finding.Title, StringComparison.Ordinal);
|
|
}
|
|
|
|
[Fact]
|
|
public void Old_catalog_is_called_out()
|
|
{
|
|
var finding = Assert.Single(Rule.Evaluate(Context("15.0.4430.1", new DateTimeOffset(2027, 6, 1, 0, 0, 0, TimeSpan.Zero))).Findings);
|
|
|
|
Assert.Contains(finding.Evidence, e => e.Value.Contains("forældet", StringComparison.Ordinal));
|
|
}
|
|
}
|