Author: spouliot
Date: 2005-04-27 14:26:02 -0400 (Wed, 27 Apr 2005)
New Revision: 43674

Modified:
   trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
   
trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/KeyPairPersistenceTest.cs
Log:
2005-04-27  Sebastien Pouliot  <[EMAIL PROTECTED]>

        * KeyPairPersistenceTest.cs: Upgrade to NUnit 2.2 API to use Ignore.
        Now Ignore all tests that results in UnauthorizedAccessException.



Modified: 
trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog     
2005-04-27 18:09:45 UTC (rev 43673)
+++ trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/ChangeLog     
2005-04-27 18:26:02 UTC (rev 43674)
@@ -1,3 +1,8 @@
+2005-04-27  Sebastien Pouliot  <[EMAIL PROTECTED]>
+
+       * KeyPairPersistenceTest.cs: Upgrade to NUnit 2.2 API to use Ignore.
+       Now Ignore all tests that results in UnauthorizedAccessException.
+
 2004-12-06  Sebastien Pouliot  <[EMAIL PROTECTED]>
 
        * RSAManagedTest.cs: New. Unit tests to validate RSA decryption when 

Modified: 
trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/KeyPairPersistenceTest.cs
===================================================================
--- 
trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/KeyPairPersistenceTest.cs
     2005-04-27 18:09:45 UTC (rev 43673)
+++ 
trunk/mcs/class/Mono.Security/Test/Mono.Security.Cryptography/KeyPairPersistenceTest.cs
     2005-04-27 18:26:02 UTC (rev 43674)
@@ -4,8 +4,27 @@
 // Author:
 //     Sebastien Pouliot <[EMAIL PROTECTED]>
 //
-// (C) 2004 Novell (http://www.novell.com)
+// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com)
 //
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
 
 using NUnit.Framework;
 using System;
