def external_users(self, experiment_id): """ returns a list of groups which have external ACL rules :param experiment_id: the ID of the experiment to be edited :type experiment_id: string """ from tardis.tardis_portal.models import ObjectACL acl = ObjectACL.objects.exclude(pluginId=django_user) acl = acl.exclude(pluginId='django_group') acl = acl.filter(content_type__name='experiment', object_id=experiment_id) if not acl: return None from tardis.tardis_portal.auth import AuthService authService = AuthService() result = [] for a in acl: group = authService.searchGroups(plugin=a.pluginId, name=a.entityId) if group: result += group return result
def external_users(self, request, experiment_id): """ returns a list of groups which have external ACL rules :param request: a HTTP Request instance :type request: :py:class:`django.http.HttpRequest` :param experiment_id: the ID of the experiment to be edited :type experiment_id: string """ from tardis.tardis_portal.models import ExperimentACL acl = ExperimentACL.objects.exclude(pluginId=django_user) acl = acl.exclude(pluginId=django_group) acl = acl.filter(experiment__id=experiment_id) if not acl: return None from tardis.tardis_portal.auth import AuthService authService = AuthService() result = [] for a in acl: group = authService.searchGroups(plugin=a.pluginId, name=a.entityId) if group: result += group return result
def external_users(self, experiment_id): """ returns a list of groups which have external ACL rules :param experiment_id: the ID of the experiment to be edited :type experiment_id: string """ from tardis.tardis_portal.models import ObjectACL acl = ObjectACL.objects.exclude(pluginId=django_user) acl = acl.exclude(pluginId='django_group') acl = acl.filter(content_type__name='experiment', object_id=experiment_id) if not acl: return None from tardis.tardis_portal.auth import AuthService authService = AuthService() result = [] for a in acl: group = authService.searchGroups(plugin=a.pluginId, name=a.entityId) if group: result += group return result
def external_users(self, request, experiment_id): """ returns a list of groups which have external ACL rules :param request: a HTTP Request instance :type request: :py:class:`django.http.HttpRequest` :param experiment_id: the ID of the experiment to be edited :type experiment_id: string """ from tardis.tardis_portal.models import ExperimentACL acl = ExperimentACL.objects.exclude(pluginId=django_user) acl = acl.exclude(pluginId=django_group) acl = acl.filter(experiment__id=experiment_id) if not acl: return None from tardis.tardis_portal.auth import AuthService authService = AuthService() result = [] for a in acl: group = authService.searchGroups(plugin=a.pluginId, name=a.entityId) if group: result += group return result
def testGroupSearch(self): from tardis.tardis_portal.auth import AuthService s = MockSettings() s.GROUP_PROVIDERS = \ ('tardis.tardis_portal.tests.test_authservice.MockGroupProvider',) a = AuthService(settings=s) a._manual_init() # check the correct group provider is registered self.assertEqual(len(a._group_providers), 1) # test searching for groups by substring self.assertEqual(len(a.searchGroups(name='Group')), 3) self.assertEqual(len(a.searchGroups(name='123')), 1) self.assertEqual(a.searchGroups(name='123')[0]['id'], '1') self.assertEqual(a.searchGroups(name='123')[0]['pluginname'], 'mockdb') # test limiting the number of results self.assertEqual(len(a.searchGroups(name='Group', max_results=1)), 1) # test sorting the result self.assertEqual( a.searchGroups(name='Group', sort_by='name')[0]['id'], '1')
def testGroupSearch(self): from tardis.tardis_portal.auth import AuthService s = MockSettings() s.GROUP_PROVIDERS = \ ('tardis.tardis_portal.tests.test_authservice.MockGroupProvider',) a = AuthService(settings=s) a._manual_init() # check the correct group provider is registered self.assertEqual(len(a._group_providers), 1) # test searching for groups by substring self.assertEqual(len(a.searchGroups(name='Group')), 3) self.assertEqual(len(a.searchGroups(name='123')), 1) self.assertEqual(a.searchGroups(name='123')[0]['id'], '1') self.assertEqual(a.searchGroups(name='123')[0]['pluginname'], 'mockdb') # test limiting the number of results self.assertEqual(len(a.searchGroups(name='Group', max_results=1)), 1) # test sorting the result self.assertEqual(a.searchGroups(name='Group', sort_by='name')[0]['id'], '1')