Skip to content

Commit

Permalink
Merge pull request opensciencegrid#3543 from matyasselmeci/pr/fix-lig…
Browse files Browse the repository at this point in the history
…o-stashcache-test

Actually look at number of LIGO namespaces when testing get_ligo_dn_list()
  • Loading branch information
matyasselmeci authored Dec 21, 2023
2 parents 39971fa + b5652fd commit 739316e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/tests/test_stashcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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:
Expand All @@ -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_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 == 6
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_auth_namespaces = len([ns for ns in ligo_stashcache.namespaces.values() if not ns.is_public()])

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_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")
Expand Down

0 comments on commit 739316e

Please sign in to comment.