Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@@ -12,6 +12,7 @@ using NUnit.Framework;
using System;
using System.Collections;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
@@ -27,6 +28,9 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
private X509Certificate2Collection coll_empty;
private X509Certificate2Collection coll;
string ReadWriteStore = "ReadWriteStore" + Process.GetCurrentProcess ().Id;
string ReadOnlyStore = "ReadOnlyStore" + Process.GetCurrentProcess ().Id;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
@@ -38,13 +42,13 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
coll.Add (cert1);
coll.Add (cert2);
CleanUpStore ("ReadOnlyStore");
CleanUpStore (ReadOnlyStore);
}
[SetUp]
public void SetUp ()
{
CleanUpStore ("ReadWriteStore");
CleanUpStore (ReadWriteStore);
}
private void CleanUpStore (string s)
@@ -323,7 +327,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void Add_OpenReadOnly ()
{
X509Store xs = new X509Store ("ReadOnlyStore");
X509Store xs = new X509Store (ReadOnlyStore);
xs.Open (OpenFlags.ReadOnly);
xs.Add (cert1);
}
@@ -331,7 +335,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Add_SameCertificate ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
int n = xs.Certificates.Count;
xs.Add (cert1);
@@ -344,7 +348,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void Add_Empty_Certificate ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.Add (cert_empty);
}
@@ -353,7 +357,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void Add_ExistingCertificateReadOnly ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.Add (cert1);
xs.Close ();
@@ -372,7 +376,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void AddRange_Empty_Closed ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.AddRange (coll_empty);
Assert.AreEqual (coll_empty.Count, xs.Certificates.Count, "Count");
}
@@ -380,7 +384,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void AddRange_Empty_ReadOnly ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadOnly);
xs.AddRange (coll_empty);
Assert.AreEqual (coll_empty.Count, xs.Certificates.Count, "Count");
@@ -389,7 +393,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void AddRange_Empty_ReadWrite ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.AddRange (coll_empty);
Assert.AreEqual (coll_empty.Count, xs.Certificates.Count, "Count");
@@ -399,7 +403,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void AddRange_Empty_Certificate ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.AddRange (new X509Certificate2Collection (cert_empty));
}
@@ -407,7 +411,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void AddRange ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.AddRange (coll);
Assert.AreEqual (coll.Count, xs.Certificates.Count, "Count");
@@ -425,7 +429,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void AddRange_OpenReadOnly ()
{
X509Store xs = new X509Store ("ReadOnlyStore");
X509Store xs = new X509Store (ReadOnlyStore);
xs.Open (OpenFlags.ReadOnly);
xs.AddRange (coll);
}
@@ -439,7 +443,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Close_Collection ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.Add (cert1);
Assert.AreEqual (1, xs.Certificates.Count, "Open");
@@ -450,7 +454,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Open_Invalid ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open ((OpenFlags) Int32.MinValue);
}
@@ -495,7 +499,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Remove_OpenReadOnly_Unexisting ()
{
X509Store xs = new X509Store ("ReadOnlyStore");
X509Store xs = new X509Store (ReadOnlyStore);
xs.Open (OpenFlags.ReadOnly);
// note: cert1 wasn't present, remove "succeed"
xs.Remove (cert1);
@@ -505,7 +509,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void Remove_OpenReadOnly_Existing ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.Add (cert1);
xs.Close ();
@@ -516,7 +520,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Remove_Empty_Certificate ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
// note: impossible to add cert_empty, so we add something else
// to be sure we'll follow the complete code path (loop) of removal
@@ -549,7 +553,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void RemoveRange_OpenReadOnly_Unexisting ()
{
X509Store xs = new X509Store ("ReadOnlyStore");
X509Store xs = new X509Store (ReadOnlyStore);
xs.Open (OpenFlags.ReadOnly);
// note: cert1 wasn't present, RemoveRange "succeed"
xs.RemoveRange (coll);
@@ -559,7 +563,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[ExpectedException (typeof (CryptographicException))]
public void RemoveRange_OpenReadOnly_Existing ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
xs.AddRange (coll);
xs.Close ();
@@ -570,7 +574,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void RemoveRange_Empty_Certificate ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Open (OpenFlags.ReadWrite);
// note: impossible to add cert_empty, so we add something else
// to be sure we'll follow the complete code path (loop) of removal
@@ -581,7 +585,7 @@ namespace MonoTests.System.Security.Cryptography.X509Certificates {
[Test]
public void Collection_Add ()
{
X509Store xs = new X509Store ("ReadWriteStore");
X509Store xs = new X509Store (ReadWriteStore);
xs.Certificates.Add (cert1);
Assert.AreEqual (0, xs.Certificates.Count, "Not Open");
xs.Close ();