Skip to content

Commit 5b8a581

Browse files
committed
User Story 38467: Backport mac server name fix
- Added a new test that was erroneously removed in the earlier cherry-pick. - Added MDS_TEST_CONFIG environment variable to unit test config to override where the confi.json file is read from. - Updated xUnit to 2.9.3 to avoid transitive System.Net.Http vulnerability warnings.
1 parent a213d8e commit 5b8a581

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,55 @@ public void TestRoundTripWithCSPAndCertStoreProvider()
157157
}
158158
}
159159

160+
[ConditionalTheory(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringSetupForAE))]
161+
[ClassData(typeof(AEConnectionStringProvider))]
162+
public void TestEncryptDecryptWithCSP(string connectionString)
163+
{
164+
string providerName = @"Microsoft Enhanced RSA and AES Cryptographic Provider";
165+
string keyIdentifier = DataTestUtility.GetUniqueNameForSqlServer("CSP");
166+
167+
try
168+
{
169+
CertificateUtilityWin.RSAPersistKeyInCsp(providerName, keyIdentifier);
170+
string cspPath = String.Concat(providerName, @"/", keyIdentifier);
171+
172+
SQLSetupStrategyCspExt sqlSetupStrategyCsp = new SQLSetupStrategyCspExt(cspPath);
173+
string tableName = sqlSetupStrategyCsp.CspProviderTable.Name;
174+
175+
try
176+
{
177+
using SqlConnection sqlConn = new(connectionString);
178+
sqlConn.Open();
179+
180+
Table.DeleteData(tableName, sqlConn);
181+
182+
// insert 1 row data
183+
Customer customer = new Customer(45, "Microsoft", "Corporation");
184+
185+
DatabaseHelper.InsertCustomerData(sqlConn, null, tableName, customer);
186+
187+
// Test INPUT parameter on an encrypted parameter
188+
using SqlCommand sqlCommand = new(@$"SELECT CustomerId, FirstName, LastName FROM [{tableName}] WHERE FirstName = @firstName",
189+
sqlConn, null, SqlCommandColumnEncryptionSetting.Enabled);
190+
SqlParameter customerFirstParam = sqlCommand.Parameters.AddWithValue(@"firstName", @"Microsoft");
191+
Console.WriteLine(@"Exception: {0}");
192+
customerFirstParam.Direction = System.Data.ParameterDirection.Input;
193+
194+
using SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
195+
ValidateResultSet(sqlDataReader);
196+
}
197+
finally
198+
{
199+
// clean up database resources
200+
sqlSetupStrategyCsp.Dispose();
201+
}
202+
}
203+
finally
204+
{
205+
CertificateUtilityWin.RSADeleteKeyInCsp(providerName, keyIdentifier);
206+
}
207+
}
208+
160209
/// <summary>
161210
/// Validates that the results are the ones expected.
162211
/// </summary>

src/Microsoft.Data.SqlClient/tests/tools/Microsoft.Data.SqlClient.TestUtilities/Config.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class Config
4545
public bool IsJsonSupported = false;
4646
public static Config Load(string configPath = @"config.json")
4747
{
48+
configPath = Environment.GetEnvironmentVariable("MDS_TEST_CONFIG") ?? configPath;
49+
4850
try
4951
{
5052
using (StreamReader r = new StreamReader(configPath))

tools/props/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
<SystemSecurityPrincipalWindowsVersion>5.0.0</SystemSecurityPrincipalWindowsVersion>
7171
<SystemServiceProcessServiceControllerVersion>6.0.0</SystemServiceProcessServiceControllerVersion>
7272
<SystemTextEncodingCodePagesVersion>6.0.0</SystemTextEncodingCodePagesVersion>
73-
<XunitVersion>2.6.3</XunitVersion>
74-
<XunitrunnervisualstudioVersion>2.5.5</XunitrunnervisualstudioVersion>
73+
<XunitVersion>2.9.3</XunitVersion>
74+
<XunitrunnervisualstudioVersion>2.8.2</XunitrunnervisualstudioVersion>
7575
</PropertyGroup>
7676
<PropertyGroup>
7777
<TestAKVProviderVersion>$(NugetPackageVersion)</TestAKVProviderVersion>

0 commit comments

Comments
 (0)