Skip to content

extract intropage_device_scope() and add a coverage harness #384

Description

@somethingwithproof

First increment of the panel de-duplication, plus the test infrastructure it needs.

Helper

The device-permission preamble (get_simple_device_perms then, for non-simple users, intropage_get_allowed_devices) is copied ~39 times across the panels. This adds one documented intropage_device_scope($user_id) returning {simple, allowed} and adopts it in the two alert.php panels (an 8-line block becomes 4, behaviour identical). It returns only the uniform parts: the IN() clause is left to the caller because the column and any AND prefix differ between panels (for example alert.php uses AND host.id IN (...)).

Coverage harness

The plugin had no coverage configuration, and its tests/Security/* are source-pattern scans rather than behavioural tests. This adds a phpunit.xml with a coverage source list so coverage is measurable, plus tests/Unit/DeviceScopeTest.php and permission-chain stubs in tests/bootstrap.php. The test drives every branch of the helper (all pass under PHP 8.4).
Note: five tests/Security/* cases already fail on develop (verified by stashing this change); they are pre-existing and untouched here.
This is deliberately one family. The remaining ~37 sites want per-site verification of each IN()-clause variant, done family by family, not a blind sweep.


Tracking issue for #378, which carries the fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions