Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,25 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.CompilerServices;
using Microsoft.DotNet.XUnitExtensions;
using Xunit;

namespace System.Security.Cryptography.X509Certificates.Tests
{
public abstract partial class X509CertificateLoaderPkcs12Tests
{
[Theory]
[ConditionalTheory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void VerifyPreserveKeyName(bool preserveName, bool machineKey)
{
if (machineKey && !PlatformDetection.IsPrivilegedProcess)
{
throw new SkipTestException("Test requires administrator privileges.");
}

Pkcs12LoaderLimits loaderLimits = new Pkcs12LoaderLimits
{
PreserveKeyName = preserveName,
Expand Down Expand Up @@ -51,13 +57,18 @@ public void VerifyPreserveKeyName(bool preserveName, bool machineKey)
}
}

[Theory]
[ConditionalTheory]
[InlineData(true, true)]
[InlineData(true, false)]
[InlineData(false, true)]
[InlineData(false, false)]
public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
{
if (machineKey && !PlatformDetection.IsPrivilegedProcess)
{
throw new SkipTestException("Test requires administrator privileges.");
}

Pkcs12LoaderLimits loaderLimits = new Pkcs12LoaderLimits
{
PreserveCertificateAlias = preserveAlias,
Expand Down Expand Up @@ -95,7 +106,7 @@ public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
}
}

[Theory]
[ConditionalTheory]
[InlineData(true, true, true)]
[InlineData(true, true, false)]
[InlineData(true, false, true)]
Expand All @@ -106,6 +117,11 @@ public void VerifyPreserveAlias(bool preserveAlias, bool machineKey)
[InlineData(false, false, false)]
public void VerifyPreserveProvider(bool preserveProvider, bool preserveName, bool machineKey)
{
if (machineKey && !PlatformDetection.IsPrivilegedProcess)
{
throw new SkipTestException("Test requires administrator privileges.");
}

// This test forces a key creation with CAPI, and verifies that
// PreserveStorageProvider keeps the key in CAPI. Additionally,
// it shows that PreserveKeyName and PreserveStorageProvider are independent.
Expand Down Expand Up @@ -158,11 +174,16 @@ public void VerifyPreserveProvider(bool preserveProvider, bool preserveName, boo
}
}

[Theory]
[ConditionalTheory]
[InlineData(false)]
[InlineData(true)]
public void VerifyNamesWithDuplicateAttributes(bool noLimits)
{
if (!PlatformDetection.IsPrivilegedProcess)
{
throw new SkipTestException("Test requires administrator privileges.");
}

// This test mainly shows that when duplicate attributes are present contents
// processed by our filter and processed directly by PFXImportCertStore come up
// with the same answer.
Expand Down
Loading