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

backport SHIRO-825 to 1.8 #310

Merged
merged 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -126,7 +126,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
Expand Up @@ -20,8 +20,6 @@

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;

Expand Down Expand Up @@ -263,4 +261,46 @@ public void testMultipleChainsPathEndsWithSlash() {
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);
}
}