Skip to content

Commit 75de390

Browse files
authored
Fix SupportsIntegratedSecurity Test Configuration (dotnet#3887)
* Test to see if our Integrated Security tests pass when they aren't skipped. * Testing if-expression evaluation with bare parameters. * Fixed null checks. * Added more cases. * Narrowing down to the string-to-bool conversion. * Root-caused the issue and documented for the future. * Disabled the failing NP tests for now. * Addressed Copilot feedback. * Skipping another test that is flaky or hangs on macOS.
1 parent 9d0b0d4 commit 75de390

File tree

5 files changed

+58
-29
lines changed

5 files changed

+58
-29
lines changed

eng/pipelines/common/templates/jobs/ci-run-tests-job.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ parameters:
1010
- name: abstractionsPackageVersion
1111
type: string
1212

13+
# The configuration properties to set in the config file.
14+
#
15+
# GOTCHA: The following keys are used in template expressions and must be
16+
# specified as boolean strings 'true' or 'false'. They cannot be specified as
17+
# runtime variables like $(SomeBooleanVar), since those are expanded after
18+
# template compilation and will literally be "$(SomeBooleanVar)" during
19+
# template expansion.
20+
#
21+
# EnclaveEnabled
22+
# IsAzureSynapse
23+
# IsDNSCachingSupportedCR
24+
# IsDNSCachingSupportedTR
25+
# ManagedIdentitySupported
26+
# SupportsFileStream
27+
# SupportsIntegratedSecurity
28+
# TracingEnabled
29+
#
1330
- name: configProperties
1431
type: object
1532
default: {} # - key: 'value'

eng/pipelines/common/templates/steps/configure-sql-server-win-step.yml

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,37 @@ steps:
7171
- powershell: |
7272
try
7373
{
74-
# enable TCP
75-
Import-Module "sqlps"
76-
$smo = 'Microsoft.SqlServer.Management.Smo.'
77-
$wmi = new-object ($smo + 'Wmi.ManagedComputer').
78-
# List the object properties, including the instance names.
79-
$Wmi
80-
81-
# Enable the TCP protocol on the default instance.
82-
$Tcp = $wmi.GetSmoObject("ManagedComputer[@Name='$env:COMPUTERNAME']/ ServerInstance[@Name='${{parameters.instanceName }}']/ServerProtocol[@Name='Tcp']")
83-
$Tcp.IsEnabled = $true
84-
$Tcp.Alter()
85-
86-
# Enable the NP protocol on the default instance.
87-
$Np = $wmi.GetSmoObject("ManagedComputer[@Name='$env:COMPUTERNAME']/ ServerInstance[@Name='${{parameters.instanceName }}']/ServerProtocol[@Name='Np']")
88-
$Np.IsEnabled = $true
89-
$Np.Alter()
90-
91-
$Tcp
74+
# Acquire a WMI handle.
75+
Import-Module "sqlps"
76+
$smo = 'Microsoft.SqlServer.Management.Smo.'
77+
$wmi = new-object ($smo + 'Wmi.ManagedComputer')
78+
79+
# List the WMI, including the instance names.
80+
Write-Host "WMI Information:"
81+
$wmi
82+
83+
# Enable the TCP protocol on the default instance.
84+
$Tcp = $wmi.GetSmoObject("ManagedComputer[@Name='$env:COMPUTERNAME']/ ServerInstance[@Name='${{parameters.instanceName }}']/ServerProtocol[@Name='Tcp']")
85+
$Tcp.IsEnabled = $true
86+
$Tcp.Alter()
87+
88+
# Emit the TCP object to the pipeline log.
89+
Write-Host "TCP Information:"
90+
$Tcp
91+
92+
# Enable the NP protocol on the default instance.
93+
$Np = $wmi.GetSmoObject("ManagedComputer[@Name='$env:COMPUTERNAME']/ ServerInstance[@Name='${{parameters.instanceName }}']/ServerProtocol[@Name='Np']")
94+
$Np.IsEnabled = $true
95+
$Np.Alter()
96+
97+
# Emit the NP object to the pipeline log.
98+
Write-Host "NP Information:"
99+
$Np
92100
}
93101
catch
94102
{
95-
$error[0] | format-list -force
96-
throw
103+
$error[0] | format-list -force
104+
throw
97105
}
98106
99107
New-NetFirewallRule -DisplayName "SQL TCP Ports" -Direction Inbound -Protocol TCP -LocalPort 1433 -Action allow

eng/pipelines/dotnet-sqlclient-ci-core.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ stages:
277277
NPConnectionString: $(SQL_NP_CONN_STRING)
278278
AzureKeyVaultUrl: $(AzureKeyVaultUrl)
279279
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
280-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
280+
SupportsIntegratedSecurity: true
281281
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
282282
FileStreamDirectory: $(FileStreamDirectory)
283283
LocalDbAppName: $(LocalDbAppName)
@@ -318,7 +318,7 @@ stages:
318318
NPConnectionString: $(SQL_NP_CONN_STRING)
319319
AzureKeyVaultUrl: $(AzureKeyVaultUrl)
320320
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
321-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
321+
SupportsIntegratedSecurity: true
322322
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
323323
FileStreamDirectory: $(FileStreamDirectory)
324324
LocalDbAppName: $(LocalDbAppName)
@@ -360,7 +360,7 @@ stages:
360360
NPConnectionString: $(SQL_NP_CONN_STRING)
361361
AzureKeyVaultUrl: $(AzureKeyVaultUrl)
362362
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
363-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
363+
SupportsIntegratedSecurity: true
364364
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
365365
FileStreamDirectory: $(FileStreamDirectory)
366366
LocalDbAppName: $(LocalDbAppName)
@@ -389,7 +389,7 @@ stages:
389389
NPConnectionString: $(SQL_NP_CONN_STRING)
390390
AzureKeyVaultUrl: $(AzureKeyVaultUrl)
391391
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
392-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
392+
SupportsIntegratedSecurity: true
393393
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
394394
FileStreamDirectory: $(FileStreamDirectory)
395395
LocalDbAppName: $(LocalDbAppName)
@@ -417,7 +417,7 @@ stages:
417417
# config.json properties
418418
TCPConnectionString: $(SQL_TCP_INSTANCE_CONN_STRING)
419419
NPConnectionString: $(SQL_NP_INSTANCE_CONN_STRING)
420-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
420+
SupportsIntegratedSecurity: true
421421
# extra config properties
422422
SQLRootPath: $(SQL22RootPath)
423423
instanceName: $(NamedInstance)
@@ -592,7 +592,7 @@ stages:
592592
AADServicePrincipalSecret: $(AADServicePrincipalSecret)
593593
AzureKeyVaultUrl: $(AzureKeyVaultUrl)
594594
AzureKeyVaultTenantId: $(AzureKeyVaultTenantId)
595-
SupportsIntegratedSecurity: $(SupportsIntegratedSecurity)
595+
SupportsIntegratedSecurity: true
596596
UserManagedIdentityClientId: $(UserManagedIdentityClientId)
597597
AliasName: $(SQLAliasName)
598598
LocalDbAppName: $(LocalDbAppName)

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/LocalDBTest/LocalDBTest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ public static void SqlLocalDbSharedInstanceConnectionTest()
9292

9393
#region NamedPipeTests
9494

95+
[ActiveIssue("https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/41665")]
9596
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
9697
public static void SqlLocalDbNamedPipeConnectionTest()
9798
{
9899
ConnectionTest(s_localDbNamedPipeConnectionString);
99100
}
100101

102+
[ActiveIssue("https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/41665")]
101103
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
102104
public static void LocalDbNamedPipeEncryptionNotSupportedTest()
103105
{
@@ -106,6 +108,7 @@ public static void LocalDbNamedPipeEncryptionNotSupportedTest()
106108
ConnectionWithEncryptionTest(s_localDbNamedPipeConnectionString);
107109
}
108110

111+
[ActiveIssue("https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/41665")]
109112
[ConditionalFact(nameof(IsLocalDBEnvironmentSet))]
110113
public static void LocalDbNamedPipeMarsTest()
111114
{

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ParameterTest/ParametersTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public static void TestParametersWithDatatablesTVPInsert()
301301

302302
cmd.ExecuteNonQuery();
303303

304-
// Verify if the data was updated
304+
// Verify if the data was updated
305305
cmd.CommandText = "select * from " + tableName;
306306
cmd.CommandType = CommandType.Text;
307307
using SqlDataReader reader = cmd.ExecuteReader();
@@ -350,7 +350,7 @@ public static void TestParametersWithSqlRecordsTVPInsert()
350350
record1,
351351
record2,
352352
};
353-
353+
354354
using SqlConnection connection = new(builder.ConnectionString);
355355
string procName = DataTestUtility.GetLongName("Proc");
356356
string typeName = DataTestUtility.GetShortName("Type");
@@ -430,7 +430,7 @@ public static void TestDateOnlyTVPDataTable_CommandSP()
430430
{
431431
cmd.CommandText = spName;
432432
cmd.CommandType = CommandType.StoredProcedure;
433-
433+
434434
DataTable dtTest = new();
435435
dtTest.Columns.Add(new DataColumn("DateColumn", typeof(DateOnly)));
436436
dtTest.Columns.Add(new DataColumn("TimeColumn", typeof(TimeOnly)));
@@ -973,6 +973,7 @@ private static void EnableOptimizedParameterBinding_ReturnSucceeds()
973973
}
974974
}
975975

976+
[SkipOnPlatform(TestPlatforms.OSX, "Flaky on macOS: https://sqlclientdrivers.visualstudio.com/ADO.Net/_workitems/edit/42351")]
976977
[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup))]
977978
public static void ClosedConnection_SqlParameterValueTest()
978979
{

0 commit comments

Comments
 (0)