snoopdave commented on code in PR #310:
URL: https://github.com/apache/roller/pull/310#discussion_r4608371956
##########
app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java:
##########
@@ -35,12 +35,15 @@ public class LoadSaltFilter implements Filter {
static final String RENDERING_PATH = "/roller-ui/rendering/";
+ /** Roller UI static files, which never hold a form. */
+ static final String[] STATIC_PATHS = {"/roller-ui/styles/",
"/roller-ui/scripts/", "/roller-ui/images/"};
Review Comment:
**Important:** The front-page stylesheet references
`/roller-ui/theme/tan/menutab-sel.gif` and `menutab-unsel.gif`. Requests for
those images still reach `getSession(true)`. Add `/roller-ui/theme/` to the
skipped paths, cover it in the test, and include the directory in the matching
static-resource rule in #300.
##########
app/src/test/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilterTest.java:
##########
@@ -162,6 +162,23 @@ void forwardedCommentPostsGetNoSessionAndNoSalt() throws
Exception {
}
}
+ @Test
+ void staticFilesGetNoSessionAndNoSalt() throws Exception {
+ try (MockedStatic<SaltCache> mockedSaltCache =
mockStatic(SaltCache.class)) {
+ mockedSaltCache.when(SaltCache::getInstance).thenReturn(saltCache);
+ for (String path : new String[] {"/roller-ui/styles/roller.css",
"/roller-ui/scripts/date-fields.js",
+ "/roller-ui/images/feather.svg"}) {
+ when(request.getServletPath()).thenReturn(path);
+ filter.doFilter(request, response, chain);
+ }
+
+ verify(request, never()).getSession(true);
+ verify(request, never()).getSession();
+ verify(request, never()).setAttribute(eq("salt"), anyString());
+ verify(saltCache, never()).put(anyString(), anyString());
Review Comment:
**Important:** Twin #332 also verifies that all three requests reach the
filter chain and that `/roller-ui/styles-settings.rol` still receives a salt.
This test omits both checks; it would pass if the static-file branch returned
without serving the files. Carry over the chain assertion and the
prefix-boundary test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]