diff --git a/WorkloadManagementSystem/Utilities/PilotCStoJSONSynchronizer.py b/WorkloadManagementSystem/Utilities/PilotCStoJSONSynchronizer.py index b188714cbff..3e97eeb8e94 100644 --- a/WorkloadManagementSystem/Utilities/PilotCStoJSONSynchronizer.py +++ b/WorkloadManagementSystem/Utilities/PilotCStoJSONSynchronizer.py @@ -183,9 +183,12 @@ def _getDNs(self, certGroupName): usersString = gConfig.getValue('/Registry/Groups/' + certGroupName + '/Users') usersInGroup = usersString.split(',') DNs = [gConfig.getValue('/Registry/Users/' + user + '/DN') for user in usersInGroup] - return S_OK(DNs) - except AttributeError: - return S_ERROR('Some error occured while getting the DNs.') + if (DNs == [None]): + return S_ERROR('Users in this group don`t have DN ') + else: + return S_OK(DNs) + except AttributeError as ae: + gLogger.exception("Error occured while getting the DNs", lException=ae) def _getPilotOptionsPerSetup(self, setup, pilotDict): """ Given a setup, returns its pilot options in a dictionary diff --git a/WorkloadManagementSystem/Utilities/test/Test_PilotCStoJSONSynchronizer.py b/WorkloadManagementSystem/Utilities/test/Test_PilotCStoJSONSynchronizer.py index 3387bfd6361..eec9e0a2801 100644 --- a/WorkloadManagementSystem/Utilities/test/Test_PilotCStoJSONSynchronizer.py +++ b/WorkloadManagementSystem/Utilities/test/Test_PilotCStoJSONSynchronizer.py @@ -29,6 +29,13 @@ def setUp(self): } } } + Resources + { + Sites + { + + } + } Systems { WorkloadManagement @@ -69,6 +76,10 @@ def setUp(self): CA = /DC=ch/DC=voodo/CN=Voodo Grid Certification Authority Email = franek.bolek@voodo.pl } + Nemo + { + + } } Groups { @@ -83,6 +94,14 @@ def setUp(self): #@@-ggg@diracAdmin - 2015-07-07 13:40:55 VO = lhcb } + Empty_group + { + + } + Nautilus + { + Users=Nemo + } } } ''' @@ -129,6 +148,16 @@ def test_failure(self): res = synchroniser._getDNs('nonExistingGroup') self.assertFalse(res['OK']) + def test_empty_group(self): + synchronizer = PilotCStoJSONSynchronizer() + res = synchronizer._getDNs('Empty') + self.assertFalse(res['OK']) + + def test_user_without_DN(self): + synchronizer = PilotCStoJSONSynchronizer() + res = synchronizer._getDNs('Nautilus') + self.assertFalse(res['OK']) + if __name__ == '__main__': suite = unittest.defaultTestLoader.loadTestsFromTestCase(PilotCStoJSONSynchronizerTestCase)