Diagnose BizTalk WMI SQL permissions
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace BizTalkCheckmkPulse.Tests
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static readonly List<string> Failures = new List<string>();
|
||||
private static int ExecutedTests;
|
||||
|
||||
private static int Main()
|
||||
{
|
||||
@@ -16,10 +18,13 @@ namespace BizTalkCheckmkPulse.Tests
|
||||
Run("KnownApplicationCreatesService", KnownApplicationCreatesService);
|
||||
Run("ServerNamesAreComparedWithoutWql", ServerNamesAreComparedWithoutWql);
|
||||
Run("GroupSettingQueryUsesDocumentedSchema", GroupSettingQueryUsesDocumentedSchema);
|
||||
Run("ProviderSqlLoginFailureIsPermission", ProviderSqlLoginFailureIsPermission);
|
||||
Run("RejectedSqlPrincipalIsExtracted", RejectedSqlPrincipalIsExtracted);
|
||||
Run("PlatformPermissionPropagatesToSqlDiscovery", PlatformPermissionPropagatesToSqlDiscovery);
|
||||
|
||||
if (Failures.Count == 0)
|
||||
{
|
||||
Console.WriteLine("PASS: 6 tests");
|
||||
Console.WriteLine("PASS: " + ExecutedTests + " tests");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -75,11 +80,54 @@ namespace BizTalkCheckmkPulse.Tests
|
||||
{
|
||||
var query = WmiBizTalkProbe.GroupSettingQuery;
|
||||
Assert(query.Contains("FROM MSBTS_GroupSetting"), "MSBTS_GroupSetting query missing");
|
||||
Assert(query.Contains("BizTalkOperatorGroup"), "configured operator group property missing");
|
||||
Assert(query.Contains("SubscriptionDBServerName"), "master MessageBox server property missing");
|
||||
Assert(query.Contains("SubscriptionDBName"), "master MessageBox database property missing");
|
||||
Assert(query.IndexOf("MessageBoxSetting", StringComparison.OrdinalIgnoreCase) < 0, "unsupported MessageBoxSetting class present");
|
||||
}
|
||||
|
||||
private static void ProviderSqlLoginFailureIsPermission()
|
||||
{
|
||||
var exception = new COMException(
|
||||
"Internal error from OLEDB provider: 'Login failed for user 'BEW\\AV23AGPWBIO1$'.'",
|
||||
unchecked((int)0x80131904));
|
||||
AssertEqual(
|
||||
DiagnosticCategory.Permission,
|
||||
WmiBizTalkProbe.ClassifyWmiException(exception),
|
||||
"provider SQL login classification");
|
||||
}
|
||||
|
||||
private static void RejectedSqlPrincipalIsExtracted()
|
||||
{
|
||||
var message = "Internal error from OLEDB provider: 'Login failed for user 'BEW\\AV23AGPWBIO1$'.'";
|
||||
AssertEqual(
|
||||
"BEW\\AV23AGPWBIO1$",
|
||||
WmiBizTalkProbe.ExtractSqlLoginPrincipal(message),
|
||||
"rejected SQL principal");
|
||||
}
|
||||
|
||||
private static void PlatformPermissionPropagatesToSqlDiscovery()
|
||||
{
|
||||
var result = new ProbeResult();
|
||||
result.Diagnostics.Add(new ProbeDiagnostic
|
||||
{
|
||||
Area = DiagnosticArea.Wmi,
|
||||
Category = DiagnosticCategory.Permission,
|
||||
Component = "MSBTS_GroupSetting",
|
||||
Required = true
|
||||
});
|
||||
|
||||
new SqlConnectivityProbe(new MonitoringOptions()).Query(result);
|
||||
|
||||
var discovery = result.Diagnostics.Single(x =>
|
||||
x.Area == DiagnosticArea.Sql
|
||||
&& x.Component == "BizTalk database discovery");
|
||||
AssertEqual(
|
||||
DiagnosticCategory.Permission,
|
||||
discovery.Category,
|
||||
"SQL discovery classification");
|
||||
}
|
||||
|
||||
private static ProbeResult CreateSuspensionResult(string applicationName)
|
||||
{
|
||||
var result = new ProbeResult();
|
||||
@@ -95,6 +143,7 @@ namespace BizTalkCheckmkPulse.Tests
|
||||
|
||||
private static void Run(string name, Action test)
|
||||
{
|
||||
ExecutedTests++;
|
||||
try
|
||||
{
|
||||
test();
|
||||
@@ -120,5 +169,21 @@ namespace BizTalkCheckmkPulse.Tests
|
||||
throw new InvalidOperationException(label + ": expected " + expected + ", actual " + actual);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertEqual(DiagnosticCategory expected, DiagnosticCategory actual, string label)
|
||||
{
|
||||
if (expected != actual)
|
||||
{
|
||||
throw new InvalidOperationException(label + ": expected " + expected + ", actual " + actual);
|
||||
}
|
||||
}
|
||||
|
||||
private static void AssertEqual(string expected, string actual, string label)
|
||||
{
|
||||
if (!string.Equals(expected, actual, StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(label + ": expected " + expected + ", actual " + actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user