From f8e5109255cd801a4a30705878fef91c245b852f Mon Sep 17 00:00:00 2001 From: cproudlock Date: Sat, 11 Jul 2026 19:56:24 -0400 Subject: [PATCH] Pin selfhosted directory modes in the authz sweep The sweep exercises usb/employees handlers, which default to EXTERNAL directory mode when no setting row exists - green on the dev box where the external MySQL databases happen to exist, red in CI where they do not. Seed selfhosted mode in an autouse fixture so the guard is deterministic everywhere. Verified by running the suite with the external DB hosts pointed at an unreachable address. Co-Authored-By: Claude Fable 5 --- tests/test_core/test_authz.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_core/test_authz.py b/tests/test_core/test_authz.py index b0ce76e..f53500d 100644 --- a/tests/test_core/test_authz.py +++ b/tests/test_core/test_authz.py @@ -40,6 +40,20 @@ EXEMPT_BLUEPRINTS = {'auth', 'collector', 'setup'} EXEMPT_ENDPOINTS = {'knowledgebase.track_click', 'users.update_user'} +@pytest.fixture(autouse=True) +def _selfhosted_directory_modes(db): + # The usb/employees plugins default to EXTERNAL directory mode when no + # setting row exists, so exercising their handlers reaches for a MySQL + # server that exists on the dev box but not in CI. Pin selfhosted mode + # so the sweep is deterministic everywhere. + from shopdb.core.models import Setting + db.session.add(Setting(key='usb_directory_mode', value='selfhosted', + valuetype='string', category='site')) + db.session.add(Setting(key='employee_directory_mode', value='selfhosted', + valuetype='string', category='site')) + db.session.commit() + + def _fill_url(rule): """Turn a Werkzeug rule into a concrete path (int/float params -> 1, else x).""" def repl(match):