Example #1
0
    def test_updateRole_normal(self):

        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        zrm = self._makeOne(id='update_normal').__of__(root)

        zrm.addRole('role', 'Original Title', 'Original description')

        info = zrm.getRoleInfo('role')
        self.assertEqual(info['id'], 'role')
        self.assertEqual(info['title'], 'Original Title')
        self.assertEqual(info['description'], 'Original description')

        zrm.updateRole('role', 'Updated Title', 'Updated description')

        info = zrm.getRoleInfo('role')
        self.assertEqual(info['id'], 'role')
        self.assertEqual(info['title'], 'Updated Title')
        self.assertEqual(info['description'], 'Updated description')
Example #2
0
    def test_enumerateGroups_skip_inactive( self ):

        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        dpg = self._makeOne( 'enumerating' ).__of__( root )

        dpg.addGroup( 'everyone', 'python:True', 'Everyone', '', True )
        dpg.addGroup( 'noone', 'python:False', active=True )
        dpg.addGroup( 'inactive', 'nothing', active=False )

        info_list = dpg.enumerateGroups()

        self.assertEqual( len( info_list ), 2 )

        ids = [ x[ 'id' ] for x in info_list ]

        self.failUnless( 'everyone' in ids )
        self.failUnless( 'noone' in ids )
        self.failIf( 'inactive' in ids )
    def test_enumerateGroups_prefixed(self):
        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        zrm = self._makeOne(id='prefixed').__of__(root)
        zrm.prefix = 'prefixed_'

        ID_LIST = ('foo', 'bar', 'baz', 'bam')
        PRE_LIST = tuple(['prefixed_%s' % x for x in ID_LIST])

        for id in ID_LIST:

            zrm.addGroup(id, 'Group %s' % id, 'This is group, %s' % id)

        info_list = zrm.enumerateGroups()

        self.assertEqual(len(info_list), len(ID_LIST))

        for info in info_list:
            self.assertTrue(info['id'] in PRE_LIST)
    def test_enumerateGroups_exact_list(self):

        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        dpg = self._makeOne('enumerating').__of__(root)

        dpg.addGroup('everyone', 'python:True', 'Everyone', '', True)
        dpg.addGroup('noone', 'python:False', active=True)
        dpg.addGroup('hohum', 'nothing', active=True)

        ID_LIST = ('everyone', 'noone')

        info_list = dpg.enumerateGroups(id=ID_LIST, exact_match=True)

        self.assertEqual(len(info_list), len(ID_LIST))

        ids = [x['id'] for x in info_list]

        for id in ID_LIST:
            self.assertTrue(id in ids)
Example #5
0
    def test_enumerateUsers_exact(self):

        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        zum = self._makeOne(id='exact').__of__(root)

        ID_LIST = ('foo', 'bar', 'baz', 'bam')

        for id in ID_LIST:

            zum.addUser(id, '*****@*****.**' % id, 'password')

        info_list = zum.enumerateUsers(id='bar', exact_match=True)

        self.assertEqual(len(info_list), 1)
        info = info_list[0]

        self.assertEqual(info['id'], 'bar')
        self.assertEqual(info['login'], '*****@*****.**')
        self.assertEqual(info['pluginid'], 'exact')
        self.assertEqual(info['editurl'], 'exact/manage_users?user_id=bar')
Example #6
0
    def test_enumerateGroups_enumerating_with_optional_prefix(self):

        from Products.PluggableAuthService.tests.test_PluggableAuthService \
            import FauxRoot

        root = FauxRoot()
        dpg = self._makeOne('enumerating').__of__(root)
        dpg.prefix = 'enumerating_'

        dpg.addGroup('everyone', 'python:True', 'Everyone', '', True)
        dpg.addGroup('noone', 'python:False', active=True)
        dpg.addGroup('hohum', 'nothing', active=True)

        ID_LIST = ('enumerating_everyone', 'enumerating_noone',
                   'enumerating_hohum')

        info_list = dpg.enumerateGroups()

        self.assertEqual(len(info_list), len(ID_LIST))

        ids = [x['id'] for x in info_list]

        for id in ID_LIST:
            self.failUnless(id in ids)