2004-10-28 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Thu, 28 Oct 2004 12:32:10 +0000 (12:32 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Thu, 28 Oct 2004 12:32:10 +0000 (12:32 -0000)
* KeyPairPersistenceTest.cs: Fix two tests to work even if the user
doesn't have access to the machine key store.

svn path=/trunk/mcs/; revision=35397

mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
mcs/class/Mono.Security/Test/Mono.Security.Cryptography/KeyPairPersistenceTest.cs

index 4f5aa5154fa25112def0219f252cec4fbcc050f9..cebf0aa4c27b2604c88a3d3aa19f50809b19b8b2 100644 (file)
@@ -1,3 +1,8 @@
+2004-10-28  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * KeyPairPersistenceTest.cs: Fix two tests to work even if the user 
+       doesn't have access to the machine key store.
+
 2004-09-22  Sebastien Pouliot  <sebastien@ximian.com>
 
        * SHA224Test.cs: Fix compilation error with NUnit 2.1.91 (CVS).
index ffbccf3d1969ac52dcadfb98055975d67b6c6aea..ae6fb23dbee7526ef0a5bff229cfda0426b75da2 100755 (executable)
@@ -123,15 +123,20 @@ namespace MonoTests.Mono.Security.Cryptography {
                        CspParameters cp = new CspParameters (-6, "Provider", "Container");
                        cp.Flags = CspProviderFlags.UseMachineKeyStore;
                        KeyPairPersistence kpp = new KeyPairPersistence (cp, "<keypair/>");
-                       kpp.Save ();
-
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
-                       Assert ("Load", kpp2.Load ());
-
-                       Compare (kpp, kpp2);
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                       try {
+                               kpp.Save ();
+
+                               Assert ("Save-Exists", File.Exists (kpp.Filename));
+                               KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
+                               Assert ("Load", kpp2.Load ());
+
+                               Compare (kpp, kpp2);
+                               kpp.Remove ();
+                               Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                       }
+                       catch (UnauthorizedAccessException) {
+                               // not everyone can write to the machine store
+                       }
                }
 
                [Test]
@@ -140,15 +145,20 @@ namespace MonoTests.Mono.Security.Cryptography {
                        CspParameters cp = new CspParameters (-7, "Provider", "Container");
                        cp.Flags = CspProviderFlags.UseDefaultKeyContainer | CspProviderFlags.UseMachineKeyStore;
                        KeyPairPersistence kpp = new KeyPairPersistence (cp, "<keypair/>");
-                       kpp.Save ();
-
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
-                       Assert ("Load", kpp2.Load ());
-
-                       Compare (kpp, kpp2);
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                       try {
+                               kpp.Save ();
+
+                               Assert ("Save-Exists", File.Exists (kpp.Filename));
+                               KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
+                               Assert ("Load", kpp2.Load ());
+
+                               Compare (kpp, kpp2);
+                               kpp.Remove ();
+                               Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                       }
+                       catch (UnauthorizedAccessException) {
+                               // not everyone can write to the machine store
+                       }
                }
 
                [Test]
@@ -173,4 +183,4 @@ namespace MonoTests.Mono.Security.Cryptography {
                        Assert ("ProviderType", cp.ProviderType != copy.ProviderType);
                }
        }
-}
\ No newline at end of file
+}