test(security): cover the admin-only authorization boundary#331
Open
Isaries wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up from #322: there was no test exercising authorization through the filter chain. The existing controller tests construct the controller directly, so
@Securedand 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
@Securedmethod security, so where both apply the tests assert the effective denial rather than isolating one layer;/admin/run/statshas no method security, so that case exercises the URL rule directly.