* 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
+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.
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
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]
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); }
+ }
}
}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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");
+ }
+ }
+}
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]
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); }
+ }
}
}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
--- /dev/null
+//
+// 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); }
+ }
+ }
+}
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]
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); }
+ }
}
}