Commit 9e011846 authored by Jérome Perrin's avatar Jérome Perrin

tests that login is case insensitive



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@11698 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 049d11d1
...@@ -52,8 +52,6 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -52,8 +52,6 @@ class TestUserManagement(ERP5TypeTestCase):
"""Tests User Management in ERP5Security. """Tests User Management in ERP5Security.
""" """
RUN_ALL_TESTS = 1
def getTitle(self): def getTitle(self):
"""Title of the test.""" """Title of the test."""
return "ERP5Security: User Management" return "ERP5Security: User Management"
...@@ -70,7 +68,7 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -70,7 +68,7 @@ class TestUserManagement(ERP5TypeTestCase):
get_transaction().commit() get_transaction().commit()
self.tic() self.tic()
def login(self, quiet=0, run=1): def login(self):
uf = self.getUserFolder() uf = self.getUserFolder()
uf._doAddUser('alex', '', ['Manager', 'Assignee', 'Assignor', uf._doAddUser('alex', '', ['Manager', 'Assignee', 'Assignor',
'Associate', 'Auditor', 'Author'], []) 'Associate', 'Auditor', 'Author'], [])
...@@ -81,36 +79,23 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -81,36 +79,23 @@ class TestUserManagement(ERP5TypeTestCase):
"""Returns the acl_users. """ """Returns the acl_users. """
return self.getPortal().acl_users return self.getPortal().acl_users
def test_GroupManagerInterfaces(self, run=RUN_ALL_TESTS): def test_GroupManagerInterfaces(self):
"""Tests group manager plugin respects interfaces.""" """Tests group manager plugin respects interfaces."""
if not run: # XXX move to GroupManager test class
return
from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin
from Products.ERP5Security.ERP5GroupManager import ERP5GroupManager from Products.ERP5Security.ERP5GroupManager import ERP5GroupManager
verifyClass(IGroupsPlugin, ERP5GroupManager) verifyClass(IGroupsPlugin, ERP5GroupManager)
def test_UserManagerInterfaces(self, run=RUN_ALL_TESTS): def test_UserManagerInterfaces(self):
"""Tests user manager plugin respects interfaces.""" """Tests user manager plugin respects interfaces."""
if not run:
return
from Products.PluggableAuthService.interfaces.plugins import\ from Products.PluggableAuthService.interfaces.plugins import\
IAuthenticationPlugin, IUserEnumerationPlugin IAuthenticationPlugin, IUserEnumerationPlugin
from Products.ERP5Security.ERP5UserManager import ERP5UserManager from Products.ERP5Security.ERP5UserManager import ERP5UserManager
verifyClass(IAuthenticationPlugin, ERP5UserManager) verifyClass(IAuthenticationPlugin, ERP5UserManager)
verifyClass(IUserEnumerationPlugin, ERP5UserManager) verifyClass(IUserEnumerationPlugin, ERP5UserManager)
def test_RolesManagerInterfaces(self, run=RUN_ALL_TESTS): def test_UserFolder(self):
"""Tests group manager plugin respects interfaces."""
if not run:
return
from Products.PluggableAuthService.interfaces.plugins import IRolesPlugin
from Products.ERP5Security.ERP5RoleManager import ERP5RoleManager
verifyClass(IRolesPlugin, ERP5RoleManager)
def test_UserFolder(self, run=RUN_ALL_TESTS):
"""Tests user folder has correct meta type.""" """Tests user folder has correct meta type."""
if not run:
return
self.failUnless(isinstance(self.getUserFolder(), self.failUnless(isinstance(self.getUserFolder(),
PluggableAuthService.PluggableAuthService)) PluggableAuthService.PluggableAuthService))
...@@ -156,13 +141,25 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -156,13 +141,25 @@ class TestUserManagement(ERP5TypeTestCase):
"Plugin %s should not have authenticated '%s' with password '%s'" % "Plugin %s should not have authenticated '%s' with password '%s'" %
(plugin_name, login, password)) (plugin_name, login, password))
def test_PersonWithLoginPasswordAreUsers(self, run=RUN_ALL_TESTS): def test_PersonWithLoginPasswordAreUsers(self):
"""Tests a person with a login & password is a valid user.""" """Tests a person with a login & password is a valid user."""
p = self._makePerson(reference='the_user', password='secret', p = self._makePerson(reference='the_user', password='secret',
career_role='internal') career_role='internal')
self._assertUserExists('the_user', 'secret') self._assertUserExists('the_user', 'secret')
def test_PersonWithLoginWithEmptyPasswordAreNotUsers(self, run=RUN_ALL_TESTS): def test_PersonLoginCaseSensitive(self):
"""Login/password are case sensitive."""
p = self._makePerson(reference='the_user', password='secret',
career_role='internal')
self._assertUserDoesNotExists('the_User', 'secret')
def test_PersonLoginNonAscii(self):
"""Login can contain non ascii chars."""
p = self._makePerson(reference='j\xc3\xa9', password='secret',
career_role='internal')
self._assertUserExists('j\xc3\xa9', 'secret')
def test_PersonWithLoginWithEmptyPasswordAreNotUsers(self):
"""Tests a person with a login but no password is not a valid user.""" """Tests a person with a login but no password is not a valid user."""
self._makePerson(reference='the_user', career_role='internal') self._makePerson(reference='the_user', career_role='internal')
self._assertUserDoesNotExists('the_user', None) self._assertUserDoesNotExists('the_user', None)
...@@ -170,27 +167,27 @@ class TestUserManagement(ERP5TypeTestCase): ...@@ -170,27 +167,27 @@ class TestUserManagement(ERP5TypeTestCase):
career_role='internal') career_role='internal')
self._assertUserDoesNotExists('another_user', '') self._assertUserDoesNotExists('another_user', '')
def test_PersonWithEmptyLoginAreNotUsers(self, run=RUN_ALL_TESTS): def test_PersonWithEmptyLoginAreNotUsers(self):
"""Tests a person with a login & password is a valid user.""" """Tests a person with a login & password is a valid user."""
self._makePerson(reference='', password='secret', career_role='internal') self._makePerson(reference='', password='secret', career_role='internal')
self._assertUserDoesNotExists('', 'secret') self._assertUserDoesNotExists('', 'secret')
def test_PersonWithSuperUserLoginCannotBeCreated(self, run=RUN_ALL_TESTS): def test_PersonWithSuperUserLoginCannotBeCreated(self):
"""Tests one cannot create person with the "super user" special login.""" """Tests one cannot create person with the "super user" special login."""
from Products.ERP5Security.ERP5UserManager import SUPER_USER from Products.ERP5Security.ERP5UserManager import SUPER_USER
self.assertRaises(RuntimeError, self._makePerson, reference=SUPER_USER) self.assertRaises(RuntimeError, self._makePerson, reference=SUPER_USER)
def test_PersonWithSuperUserLogin(self, run=RUN_ALL_TESTS): def test_PersonWithSuperUserLogin(self):
"""Tests one cannot use the "super user" special login.""" """Tests one cannot use the "super user" special login."""
from Products.ERP5Security.ERP5UserManager import SUPER_USER from Products.ERP5Security.ERP5UserManager import SUPER_USER
self._assertUserDoesNotExists(SUPER_USER, '') self._assertUserDoesNotExists(SUPER_USER, '')
def test_MultiplePersonReference(self, run=RUN_ALL_TESTS): def test_MultiplePersonReference(self):
"""Tests that it's refused to create two Persons with same reference.""" """Tests that it's refused to create two Persons with same reference."""
self._makePerson(reference='new_person') self._makePerson(reference='new_person')
self.assertRaises(RuntimeError, self._makePerson, reference='new_person') self.assertRaises(RuntimeError, self._makePerson, reference='new_person')
def test_PersonCopyAndPaste(self, run=RUN_ALL_TESTS): def test_PersonCopyAndPaste(self):
"""If we copy and paste a person, login must not be copyied.""" """If we copy and paste a person, login must not be copyied."""
person = self._makePerson(reference='new_person') person = self._makePerson(reference='new_person')
person_module = self.getPersonModule() person_module = self.getPersonModule()
...@@ -274,6 +271,12 @@ class TestLocalRoleManagement(ERP5TypeTestCase): ...@@ -274,6 +271,12 @@ class TestLocalRoleManagement(ERP5TypeTestCase):
"""List of BT to install. """ """List of BT to install. """
return ('erp5_base',) return ('erp5_base',)
def test_RolesManagerInterfaces(self):
"""Tests group manager plugin respects interfaces."""
from Products.PluggableAuthService.interfaces.plugins import IRolesPlugin
from Products.ERP5Security.ERP5RoleManager import ERP5RoleManager
verifyClass(IRolesPlugin, ERP5RoleManager)
def testMemberRole(self): def testMemberRole(self):
"""Test users have the Member role. """Test users have the Member role.
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment