Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,95 @@
2010-02-11 Marek Habersack <mhabersack@novell.com>
* RolesTest.cs: added a test for IsUserInRole. Patch from Tiaan
Geldenhuys <tagdev@gmail.com>, thanks!
2007-02-10 Gert Driesen <drieseng@users.sourceforge.net>
* FormsAuthenticationTest.cs: Fixed build using csc 1.x.
2006-12-10 Igor Zelmanovich <igorz@mainsoft.com>
* FormsAuthenticationTest.cs: fixed tests.
2006-11-29 Igor Zelmanovich <igorz@mainsoft.com>
* FormsAuthenticationTest.cs: fixed NunitWeb tests.
2006-07-10 Andrew Skiba <andrews@mainsoft.com>
* FormsAuthenticationTest.cs: run 2 tests in web context, so they
succeed.
2006-05-01 Chris Toshok <toshok@ximian.com>
* MembershipTest.cs (GeneratePassword): add test for password
generation.
2005-09-21 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthenticationTest.cs: CookieDomain property (2.0) changed from
String.Empty (beta2) to null (RC).
* MembershipProviderTest.cs: New. Mostly* useless test cases (* well
in proves it cannot be tested without providers and some extra infra).
* RolePrincipalTest.cs: : New. Mostly* useless test cases (* well
in proves it cannot be tested without providers and some extra infra).
2005-09-18 Sebastien Pouliot <sebastien@ximian.com>
* FormsIdentityTest.cs: Changed constructor used to create the ticket
to one that doesn't throw a NRE under MS runtime.
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.
* WindowsAuthenticationModuleCas.cs: New. CAS unit tests.
* UrlAuthorizationModuleCas.cs: New. CAS unit tests.
2005-09-01 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthenticationEventArgsCas.cs: New. CAS unit tests.
* PassportAuthenticationEventArgsCas.cs: New. CAS unit tests.
* WindowsAuthenticationEventArgsCas.cs: New. CAS unit tests.
2005-08-25 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthenticationTest.cs: Some results are different in 1.x.
Some results are different for Mono too (Gonzalo's beautification).
2005-08-25 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthenticationTest.cs: Added tests for default properties
(both 1.x and 2.0).
* MembershipProviderCollectionTest.cs: Add test case for unexisting
membership provider.
* MembershipUserCollectionTest.cs: New (2.0). Unit tests for
MembershipUserCollection.
* RolesTest.cs: New (2.0). Basic tests for Roles default properties
(sadly anything else requires settings in web.config).
2005-08-23 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthentication.cs: Added basic tests for new some 2.0 stuff.
Normalized line endings.
2005-08-18 Sebastien Pouliot <sebastien@ximian.com>
* MembershipTest.cs: New. Unit tests for Membership class.
* MembershipProviderCollectionTest.cs: New. Unit tests for
MembershipProviderCollection class.
2005-05-21 Sebastien Pouliot <sebastien@ximian.com>
* FormsAuthenticationTest.cs: New. Unit tests for FormsAuthentication.

View File

@ -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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -0,0 +1,96 @@
//
// FormsAuthenticationEventArgsCas.cs
// - CAS unit tests for System.Web.Security.FormsAuthenticationEventArgs
//
// 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.Security.Principal;
using System.Web;
using System.Web.Security;
namespace MonoCasTests.System.Web.Security {
[TestFixture]
[Category ("CAS")]
public class FormsAuthenticationEventArgsCas : AspNetHostingMinimal {
private HttpContext context;
private FormsAuthenticationEventArgs faea;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
context = new HttpContext (null);
faea = new FormsAuthenticationEventArgs (context);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void All_Get_Deny_Unrestricted ()
{
Assert.IsNotNull (faea.Context, "Context");
Assert.IsNull (faea.User, "User");
}
[Test]
[SecurityPermission (SecurityAction.Deny, ControlPrincipal = true)]
[ExpectedException (typeof (SecurityException))]
public void User_Set_Deny_ControlPrincipal ()
{
faea.User = new GenericPrincipal (new GenericIdentity ("me"), null);
}
[Test]
[SecurityPermission (SecurityAction.PermitOnly, ControlPrincipal = true)]
public void User_Set_PermitOnly_ControlPrincipal ()
{
Assert.IsNull (faea.Context.User, "Context.User-before");
Assert.IsNull (faea.User, "User-before");
faea.User = new GenericPrincipal (new GenericIdentity ("me"), null);
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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -0,0 +1,150 @@
//
// FormsAuthenticationTest.cs - NUnit Test Cases for FormsAuthentication
//
// Author:
// Sebastien Pouliot (sebastien@ximian.com)
//
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//
using System;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Security;
using NUnit.Framework;
using MonoTests.SystemWeb.Framework;
namespace MonoTests.System.Web.Security
{
[TestFixture]
public class FormsAuthenticationTest
{
[Test]
[Category ("NotDotNet")] // Dot.net url must include Namespace name
[Category("NunitWeb")]
public void DefaultValues ()
{
new WebTest(new HandlerInvoker (new HandlerDelegate(DefaultValues_delegate))).Run ();
}
static public void DefaultValues_delegate ()
{
// MS use ".ASPXAUTH" while Mono use ".MONOAUTH"
string str = FormsAuthentication.FormsCookieName;
Assert.IsTrue ((str.Length == 9 && str [0] == '.' && str.EndsWith ("AUTH")), "FormsCookieName");
Assert.AreEqual ("/", FormsAuthentication.FormsCookiePath, "FormsCookiePath");
Assert.IsFalse (FormsAuthentication.RequireSSL, "RequireSSL");
Assert.IsTrue (FormsAuthentication.SlidingExpiration, "SlidingExpiration");
#if NET_2_0
// MSDN: The default is an empty string ("") but null.
Assert.AreEqual ("", FormsAuthentication.CookieDomain, "CookieDomain");
Assert.AreEqual (HttpCookieMode.UseDeviceProfile, FormsAuthentication.CookieMode, "CookieMode");
Assert.IsTrue (FormsAuthentication.CookiesSupported, "CookiesSupported");
Assert.AreEqual ("/NunitWeb/default.aspx", FormsAuthentication.DefaultUrl);
Assert.IsFalse (FormsAuthentication.EnableCrossAppRedirects, "EnableCrossAppRedirects");
Assert.AreEqual ("/NunitWeb/login.aspx", FormsAuthentication.LoginUrl, "LoginUrl");
#endif
}
[Test]
[Category ("NotDotNet")] // Dot.net url must include Namespace name
[Category("NunitWeb")]
public void Initialize ()
{
new WebTest(new HandlerInvoker (new HandlerDelegate(Initialize_delegate))).Run ();
}
static public void Initialize_delegate ()
{
// calling Initialize without an HttpContext
FormsAuthentication.Initialize ();
// and that doesn't change the default values
DefaultValues_delegate ();
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void HashPasswordForStoringInConfigFile_NullPassword ()
{
FormsAuthentication.HashPasswordForStoringInConfigFile (null, "MD5");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void HashPasswordForStoringInConfigFile_NullPasswordFormat ()
{
FormsAuthentication.HashPasswordForStoringInConfigFile ("Mono", null);
}
[Test]
public void HashPasswordForStoringInConfigFile_MD5 ()
{
// § (C2-A7)
string s = Encoding.UTF8.GetString (new byte [2] { 0xC2, 0xA7 });
Assert.AreEqual ("BD9A4C255DEEC8944D99E01A64C1E322", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "MD5"));
// ä (C3-A4)
s = Encoding.UTF8.GetString (new byte [2] { 0xC3, 0xA4 });
Assert.AreEqual ("8419B71C87A225A2C70B50486FBEE545", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "md5"));
}
[Test]
public void HashPasswordForStoringInConfigFile_SHA1 ()
{
// § (C2-A7)
string s = Encoding.UTF8.GetString (new byte [2] { 0xC2, 0xA7 });
Assert.AreEqual ("EB2CB244889599F736B6CDD633C5E324F521D1BB", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "SHA1"));
// ä (C3-A4)
s = Encoding.UTF8.GetString (new byte [2] { 0xC3, 0xA4 });
Assert.AreEqual ("961FA22F61A56E19F3F5F8867901AC8CF5E6D11F", FormsAuthentication.HashPasswordForStoringInConfigFile (s, "sha1"));
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void HashPasswordForStoringInConfigFile_SHA256 ()
{
FormsAuthentication.HashPasswordForStoringInConfigFile ("mono", "SHA256");
}
#if NET_2_0
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void RedirectToLoginPage ()
{
FormsAuthentication.RedirectToLoginPage ();
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void RedirectToLoginPage_XtraQuery_Null ()
{
FormsAuthentication.RedirectToLoginPage (null);
}
[Test]
[ExpectedException (typeof (NullReferenceException))]
public void RedirectToLoginPage_XtraQuery_Empty ()
{
FormsAuthentication.RedirectToLoginPage (String.Empty);
}
[Test]
[Category ("NotWorking")] // works on .net
public void Authenticate ()
{
Assert.IsFalse (FormsAuthentication.Authenticate (null, "password"), "null,string");
Assert.IsFalse (FormsAuthentication.Authenticate ("user", null), "string,null");
// not throwing
Assert.IsFalse (FormsAuthentication.Authenticate ("user", "password"), "string,string");
}
#endif
[TestFixtureTearDown]
public void TestFixtureTearDown()
{
WebTest.Unload();
}
}
}

View File

@ -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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -0,0 +1,68 @@
//
// 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 ()
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket (3, "mine", DateTime.MinValue, DateTime.Now.AddSeconds (-1), false, "data", "path");
FormsIdentity identity = new FormsIdentity (ticket);
Assert.AreEqual ("Forms", identity.AuthenticationType, "AuthenticationType");
Assert.IsTrue (identity.IsAuthenticated, "IsAuthenticated");
Assert.AreEqual ("mine", identity.Name, "Name");
Assert.IsNotNull (identity.Ticket, "Ticket");
}
}
}

View File

@ -0,0 +1,171 @@
//
// Authors:
// Marek Habersack <grendel@twistedcode.net>
//
// (C) 2011 Novell, Inc (http://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.
//
#if NET_4_0
using System;
using System.Text;
using System.Web.Security;
using MonoTests.Common;
using NUnit.Framework;
namespace MonoTests.System.Web.Security
{
[TestFixture]
public class MachineKeyTest
{
[Test]
[MonoTODO ("Find out why the difference in result sizes exists between .NET and Mono")]
public void Encode ()
{
#if DOT_NET
const int ALL_EXPECTED_SIZE = 192;
const int ENCRYPTION_EXPECTED_SIZE = 128;
#else
const int ALL_EXPECTED_SIZE = 128;
const int ENCRYPTION_EXPECTED_SIZE = 64;
#endif
const int VALIDATION_EXPECTED_SIZE = 64;
AssertExtensions.Throws<ArgumentNullException> (() => {
MachineKey.Encode (null, MachineKeyProtection.All);
}, "#A1-1");
string result = MachineKey.Encode (new byte[] {}, (MachineKeyProtection)12345);
Assert.IsNotNull (result, "#A1-1");
Assert.AreEqual (0, result.Length, "#A1-2");
result = MachineKey.Encode (new byte[] {}, MachineKeyProtection.All);
Assert.IsNotNull (result, "#B1-1");
Assert.AreEqual (ALL_EXPECTED_SIZE, result.Length, "#B1-2");
result = MachineKey.Encode (new byte [] { }, MachineKeyProtection.Encryption);
Assert.IsNotNull (result, "#C1-1");
Assert.AreEqual (ENCRYPTION_EXPECTED_SIZE, result.Length, "#C1-2");
result = MachineKey.Encode (new byte [] { }, MachineKeyProtection.Validation);
Assert.IsNotNull (result, "#D1-1");
Assert.AreEqual (VALIDATION_EXPECTED_SIZE, result.Length, "#D1-2");
}
[Test]
public void Decode ()
{
byte[] decoded;
AssertExtensions.Throws<ArgumentNullException> (() => {
MachineKey.Decode (null, MachineKeyProtection.All);
}, "#A1-1");
AssertExtensions.Throws<ArgumentException> (() => {
decoded = MachineKey.Decode (String.Empty, MachineKeyProtection.All);
}, "#A1-2");
var sb = new StringBuilder ().Append ('0', 192);
decoded = MachineKey.Decode (sb.ToString (), (MachineKeyProtection)12345);
Assert.IsNotNull (decoded, "#A2-1");
Assert.AreEqual (96, decoded.Length, "#A2-2");
sb = new StringBuilder ().Append ('0', 128);
decoded = MachineKey.Decode (sb.ToString (), (MachineKeyProtection) 12345);
Assert.IsNotNull (decoded, "#A3-1");
Assert.AreEqual (64, decoded.Length, "#A3-2");
sb = new StringBuilder ().Append ('0', 96);
decoded = MachineKey.Decode (sb.ToString (), (MachineKeyProtection) 12345);
Assert.IsNotNull (decoded, "#A4-1");
Assert.AreEqual (48, decoded.Length, "#A4-2");
sb = new StringBuilder ().Append ('0', 10);
decoded = MachineKey.Decode (sb.ToString (), (MachineKeyProtection) 12345);
Assert.IsNotNull (decoded, "#A5-1");
Assert.AreEqual (5, decoded.Length, "#A5-2");
AssertExtensions.Throws<ArgumentException> (() => {
decoded = MachineKey.Decode ("test", MachineKeyProtection.All);
}, "#B1-1");
AssertExtensions.Throws<ArgumentException> (() => {
decoded = MachineKey.Decode ("test", MachineKeyProtection.Encryption);
}, "#B1-2");
AssertExtensions.Throws<ArgumentException> (() => {
decoded = MachineKey.Decode ("test", MachineKeyProtection.Validation);
}, "#B1-3");
sb = new StringBuilder ().Append ('0', 1);
try {
decoded = MachineKey.Decode (sb.ToString (), MachineKeyProtection.All);
Assert.Fail ("#C1-2 [no exception]");
} catch (ArgumentException) {
// success
} catch {
Assert.Fail ("#C1-2 [invalid exception]");
}
sb = new StringBuilder ().Append ('0', 2);
try {
decoded = MachineKey.Decode (sb.ToString (), MachineKeyProtection.All);
} catch (ArgumentException ex) {
Console.WriteLine (ex);
Assert.Fail ("#C1-3");
} catch {
// success
}
sb = new StringBuilder ().Append ('0', 193);
try {
decoded = MachineKey.Decode (sb.ToString (), MachineKeyProtection.All);
Assert.Fail ("#C2-1 [no exception]");
} catch (ArgumentException) {
// success
} catch {
Assert.Fail ("#C2-1 [invalid exception]");
}
sb = new StringBuilder ().Append ('0', 129);
try {
decoded = MachineKey.Decode (sb.ToString (), MachineKeyProtection.All);
Assert.Fail ("#C3-1 [no exception]");
} catch (ArgumentException) {
// success
} catch {
Assert.Fail ("#C3-2 [invalid exception]");
}
sb = new StringBuilder ().Append ('0', 64);
try {
decoded = MachineKey.Decode (sb.ToString (), MachineKeyProtection.All);
} catch (ArgumentException) {
Assert.Fail ("#C4-1");
} catch {
// Success
}
}
}
}
#endif

View File

@ -0,0 +1,77 @@
//
// MembershipProviderCollectionTest.cs
// - Unit tests for System.Web.Security.MembershipProviderCollection
//
// 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.
//
#if NET_2_0
using System;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Web.Security;
using NUnit.Framework;
namespace MonoTests.System.Web.Security {
class TestProviderBase : ProviderBase {
}
[TestFixture]
public class MembershipProviderCollectionTest {
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Add_Null ()
{
MembershipProviderCollection mpc = new MembershipProviderCollection ();
mpc.Add (null);
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void Add_ProviderBase ()
{
TestProviderBase pb = new TestProviderBase ();
MembershipProviderCollection mpc = new MembershipProviderCollection ();
mpc.Add (pb);
// Add accept ProviderBase but docs says it throws
// an exception if it's not a MembershipProvider
}
[Test]
public void UnexistingProvider ()
{
MembershipProviderCollection mpc = new MembershipProviderCollection ();
Assert.IsNull (mpc["uho"]);
// but this will throw an HttpException if we're using an unknown provider
// in an ASP.NET control (like Login)
}
}
}
#endif

View File

@ -0,0 +1,217 @@
//
// MembershipProviderTest.cs
// - Unit tests for System.Web.Security.MembershipProvider
//
// 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.
//
#if NET_2_0
using System;
using System.Configuration.Provider;
using System.Security.Principal;
using System.Web.Security;
using System.Text;
using NUnit.Framework;
using MonoTests.SystemWeb.Framework;
using System.Web.UI;
namespace MonoTests.System.Web.Security {
class TestMembershipProvider : MembershipProvider {
public override string ApplicationName {
get {
throw new Exception ("The method or operation is not implemented.");
}
set {
throw new Exception ("The method or operation is not implemented.");
}
}
public override bool ChangePassword (string username, string oldPassword, string newPassword)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool ChangePasswordQuestionAndAnswer (string username, string password, string newPasswordQuestion, string newPasswordAnswer)
{
throw new Exception ("The method or operation is not implemented.");
}
public override MembershipUser CreateUser (string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool DeleteUser (string username, bool deleteAllRelatedData)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool EnablePasswordReset {
get { throw new Exception ("The method or operation is not implemented."); }
}
public override bool EnablePasswordRetrieval {
get { throw new Exception ("The method or operation is not implemented."); }
}
public override MembershipUserCollection FindUsersByEmail (string emailToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new Exception ("The method or operation is not implemented.");
}
public override MembershipUserCollection FindUsersByName (string usernameToMatch, int pageIndex, int pageSize, out int totalRecords)
{
throw new Exception ("The method or operation is not implemented.");
}
public override MembershipUserCollection GetAllUsers (int pageIndex, int pageSize, out int totalRecords)
{
throw new Exception ("The method or operation is not implemented.");
}
public override int GetNumberOfUsersOnline ()
{
throw new Exception ("The method or operation is not implemented.");
}
public override string GetPassword (string username, string answer)
{
throw new Exception ("The method or operation is not implemented.");
}
public override MembershipUser GetUser (string username, bool userIsOnline)
{
throw new Exception ("The method or operation is not implemented.");
}
public override MembershipUser GetUser (object providerUserKey, bool userIsOnline)
{
throw new Exception ("The method or operation is not implemented.");
}
public override string GetUserNameByEmail (string email)
{
throw new Exception ("The method or operation is not implemented.");
}
public override int MaxInvalidPasswordAttempts
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override int MinRequiredNonAlphanumericCharacters
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override int MinRequiredPasswordLength
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override int PasswordAttemptWindow
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override MembershipPasswordFormat PasswordFormat
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override string PasswordStrengthRegularExpression
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override bool RequiresQuestionAndAnswer
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override bool RequiresUniqueEmail
{
get { throw new Exception ("The method or operation is not implemented."); }
}
public override string ResetPassword (string username, string answer)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool UnlockUser (string userName)
{
throw new Exception ("The method or operation is not implemented.");
}
public override void UpdateUser (MembershipUser user)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool ValidateUser (string username, string password)
{
throw new Exception ("The method or operation is not implemented.");
}
public byte[] Decrypt (byte[] data)
{
return base.DecryptPassword (data);
}
public byte[] Encrypt (byte[] data)
{
return base.EncryptPassword (data);
}
}
[TestFixture]
public class MembershipProviderTest {
[Test]
[ExpectedException (typeof (ProviderException))]
public void EncryptPassword ()
{
WebTest t = new WebTest (PageInvoker.CreateOnLoad (EncryptOnLoad));
t.Run ();
}
public static void EncryptOnLoad (Page p)
{
TestMembershipProvider mp = new TestMembershipProvider ();
string password = "";
byte [] buffer = ASCIIEncoding.Default.GetBytes (password);
mp.Encrypt (buffer);
}
}
}
#endif

View File

@ -0,0 +1,93 @@
//
// MembershipTest.cs - Unit tests for System.Web.Security.Membership
//
// 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.
//
#if NET_2_0
using System;
using System.Text;
using System.Web.Security;
using NUnit.Framework;
using MonoTests.Common;
namespace MonoTests.System.Web.Security {
[TestFixture]
public class MembershipTest {
[Test]
public void Provider ()
{
Assert.IsNotNull (Membership.Provider, "Membership.Provider");
}
[Test]
public void GeneratePassword ()
{
string pwd;
int count;
int i;
pwd = Membership.GeneratePassword (5, 0);
Assert.AreEqual (5, pwd.Length, "A1");
pwd = Membership.GeneratePassword (5, 1);
Assert.AreEqual (5, pwd.Length, "A2");
/* count up the non-alphanumeric characters in the string */
count = 0;
for (i = 0; i < pwd.Length; i ++)
if (!Char.IsLetterOrDigit (pwd, i))
count++;
Assert.IsTrue (count >= 1, "A2");
}
[Test (Description = "Bug #647631")]
public void CreatePassword_InvalidInput ()
{
MembershipUser user;
AssertExtensions.Throws<MembershipCreateUserException> (() => {
user = Membership.CreateUser (null, "password");
}, "#A1");
AssertExtensions.Throws<MembershipCreateUserException> (() => {
user = Membership.CreateUser (String.Empty, "password");
}, "#A2");
AssertExtensions.Throws<MembershipCreateUserException> (() => {
user = Membership.CreateUser ("user", null);
}, "#B1");
AssertExtensions.Throws<MembershipCreateUserException> (() => {
user = Membership.CreateUser ("user", String.Empty);
}, "#B2");
}
}
}
#endif

View File

@ -0,0 +1,155 @@
//
// MembershipUserCollectionTest.cs
// - Unit tests for System.Web.Security.MembershipUserCollection
//
// 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.
//
#if NET_2_0
using System;
using System.Collections;
using System.Web.Security;
using NUnit.Framework;
namespace MonoTests.System.Web.Security {
[TestFixture]
public class MembershipUserCollectionTest {
private MembershipUser GetMember (string name)
{
return new MembershipUser (Membership.Provider.Name, name, null, String.Empty, String.Empty, String.Empty,
true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
}
[Test]
public void Default ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
Assert.IsFalse (muc.IsSynchronized, "IsSynchronized");
Assert.IsTrue (Object.ReferenceEquals (muc, muc.SyncRoot), "SyncRoot");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Add_Null ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Add_ReadOnly ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.SetReadOnly ();
muc.Add (GetMember ("me"));
}
[Test]
[ExpectedException (typeof (ArgumentException))]
public void Add_Twice ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (GetMember ("me"));
muc.Add (GetMember ("me"));
}
[Test]
public void Count ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
Assert.AreEqual (0, muc.Count, "0");
muc.Add (GetMember ("me"));
Assert.AreEqual (1, muc.Count, "1");
muc.Add (GetMember ("me too"));
Assert.AreEqual (2, muc.Count, "2");
muc.SetReadOnly ();
Assert.AreEqual (2, muc.Count, "2b");
}
[Test]
public void GetEnumerator ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
int i = 0;
muc.Add (GetMember ("me"));
muc.Add (GetMember ("me too"));
IEnumerator e = muc.GetEnumerator ();
Assert.IsNotNull (e, "GetEnumerator");
while (e.MoveNext ()) i++;
Assert.AreEqual (2, i, "2");
}
[Test]
public void Item ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (GetMember ("me"));
Assert.IsNotNull (muc["me"], "me");
Assert.IsNull (muc["me too"], "me too");
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Remove_Null ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Remove (null);
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void Remove_ReadOnly ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (GetMember ("me"));
muc.SetReadOnly ();
muc.Remove ("me");
}
[Test]
public void Remove_Unexisting ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (GetMember ("me"));
muc.Remove ("me too");
}
[Test]
public void SetReadOnly ()
{
MembershipUserCollection muc = new MembershipUserCollection ();
muc.Add (GetMember ("me"));
muc.SetReadOnly ();
muc.SetReadOnly (); // twice
}
}
}
#endif

