Skip to content

Commit d2be2be

Browse files
authored
Tests | Active Issues (Part 2) (#3624)
* Reactivate: OpeningConnectionWithGoodCertificateTest, OpeningConnectionWithHnicTest * Fix name
1 parent d244be2 commit d2be2be

File tree

1 file changed

+14
-16
lines changed
  • src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert

1 file changed

+14
-16
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/SQL/ConnectionTestWithSSLCert/CertificateTest.cs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace Microsoft.Data.SqlClient.ManualTesting.Tests
2020
{
21+
[PlatformSpecific(TestPlatforms.Windows)]
2122
public class CertificateTest : IDisposable
2223
{
2324
#region Private Fields
@@ -75,10 +76,11 @@ public CertificateTest()
7576
SlashInstanceName = $"\\{InstanceName}";
7677
}
7778

78-
Assert.True(DataTestUtility.IsAdmin, "CertificateTest class needs to be run in Admin mode.");
79-
80-
CreateValidCertificate(s_fullPathToPowershellScript);
81-
_thumbprint = Environment.GetEnvironmentVariable(ThumbPrintEnvName, EnvironmentVariableTarget.Machine);
79+
if (IsAdmin())
80+
{
81+
CreateValidCertificate(s_fullPathToPowershellScript);
82+
_thumbprint = Environment.GetEnvironmentVariable(ThumbPrintEnvName, EnvironmentVariableTarget.Machine);
83+
}
8284
}
8385

8486
private static bool IsLocalHost()
@@ -89,19 +91,18 @@ private static bool IsLocalHost()
8991
}
9092

9193
private static bool AreConnStringsSetup() => DataTestUtility.AreConnStringsSetup();
94+
private static bool IsAdmin() => DataTestUtility.IsAdmin;
9295
private static bool IsNotAzureServer() => DataTestUtility.IsNotAzureServer();
9396
private static bool UseManagedSNIOnWindows() => DataTestUtility.UseManagedSNIOnWindows;
9497

95-
[ActiveIssue("31754")]
96-
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost))]
97-
[PlatformSpecific(TestPlatforms.Windows)]
98-
public void OpenningConnectionWithGoodCertificateTest()
98+
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
99+
public void OpeningConnectionWithGoodCertificateTest()
99100
{
100101
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString);
101102

102103
// confirm that ForceEncryption is enabled
103-
using SqlConnection notEncryptedConnection = new(builder.ConnectionString);
104104
builder.Encrypt = SqlConnectionEncryptOption.Optional;
105+
using SqlConnection notEncryptedConnection = new(builder.ConnectionString);
105106
notEncryptedConnection.Open();
106107
Assert.Equal(ConnectionState.Open, notEncryptedConnection.State);
107108

@@ -122,10 +123,8 @@ public void OpenningConnectionWithGoodCertificateTest()
122123

123124
// Provided hostname in certificate are:
124125
// localhost, FQDN, Loopback IPv4: 127.0.0.1, IPv6: ::1
125-
[ActiveIssue("31754")]
126-
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost))]
127-
[PlatformSpecific(TestPlatforms.Windows)]
128-
public void OpeningConnectionWitHNICTest()
126+
[ConditionalFact(nameof(AreConnStringsSetup), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
127+
public void OpeningConnectionWithNicTest()
129128
{
130129
// Mandatory
131130
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString)
@@ -143,7 +142,7 @@ public void OpeningConnectionWitHNICTest()
143142
Assert.Equal(ConnectionState.Open, connection.State);
144143

145144
// Ipv6 however causes name mistmatch error
146-
// In net6 Manged SNI does not check for SAN. Therefore Application using Net6 have to use FQDN as HNIC
145+
// In net6 Manged SNI does not check for SAN. Therefore, Application using Net6 have to use FQDN as HNIC
147146
// According to above no other hostname in certificate than FQDN will work in net6 which is same as SubjectName in case of RemoteCertificateNameMismatch
148147
// Net7.0 the new API added by dotnet runtime will check SANS and then SubjectName
149148

@@ -166,8 +165,7 @@ public void OpeningConnectionWitHNICTest()
166165
}
167166
}
168167

169-
[ConditionalFact(nameof(AreConnStringsSetup), nameof(UseManagedSNIOnWindows), nameof(IsNotAzureServer), nameof(IsLocalHost))]
170-
[PlatformSpecific(TestPlatforms.Windows)]
168+
[ConditionalFact(nameof(AreConnStringsSetup), nameof(UseManagedSNIOnWindows), nameof(IsNotAzureServer), nameof(IsLocalHost), nameof(IsAdmin))]
171169
public void RemoteCertificateNameMismatchErrorTest()
172170
{
173171
SqlConnectionStringBuilder builder = new(DataTestUtility.TCPConnectionString)

0 commit comments

Comments
 (0)