@@ -17,7 +36,7 @@
 namespace MonoTests.Mono.Security.Cryptography {
 
        [TestFixture]
-       public class KeyPairPersistenceTest : Assertion {
+       public class KeyPairPersistenceTest {
 
                [Test]
                [ExpectedException (typeof (ArgumentNullException))]
@@ -31,160 +50,198 @@
                        // Note: there is an additional Environement.NewLine 
                        // at the end of the loaded string - that's why we do
                        // not use AssertEquals (for strings)
-                       Assert ("Filename", loaded.Filename.StartsWith 
(saved.Filename));
-                       Assert ("KeyValue", loaded.KeyValue.StartsWith 
(saved.KeyValue));
-                       Assert ("Parameters.KeyContainerName", 
loaded.Parameters.KeyContainerName.StartsWith 
(saved.Parameters.KeyContainerName));
-                       AssertEquals ("Parameters.KeyNumber", 
saved.Parameters.KeyNumber, loaded.Parameters.KeyNumber);
-                       Assert ("Parameters.ProviderName", 
loaded.Parameters.ProviderName.StartsWith (saved.Parameters.ProviderName));
-                       AssertEquals ("Parameters.ProviderType", 
saved.Parameters.ProviderType, loaded.Parameters.ProviderType);
+                       Assert.IsTrue (loaded.Filename.StartsWith 
(saved.Filename), "Filename");
+                       Assert.IsTrue (loaded.KeyValue.StartsWith 
(saved.KeyValue), "KeyValue");
+                       Assert.IsTrue 
(loaded.Parameters.KeyContainerName.StartsWith 
(saved.Parameters.KeyContainerName), "Parameters.KeyContainerName");
+                       Assert.AreEqual (saved.Parameters.KeyNumber, 
loaded.Parameters.KeyNumber, "Parameters.KeyNumber");
+                       Assert.IsTrue 
(loaded.Parameters.ProviderName.StartsWith (saved.Parameters.ProviderName), 
"Parameters.ProviderName");
+                       Assert.AreEqual (saved.Parameters.ProviderType, 
loaded.Parameters.ProviderType, "Parameters.ProviderType");
                }
 
                [Test]
                public void CspType () 
                {
-                       CspParameters cp = new CspParameters (-1);
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
-                       kpp.Save ();
+                       try {
+                               CspParameters cp = new CspParameters (-1);
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp, "<keypair/>");
+                               kpp.Save ();
 
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       // we didn't supply a name so we can't load it back
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
+                               // we didn't supply a name so we can't load it 
back
 
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                               kpp.Remove ();
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspTypeProvider () 
                {
-                       CspParameters cp = new CspParameters (-2, "Provider");
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
-                       kpp.Save ();
+                       try {
+                               CspParameters cp = new CspParameters (-2, 
"Provider");
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp, "<keypair/>");
+                               kpp.Save ();
 
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       // we didn't supply a name so we can't load it back
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
+                               // we didn't supply a name so we can't load it 
back
 
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                               kpp.Remove ();
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspTypeProviderContainer () 
                {
-                       CspParameters cp = new CspParameters (-3, "Provider", 
"Container");
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
-                       kpp.Save ();
+                       try {
+                               CspParameters cp = new CspParameters (-3, 
"Provider", "Container");
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp, "<keypair/>");
+                               kpp.Save ();
 
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
-                       Assert ("Load", kpp2.Load ());
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
+                               KeyPairPersistence kpp2 = new 
KeyPairPersistence (cp);
+                               Assert.IsTrue (kpp2.Load (), "Load");
 
-                       Compare (kpp, kpp2);
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                               Compare (kpp, kpp2);
+                               kpp.Remove ();
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspTypeProviderContainerKeyNumber () 
                {
-                       CspParameters cp = new CspParameters (-4, "Provider", 
"Container");
-                       cp.KeyNumber = 0;
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
-                       kpp.Save ();
+                       try {
+                               CspParameters cp = new CspParameters (-4, 
"Provider", "Container");
+                               cp.KeyNumber = 0;
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp, "<keypair/>");
+                               kpp.Save ();
 
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
-                       Assert ("Load", kpp2.Load ());
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
+                               KeyPairPersistence kpp2 = new 
KeyPairPersistence (cp);
+                               Assert.IsTrue (kpp2.Load (), "Load");
 
-                       Compare (kpp, kpp2);
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                               Compare (kpp, kpp2);
+                               kpp.Remove ();
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspFlagsDefault () 
                {
-                       CspParameters cp = new CspParameters (-5, "Provider", 
"Container");
-                       cp.Flags = CspProviderFlags.UseDefaultKeyContainer;
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
-                       kpp.Save ();
+                       try {
+                               CspParameters cp = new CspParameters (-5, 
"Provider", "Container");
+                               cp.Flags = 
CspProviderFlags.UseDefaultKeyContainer;
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp, "<keypair/>");
+                               kpp.Save ();
 
-                       Assert ("Save-Exists", File.Exists (kpp.Filename));
-                       KeyPairPersistence kpp2 = new KeyPairPersistence (cp);
-                       Assert ("Load", kpp2.Load ());
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
+                               KeyPairPersistence kpp2 = new 
KeyPairPersistence (cp);
+                               Assert.IsTrue (kpp2.Load (), "Load");
 
-                       Compare (kpp, kpp2);
-                       kpp.Remove ();
-                       Assert ("Remove-!Exists", !File.Exists (kpp.Filename));
+                               Compare (kpp, kpp2);
+                               kpp.Remove ();
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspFlagsMachine () 
                {
-                       CspParameters cp = new CspParameters (-6, "Provider", 
"Container");
-                       cp.Flags = CspProviderFlags.UseMachineKeyStore;
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
                        try {
+                               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));
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
                                KeyPairPersistence kpp2 = new 
KeyPairPersistence (cp);
-                               Assert ("Load", kpp2.Load ());
+                               Assert.IsTrue (kpp2.Load (), "Load");
 
                                Compare (kpp, kpp2);
                                kpp.Remove ();
-                               Assert ("Remove-!Exists", !File.Exists 
(kpp.Filename));
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
                        }
                        catch (CryptographicException ce) {
                                // not everyone can write to the machine store
                                if (!(ce.InnerException is 
UnauthorizedAccessException))
                                        throw;
+                               Assert.Ignore ("Access denied to key containers 
files.");
                        }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspFlagsDefaultMachine () 
                {
-                       CspParameters cp = new CspParameters (-7, "Provider", 
"Container");
-                       cp.Flags = CspProviderFlags.UseDefaultKeyContainer | 
CspProviderFlags.UseMachineKeyStore;
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp, 
"<keypair/>");
                        try {
+                               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));
+                               Assert.IsTrue (File.Exists (kpp.Filename), 
"Save-Exists");
                                KeyPairPersistence kpp2 = new 
KeyPairPersistence (cp);
-                               Assert ("Load", kpp2.Load ());
+                               Assert.IsTrue (kpp2.Load (), "Load");
 
                                Compare (kpp, kpp2);
                                kpp.Remove ();
-                               Assert ("Remove-!Exists", !File.Exists 
(kpp.Filename));
+                               Assert.IsFalse (File.Exists (kpp.Filename), 
"Remove-!Exists");
                        }
                        catch (CryptographicException ce) {
                                // not everyone can write to the machine store
                                if (!(ce.InnerException is 
UnauthorizedAccessException))
                                        throw;
+                               Assert.Ignore ("Access denied to key containers 
files.");
                        }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
 
                [Test]
                public void CspNoChangesPermitted () 
                {
-                       CspParameters cp = new CspParameters (-8, "Provider", 
"Container");
-                       cp.KeyNumber = 0;
-                       cp.Flags = CspProviderFlags.UseMachineKeyStore;
+                       try {
+                               CspParameters cp = new CspParameters (-8, 
"Provider", "Container");
+                               cp.KeyNumber = 0;
+                               cp.Flags = CspProviderFlags.UseMachineKeyStore;
 
-                       KeyPairPersistence kpp = new KeyPairPersistence (cp);
-                       CspParameters copy = kpp.Parameters;
-                       copy.Flags = CspProviderFlags.UseDefaultKeyContainer;
-                       copy.KeyContainerName = "NewContainerName";
-                       copy.KeyNumber = 1;
-                       copy.ProviderName = "NewProviderName";
-                       copy.ProviderType = -9;
+                               KeyPairPersistence kpp = new KeyPairPersistence 
(cp);
+                               CspParameters copy = kpp.Parameters;
+                               copy.Flags = 
CspProviderFlags.UseDefaultKeyContainer;
+                               copy.KeyContainerName = "NewContainerName";
+                               copy.KeyNumber = 1;
+                               copy.ProviderName = "NewProviderName";
+                               copy.ProviderType = -9;
 
-                       Assert ("Flags", cp.Flags != copy.Flags);
-                       Assert ("KeyContainerName", cp.KeyContainerName != 
copy.KeyContainerName);
-                       Assert ("KeyNumber", cp.KeyNumber != copy.KeyNumber);
-                       Assert ("ProviderName", cp.ProviderName != 
copy.ProviderName);
-                       Assert ("ProviderType", cp.ProviderType != 
copy.ProviderType);
+                               Assert.IsTrue (cp.Flags != copy.Flags, "Flags");
+                               Assert.IsTrue (cp.KeyContainerName != 
copy.KeyContainerName, "KeyContainerName");
+                               Assert.IsTrue (cp.KeyNumber != copy.KeyNumber, 
"KeyNumber");
+                               Assert.IsTrue (cp.ProviderName != 
copy.ProviderName, "ProviderName");
+                               Assert.IsTrue (cp.ProviderType != 
copy.ProviderType, "ProviderType");
+                       }
+                       catch (UnauthorizedAccessException) {
+                               Assert.Ignore ("Access denied to key containers 
files.");
+                       }
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to