diff --git a/app/tests/test_utils.py b/app/tests/test_utils.py index 1d23a1a7e..7fe6abeca 100644 --- a/app/tests/test_utils.py +++ b/app/tests/test_utils.py @@ -28,9 +28,10 @@ class TestUtils(unittest.TestCase): def test_getUserVOs(self): entitlements = ['urn:mace:egi.eu:group:vo.test.egi.eu:role=member#aai.egi.eu', 'urn:mace:egi.eu:group:vo.test.egi.eu:role=vm_operator#aai.egi.eu', - 'urn:mace:egi.eu:group:vo.test2.egi.eu:role=member#aai.egi.eu'] + 'urn:mace:egi.eu:group:vo.test2.egi.eu:role=member#aai.egi.eu', + 'urn:mace:egi.eu:group:vo.test3.egi.eu:vm_operator:role=member#aai.egi.eu'] res = utils.getUserVOs(entitlements) - self.assertEqual(res, ['vo.test.egi.eu', 'vo.test2.egi.eu']) + self.assertEqual(res, ['vo.test.egi.eu', 'vo.test2.egi.eu', 'vo.test3.egi.eu']) @patch("app.utils.getCachedProjectIDs") @patch("app.utils.getCachedSiteList") diff --git a/app/utils.py b/app/utils.py index 2ca98a598..a4356683c 100644 --- a/app/utils.py +++ b/app/utils.py @@ -123,10 +123,12 @@ def getUserVOs(entitlements, vo_role=None): vos = [] for elem in entitlements: # format: urn:mace:egi.eu:group:eosc-synergy.eu:role=vm_operator#aai.egi.eu + # or urn:mace:egi.eu:group:demo.fedcloud.egi.eu:vm_operator:role=member#aai.egi.eu if elem.startswith('urn:mace:egi.eu:group:'): vo = elem[22:22 + elem[22:].find(':')] - if vo and (not vo_role or ":role=%s#" % vo_role in elem) and vo not in vos: - vos.append(vo) + if vo and vo not in vos: + if not vo_role or ":role=%s#" % vo_role in elem or ":%s:" % vo_role in elem: + vos.append(vo) elif elem in g.settings.vo_map and g.settings.vo_map[elem] not in vos: vos.append(g.settings.vo_map[elem]) vos.sort()