Skip to content

Commit

Permalink
Implements: #578
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Sep 5, 2024
1 parent f091fc5 commit d5d341a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d5d341a

Please sign in to comment.