Skip to content

Commit 4a3cc2f

Browse files
committed
Initial round of cross-platform test enablement
1 parent 4782c30 commit 4a3cc2f

15 files changed

+27
-121
lines changed

src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/ExceptionsCertStore.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public class ExceptionsCertStore : IClassFixture<ExceptionCertFixture>
1313
private readonly string masterKeyEncAlgo = "RSA_OAEP";
1414

1515
[Fact]
16-
[PlatformSpecific(TestPlatforms.Windows)]
1716
public void EmptyCertificateThumbprint()
1817
{
1918
string dummyPath = string.Format("CurrentUser/My/");
@@ -28,7 +27,6 @@ public void EmptyCertificateThumbprint()
2827
}
2928

3029
[Fact]
31-
[PlatformSpecific(TestPlatforms.Windows)]
3230
public void CertificateNotFound()
3331
{
3432
string dummyPath = string.Format("CurrentUser/My/JunkThumbprint");
@@ -41,9 +39,7 @@ public void CertificateNotFound()
4139
Assert.Matches(expectedMessage, e.Message);
4240
}
4341

44-
#if NETFRAMEWORK
4542
[Fact]
46-
[SkipOnTargetFramework(TargetFrameworkMonikers.Netcoreapp)]
4743
public void CertificateWithNoPrivateKey()
4844
{
4945
string expectedMessage = string.Format("Certificate specified in key path '{0}' does not have a private key to encrypt a column encryption key. Verify the certificate is imported correctly.\r\nParameter name: masterKeyPath", ExceptionCertFixture.masterKeyPathNPK);
@@ -58,7 +54,6 @@ public void CertificateWithNoPrivateKey()
5854
ExceptionCertFixture.masterKeyPathNPK, masterKeyEncAlgo, ExceptionCertFixture.encryptedCek));
5955
Assert.Contains(expectedMessage, e.Message);
6056
}
61-
#endif
6257
}
6358
public class ExceptionCertFixture : IDisposable
6459
{
@@ -68,11 +63,9 @@ public class ExceptionCertFixture : IDisposable
6863
public static string thumbprint;
6964
public static byte[] cek;
7065
public static byte[] encryptedCek;
71-
#if NETFRAMEWORK
7266
public static X509Certificate2 masterKeyCertificateNPK; // no private key
7367
public static string thumbprintNPK; // No private key
7468
public static string masterKeyPathNPK;
75-
#endif
7669

7770
public ExceptionCertFixture()
7871
{
@@ -84,14 +77,12 @@ public ExceptionCertFixture()
8477
certificatePath = string.Format("CurrentUser/My/{0}", thumbprint);
8578
cek = Utility.GenerateRandomBytes(32);
8679
encryptedCek = certStoreProvider.EncryptColumnEncryptionKey(certificatePath, "RSA_OAEP", cek);
87-
#if NETFRAMEWORK
8880
if (masterKeyCertificateNPK == null)
8981
{
9082
masterKeyCertificateNPK = Utility.CreateCertificateWithNoPrivateKey();
9183
}
9284
thumbprintNPK = masterKeyCertificateNPK.Thumbprint;
9385
masterKeyPathNPK = "CurrentUser/My/" + thumbprintNPK;
94-
#endif
9586
// Disable the cache to avoid false failures.
9687
SqlConnection.ColumnEncryptionQueryMetadataCacheEnabled = false;
9788
}

src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
namespace Microsoft.Data.SqlClient.Tests.AlwaysEncryptedTests
1818
{
19-
public class SqlColumnEncryptionCertificateStoreProviderWindowsShould : IClassFixture<CertificateFixture>
19+
public class SqlColumnEncryptionCertificateStoreProviderShould : IClassFixture<CertificateFixture>
2020
{
2121
private const string MASTER_KEY_PATH = "CurrentUser/My/C74D53B816A971E3FF9714FE1DD2E57E1710D946";
2222
private const string ENCRYPTION_ALGORITHM = "RSA_OAEP";
@@ -95,7 +95,6 @@ public class SqlColumnEncryptionCertificateStoreProviderWindowsShould : IClassFi
9595

9696
[Theory]
9797
[InvalidDecryptionParameters]
98-
[PlatformSpecific(TestPlatforms.Windows)]
9998
public void ThrowExceptionWithInvalidParameterWhileDecryptingColumnEncryptionKey(string errorMsg, Type exceptionType, string masterKeyPath, string encryptionAlgorithm, byte[] bytes)
10099
{
101100
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -105,7 +104,6 @@ public void ThrowExceptionWithInvalidParameterWhileDecryptingColumnEncryptionKey
105104

106105
[Theory]
107106
[InvalidEncryptionParameters]
108-
[PlatformSpecific(TestPlatforms.Windows)]
109107
public void ThrowExceptionWithInvalidParameterWhileEncryptingColumnEncryptionKey(string errorMsg, Type exceptionType, string masterKeyPath, string encryptionAlgorithm, byte[] bytes)
110108
{
111109
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -115,7 +113,6 @@ public void ThrowExceptionWithInvalidParameterWhileEncryptingColumnEncryptionKey
115113

116114
[Theory]
117115
[InvalidSigningParameters]
118-
[PlatformSpecific(TestPlatforms.Windows)]
119116
public void ThrowExceptionWithInvalidParameterWhileSigningColumnMasterKeyMetadata(string errorMsg, Type exceptionType, string masterKeyPath)
120117
{
121118
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -127,7 +124,6 @@ public void ThrowExceptionWithInvalidParameterWhileSigningColumnMasterKeyMetadat
127124
[InlineData("CurrentUser/My/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
128125
[InlineData("CURRENTUSER/My/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
129126
[InlineData("currentuser/My/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
130-
[PlatformSpecific(TestPlatforms.Windows)]
131127
public void SetStoreLocationApproperiatelyFromMasterKeyPathRegardlessOfCase(string masterKeyPath)
132128
{
133129
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -139,7 +135,6 @@ public void SetStoreLocationApproperiatelyFromMasterKeyPathRegardlessOfCase(stri
139135
[InlineData("CurrentUser/my/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
140136
[InlineData("CurrentUser/MY/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
141137
[InlineData("CurrentUser/My/C74D53B816A971E3FF9714FE1DD2E57E1710D946")]
142-
[PlatformSpecific(TestPlatforms.Windows)]
143138
public void SetStoreNameApproperiatelyFromMasterKeyPathRegardlessOfCase(string masterKeyPath)
144139
{
145140
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -151,7 +146,6 @@ public void SetStoreNameApproperiatelyFromMasterKeyPathRegardlessOfCase(string m
151146
[InlineData("RSA_OAEP")]
152147
[InlineData("rsa_oaep")]
153148
[InlineData("RsA_oAeP")]
154-
[PlatformSpecific(TestPlatforms.Windows)]
155149
public void AcceptEncryptionAlgorithmRegardlessOfCase(string algorithm)
156150
{
157151
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -163,7 +157,6 @@ public void AcceptEncryptionAlgorithmRegardlessOfCase(string algorithm)
163157
[InlineData(32)]
164158
[InlineData(64)]
165159
[InlineData(128)]
166-
[PlatformSpecific(TestPlatforms.Windows)]
167160
public void EncryptKeyAndThenDecryptItSuccessfully(int dataSize)
168161
{
169162
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -179,7 +172,6 @@ public void EncryptKeyAndThenDecryptItSuccessfully(int dataSize)
179172
[Theory]
180173
[InlineData(true)]
181174
[InlineData(false)]
182-
[PlatformSpecific(TestPlatforms.Windows)]
183175
public void SignAndVerifyColumnMasterKeyMetadataSuccessfully(bool allowEnclaveComputations)
184176
{
185177
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -192,7 +184,6 @@ public void SignAndVerifyColumnMasterKeyMetadataSuccessfully(bool allowEnclaveCo
192184
[Theory]
193185
[InlineData(true)]
194186
[InlineData(false)]
195-
[PlatformSpecific(TestPlatforms.Windows)]
196187
public void FailToVerifyColumnMasterKeyMetadataWithWrongCertificate(bool allowEnclaveComputations)
197188
{
198189
var provider = new SqlColumnEncryptionCertificateStoreProvider();
@@ -204,7 +195,6 @@ public void FailToVerifyColumnMasterKeyMetadataWithWrongCertificate(bool allowEn
204195
}
205196

206197
[Fact]
207-
[PlatformSpecific(TestPlatforms.Windows)]
208198
public void EncryptAndDecryptDataSuccessfully()
209199
{
210200
var input = new byte[] { 1, 2, 3, 4, 5 };
@@ -218,7 +208,6 @@ public void EncryptAndDecryptDataSuccessfully()
218208

219209
[Theory]
220210
[CEKEncryptionReversalParameters]
221-
[PlatformSpecific(TestPlatforms.Windows)]
222211
public void TestCEKEncryptionReversal(StoreLocation certificateStoreLocation, String certificateStoreNameAndLocation)
223212
{
224213
Assert.True(!string.IsNullOrWhiteSpace(certificateStoreNameAndLocation));
@@ -284,7 +273,6 @@ private void TestEncryptionReversalUsingAead(byte[] plainTextInBytes, byte[] roo
284273
}
285274

286275
[Theory]
287-
[PlatformSpecific(TestPlatforms.Windows)]
288276
[AeadEncryptionParameters]
289277
public void TestAeadEncryptionReversal(string dataType, object data, Utility.CColumnEncryptionType encType)
290278
{
@@ -319,7 +307,6 @@ public void TestAeadEncryptionReversal(string dataType, object data, Utility.CCo
319307
}
320308

321309
[Fact]
322-
[PlatformSpecific(TestPlatforms.Windows)]
323310
public void TestCustomKeyProviderListSetter()
324311
{
325312
lock (Utility.ClearSqlConnectionGlobalProvidersLock)
@@ -370,7 +357,6 @@ public void TestCustomKeyProviderListSetter()
370357
}
371358

372359
[Theory]
373-
[PlatformSpecific(TestPlatforms.Windows)]
374360
[ValidCertificatePathsParameters]
375361
public void TestValidCertificatePaths(string certificateStoreNameAndLocation, object location)
376362
{
@@ -414,7 +400,6 @@ public void TestValidCertificatePaths(string certificateStoreNameAndLocation, ob
414400
}
415401

416402
[Theory]
417-
[PlatformSpecific(TestPlatforms.Windows)]
418403
[InlineData(new object[3] { @"iv", Utility.CColumnEncryptionType.Randomized, @"Specified ciphertext has an invalid authentication tag.\s+\(?Parameter (name: )?'?cipherText('\))?" })]
419404
[InlineData(new object[3] { @"tag", Utility.CColumnEncryptionType.Randomized, @"Specified ciphertext has an invalid authentication tag.\s+\(?Parameter (name: )?'?cipherText('\))?" })]
420405
[InlineData(new object[3] { @"cipher", Utility.CColumnEncryptionType.Randomized, @"Specified ciphertext has an invalid authentication tag.\s+\(?Parameter (name: )?'?cipherText('\))?" })]
@@ -617,29 +602,12 @@ public static string GenerateString(int length)
617602
}
618603
}
619604

620-
public class SqlColumnEncryptionCertificateStoreProviderUnixShould
621-
{
622-
[Fact]
623-
[PlatformSpecific(TestPlatforms.AnyUnix)]
624-
public void ThrowPlatformNotSupportedExceptionInUnix()
625-
{
626-
var provider = new SqlColumnEncryptionCertificateStoreProvider();
627-
Assert.Throws<PlatformNotSupportedException>(() => provider.EncryptColumnEncryptionKey("", "", new byte[] { }));
628-
Assert.Throws<PlatformNotSupportedException>(() => provider.DecryptColumnEncryptionKey("", "", new byte[] { }));
629-
Assert.Throws<PlatformNotSupportedException>(() => provider.SignColumnMasterKeyMetadata("", false));
630-
Assert.Throws<PlatformNotSupportedException>(() => provider.VerifyColumnMasterKeyMetadata("", false, new byte[] { }));
631-
}
632-
}
633-
634605
public class CertificateFixture : IDisposable
635606
{
636607
public static bool IsAdmin
637608
{
638609
get
639610
{
640-
#if NET
641-
System.Diagnostics.Debug.Assert(OperatingSystem.IsWindows());
642-
#endif
643611
return new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
644612
}
645613
}

0 commit comments

Comments
 (0)