You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2011/08/02 12:17:54 UTC
svn commit: r1153088 -
/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java
Author: angela
Date: Tue Aug 2 10:17:54 2011
New Revision: 1153088
URL: http://svn.apache.org/viewvc?rev=1153088&view=rev
Log:
JCR-2919 : Security of token base authentication (fix tests)
Modified:
jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java
Modified: jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java?rev=1153088&r1=1153087&r2=1153088&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java (original)
+++ jackrabbit/trunk/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/token/TokenBasedLoginTest.java Tue Aug 2 10:17:54 2011
@@ -26,7 +26,6 @@ import org.apache.jackrabbit.test.Abstra
import org.apache.jackrabbit.test.NotExecutableException;
import org.apache.jackrabbit.test.RepositoryStub;
-import javax.jcr.Credentials;
import javax.jcr.LoginException;
import javax.jcr.Node;
import javax.jcr.Repository;
@@ -160,7 +159,7 @@ public class TokenBasedLoginTest extends
assertEquals("any", ttNode.getProperty(TOKEN_ATTRIBUTE + ".any").getString());
String id = ttNode.getIdentifier();
- assertEquals(token, id);
+ assertTrue(token.startsWith(id));
}
} finally {
@@ -340,16 +339,33 @@ public class TokenBasedLoginTest extends
}
}
- /**
+ /**
* Tests concurrent login on the Repository including token creation.
* Test copied and slightly adjusted from org.apache.jackrabbit.core.ConcurrentLoginTest
*/
public void testConcurrentLoginDifferentWorkspaces() throws RepositoryException, NotExecutableException {
+ final String testID = testuser.getID();
+ // check if test is executable
+ // - multiple workspaces must be present
final List<String> wspNames = Arrays.asList(superuser.getWorkspace().getAccessibleWorkspaceNames());
if (wspNames.size() <= 1) {
throw new NotExecutableException();
}
+ // - testuser must be present for all workspaces
+ for (String wspName : wspNames) {
+ JackrabbitSession s = null;
+ try {
+ s = (JackrabbitSession) getHelper().getSuperuserSession(wspName);
+ if (s.getUserManager().getAuthorizable(testID) == null) {
+ throw new NotExecutableException();
+ }
+ } finally {
+ if (s != null) {
+ s.logout();
+ }
+ }
+ }
final Exception[] exception = new Exception[1];
List<Thread> testRunner = new ArrayList<Thread>();
@@ -362,7 +378,7 @@ public class TokenBasedLoginTest extends
int index = (int) Math.floor(rand);
String wspName = wspNames.get(index);
- SimpleCredentials sc = new SimpleCredentials(testuser.getID(), testuser.getID().toCharArray());
+ SimpleCredentials sc = new SimpleCredentials(testID, testID.toCharArray());
sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, "");
Session s = getHelper().getRepository().login(sc, wspName);