Skip to content

Commit

Permalink
Fix test sensitivity to PKCS7 certificate ordering (#59818)
Browse files Browse the repository at this point in the history
Android exports PKCS7 certificates in a different order, and the xunit assertion is sensitive to order. So we sort them first.

Fixes #59777.
  • Loading branch information
vcsjones authored Oct 11, 2021
1 parent 565ff52 commit 5f9fec9
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,9 @@ static void AssertPem(X509Certificate2Collection expected, ReadOnlySpan<char> pe

using (ImportedCollection imported = Cert.Import(data))
{
Assert.Equal(expected.ToArray(), imported.Collection.ToArray(), new X509Certificate2EqualityComparer());
X509Certificate2[] expectedCollection = expected.OrderBy(c => c.Thumbprint).ToArray();
X509Certificate2[] actualCollection = imported.Collection.OrderBy(c => c.Thumbprint).ToArray();
Assert.Equal(expectedCollection, actualCollection, new X509Certificate2EqualityComparer());
}
}

Expand Down

0 comments on commit 5f9fec9

Please sign in to comment.