You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by as...@apache.org on 2017/05/10 08:53:26 UTC
svn commit: r1794688 -
/sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
Author: asanso
Date: Wed May 10 08:53:26 2017
New Revision: 1794688
URL: http://svn.apache.org/viewvc?rev=1794688&view=rev
Log:
SLING-6053 - SlingAuthenticator identifies wrong sibling node with AuthenticationInfo
* add additional test
Modified:
sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
Modified: sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java?rev=1794688&r1=1794687&r2=1794688&view=diff
==============================================================================
--- sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java (original)
+++ sling/trunk/bundles/auth/core/src/test/java/org/apache/sling/auth/core/impl/SlingAuthenticatorTest.java Wed May 10 08:53:26 2017
@@ -242,6 +242,32 @@ public class SlingAuthenticatorTest {
Assert.assertTrue(AUTH_TYPE.equals(authInfo.getAuthType()));
}
+ @Test
+ public void test_childNodeShouldHaveAuthenticationInfoLonger() throws Throwable {
+ final String AUTH_TYPE = "AUTH_TYPE_TEST";
+ final String AUTH_TYPE_LONGER = "AUTH_TYPE_LONGER_TEST";
+ final String PROTECTED_PATH = "/resource1";
+ final String PROTECTED_PATH_LONGER = "/resource1.test2";
+ final String REQUEST_CHILD_NODE = "/resource1.test2";
+
+ SlingAuthenticator slingAuthenticator = new SlingAuthenticator();
+
+ PathBasedHolderCache<AbstractAuthenticationHandlerHolder> authRequiredCache = new PathBasedHolderCache<AbstractAuthenticationHandlerHolder>();
+ authRequiredCache.addHolder(buildAuthHolderForAuthTypeAndPath(AUTH_TYPE, PROTECTED_PATH));
+ authRequiredCache.addHolder(buildAuthHolderForAuthTypeAndPath(AUTH_TYPE_LONGER, PROTECTED_PATH_LONGER));
+
+ PrivateAccessor.setField(slingAuthenticator, "authHandlerCache", authRequiredCache);
+ final HttpServletRequest request = context.mock(HttpServletRequest.class);
+ buildExpectationsForRequestPathAndAuthPath(request, REQUEST_CHILD_NODE, PROTECTED_PATH);
+
+ AuthenticationInfo authInfo = (AuthenticationInfo) PrivateAccessor.invoke(slingAuthenticator, "getAuthenticationInfo",
+ new Class[]{HttpServletRequest.class, HttpServletResponse.class}, new Object[]{request, context.mock(HttpServletResponse.class)});
+ /**
+ * The AUTH TYPE defined aboved should be used for the path /test and his children: eg /test/childnode.
+ */
+ Assert.assertTrue(AUTH_TYPE_LONGER.equals(authInfo.getAuthType()));
+ }
+
/**
* JIRA: SLING-6053