View File

@ -0,0 +1,99 @@
//
// PassportAuthenticationEventArgsCas.cs
// - CAS unit tests for System.Web.Security.PassportAuthenticationEventArgs
//
// 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.Security.Principal;
using System.Web;
using System.Web.Security;
namespace MonoCasTests.System.Web.Security {
[TestFixture]
[Category ("CAS")]
public class PassportAuthenticationEventArgsCas : AspNetHostingMinimal {
private HttpContext context;
private PassportAuthenticationEventArgs paea;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
context = new HttpContext (null);
paea = new PassportAuthenticationEventArgs (null, context);
}
[Test]
[PermissionSet (SecurityAction.Deny, Unrestricted = true)]
public void All_Get_Deny_Unrestricted ()
{
Assert.IsNotNull (paea.Context, "Context");
Assert.IsNull (paea.Identity, "Identity");
Assert.IsNull (paea.User, "User");
}
[Test]
[SecurityPermission (SecurityAction.Deny, ControlPrincipal = true)]
[ExpectedException (typeof (SecurityException))]
public void User_Set_Deny_ControlPrincipal ()
{
paea.User = new GenericPrincipal (new GenericIdentity ("me"), null);
}
[Test]
[SecurityPermission (SecurityAction.PermitOnly, ControlPrincipal = true)]
public void User_Set_PermitOnly_ControlPrincipal ()
{
Assert.IsNull (paea.Context.User, "Context.User-before");
Assert.IsNull (paea.Identity, "Identity-before");
Assert.IsNull (paea.User, "User-before");
paea.User = new GenericPrincipal (new GenericIdentity ("me"), null);
Assert.IsNull (paea.Context.User, "Context.User-after");
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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -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); }
}
}
}

