Skip to content

test(security): extend authorization tests for endpoints permitted in #347 - #349

Merged
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:test/extend-authorization-tests-for-347
Sep 10, 2026
Merged

test(security): extend authorization tests for endpoints permitted in #347#349
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:test/extend-authorization-tests-for-347

Conversation

@Isaries

@Isaries Isaries commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Following up on #347 and @hirokiterashima's review comment about extending WebSecurityConfigAuthorizationTest to cover the newly permitted endpoints and prevent regression.

What this adds

Eight test methods exercising the anonymous-access whitelist through the real Spring Security filter chain:

Test Endpoints covered
unauthenticated_staticAssetPaths_shouldBeAllowed /pages/resources/**, /portal/javascript/**, /portal/themes/**, /portal/translate/**, /vle/**, /projectIcons/**
unauthenticated_passwordRecoveryEndpoints_shouldBeAllowed /api/student/forgot/**, /api/teacher/forgot/**
unauthenticated_contactNewsAndAnnouncement_shouldBeAllowed POST /api/contact, /api/news/**, /api/announcement
unauthenticated_projectInfoAndGoogleUserChecks_shouldBeAllowed /api/project/info/*, /api/google-user/check-user-exists, /api/google-user/check-user-matches
unauthenticated_previewAndSurveyPaths_shouldBeAllowed /previewproject.html, /run-survey/**
unauthenticated_errorAndFrameworkPaths_shouldBeAllowed /error, /errors/**, /favicon.ico
unauthenticated_registrationAndOAuthEndpoints_shouldBeAllowed /api/teacher/register, /api/student/register, /api/student/register/questions, /oauth2/**, /login/oauth2/**, /login, /
unauthenticated_protectedEndpoints_shouldBeDenied Negative test: /api/teacher/**, /author/**, /api/admin/** must reject anonymous requests

Helpers

assertDeniedForAnonymous checks for 403 or a 302 redirect specifically targeting /login. A plain 302 check would not be enough: some controllers return their own redirects, so a security regression that lets the request through to the controller would produce a 302 from the handler and pass the test vacuously.

Why the negative test matters

The existing suite only tested that permitted endpoints are reachable. Without a test that protected endpoints are not reachable anonymously, a future whitelist change that accidentally opens a role-guarded path would pass the suite silently.

…ISE-Community#347

Cover the anonymous-access endpoints that WISE-Community#347 added to the permitAll
whitelist: static asset paths, password recovery (both student and
teacher), contact form, news, announcements, project info, Google user
registration checks, project preview, survey entry, error dispatch
paths, and favicon.

Also cover the pre-existing permitAll endpoints that had no test:
registration (teacher, student, questions), OAuth2 authorization and
callback paths, login page, and the root path.

Add a negative test that verifies unauthenticated requests to protected
endpoints (/api/teacher/**, /author/**, /api/admin/**) are still denied,
so that a future whitelist change that accidentally opens a role-guarded
path is caught.

Introduce an assertDeniedForAnonymous helper that checks for 403 or a
302 redirect specifically targeting /login, so that a controller-level
redirect (which would mean the request passed the security layer) does
not make the test pass vacuously.

@hirokiterashima hirokiterashima left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding these tests.

@hirokiterashima
hirokiterashima merged commit 9699d2c into WISE-Community:develop Sep 10, 2026
1 check passed
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.

2 participants