mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#17691: Possible to create invalid admin account with Turkish collation
--HG-- branch : 1.x
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
using System.Xml.Linq;
|
||||
using Autofac;
|
||||
using Moq;
|
||||
@@ -39,6 +41,7 @@ namespace Orchard.Tests.Modules.Users.Services {
|
||||
private ISessionFactory _sessionFactory;
|
||||
private ISession _session;
|
||||
private IContainer _container;
|
||||
private CultureInfo _currentCulture;
|
||||
|
||||
|
||||
public class TestSessionLocator : ISessionLocator {
|
||||
@@ -55,6 +58,7 @@ namespace Orchard.Tests.Modules.Users.Services {
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void InitFixture() {
|
||||
_currentCulture = Thread.CurrentThread.CurrentCulture;
|
||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||
_sessionFactory = DataUtility.CreateSessionFactory(
|
||||
databaseFileName,
|
||||
@@ -66,7 +70,7 @@ namespace Orchard.Tests.Modules.Users.Services {
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void TermFixture() {
|
||||
|
||||
Thread.CurrentThread.CurrentCulture = _currentCulture;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
@@ -122,5 +126,18 @@ namespace Orchard.Tests.Modules.Users.Services {
|
||||
Assert.That(username, Is.EqualTo("foo"));
|
||||
Assert.That(validateByUtc, Is.GreaterThan(_clock.UtcNow));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VerifyUserUnicityTurkishTest() {
|
||||
CultureInfo turkishCulture = new CultureInfo("tr-TR");
|
||||
Thread.CurrentThread.CurrentCulture = turkishCulture;
|
||||
|
||||
// Create user lower case
|
||||
_membershipService.CreateUser(new CreateUserParams("admin", "66554321", "foo@bar.com", "", "", true));
|
||||
_container.Resolve<IOrchardServices>().ContentManager.Flush();
|
||||
|
||||
// Verify unicity with upper case which with turkish coallition would yeld admin with an i without the dot and therefore generate a different user name
|
||||
Assert.That(_userService.VerifyUserUnicity("ADMIN", "differentfoo@bar.com"), Is.False);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user