2005-09-09 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Fri, 9 Sep 2005 18:46:01 +0000 (18:46 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Fri, 9 Sep 2005 18:46:01 +0000 (18:46 -0000)
* DefaultAuthenticationEventArgsCas.cs: New. CAS unit tests.
* DefaultAuthenticationModuleCas.cs: New. CAS unit tests.
* FileAuthorizationModuleCas.cs: New. CAS unit tests.
* FormsAuthenticationCas.cs: New. CAS unit tests.
* FormsAuthenticationEventArgsCas.cs: Added LinkDemand tests.
* FormsAuthenticationModuleCas.cs: New. CAS unit tests.
* FormsAuthenticationTicketCas.cs: New. CAS unit tests.
* FormsIdentityCas.cs: New. CAS unit tests.
* FormsIdentityTest.cs: New. Unit tests for FormsIdentity.
* PassportAuthenticationEventArgsCas.cs: Added LinkDemand tests.
* PassportAuthenticationModuleCas.cs: New. CAS unit tests.
* PassportIdentityCas.cs: New. CAS unit tests.
* WindowsAuthenticationEventArgsCas.cs: Added LinkDemand tests.
* UrlAuthorizationModuleCas.cs: New. CAS unit tests.

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

15 files changed:
mcs/class/System.Web/Test/System.Web.Security/ChangeLog
mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationEventArgsCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationModuleCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FileAuthorizationModuleCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationEventArgsCas.cs
mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationModuleCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTicketCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsIdentityCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/FormsIdentityTest.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/PassportAuthenticationEventArgsCas.cs
mcs/class/System.Web/Test/System.Web.Security/PassportAuthenticationModuleCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/PassportIdentityCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/UrlAuthorizationModuleCas.cs [new file with mode: 0644]
mcs/class/System.Web/Test/System.Web.Security/WindowsAuthenticationEventArgsCas.cs

index e96b3df37051512830046f42c0a9b5325291d43c..d21084c4f59fb9fd3bb71afd14308f0165d0ab9c 100644 (file)
@@ -1,3 +1,20 @@
+2005-09-09  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * DefaultAuthenticationEventArgsCas.cs: New. CAS unit tests.
+       * DefaultAuthenticationModuleCas.cs: New. CAS unit tests.
+       * FileAuthorizationModuleCas.cs: New. CAS unit tests.
+       * FormsAuthenticationCas.cs: New. CAS unit tests.
+       * FormsAuthenticationEventArgsCas.cs: Added LinkDemand tests.
+       * FormsAuthenticationModuleCas.cs: New. CAS unit tests.
+       * FormsAuthenticationTicketCas.cs: New. CAS unit tests.
+       * FormsIdentityCas.cs: New. CAS unit tests.
+       * FormsIdentityTest.cs: New. Unit tests for FormsIdentity.
+       * PassportAuthenticationEventArgsCas.cs: Added LinkDemand tests.
+       * PassportAuthenticationModuleCas.cs: New. CAS unit tests.
+       * PassportIdentityCas.cs: New. CAS unit tests.
+       * WindowsAuthenticationEventArgsCas.cs: Added LinkDemand tests.
+       * UrlAuthorizationModuleCas.cs: New. CAS unit tests.
+
 2005-09-01  Sebastien Pouliot  <sebastien@ximian.com>
 
        * FormsAuthenticationEventArgsCas.cs: New. CAS unit tests.
diff --git a/mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationEventArgsCas.cs b/mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationEventArgsCas.cs
new file mode 100644 (file)
index 0000000..d81a71c
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// DefaultAuthenticationEventArgsCas.cs 
+//     - CAS unit tests for System.Web.Security.DefaultAuthenticationEventArgs
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class DefaultAuthenticationEventArgsCas : AspNetHostingMinimal {
+
+               private HttpContext context;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       context = new HttpContext (null);
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor_Deny_Unrestricted ()
+               {
+                       DefaultAuthenticationEventArgs daea = new DefaultAuthenticationEventArgs (context);
+                       Assert.IsNotNull (daea.Context, "Context");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (HttpContext) });
+                       Assert.IsNotNull (ci, ".ctor(HttpContext)");
+                       return ci.Invoke (new object[1] { context });
+               }
+
+               public override Type Type {
+                       get { return typeof (DefaultAuthenticationEventArgs); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationModuleCas.cs b/mcs/class/System.Web/Test/System.Web.Security/DefaultAuthenticationModuleCas.cs
new file mode 100644 (file)
index 0000000..49b4b8f
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// DefaultAuthenticationModuleCas.cs 
+//     - CAS unit tests for System.Web.Security.DefaultAuthenticationModule
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class DefaultAuthenticationModuleCas : AspNetHostingMinimal {
+
+               private HttpApplication app;
+               private DefaultAuthenticationModule module;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       app = new HttpApplication ();
+                       module = new DefaultAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_UnmanagedCode ()
+               {
+                       new DefaultAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+               public void Constructor_PermitOnly_UnmanagedCode ()
+               {
+                       new DefaultAuthenticationModule ();
+               }
+
+               private void Authenticate (object sender, DefaultAuthenticationEventArgs e)
+               {
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Module ()
+               {
+                       // only the ctor requires UnmanagedCode
+                       module.Init (app);
+                       module.Authenticate += new DefaultAuthenticationEventHandler (Authenticate);
+                       module.Authenticate -= new DefaultAuthenticationEventHandler (Authenticate);
+                       module.Dispose (); // but doesn't implement IDisposable
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       return base.CreateControl (action, level);
+               }
+
+               public override Type Type {
+                       get { return typeof (DefaultAuthenticationModule); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FileAuthorizationModuleCas.cs b/mcs/class/System.Web/Test/System.Web.Security/FileAuthorizationModuleCas.cs
new file mode 100644 (file)
index 0000000..2a5e572
--- /dev/null
@@ -0,0 +1,96 @@
+//
+// FileAuthorizationModuleCas.cs 
+//     - CAS unit tests for System.Web.Security.FileAuthorizationModule
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class FileAuthorizationModuleCas : AspNetHostingMinimal {
+
+               private HttpApplication app;
+               private FileAuthorizationModule module;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       app = new HttpApplication ();
+                       module = new FileAuthorizationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_UnmanagedCode ()
+               {
+                       new FileAuthorizationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+               public void Constructor_PermitOnly_UnmanagedCode ()
+               {
+                       new FileAuthorizationModule ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Module ()
+               {
+                       // only the ctor requires UnmanagedCode
+                       try {
+                               module.Init (app);
+                       }
+                       catch (NotImplementedException) {
+                               // mono
+                       }
+                       module.Dispose (); // but doesn't implement IDisposable
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       return base.CreateControl (action, level);
+               }
+
+               public override Type Type {
+                       get { return typeof (FileAuthorizationModule); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationCas.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationCas.cs
new file mode 100644 (file)
index 0000000..e469978
--- /dev/null
@@ -0,0 +1,62 @@
+//
+// FormsAuthenticationCas.cs 
+//     - CAS unit tests for System.Web.Security.FormsAuthentication
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class FormsAuthenticationCas : AspNetHostingMinimal {
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Identity ()
+               {
+               }
+
+               // LinkDemand
+
+               public override Type Type {
+                       get { return typeof (FormsAuthentication); }
+               }
+       }
+}
index edb70a7abd3e580ebb8b8e8435f148df22939e51..fab7270c8e269766d3198b9443dedac55c848838 100644 (file)
@@ -37,25 +37,20 @@ using System.Security.Principal;
 using System.Web;
 using System.Web.Security;
 
-namespace MonoCasTests.System.Web {
+namespace MonoCasTests.System.Web.Security {
 
        [TestFixture]
        [Category ("CAS")]
-       public class FormsAuthenticationEventArgsCas {
+       public class FormsAuthenticationEventArgsCas : AspNetHostingMinimal {
 
+               private HttpContext context;
                private FormsAuthenticationEventArgs faea;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
-                       faea = new FormsAuthenticationEventArgs (new HttpContext (null));
-               }
-
-               [SetUp]
-               public void SetUp ()
-               {
-                       if (!SecurityManager.SecurityEnabled)
-                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+                       context = new HttpContext (null);
+                       faea = new FormsAuthenticationEventArgs (context);
                }
 
                [Test]
@@ -84,5 +79,18 @@ namespace MonoCasTests.System.Web {
                        Assert.IsNull (faea.Context.User, "Context.User-after");
                        Assert.IsNotNull (faea.User, "User-after");
                }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (HttpContext) });
+                       Assert.IsNotNull (ci, ".ctor(HttpContext)");
+                       return ci.Invoke (new object[1] { context });
+               }
+
+               public override Type Type {
+                       get { return typeof (DefaultAuthenticationEventArgs); }
+               }
        }
 }
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationModuleCas.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationModuleCas.cs
new file mode 100644 (file)
index 0000000..fe5bff2
--- /dev/null
@@ -0,0 +1,97 @@
+//
+// FormsAuthenticationModuleCas.cs 
+//     - CAS unit tests for System.Web.Security.FormsAuthenticationModule
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class FormsAuthenticationModuleCas : AspNetHostingMinimal {
+
+               private HttpApplication app;
+               private FormsAuthenticationModule module;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       app = new HttpApplication ();
+                       module = new FormsAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_UnmanagedCode ()
+               {
+                       new FormsAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+               public void Constructor_PermitOnly_UnmanagedCode ()
+               {
+                       new FormsAuthenticationModule ();
+               }
+
+               private void Authenticate (object sender, FormsAuthenticationEventArgs e)
+               {
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Module ()
+               {
+                       // only the ctor requires UnmanagedCode
+                       module.Init (app);
+                       module.Authenticate += new FormsAuthenticationEventHandler (Authenticate);
+                       module.Authenticate -= new FormsAuthenticationEventHandler (Authenticate);
+                       module.Dispose (); // but doesn't implement IDisposable
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       return base.CreateControl (action, level);
+               }
+
+               public override Type Type {
+                       get { return typeof (FormsAuthenticationModule); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTicketCas.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsAuthenticationTicketCas.cs
new file mode 100644 (file)
index 0000000..3247324
--- /dev/null
@@ -0,0 +1,126 @@
+//
+// FormsAuthenticationTicketCasCas.cs
+//     - CAS unit tests for System.Web.Security.FormsAuthenticationTicketCas
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class FormsAuthenticationTicketCas : AspNetHostingMinimal {
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor3 ()
+               {
+                       FormsAuthenticationTicket ticket = null;
+                       try {
+                               // this ctor got a problem on MS 1.x
+                               ticket = new FormsAuthenticationTicket ("mine", false, Int32.MaxValue);
+                       }
+                       catch (NullReferenceException) {
+#if NET_2_0
+                               Assert.Fail ("this should work on 2.0");
+#else
+                               Assert.Ignore ("fails with NullReferenceException on MS 1.x");
+#endif
+                       }
+                       Assert.AreEqual ("/", ticket.CookiePath, "CookiePath");
+                       Assert.IsTrue (ticket.Expiration.Year >= 6088, "Expiration");
+                       Assert.IsFalse (ticket.Expired, "Expired");
+                       Assert.IsFalse (ticket.IsPersistent, "IsPersistent");
+                       Assert.IsTrue (ticket.IssueDate <= DateTime.Now, "IssueDate");
+                       Assert.AreEqual ("mine", ticket.Name, "Name");
+                       Assert.AreEqual (String.Empty, ticket.UserData, "UserData");
+                       Assert.IsTrue (ticket.Version > 0, "Version");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor6 ()
+               {
+                       FormsAuthenticationTicket ticket = null;
+                       try {
+                               // this ctor got a problem on MS 1.x
+                               ticket = new FormsAuthenticationTicket (1, "mine", DateTime.MinValue, DateTime.MaxValue, true, "data");
+                       }
+                       catch (NullReferenceException) {
+#if NET_2_0
+                               Assert.Fail ("this should work on 2.0");
+#else
+                               Assert.Ignore ("fails with NullReferenceException on MS 1.x");
+#endif
+                       }
+                       Assert.AreEqual ("/", ticket.CookiePath, "CookiePath");
+                       Assert.AreEqual (DateTime.MaxValue, ticket.Expiration, "Expiration");
+                       Assert.IsFalse (ticket.Expired, "Expired");
+                       Assert.IsTrue (ticket.IsPersistent, "IsPersistent");
+                       Assert.AreEqual (DateTime.MinValue, ticket.IssueDate, "IssueDate");
+                       Assert.AreEqual ("mine", ticket.Name, "Name");
+                       Assert.AreEqual ("data", ticket.UserData, "UserData");
+                       Assert.AreEqual (1, ticket.Version, "Version");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Constructor7 ()
+               {
+                       FormsAuthenticationTicket ticket = new FormsAuthenticationTicket (3, "mine", DateTime.MinValue, DateTime.Now.AddSeconds (-1), false, "data", "path");
+                       Assert.AreEqual ("path", ticket.CookiePath, "CookiePath");
+                       Assert.IsTrue (ticket.Expiration <= DateTime.Now, "Expiration");
+                       Assert.IsTrue (ticket.Expired, "Expired");
+                       Assert.IsFalse (ticket.IsPersistent, "IsPersistent");
+                       Assert.AreEqual (DateTime.MinValue, ticket.IssueDate, "IssueDate");
+                       Assert.AreEqual ("mine", ticket.Name, "Name");
+                       Assert.AreEqual ("data", ticket.UserData, "UserData");
+                       Assert.AreEqual (3, ticket.Version, "Version");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       // we can't take the simpler (3 params) ctor as it fails under 1.x (NRE)
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[7] { typeof (int), typeof (string), typeof (DateTime), typeof (DateTime), typeof (bool), typeof (string), typeof (string) });
+                       Assert.IsNotNull (ci, ".ctor(string,bool,int)");
+                       return ci.Invoke (new object[7] { 3, "mine", DateTime.MinValue, DateTime.Now.AddSeconds (-1), false, "data", "path" });
+               }
+
+               public override Type Type {
+                       get { return typeof (FormsAuthenticationTicket); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsIdentityCas.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsIdentityCas.cs
new file mode 100644 (file)
index 0000000..3fb36a2
--- /dev/null
@@ -0,0 +1,77 @@
+//
+// FormsIdentityCas.cs - CAS unit tests for System.Web.Security.FormsIdentity
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class FormsIdentityCas : AspNetHostingMinimal {
+
+               private FormsAuthenticationTicket ticket;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       // other (simpler) ctors fails with NRE under 1.x
+                       ticket = new FormsAuthenticationTicket (3, "mine", DateTime.MinValue, DateTime.Now.AddSeconds (-1), false, "data", "path");
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Identity ()
+               {
+                       FormsIdentity identity = new FormsIdentity (ticket);
+                       Assert.AreEqual ("Forms", identity.AuthenticationType, "AuthenticationType");
+                       Assert.IsTrue (identity.IsAuthenticated, "IsAuthenticated");
+                       Assert.AreEqual ("mine", identity.Name, "Name");
+                       Assert.IsTrue (Object.ReferenceEquals (ticket, identity.Ticket), "Ticket");
+               }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[1] { typeof (FormsAuthenticationTicket) });
+                       Assert.IsNotNull (ci, ".ctor(FormsAuthenticationTicket)");
+                       return ci.Invoke (new object[1] { ticket });
+               }
+
+               public override Type Type {
+                       get { return typeof (FormsIdentity); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/FormsIdentityTest.cs b/mcs/class/System.Web/Test/System.Web.Security/FormsIdentityTest.cs
new file mode 100644 (file)
index 0000000..40357b6
--- /dev/null
@@ -0,0 +1,67 @@
+//
+// FormsIdentityTest.cs - Unit tests for System.Web.Security.FormsIdentity
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoTests.System.Web.Security {
+
+       [TestFixture]
+       public class FormsIdentityTest {
+
+               [Test]
+               public void Null ()
+               {
+                       FormsIdentity identity = new FormsIdentity (null);
+                       Assert.AreEqual ("Forms", identity.AuthenticationType, "AuthenticationType");
+                       Assert.IsTrue (identity.IsAuthenticated, "IsAuthenticated");
+                       Assert.IsNull (identity.Ticket, "Ticket");
+               }
+
+               [Test]
+               [ExpectedException (typeof (NullReferenceException))]
+               public void Null_Name ()
+               {
+                       FormsIdentity identity = new FormsIdentity (null);
+                       Assert.IsNull (identity.Name, "Name");
+               }
+
+               [Test]
+               public void Ticket ()
+               {
+                       FormsIdentity identity = new FormsIdentity (new FormsAuthenticationTicket ("mine", false, Int32.MaxValue));
+                       Assert.AreEqual ("Forms", identity.AuthenticationType, "AuthenticationType");
+                       Assert.IsTrue (identity.IsAuthenticated, "IsAuthenticated");
+                       Assert.AreEqual ("mine", identity.Name, "Name");
+                       Assert.IsNotNull (identity.Ticket, "Ticket");
+               }
+       }
+}
index e6084cfa48226a5bef1c5a73e9d3cd6a96894fc3..03ffbb87301992f14f4e8a4f3b94772a9201fc5e 100644 (file)
@@ -37,25 +37,20 @@ using System.Security.Principal;
 using System.Web;
 using System.Web.Security;
 
-namespace MonoCasTests.System.Web {
+namespace MonoCasTests.System.Web.Security {
 
        [TestFixture]
        [Category ("CAS")]
-       public class PassportAuthenticationEventArgsCas {
+       public class PassportAuthenticationEventArgsCas : AspNetHostingMinimal {
 
+               private HttpContext context;
                private PassportAuthenticationEventArgs paea;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
-                       paea = new PassportAuthenticationEventArgs (null, new HttpContext (null));
-               }
-
-               [SetUp]
-               public void SetUp ()
-               {
-                       if (!SecurityManager.SecurityEnabled)
-                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+                       context = new HttpContext (null);
+                       paea = new PassportAuthenticationEventArgs (null, context);
                }
 
                [Test]
@@ -87,5 +82,18 @@ namespace MonoCasTests.System.Web {
                        Assert.IsNull (paea.Identity, "Identity-after");
                        Assert.IsNotNull (paea.User, "User-after");
                }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[2] { typeof (PassportIdentity), typeof (HttpContext) });
+                       Assert.IsNotNull (ci, ".ctor(PassportIdentity,HttpContext)");
+                       return ci.Invoke (new object[2] { null, context });
+               }
+
+               public override Type Type {
+                       get { return typeof (PassportAuthenticationEventArgs); }
+               }
        }
 }
diff --git a/mcs/class/System.Web/Test/System.Web.Security/PassportAuthenticationModuleCas.cs b/mcs/class/System.Web/Test/System.Web.Security/PassportAuthenticationModuleCas.cs
new file mode 100644 (file)
index 0000000..e87131f
--- /dev/null
@@ -0,0 +1,102 @@
+//
+// PassportAuthenticationModuleCas.cs 
+//     - CAS unit tests for System.Web.Security.PassportAuthenticationModule
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class PassportAuthenticationModuleCas : AspNetHostingMinimal {
+
+               private HttpApplication app;
+               private PassportAuthenticationModule module;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       app = new HttpApplication ();
+                       module = new PassportAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_UnmanagedCode ()
+               {
+                       new PassportAuthenticationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+               public void Constructor_PermitOnly_UnmanagedCode ()
+               {
+                       new PassportAuthenticationModule ();
+               }
+
+               private void Authenticate (object sender, PassportAuthenticationEventArgs e)
+               {
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Module ()
+               {
+                       // only the ctor requires UnmanagedCode
+                       try {
+                               module.Init (app);
+                       }
+                       catch (NotImplementedException) {
+                               // Mono
+                       }
+                       module.Authenticate += new PassportAuthenticationEventHandler (Authenticate);
+                       module.Authenticate -= new PassportAuthenticationEventHandler (Authenticate);
+                       module.Dispose (); // but doesn't implement IDisposable
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       return base.CreateControl (action, level);
+               }
+
+               public override Type Type {
+                       get { return typeof (PassportAuthenticationModule); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/PassportIdentityCas.cs b/mcs/class/System.Web/Test/System.Web.Security/PassportIdentityCas.cs
new file mode 100644 (file)
index 0000000..6d7a8ed
--- /dev/null
@@ -0,0 +1,87 @@
+//
+// PassportIdentityCas.cs 
+//     - CAS unit tests for System.Web.Security.PassportIdentity
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class PassportIdentityCas : AspNetHostingMinimal {
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, Unrestricted = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_Unmanaged ()
+               {
+                       new PassportIdentity ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, Unrestricted = true)]
+               public void Constructor_PermitOnly_Unmanaged ()
+               {
+                       try {
+                               new PassportIdentity ();
+                       }
+                       catch (NullReferenceException) {
+                               Assert.Ignore ("fails with NullReferenceException on MS");
+                       }
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, Unrestricted = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       // the ctor NRE makes it more complex
+                       try {
+                               return base.CreateControl (action, level);
+                       }
+                       catch (TargetInvocationException tie) {
+                               // we really checking for security exceptions that occurs before a NRE can occurs
+                               if (tie.InnerException is NullReferenceException)
+                                       return String.Empty;
+                               else
+                                       return null;
+                       }
+               }
+
+               public override Type Type {
+                       get { return typeof (PassportIdentity); }
+               }
+       }
+}
diff --git a/mcs/class/System.Web/Test/System.Web.Security/UrlAuthorizationModuleCas.cs b/mcs/class/System.Web/Test/System.Web.Security/UrlAuthorizationModuleCas.cs
new file mode 100644 (file)
index 0000000..c35aab5
--- /dev/null
@@ -0,0 +1,91 @@
+//
+// UrlAuthorizationModuleCas.cs 
+//     - CAS unit tests for System.Web.Security.UrlAuthorizationModule
+//
+// Author:
+//     Sebastien Pouliot  <sebastien@ximian.com>
+//
+// Copyright (C) 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;
+using System.Reflection;
+using System.Security;
+using System.Security.Permissions;
+using System.Web;
+using System.Web.Security;
+
+namespace MonoCasTests.System.Web.Security {
+
+       [TestFixture]
+       [Category ("CAS")]
+       public class UrlAuthorizationModuleCas : AspNetHostingMinimal {
+
+               private HttpApplication app;
+               private UrlAuthorizationModule module;
+
+               [TestFixtureSetUp]
+               public void FixtureSetUp ()
+               {
+                       app = new HttpApplication ();
+                       module = new UrlAuthorizationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.Deny, UnmanagedCode = true)]
+               [ExpectedException (typeof (SecurityException))]
+               public void Constructor_Deny_UnmanagedCode ()
+               {
+                       new UrlAuthorizationModule ();
+               }
+
+               [Test]
+               [SecurityPermission (SecurityAction.PermitOnly, UnmanagedCode = true)]
+               public void Constructor_PermitOnly_UnmanagedCode ()
+               {
+                       new UrlAuthorizationModule ();
+               }
+
+               [Test]
+               [PermissionSet (SecurityAction.Deny, Unrestricted = true)]
+               public void Module ()
+               {
+                       // only the ctor requires UnmanagedCode
+                       module.Init (app);
+                       module.Dispose (); // but doesn't implement IDisposable
+               }
+
+               // LinkDemand
+
+               [SecurityPermission (SecurityAction.Assert, UnmanagedCode = true)]
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       return base.CreateControl (action, level);
+               }
+
+               public override Type Type {
+                       get { return typeof (UrlAuthorizationModule); }
+               }
+       }
+}
index e7461d09b0387c2006f7f31f88640af9a6e8ce4b..b97d95f50e99a9570ad769278684bc9e9ac718e7 100644 (file)
@@ -37,25 +37,20 @@ using System.Security.Principal;
 using System.Web;
 using System.Web.Security;
 
-namespace MonoCasTests.System.Web {
+namespace MonoCasTests.System.Web.Security {
 
        [TestFixture]
        [Category ("CAS")]
-       public class WindowsAuthenticationEventArgsCas {
+       public class WindowsAuthenticationEventArgsCas : AspNetHostingMinimal {
 
+               private HttpContext context;
                private WindowsAuthenticationEventArgs waea;
 
                [TestFixtureSetUp]
                public void FixtureSetUp ()
                {
-                       waea = new WindowsAuthenticationEventArgs (null, new HttpContext (null));
-               }
-
-               [SetUp]
-               public void SetUp ()
-               {
-                       if (!SecurityManager.SecurityEnabled)
-                               Assert.Ignore ("SecurityManager.SecurityEnabled is OFF");
+                       context = new HttpContext (null);
+                       waea = new WindowsAuthenticationEventArgs (null, context);
                }
 
                [Test]
@@ -87,5 +82,18 @@ namespace MonoCasTests.System.Web {
                        Assert.IsNull (waea.Identity, "Identity-after");
                        Assert.IsNotNull (waea.User, "User-after");
                }
+
+               // LinkDemand
+
+               public override object CreateControl (SecurityAction action, AspNetHostingPermissionLevel level)
+               {
+                       ConstructorInfo ci = this.Type.GetConstructor (new Type[2] { typeof (WindowsIdentity), typeof (HttpContext) });
+                       Assert.IsNotNull (ci, ".ctor(WindowsIdentity,HttpContext)");
+                       return ci.Invoke (new object[2] { null, context });
+               }
+
+               public override Type Type {
+                       get { return typeof (WindowsAuthenticationEventArgs); }
+               }
        }
 }