18
18
19
19
namespace Microsoft . Data . SqlClient . ManualTesting . Tests
20
20
{
21
+ [ PlatformSpecific ( TestPlatforms . Windows ) ]
21
22
public class CertificateTest : IDisposable
22
23
{
23
24
#region Private Fields
@@ -75,10 +76,11 @@ public CertificateTest()
75
76
SlashInstanceName = $ "\\ { InstanceName } ";
76
77
}
77
78
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
+ }
82
84
}
83
85
84
86
private static bool IsLocalHost ( )
@@ -91,17 +93,16 @@ private static bool IsLocalHost()
91
93
private static bool AreConnStringsSetup ( ) => DataTestUtility . AreConnStringsSetup ( ) ;
92
94
private static bool IsNotAzureServer ( ) => DataTestUtility . IsNotAzureServer ( ) ;
93
95
private static bool UseManagedSNIOnWindows ( ) => DataTestUtility . UseManagedSNIOnWindows ;
96
+ private static bool IsAdmin ( ) => DataTestUtility . IsAdmin ;
94
97
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 ( )
99
100
{
100
101
SqlConnectionStringBuilder builder = new ( DataTestUtility . TCPConnectionString ) ;
101
102
102
103
// confirm that ForceEncryption is enabled
103
- using SqlConnection notEncryptedConnection = new ( builder . ConnectionString ) ;
104
104
builder . Encrypt = SqlConnectionEncryptOption . Optional ;
105
+ using SqlConnection notEncryptedConnection = new ( builder . ConnectionString ) ;
105
106
notEncryptedConnection . Open ( ) ;
106
107
Assert . Equal ( ConnectionState . Open , notEncryptedConnection . State ) ;
107
108
@@ -122,9 +123,7 @@ public void OpenningConnectionWithGoodCertificateTest()
122
123
123
124
// Provided hostname in certificate are:
124
125
// 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 ) ]
126
+ [ ConditionalFact ( nameof ( AreConnStringsSetup ) , nameof ( IsNotAzureServer ) , nameof ( IsLocalHost ) , nameof ( IsAdmin ) ) ]
128
127
public void OpeningConnectionWitHNICTest ( )
129
128
{
130
129
// Mandatory
@@ -142,8 +141,8 @@ public void OpeningConnectionWitHNICTest()
142
141
connection . Open ( ) ;
143
142
Assert . Equal ( ConnectionState . Open , connection . State ) ;
144
143
145
- // 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
144
+ // Ipv6 however causes name mismatch error
145
+ // In net6 Manged SNI does not check for SAN. Therefor Application using Net6 have to use FQDN as HNIC
147
146
// According to above no other hostname in certificate than FQDN will work in net6 which is same as SubjectName in case of RemoteCertificateNameMismatch
148
147
// Net7.0 the new API added by dotnet runtime will check SANS and then SubjectName
149
148
@@ -165,9 +164,8 @@ public void OpeningConnectionWitHNICTest()
165
164
Assert . Equal ( ConnectionState . Open , connection3 . State ) ;
166
165
}
167
166
}
168
-
169
- [ ConditionalFact ( nameof ( AreConnStringsSetup ) , nameof ( UseManagedSNIOnWindows ) , nameof ( IsNotAzureServer ) , nameof ( IsLocalHost ) ) ]
170
- [ PlatformSpecific ( TestPlatforms . Windows ) ]
167
+
168
+ [ ConditionalFact ( nameof ( AreConnStringsSetup ) , nameof ( UseManagedSNIOnWindows ) , nameof ( IsNotAzureServer ) , nameof ( IsLocalHost ) , nameof ( IsAdmin ) ) ]
171
169
public void RemoteCertificateNameMismatchErrorTest ( )
172
170
{
173
171
SqlConnectionStringBuilder builder = new ( DataTestUtility . TCPConnectionString )
0 commit comments