Security hardening, multi-site portability, and a documentation and API-surface sweep

This commit is contained in:
2026-08-14 16:28:34 -04:00
parent 72f8da0e58
commit 265ca2eb01
76 changed files with 3684 additions and 811 deletions

View File

@@ -206,12 +206,19 @@ def test_partmarker_kind_is_share_backed_and_not_renderable():
assert kind.parse(b'anything') is None
def test_partmarker_sharedir_is_under_the_sfld_backups_root():
path = registry.getkind('partmarker').sharedir('lathe', '3204')
assert path.startswith(registry.DEFAULTSHAREROOT)
def test_partmarker_sharedir_is_under_the_configured_backups_root():
root = r'\\fileserver\shopfloor\backups'
path = registry.getkind('partmarker').sharedir('lathe', '3204', shareroot=root)
assert path.startswith(root)
assert path.endswith(r'lathe\3204\partmarker')
def test_sharedir_is_empty_when_no_root_is_configured():
"""No default root ships (ADR-015), so an unconfigured site gets nothing
rather than a path composed from another site's file server."""
assert registry.getkind('partmarker').sharedir('lathe', '3204') == ''
def test_getkind_is_case_insensitive_and_returns_none_when_unknown():
assert registry.getkind('NTLARS') is not None
assert registry.getkind('nosuchkind') is None
@@ -981,3 +988,21 @@ def test_the_panel_shows_verified_beside_captured(bk_app, bk_plugin):
listpanel = next(p for p in panels if p.get('render') == 'list')
labels = [m['label'] for m in listpanel['map']['meta']]
assert 'Captured' in labels and 'Verified' in labels
def test_retention_reads_the_key_the_settings_page_writes(app, db):
"""The plugin helper namespaces to `plugin.backups.<key>`; the declared key
is bare. Reading through the helper meant retention was configurable and
inert - it always fell back to 0, which means keep everything."""
from shopdb.core.models import Setting
from plugins.backups.plugin import BackupsPlugin
declared = {entry['key'] for entry in BackupsPlugin().get_settings_defaults()}
assert 'backups_retentioncount' in declared
Setting.set('backups_retentioncount', 5)
db.session.commit()
assert int(Setting.get('backups_retentioncount', 0)) == 5
# The helper cannot see it, which is the whole defect: it looks under
# plugin.backups.backups_retentioncount, which nothing writes.
assert int(BackupsPlugin().get_setting('backups_retentioncount', 0) or 0) == 0