Skip to content

Commit

Permalink
Merge pull request #309 from zAlbee/patch-1
Browse files Browse the repository at this point in the history
[SHIRO-825] Fixes "IllegalArgumentException: There is no configured chain under the name/key"
  • Loading branch information
bmarwell authored Jul 12, 2021
2 parents 69132cd + 367c3d5 commit 2b2bdb1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
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() {
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();
}
}

0 comments on commit 2b2bdb1

Please sign in to comment.