Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SHIRO-825] Fixes "IllegalArgumentException: There is no configured chain under the name/key" #309

Merged
merged 2 commits into from
Jul 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public FilterChain getChain(ServletRequest request, ServletResponse response, Fi
log.trace("Matched path pattern [{}] for requestURI [{}]. " +
"Utilizing corresponding filter chain...", pathPattern, Encode.forHtml(requestURINoTrailingSlash));
}
return filterChainManager.proxy(originalChain, requestURINoTrailingSlash);
return filterChainManager.proxy(originalChain, pathPattern);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,4 +255,44 @@ public void testMultipleChainsPathEndsWithSlash() {
FilterChain resolved = resolver.getChain(request, response, chain);
assertThat(resolved, notNullValue());
}

/**
* Test asserting <a href="https://issues.apache.org/jira/browse/SHIRO-825">SHIRO-825<a/>.
*/
@Test
public void testGetChainWhenPathEndsWithSlash() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I verified that this test passes in Shiro 1.7.0 and fails in 1.7.1 (without the fix). Thanks!

HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
FilterChain chain = mock(FilterChain.class);

//ensure at least one chain is defined:
resolver.getFilterChainManager().addToChain("/resource/*/book", "authcBasic");

when(request.getServletPath()).thenReturn("");
when(request.getPathInfo()).thenReturn("/resource/123/book/");

FilterChain resolved = resolver.getChain(request, response, chain);
assertNotNull(resolved);
verify(request).getServletPath();
}

/**
* Test asserting <a href="https://issues.apache.org/jira/browse/SHIRO-825">SHIRO-825<a/>.
*/
@Test
public void testGetChainWhenPathDoesNotEndWithSlash() {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
FilterChain chain = mock(FilterChain.class);

//ensure at least one chain is defined:
resolver.getFilterChainManager().addToChain("/resource/*/book", "authcBasic");

when(request.getServletPath()).thenReturn("");
when(request.getPathInfo()).thenReturn("/resource/123/book");

FilterChain resolved = resolver.getChain(request, response, chain);
assertNotNull(resolved);
verify(request).getServletPath();
}
}