def test_user_mapped_attributes(self):
     acl = self.folder.acl_users
     self.assertEqual(len(acl.getMappedUserAttrs()), 0)
     acl.manage_addLDAPSchemaItem('mail', 'Email', '', 'email')
     for role in user.get('user_roles'):
         acl.manage_addGroup(role)
     acl.manage_addUser(REQUEST=None, kwargs=user)
     user_ob = acl.getUser(user.get(acl.getProperty('_login_attr')))
     self.assertEqual(user.get('mail'), user_ob.getProperty('mail'))
     self.assertEqual(user.get('mail'), user_ob.getProperty('email'))
 def test_user_mapped_attributes(self):
     acl = self.folder.acl_users
     self.assertEquals(len(acl.getMappedUserAttrs()), 0)
     acl.manage_addLDAPSchemaItem( 'mail'
                                 , 'Email'
                                 , ''
                                 , 'email'
                                 )
     for role in user.get('user_roles'):
         acl.manage_addGroup(role)
     msg = acl.manage_addUser(REQUEST=None, kwargs=user)
     user_ob = acl.getUser(user.get(acl.getProperty('_login_attr')))
     self.assertEqual(user.get('mail'), user_ob.getProperty('mail'))
     self.assertEqual(user.get('mail'), user_ob.getProperty('email'))
 def testAuthenticateUser(self):
     acl = self.folder.acl_users
     for role in user.get('user_roles'):
         acl.manage_addGroup(role)
     acl.manage_addUser(REQUEST=None, kwargs=user)
     user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                user.get('user_pw'), {})
     self.failIf(user_ob is None)
     user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                '', {})
     self.failUnless(user_ob is None)
     user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                'falsepassword', {})
     self.failUnless(user_ob is None)
Beispiel #4
0
 def testAuthenticateUser(self):
     acl = self.folder.acl_users
     for role in user.get('user_roles'):
         acl.manage_addGroup(role)
     acl.manage_addUser(REQUEST=None, kwargs=user)
     user_ob = acl.authenticate( user.get(acl.getProperty('_login_attr'))
                               , user.get('user_pw')
                               , {}
                               )
     self.failIf(user_ob is None)
     user_ob = acl.authenticate( "%s " % # extra space after login attr
                                 user.get(acl.getProperty('_login_attr'))
                               , user.get('user_pw')
                               , {}
                               )
     self.failIf(user_ob is None)
     user_ob = acl.authenticate( user.get(acl.getProperty('_login_attr'))
                               , ''
                               , {}
                               )
     self.failUnless(user_ob is None)
     user_ob = acl.authenticate( user.get(acl.getProperty('_login_attr'))
                               , 'falsepassword'
                               , {}
                               )
     self.failUnless(user_ob is None)
Beispiel #5
0
    def testAuthenticateUserWithCache(self):
        acl = self.folder.acl_users
        for role in user.get('user_roles'):
            acl.manage_addGroup(role)
        acl.manage_addUser(REQUEST=None, kwargs=user)

        user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                   'falsepassword', {})

        # make sure the user could not connect
        self.assertIsNone(user_ob)

        # now let's try again with the right password
        user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                   user.get('user_pw'), {})

        # now we should be OK
        self.assertIsNotNone(user_ob)
    def testAuthenticateUserWithCache(self):
        acl = self.folder.acl_users
        for role in user.get('user_roles'):
            acl.manage_addGroup(role)
        acl.manage_addUser(REQUEST=None, kwargs=user)

        user_ob = acl.authenticate( user.get(acl.getProperty('_login_attr'))
                                  , 'falsepassword'
                                  , {}
                                  )

        # make sure the user could not connect
        self.failUnless(user_ob is None)

        # now let's try again with the right password
        user_ob = acl.authenticate( user.get(acl.getProperty('_login_attr'))
                                  , user.get('user_pw')
                                  , {}
                                  )
    
        # now we should be OK
        self.failIf(user_ob is None)
Beispiel #7
0
    def testAuthenticateUser(self):
        acl = self.folder.acl_users
        for role in user.get('user_roles'):
            acl.manage_addGroup(role)
        acl.manage_addUser(REQUEST=None, kwargs=user)

        # Correct login
        user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                   user.get('user_pw'), {})
        self.assertIsNotNone(user_ob)

        # Login with empty password
        user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                   '', {})
        self.assertIsNone(user_ob)

        # Login with wrong password
        user_ob = acl.authenticate(user.get(acl.getProperty('_login_attr')),
                                   'falsepassword', {})
        self.assertIsNone(user_ob)

        # Extra space after login attr - should not fail
        login = '******' % user.get(acl.getProperty('_login_attr'))
        user_ob = acl.authenticate(login, user.get('user_pw'), {})
        self.assertIsNotNone(user_ob)

        # extra space before login attr - should not fail
        login = '******' % user.get(acl.getProperty('_login_attr'))
        user_ob = acl.authenticate(login, user.get('user_pw'), {})
        self.assertIsNotNone(user_ob)

        # Extra spaces around login attr - should not fail
        login = '******' % user.get(acl.getProperty('_login_attr'))
        user_ob = acl.authenticate(login, user.get('user_pw'), {})
        self.assertIsNotNone(user_ob)