Skip to content

Commit

Permalink
fix session injection when the path is null.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Jun 20, 2013
1 parent 6876181 commit 4d5ddd1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Expand Up @@ -135,17 +135,28 @@ public AuthenticatedSessionProvider getSessionProvider(

private String getEmbeddedWorkspace(final HttpServletRequest servletRequest) {
final String requestPath = servletRequest.getPathInfo();

if (requestPath == null) {
return null;
}

final String[] part = requestPath.split("/");

if (part.length > 1 && part[1].startsWith("workspace:")) {
return part[1].substring("workspace:".length());
} else {
return null;
}

}

private Transaction getEmbeddedTransaction(final HttpServletRequest servletRequest) throws PathNotFoundException {
final String requestPath = servletRequest.getPathInfo();

if (requestPath == null) {
return null;
}

final String[] part = requestPath.split("/");

if (part.length > 1 && part[1].startsWith("tx:")) {
Expand Down
Expand Up @@ -43,6 +43,18 @@ public void tearDown() {

}

@Test
public void testGetSessionWithNullPath() throws LoginException,
RepositoryException {
final HttpServletRequest mockRequest = mock(HttpServletRequest.class);
when(mockRequest.getPathInfo()).thenReturn(null);

testObj.getSession(mockRequest);
verify(mockRepo).login();
}



@Test
public void testGetSessionAuthenticated() throws LoginException,
RepositoryException {
Expand Down

0 comments on commit 4d5ddd1

Please sign in to comment.