You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by bd...@apache.org on 2021/07/09 17:07:40 UTC
[shiro] branch backport-SHIRO-825-18 created (now 4a20bf0)
This is an automated email from the ASF dual-hosted git repository.
bdemers pushed a change to branch backport-SHIRO-825-18
in repository https://gitbox.apache.org/repos/asf/shiro.git.
at 4a20bf0 Backport SHIRO-825
This branch includes the following new commits:
new 4a20bf0 Backport SHIRO-825
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[shiro] 01/01: Backport SHIRO-825
Posted by bd...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bdemers pushed a commit to branch backport-SHIRO-825-18
in repository https://gitbox.apache.org/repos/asf/shiro.git
commit 4a20bf0e995909d8fda58f9c0485ea9eb2d43f0e
Author: Albert Choi <ac...@venasolutions.com>
AuthorDate: Tue Jul 6 14:57:02 2021 -0400
Backport SHIRO-825
This was causing "java.lang.IllegalArgumentException: There is no configured chain under the name/key"
---
.../mgt/PathMatchingFilterChainResolver.java | 2 +-
.../mgt/PathMatchingFilterChainResolverTest.java | 44 +++++++++++++++++++++-
2 files changed, 43 insertions(+), 3 deletions(-)
diff --git a/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java b/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java
index 452d186..4d12bfe 100644
--- a/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java
+++ b/web/src/main/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolver.java
@@ -126,7 +126,7 @@ public class PathMatchingFilterChainResolver implements FilterChainResolver {
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);
}
}
}
diff --git a/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java b/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
index f3fd0c3..fffd168 100644
--- a/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
+++ b/web/src/test/java/org/apache/shiro/web/filter/mgt/PathMatchingFilterChainResolverTest.java
@@ -20,8 +20,6 @@ package org.apache.shiro.web.filter.mgt;
import org.apache.shiro.util.AntPathMatcher;
import org.apache.shiro.web.WebTest;
-import org.apache.shiro.web.util.WebUtils;
-import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.Test;
@@ -263,4 +261,46 @@ public class PathMatchingFilterChainResolverTest extends WebTest {
assertThat(resolved, notNullValue());
verify(request);
}
+
+ /**
+ * Test asserting <a href="https://issues.apache.org/jira/browse/SHIRO-825">SHIRO-825<a/>.
+ */
+ @Test
+ public void testGetChainWhenPathEndsWithSlash() {
+ HttpServletRequest request = createNiceMock(HttpServletRequest.class);
+ HttpServletResponse response = createNiceMock(HttpServletResponse.class);
+ FilterChain chain = createNiceMock(FilterChain.class);
+
+ //ensure at least one chain is defined:
+ resolver.getFilterChainManager().addToChain("/resource/*/book", "authcBasic");
+
+ expect(request.getServletPath()).andReturn("");
+ expect(request.getPathInfo()).andReturn("/resource/123/book/");
+ replay(request);
+
+ FilterChain resolved = resolver.getChain(request, response, chain);
+ assertNotNull(resolved);
+ verify(request);
+ }
+
+ /**
+ * Test asserting <a href="https://issues.apache.org/jira/browse/SHIRO-825">SHIRO-825<a/>.
+ */
+ @Test
+ public void testGetChainWhenPathDoesNotEndWithSlash() {
+ HttpServletRequest request = createNiceMock(HttpServletRequest.class);
+ HttpServletResponse response = createNiceMock(HttpServletResponse.class);
+ FilterChain chain = createNiceMock(FilterChain.class);
+
+ //ensure at least one chain is defined:
+ resolver.getFilterChainManager().addToChain("/resource/*/book", "authcBasic");
+
+ expect(request.getServletPath()).andReturn("");
+ expect(request.getPathInfo()).andReturn("/resource/123/book");
+ replay(request);
+
+ FilterChain resolved = resolver.getChain(request, response, chain);
+ assertNotNull(resolved);
+ verify(request);
+ }
}