def test_local_roles_add_remove(self):
        self.browser_do_login('admin', '')
        role_logger = IRoleLogger(self.portal.info)

        self.portal.info.manage_setLocalRoles(self.username, ['Manager'])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(len(additional_info) == 1)
        self.assertTrue(additional_info[0]['roles'] == ['Manager'])
        self.assertTrue(additional_info[0].has_key('date'))
        self.assertTrue(additional_info[0]['user_granting_roles'] == 'admin')

        self.portal.info.manage_addLocalRoles(self.username, ['Reader'])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(len(additional_info) == 2)
        self.assertTrue(additional_info[0]['roles'] == ['Manager'])
        self.assertTrue(additional_info[0].has_key('date'))
        self.assertTrue(additional_info[0]['user_granting_roles'] == 'admin')
        self.assertTrue(additional_info[1]['roles'] == ['Reader'])
        self.assertTrue(additional_info[1].has_key('date'))
        self.assertTrue(additional_info[1]['user_granting_roles'] == 'admin')

        self.portal.info.manage_delLocalRoles([self.username])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(additional_info is None)

        self.browser_do_logout()
    def test_local_roles_add_remove(self):
        self.browser_do_login('admin', '')
        role_logger = IRoleLogger(self.portal.info)

        self.portal.info.manage_setLocalRoles(self.username, ['Manager'])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(len(additional_info) == 1)
        self.assertTrue(additional_info[0]['roles'] == ['Manager'])
        self.assertTrue(additional_info[0].has_key('date'))
        self.assertTrue(additional_info[0]['user_granting_roles'] == 'admin')

        self.portal.info.manage_addLocalRoles(self.username, ['Reader'])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(len(additional_info) == 2)
        self.assertTrue(additional_info[0]['roles'] == ['Manager'])
        self.assertTrue(additional_info[0].has_key('date'))
        self.assertTrue(additional_info[0]['user_granting_roles'] == 'admin')
        self.assertTrue(additional_info[1]['roles'] == ['Reader'])
        self.assertTrue(additional_info[1].has_key('date'))
        self.assertTrue(additional_info[1]['user_granting_roles'] == 'admin')

        self.portal.info.manage_delLocalRoles([self.username])
        additional_info = role_logger.getLocalRolesInfo(self.username)
        self.assertTrue(additional_info is None)

        self.browser_do_logout()
    def test_match_local_roles_data(self):
        self.browser_do_login('admin', '')
        role_logger = IRoleLogger(self.portal.info)

        self.portal.info.manage_setLocalRoles(self.username, ['Manager'])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.portal.info.manage_addLocalRoles(self.username, ['Reader'])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.portal.info.manage_delLocalRoles([self.username])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.browser_do_logout()
    def test_match_local_roles_data(self):
        self.browser_do_login('admin', '')
        role_logger = IRoleLogger(self.portal.info)

        self.portal.info.manage_setLocalRoles(self.username, ['Manager'])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.portal.info.manage_addLocalRoles(self.username, ['Reader'])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.portal.info.manage_delLocalRoles([self.username])
        info = self.portal.info.get_local_roles_for_userid(self.username)
        additional_info = role_logger.getLocalRolesInfo(self.username)
        zope_roles = set(info)
        naaya_roles = self._get_roles_from_additional_info(additional_info)
        self.assertTrue(len(zope_roles.symmetric_difference(naaya_roles)) == 0)

        self.browser_do_logout()