From edb2eae175669c1dfc4d3bde0bf4205d659db516 Mon Sep 17 00:00:00 2001 From: Matyas Selmeci Date: Thu, 21 Dec 2023 15:11:32 -0600 Subject: [PATCH 1/2] Actually look at number of LIGO namespaces when testing get_ligo_dn_list() --- src/tests/test_stashcache.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/tests/test_stashcache.py b/src/tests/test_stashcache.py index 608e9b444..9c5fdd72c 100644 --- a/src/tests/test_stashcache.py +++ b/src/tests/test_stashcache.py @@ -20,7 +20,7 @@ from app import app, global_data from webapp import models, topology, vos_data from webapp.common import load_yaml_file -from webapp.data_federation import CredentialGeneration +from webapp.data_federation import CredentialGeneration, StashCache import stashcache HOST_PORT_RE = re.compile(r"[a-zA-Z0-9.-]{3,63}:[0-9]{2,5}") @@ -85,6 +85,12 @@ def test_global_data() -> models.GlobalData: return new_global_data +@pytest.fixture +def ligo_stashcache(): + vos_data = global_data.get_vos_data() + return vos_data.stashcache_by_vo_name["LIGO"] + + @pytest.fixture def client(): with app.test_client() as client: @@ -93,19 +99,29 @@ def client(): class TestStashcache: - def test_allowedVO_includes_ANY_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture): + def test_allowedVO_includes_ANY_for_ligo_inclusion(self, + client: flask.Flask, + mocker: MockerFixture, + ligo_stashcache: StashCache): + num_namespaces = len(ligo_stashcache.namespaces) + spy = mocker.spy(global_data, "get_ligo_dn_list") stashcache.generate_cache_authfile(global_data, "osg-sunnyvale-stashcache.nrp.internet2.edu") - assert spy.call_count == 6 + assert spy.call_count == num_namespaces + + def test_allowedVO_includes_LIGO_for_ligo_inclusion(self, + client: flask.Flask, + mocker: MockerFixture, + ligo_stashcache: StashCache): + num_namespaces = len(ligo_stashcache.namespaces) - def test_allowedVO_includes_LIGO_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture): spy = mocker.spy(global_data, "get_ligo_dn_list") stashcache.generate_cache_authfile(global_data, "stashcache.gwave.ics.psu.edu") - assert spy.call_count == 6 + assert spy.call_count == num_namespaces def test_allowedVO_excludes_LIGO_and_ANY_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture): spy = mocker.spy(global_data, "get_ligo_dn_list") From b5652fd825753320dabfa09c0b6783fca9af0b16 Mon Sep 17 00:00:00 2001 From: Matyas Selmeci Date: Thu, 21 Dec 2023 15:25:04 -0600 Subject: [PATCH 2/2] Exclude public namespaces since we don't look at DNs for those --- src/tests/test_stashcache.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/test_stashcache.py b/src/tests/test_stashcache.py index 9c5fdd72c..cb6f3bf60 100644 --- a/src/tests/test_stashcache.py +++ b/src/tests/test_stashcache.py @@ -103,25 +103,25 @@ def test_allowedVO_includes_ANY_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture, ligo_stashcache: StashCache): - num_namespaces = len(ligo_stashcache.namespaces) + num_auth_namespaces = len([ns for ns in ligo_stashcache.namespaces.values() if not ns.is_public()]) spy = mocker.spy(global_data, "get_ligo_dn_list") stashcache.generate_cache_authfile(global_data, "osg-sunnyvale-stashcache.nrp.internet2.edu") - assert spy.call_count == num_namespaces + assert spy.call_count == num_auth_namespaces def test_allowedVO_includes_LIGO_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture, ligo_stashcache: StashCache): - num_namespaces = len(ligo_stashcache.namespaces) + num_auth_namespaces = len([ns for ns in ligo_stashcache.namespaces.values() if not ns.is_public()]) spy = mocker.spy(global_data, "get_ligo_dn_list") stashcache.generate_cache_authfile(global_data, "stashcache.gwave.ics.psu.edu") - assert spy.call_count == num_namespaces + assert spy.call_count == num_auth_namespaces def test_allowedVO_excludes_LIGO_and_ANY_for_ligo_inclusion(self, client: flask.Flask, mocker: MockerFixture): spy = mocker.spy(global_data, "get_ligo_dn_list")