Skip to content

Commit

Permalink
Clean up some X509FilesystemTests tests (dotnet/corefx#42089)
Browse files Browse the repository at this point in the history
* Make all of the Fact methods public
* Improve the assert messages in VerifyCrlCache
* Make VerifyCrlCache understand offline revocation unknown asserts two flags now.

Commit migrated from dotnet/corefx@4494e09
  • Loading branch information
bartonjs authored and stephentoub committed Oct 24, 2019
1 parent 304fcbe commit b0dabf2
Showing 1 changed file with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ public static void VerifyCrlCache()
int initialErrorCount = chain.ChainStatus.Length;
Assert.InRange(initialErrorCount, 0, 1);

if (initialErrorCount > 0)
X509ChainStatusFlags initialFlags = chain.AllStatusFlags();

if (initialFlags != X509ChainStatusFlags.NoError)
{
Assert.Equal(X509ChainStatusFlags.UntrustedRoot, chain.ChainStatus[0].Status);
Assert.Equal(X509ChainStatusFlags.UntrustedRoot, initialFlags);
}

chainHolder.DisposeChainElements();
Expand All @@ -64,8 +66,10 @@ public static void VerifyCrlCache()
valid = chain.Build(microsoftDotComIssuer);
Assert.False(valid, "Chain should not build validly");

Assert.Equal(initialErrorCount + 1, chain.ChainStatus.Length);
Assert.Equal(X509ChainStatusFlags.RevocationStatusUnknown, chain.ChainStatus[0].Status);
const X509ChainStatusFlags UnknownOffline =
X509ChainStatusFlags.RevocationStatusUnknown | X509ChainStatusFlags.OfflineRevocation;

Assert.Equal(initialFlags | UnknownOffline, chain.AllStatusFlags());

File.WriteAllText(crlFile, MicrosoftDotComRootCrlPem, Encoding.ASCII);

Expand All @@ -90,7 +94,7 @@ public static void X509Store_OpenExisting_Fails()
}

[Fact]
private static void X509Store_AddReadOnly()
public static void X509Store_AddReadOnly()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -109,7 +113,7 @@ private static void X509Store_AddReadOnly()
}

[Fact]
private static void X509Store_AddClosed()
public static void X509Store_AddClosed()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -127,7 +131,7 @@ private static void X509Store_AddClosed()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddOne()
public static void X509Store_AddOne()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -158,7 +162,7 @@ private static void X509Store_AddOne()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddOneAfterUpgrade()
public static void X509Store_AddOneAfterUpgrade()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -198,7 +202,7 @@ private static void X509Store_AddOneAfterUpgrade()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_DowngradePermissions()
public static void X509Store_DowngradePermissions()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -221,7 +225,7 @@ private static void X509Store_DowngradePermissions()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddAfterDispose()
public static void X509Store_AddAfterDispose()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -244,7 +248,7 @@ private static void X509Store_AddAfterDispose()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddAndClear()
public static void X509Store_AddAndClear()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -268,7 +272,7 @@ private static void X509Store_AddAndClear()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddDuplicate()
public static void X509Store_AddDuplicate()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand All @@ -290,7 +294,7 @@ private static void X509Store_AddDuplicate()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddTwo()
public static void X509Store_AddTwo()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -321,7 +325,7 @@ private static void X509Store_AddTwo()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddTwo_UpgradePrivateKey()
public static void X509Store_AddTwo_UpgradePrivateKey()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -383,7 +387,7 @@ private static void X509Store_AddTwo_UpgradePrivateKey()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_AddTwo_UpgradePrivateKey_NoDowngrade()
public static void X509Store_AddTwo_UpgradePrivateKey_NoDowngrade()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -443,7 +447,7 @@ private static void X509Store_AddTwo_UpgradePrivateKey_NoDowngrade()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_DistinctCollections()
public static void X509Store_DistinctCollections()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -484,7 +488,7 @@ private static void X509Store_DistinctCollections()

[Fact]
[OuterLoop(/* Alters user/machine state */)]
private static void X509Store_Add4_Remove1()
public static void X509Store_Add4_Remove1()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -535,7 +539,7 @@ private static void X509Store_Add4_Remove1()
[OuterLoop(/* Alters user/machine state */)]
[InlineData(false)]
[InlineData(true)]
private static void X509Store_MultipleObjects(bool matchCase)
public static void X509Store_MultipleObjects(bool matchCase)
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down Expand Up @@ -580,7 +584,7 @@ private static void X509Store_MultipleObjects(bool matchCase)

[Fact]
[OuterLoop( /* Alters user/machine state */)]
private static void X509Store_FiltersDuplicateOnLoad()
public static void X509Store_FiltersDuplicateOnLoad()
{
RunX509StoreTest(
(store, storeDirectory) =>
Expand Down

0 comments on commit b0dabf2

Please sign in to comment.