diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index d19255d52..e12a0a6d6 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -25,14 +25,15 @@ concurrency:
# SEQUENTIAL_ENV: SEQUENTIAL_TEST_RUN
jobs:
- test-windows:
- name: Tests on Windows
+ test-windows-core:
+ name: Tests on Windows for Core
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
- dotnet: ['net6.0', 'net7.0', 'net8.0', 'net9.0', 'net462', 'net471', 'net472', 'net48', 'net481']
+ dotnet: ['net6.0', 'net7.0', 'net8.0', 'net9.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
+ target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- name: Checkout code
uses: actions/checkout@v4
@@ -62,31 +63,101 @@ jobs:
cd Snowflake.Data.Tests
dotnet restore
dotnet build -f ${{ matrix.dotnet }} '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
+ env:
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
- dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
+ dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
- name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
- name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
+ name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
- files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
+
+ test-windows-framework:
+ name: Tests on Windows for Framework
+ runs-on: windows-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ dotnet: ['net462', 'net471', 'net472', 'net48', 'net481']
+ cloud_env: ['AZURE', 'GCP', 'AWS']
+ target_framework: ['netstandard2.0']
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ - name: Setup Dotnet
+ uses: actions/setup-dotnet@v4
+ with:
+ dotnet-version: |
+ 6.0.x
+ 8.0.x
+ 9.0.x
+ dotnet-quality: 'ga'
+ - name: Setup Python
+ uses: actions/setup-python@v5
+ with:
+ python-version: '3.x'
+ - name: Setup dotnet-coverage
+ run: dotnet tool install --global dotnet-coverage --version 17.8.4
+ - name: Decrypt Parameters
+ shell: bash
+ env:
+ PARAMETER_SECRET: ${{ secrets.PARAMETER_SECRET }}
+ run: |
+ gpg --quiet --batch --yes --decrypt --passphrase="$PARAMETER_SECRET" \
+ ./.github/workflows/parameters/parameters_${{ matrix.cloud_env }}.json.gpg > Snowflake.Data.Tests/parameters.json
+ - name: Build Driver
+ run: |
+ cd Snowflake.Data.Tests
+ dotnet restore
+ dotnet build -f ${{ matrix.dotnet }} '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
+ env:
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
+ - name: Run Tests
+ run: |
+ cd Snowflake.Data.Tests
+ dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
+ env:
+ snowflake_cloud_env: ${{ matrix.cloud_env }}
+ net_version: ${{ matrix.dotnet }}
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
+ - name: Upload Code Coverage Report
+ uses: actions/upload-artifact@v4
+ with:
+ name: code-coverage-report_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
+
+ - name: Upload Test Performance Report
+ uses: actions/upload-artifact@v4
+ with:
+ name: tests-performance_windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
+ - name: Upload coverage reports to Codecov
+ uses: codecov/codecov-action@v4
+ with:
+ # without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
+ token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
+ fail_ci_if_error: true
+ files: Snowflake.Data.Tests\windows_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
test-linux:
name: Tests on Linux
@@ -96,6 +167,7 @@ jobs:
matrix:
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net9.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
+ target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- uses: actions/checkout@v4
- name: Setup Dotnet
@@ -123,30 +195,33 @@ jobs:
run: |
dotnet restore
dotnet build '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
+ env:
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
- dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
+ dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
- name: code-coverage-report_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ name: code-coverage-report_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
- name: tests-performance_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
+ name: tests-performance_linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
- files: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ files: Snowflake.Data.Tests/linux_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
test-mac:
name: Tests on MAC
@@ -156,6 +231,7 @@ jobs:
matrix:
dotnet: ['net6.0', 'net7.0', 'net8.0', 'net9.0']
cloud_env: ['AZURE', 'GCP', 'AWS']
+ target_framework: ['netstandard2.0', 'netstandard2.1']
steps:
- uses: actions/checkout@v4
- name: Setup Dotnet
@@ -183,27 +259,30 @@ jobs:
run: |
dotnet restore
dotnet build '-p:DefineAdditionalConstants=SF_PUBLIC_ENVIRONMENT'
+ env:
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Run Tests
run: |
cd Snowflake.Data.Tests
- dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml --output-format cobertura --settings coverage.config
+ dotnet-coverage collect "dotnet test --framework ${{ matrix.dotnet }} --no-build -l console;verbosity=normal" --output macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml --output-format cobertura --settings coverage.config
env:
snowflake_cloud_env: ${{ matrix.cloud_env }}
net_version: ${{ matrix.dotnet }}
+ SF_TARGET_FRAMEWORK: ${{ matrix.target_framework }}
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v4
with:
- name: code-coverage-report_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ name: code-coverage-report_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
- name: Upload Test Performance Report
uses: actions/upload-artifact@v4
with:
- name: tests-performance_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}
- path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_performance.csv
+ name: tests-performance_macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}
+ path: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_performance.csv
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
fail_ci_if_error: true
- files: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_coverage.xml
+ files: Snowflake.Data.Tests/macos_${{ matrix.dotnet }}_${{ matrix.cloud_env }}_${{ matrix.target_framework }}_coverage.xml
diff --git a/Snowflake.Data.Tests/Snowflake.Data.Tests.csproj b/Snowflake.Data.Tests/Snowflake.Data.Tests.csproj
index 89d295439..105e5b2a1 100644
--- a/Snowflake.Data.Tests/Snowflake.Data.Tests.csproj
+++ b/Snowflake.Data.Tests/Snowflake.Data.Tests.csproj
@@ -20,8 +20,18 @@
-
+
+
+
+ TargetFramework=$(SF_TARGET_FRAMEWORK)
+
+
+
+
+
+
+
diff --git a/Snowflake.Data.Tests/UnitTests/GcmEncryptionProviderTest.cs b/Snowflake.Data.Tests/UnitTests/GcmEncryptionProviderTest.cs
index 53bc7c27e..e0a31455c 100644
--- a/Snowflake.Data.Tests/UnitTests/GcmEncryptionProviderTest.cs
+++ b/Snowflake.Data.Tests/UnitTests/GcmEncryptionProviderTest.cs
@@ -1,8 +1,8 @@
using System;
+using System.Collections.Generic;
using System.IO;
using System.Text;
using NUnit.Framework;
-using Org.BouncyCastle.Crypto;
using Snowflake.Data.Core;
using Snowflake.Data.Core.FileTransfer;
using Snowflake.Data.Tests.Util;
@@ -10,7 +10,7 @@
namespace Snowflake.Data.Tests.UnitTests
{
[TestFixture]
- public class GcmEncryptionProviderTest
+ internal class GcmEncryptionProviderTest
{
private const string PlainText = "there is no rose without thorns";
private static readonly byte[] s_plainTextBytes = Encoding.UTF8.GetBytes(PlainText);
@@ -36,24 +36,26 @@ public class GcmEncryptionProviderTest
queryId = s_queryId,
smkId = SmkId
};
- private static readonly FileTransferConfiguration s_fileTransferConfiguration = new FileTransferConfiguration
+ internal static readonly FileTransferConfiguration s_fileTransferConfiguration = new FileTransferConfiguration
{
TempDir = Path.GetTempPath(),
MaxBytesInMemory = FileTransferConfiguration.DefaultMaxBytesInMemory
};
[Test]
- public void TestEncryptAndDecryptWithoutAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestEncryptAndDecryptWithoutAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
// act
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
null,
null))
{
@@ -67,7 +69,7 @@ public void TestEncryptAndDecryptWithoutAad()
Assert.IsNull(encryptionMetadata.aad);
// act
- using (var decryptedStream = GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata, s_fileTransferConfiguration))
+ using (var decryptedStream = decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata))
{
// assert
var decryptedText = ExtractContent(decryptedStream);
@@ -77,17 +79,19 @@ public void TestEncryptAndDecryptWithoutAad()
}
[Test]
- public void TestEncryptAndDecryptWithEmptyAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestEncryptAndDecryptWithEmptyAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
// act
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
s_emptyAadBytes,
s_emptyAadBytes))
{
@@ -101,7 +105,7 @@ public void TestEncryptAndDecryptWithEmptyAad()
Assert.AreEqual(s_emptyAadBase64, encryptionMetadata.aad);
// act
- using (var decryptedStream = GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata, s_fileTransferConfiguration))
+ using (var decryptedStream = decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata))
{
// assert
var decryptedText = ExtractContent(decryptedStream);
@@ -111,17 +115,19 @@ public void TestEncryptAndDecryptWithEmptyAad()
}
[Test]
- public void TestEncryptAndDecryptWithAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestEncryptAndDecryptWithAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
// act
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
s_contentAadBytes,
s_keyAadBytes))
{
@@ -135,7 +141,7 @@ public void TestEncryptAndDecryptWithAad()
CollectionAssert.AreEqual(s_contentAadBase64, encryptionMetadata.aad);
// act
- using (var decryptedStream = GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata, s_fileTransferConfiguration))
+ using (var decryptedStream = decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata))
{
// assert
var decryptedText = ExtractContent(decryptedStream);
@@ -145,15 +151,17 @@ public void TestEncryptAndDecryptWithAad()
}
[Test]
- public void TestFailDecryptWithInvalidKeyAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestFailDecryptWithInvalidKeyAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
null,
s_keyAadBytes))
{
@@ -166,24 +174,27 @@ public void TestFailDecryptWithInvalidKeyAad()
encryptionMetadata.keyAad = s_invalidAadBase64;
// act
- var thrown = Assert.Throws(() =>
- GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata, s_fileTransferConfiguration));
+ var thrown = Assert.Catch(() =>
+ decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata));
// assert
- Assert.AreEqual("mac check in GCM failed", thrown.Message);
+ Assert.NotNull(thrown);
+ Assert.AreEqual(decryptionProvider.ExpectedExceptionMessage(), thrown.Message);
}
}
[Test]
- public void TestFailDecryptWithInvalidContentAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestFailDecryptWithInvalidContentAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
s_contentAadBytes,
null))
{
@@ -196,24 +207,27 @@ public void TestFailDecryptWithInvalidContentAad()
encryptionMetadata.aad = s_invalidAadBase64;
// act
- var thrown = Assert.Throws(() =>
- GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata, s_fileTransferConfiguration));
+ var thrown = Assert.Catch(() =>
+ decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata));
// assert
- Assert.AreEqual("mac check in GCM failed", thrown.Message);
+ Assert.NotNull(thrown);
+ Assert.AreEqual(decryptionProvider.ExpectedExceptionMessage(), thrown.Message);
}
}
[Test]
- public void TestFailDecryptWhenMissingAad()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestFailDecryptWhenMissingAad(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
- using (var encryptedStream = GcmEncryptionProvider.Encrypt(
+ using (var encryptedStream = encryptionProvider.Encrypt(
s_encryptionMaterial,
encryptionMetadata, // this is output parameter
- s_fileTransferConfiguration,
- new MemoryStream(s_plainTextBytes),
+ s_plainTextBytes,
s_contentAadBytes,
s_keyAadBytes))
{
@@ -227,16 +241,20 @@ public void TestFailDecryptWhenMissingAad()
encryptionMetadata.aad = null;
// act
- var thrown = Assert.Throws(() =>
- GcmEncryptionProvider.Decrypt(new MemoryStream(encryptedContent), s_encryptionMaterial, encryptionMetadata,s_fileTransferConfiguration));
+ var thrown = Assert.Catch(() =>
+ decryptionProvider.Decrypt(encryptedContent, s_encryptionMaterial, encryptionMetadata));
// assert
- Assert.AreEqual("mac check in GCM failed", thrown.Message);
+ Assert.NotNull(thrown);
+ Assert.AreEqual(decryptionProvider.ExpectedExceptionMessage(), thrown.Message);
}
}
[Test]
- public void TestEncryptAndDecryptFile()
+ [TestCaseSource(nameof(EncryptionTestCases))]
+ public void TestEncryptAndDecryptFile(
+ IEncryptionProvider encryptionProvider,
+ IDecryptionProvider decryptionProvider)
{
// arrange
SFEncryptionMetadata encryptionMetadata = new SFEncryptionMetadata();
@@ -247,8 +265,8 @@ public void TestEncryptAndDecryptFile()
CreateFile(plainTextFilePath, PlainText);
// act
- using (var encryptedStream = GcmEncryptionProvider.EncryptFile(plainTextFilePath, s_encryptionMaterial, encryptionMetadata,
- s_fileTransferConfiguration, s_contentAadBytes, s_keyAadBytes))
+ using (var encryptedStream = encryptionProvider.EncryptFile(plainTextFilePath, s_encryptionMaterial, encryptionMetadata,
+ s_contentAadBytes, s_keyAadBytes))
{
CreateFile(encryptedFilePath, encryptedStream);
}
@@ -262,8 +280,7 @@ public void TestEncryptAndDecryptFile()
// act
string result;
- using (var decryptedStream = GcmEncryptionProvider.DecryptFile(encryptedFilePath, s_encryptionMaterial, encryptionMetadata,
- s_fileTransferConfiguration))
+ using (var decryptedStream = decryptionProvider.DecryptFile(encryptedFilePath, s_encryptionMaterial, encryptionMetadata))
{
decryptedStream.Position = 0;
var resultBytes = new byte[decryptedStream.Length];
@@ -314,5 +331,49 @@ private byte[] ExtractContentBytes(Stream stream)
stream.CopyTo(memoryStream);
return memoryStream.ToArray();
}
+
+ internal static IEnumerable