View File

@ -0,0 +1,131 @@
//
// RolePrincipalTest.cs
// - Unit tests for System.Web.Security.RolePrincipal
//
// 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.
//
#if NET_2_0
using System;
using System.Configuration.Provider;
using System.Security.Principal;
using System.Web.Security;
using NUnit.Framework;
namespace MonoTests.System.Web.Security {
public class TestRoleProvider : RoleProvider {
public override void AddUsersToRoles (string[] usernames, string[] roleNames)
{
throw new Exception ("The method or operation is not implemented.");
}
public override string ApplicationName
{
get
{
throw new Exception ("The method or operation is not implemented.");
}
set
{
throw new Exception ("The method or operation is not implemented.");
}
}
public override void CreateRole (string roleName)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool DeleteRole (string roleName, bool throwOnPopulatedRole)
{
throw new Exception ("The method or operation is not implemented.");
}
public override string[] FindUsersInRole (string roleName, string usernameToMatch)
{
throw new Exception ("The method or operation is not implemented.");
}
public override string[] GetAllRoles ()
{
throw new Exception ("The method or operation is not implemented.");
}
public override string[] GetRolesForUser (string username)
{
throw new Exception ("The method or operation is not implemented.");
}
public override string[] GetUsersInRole (string roleName)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool IsUserInRole (string username, string roleName)
{
throw new Exception ("The method or operation is not implemented.");
}
public override void RemoveUsersFromRoles (string[] usernames, string[] roleNames)
{
throw new Exception ("The method or operation is not implemented.");
}
public override bool RoleExists (string roleName)
{
throw new Exception ("The method or operation is not implemented.");
}
}
[TestFixture]
public class RolePrincipalTest {
private IIdentity GetGenericIdentity (string name)
{
return new GenericIdentity (name);
}
[Test]
[ExpectedException (typeof (ArgumentNullException))]
public void Contructor_Identity_Null ()
{
RolePrincipal rp = new RolePrincipal (null);
}
[Test]
[ExpectedException (typeof (ProviderException))]
[Category ("NotWorking")]
public void Contructor_Identity ()
{
RolePrincipal rp = new RolePrincipal (GetGenericIdentity ("me"));
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More