Skip to content

test(security): cover the admin-only authorization boundary#331

Open
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:test/admin-role-authorization
Open

test(security): cover the admin-only authorization boundary#331
Isaries wants to merge 1 commit into
WISE-Community:developfrom
Isaries:test/admin-role-authorization

Conversation

@Isaries

@Isaries Isaries commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Follow-up from #322: there was no test exercising authorization through the filter chain. The existing controller tests construct the controller directly, so @Secured and the URL rules are never in the call path.

Adds a MockMvc test that runs through the real security filter chain and asserts a researcher is forbidden from /admin/account/** and from the trailing-slash form of an exact admin path, while an administrator is allowed and a researcher keeps access to the rest of /admin/**. Uses spring-security-test for the request post-processors and a Redis container for the session repository, matching the data store integration tests.

The sensitive admin paths are guarded by both the URL rules and @Secured method security, so where both apply the tests assert the effective denial rather than isolating one layer; /admin/run/stats has no method security, so that case exercises the URL rule directly.

The controllers behind /admin/account/** and the exact admin paths are
only guarded by the security filter chain and method security. The
existing controller tests instantiate the controller directly, so they
never pass through the security proxy and cannot catch a regression in
the URL rules.

Add a MockMvc test that runs requests through the real filter chain and
asserts a researcher is forbidden from user and account management and
from the trailing-slash form of an exact admin path, while an
administrator is allowed and a researcher keeps access to the rest of
/admin/**. Pull in spring-security-test for the request post-processors
and back the session repository with a Redis container the same way the
data store integration tests do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant