Skip to content

Commit 76c4fff

Browse files
committed
Fixed tests when executed remotely on a Jenkins agent
1 parent ac0d028 commit 76c4fff

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
using System.Security.Cryptography;
2+
using System.Security.Cryptography.X509Certificates;
23
using Mastercard.Developer.OAuth1Signer.Core.Utils;
34

45
namespace Mastercard.Developer.OAuth1Signer.Tests.Test
56
{
67
internal static class TestUtils
78
{
8-
internal static RSA GetTestPrivateKey() => SecurityUtils.LoadPrivateKey("./_Resources/test_key_container.p12", "mykeyalias", "Password1");
9+
internal static RSA GetTestPrivateKey() => SecurityUtils.LoadPrivateKey(
10+
"./_Resources/test_key_container.p12",
11+
"mykeyalias",
12+
"Password1",
13+
X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable // https://github.com/dotnet/corefx/issues/14745
14+
);
915
}
1016
}

Mastercard.Developer.OAuth1Signer.Tests/Utils/SecurityUtilsTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Mastercard.Developer.OAuth1Signer.Core.Utils;
1+
using System.Security.Cryptography.X509Certificates;
2+
using Mastercard.Developer.OAuth1Signer.Core.Utils;
23
using Microsoft.VisualStudio.TestTools.UnitTesting;
34

45
namespace Mastercard.Developer.OAuth1Signer.Tests.Utils
@@ -15,7 +16,8 @@ public void TestLoadPrivateKey_ShouldReturnKey()
1516
const string keyPassword = "Password1";
1617

1718
// WHEN
18-
var privateKey = SecurityUtils.LoadPrivateKey(keyContainerPath, keyAlias, keyPassword);
19+
const X509KeyStorageFlags flags = X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.Exportable; // https://github.com/dotnet/corefx/issues/14745
20+
var privateKey = SecurityUtils.LoadPrivateKey(keyContainerPath, keyAlias, keyPassword, flags);
1921

2022
// THEN
2123
Assert.AreEqual(2048, privateKey.KeySize);

0 commit comments

Comments
 (0)