From f1d8779c4987b542d079a85e0cd70b453291c9a5 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Tue, 12 Mar 2024 13:28:07 +0100 Subject: [PATCH] Fix getvos --- app/tests/test_utils.py | 1 + app/utils.py | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/tests/test_utils.py b/app/tests/test_utils.py index fce469495..0843b76de 100644 --- a/app/tests/test_utils.py +++ b/app/tests/test_utils.py @@ -27,6 +27,7 @@ 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'] res = utils.getUserVOs(entitlements) self.assertEquals(res, ['vo.test.egi.eu', 'vo.test2.egi.eu']) diff --git a/app/utils.py b/app/utils.py index 58c029955..72a1567a9 100644 --- a/app/utils.py +++ b/app/utils.py @@ -125,12 +125,10 @@ def getUserVOs(entitlements, vo_role=None): # format: urn:mace:egi.eu:group:eosc-synergy.eu:role=vm_operator#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): + if vo and (not vo_role or ":role=%s#" % vo_role in elem) and vo not in vos: vos.append(vo) - elif elem in g.settings.vo_map: + elif elem in g.settings.vo_map and g.settings.vo_map[elem] not in vos: vos.append(g.settings.vo_map[elem]) - - vos = list(set(vos)) vos.sort() return vos