On SQL Server 2005 twenty rules stood as "not measurable" (Query Store, system_health, memory columns …) between the real gaps, and counted in the overview's "regler ikke målbare". They are not gaps: the version simply lacks what they look at. - New RuleOutcome.NotApplicable (last in the enum: outcomes are stored as numbers, so existing rows keep their meaning). - A rule or collector missing only capabilities inherent to the instance (version-gated, plan cache memory columns, or Azure-managed) is not applicable, with the version each needs: "Ikke relevant for SQL Server 2005: kræver QueryStore (fra SQL Server 2016)". Missing settings or rights (HADR not enabled …), collector failures and permission errors stay "not measurable". CollectedData.MarkNotApplicable carries this from collectors to the rules that use their data; community rules below their minimumVersion are not applicable too. - Counts are unchanged in shape: the overview, KPI, JSON API and Prometheus count outcomes 2 and 3 only. The instance page lists the rest in a collapsed "Ikke relevant for SQL Server 2005 (n)" (details/summary, no JS) after the real gaps. Report controls whose core rule does not apply count neither as met nor as not measured. Tests: engine (version vs. setting vs. collected data), inherent capabilities, the existing version tests now expect not applicable, report control status, and the web page and overview count. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
28 lines
1.3 KiB
C#
28 lines
1.3 KiB
C#
using SQLInsight.Reports;
|
|
using SQLInsight.Repository;
|
|
using SQLInsight.Rules.Engine;
|
|
|
|
namespace SQLInsight.Agent.Tests;
|
|
|
|
public class ComplianceControlTests
|
|
{
|
|
private static readonly ComplianceControl Integrity = ComplianceControl.All.Single(c => c.Name == "Integritetstjek");
|
|
|
|
[Fact]
|
|
public void Control_whose_core_rule_does_not_apply_to_the_version_is_not_counted_as_not_measured()
|
|
{
|
|
var states = new[]
|
|
{
|
|
new InstanceRuleState("KGAA-S05", "SQLI-DB-009", RuleOutcome.NotApplicable, "Ikke relevant for SQL Server 2005"),
|
|
new InstanceRuleState("KGAA-S05", "SQLI-DB-010", RuleOutcome.Passed, null),
|
|
new InstanceRuleState("SQL01", "SQLI-DB-009", RuleOutcome.NotMeasurable, "Adgang nægtet"),
|
|
new InstanceRuleState("SQL02", "SQLI-DB-009", RuleOutcome.Passed, null),
|
|
new InstanceRuleState("SQL03", "SQLI-DB-010", RuleOutcome.Findings, null),
|
|
};
|
|
|
|
Assert.Equal(ControlStatus.NotApplicable, Integrity.StatusOn("KGAA-S05", states));
|
|
Assert.Equal(ControlStatus.NotMeasured, Integrity.StatusOn("SQL01", states)); // a real gap stays a gap
|
|
Assert.Equal(ControlStatus.Met, Integrity.StatusOn("SQL02", states));
|
|
Assert.Equal(ControlStatus.NotMet, Integrity.StatusOn("SQL03", states)); // a finding always counts
|
|
}
|
|
}
|