You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
Assembly
Documentation
Mono.Web.Util
ReferenceSources
System.Collections.Concurrent
System.Web
System.Web.Caching
System.Web.Compilation
System.Web.Configuration_2.0
System.Web.Handlers
System.Web.Hosting
System.Web.Mail
System.Web.Management
System.Web.Profile
System.Web.Properties
System.Web.Security
System.Web.SessionState_2.0
System.Web.UI
System.Web.UI.Adapters
System.Web.UI.HtmlControls
System.Web.UI.WebControls
System.Web.UI.WebControls.Adapters
System.Web.UI.WebControls.WebParts
System.Web.Util
Test
Cas
System.Web
System.Web.Caching
System.Web.Compilation
System.Web.Configuration
System.Web.Handlers
System.Web.Hosting
System.Web.Mail
System.Web.Profile
System.Web.Security
DefaultAuthenticationEventArgsCas.cs
DefaultAuthenticationModuleCas.cs
FileAuthorizationModuleCas.cs
FormsAuthenticationCas.cs
FormsAuthenticationEventArgsCas.cs
FormsAuthenticationModuleCas.cs
FormsAuthenticationTest.cs
FormsAuthenticationTicketCas.cs
FormsIdentityCas.cs
FormsIdentityTest.cs
MachineKeyTest.cs
MembershipPasswordAttributeTest.cs
MembershipProviderCollectionTest.cs
MembershipProviderTest.cs
MembershipTest.cs
MembershipUserCollectionTest.cs
PassportAuthenticationEventArgsCas.cs
PassportAuthenticationModuleCas.cs
PassportIdentityCas.cs
RolePrincipalTest.cs
RolesTest.cs
UrlAuthorizationModuleCas.cs
WindowsAuthenticationEventArgsCas.cs
WindowsAuthenticationModuleCas.cs
System.Web.SessionState
System.Web.UI
System.Web.UI.Adapters
System.Web.UI.HtmlControls
System.Web.UI.WebControls
System.Web.UI.WebControls.Adapters
System.Web.UI.WebControls.WebParts
System.Web.Util
TestMonoWeb
mainsoft
standalone
standalone-runner-support
standalone-tests
tools
DataBinderTests.cs
Makefile
test.aspx
test2.aspx
test3.aspx
test4.aspx
test5.aspx
test6.aspx
resources
ASPState.sql
Makefile
SQLiteProviders_DatabaseSchema.sql
System.Web.dll.sources
System.Web_standalone_test.dll.sources
System.Web_test.dll.sources
UplevelHelperDefinitions.xml
standalone-runner-support.dll.sources
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
147 lines
4.7 KiB
C#
147 lines
4.7 KiB
C#
![]() |
//
|
||
|
// 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");
|
||
|
// 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");
|
||
|
}
|
||
|
|
||
|
[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");
|
||
|
}
|
||
|
[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");
|
||
|
}
|
||
|
|
||
|
[TestFixtureTearDown]
|
||
|
public void TestFixtureTearDown()
|
||
|
{
|
||
|
WebTest.Unload();
|
||
|
}
|
||
|
}
|
||
|
}
|