Merge branch 'jetty-8'
This commit is contained in:
commit
2cbb630f8e
|
@ -468,7 +468,9 @@ public class HashSessionManager extends AbstractSessionManager
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void setStoreDirectory (File dir) throws IOException
|
||||
{
|
||||
{
|
||||
// CanonicalFile is used to capture the base store directory in a way that will
|
||||
// work on Windows. Case differences may through off later checks using this directory.
|
||||
_storeDir=dir.getCanonicalFile();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,37 @@ import java.io.File;
|
|||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eclipse.jetty.server.SessionManager;
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.StdErrLog;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class HashSessionManagerTest
|
||||
{
|
||||
|
||||
@After
|
||||
public void enableStacks()
|
||||
{
|
||||
enableStacks(true);
|
||||
}
|
||||
|
||||
@Before
|
||||
public void quietStacks()
|
||||
{
|
||||
enableStacks(false);
|
||||
}
|
||||
|
||||
protected void enableStacks(boolean enabled)
|
||||
{
|
||||
StdErrLog log = (StdErrLog)Log.getLogger("org.eclipse.jetty.server.session");
|
||||
log.setHideStacks(!enabled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDangerousSessionId() throws Exception
|
||||
public void testDangerousSessionIdRemoval() throws Exception
|
||||
{
|
||||
final HashSessionManager manager = new HashSessionManager();
|
||||
manager.setDeleteUnrestorableSessions(true);
|
||||
|
@ -41,10 +64,30 @@ public class HashSessionManagerTest
|
|||
MavenTestingUtils.getTargetFile("dangerFile.session").createNewFile();
|
||||
|
||||
Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
|
||||
|
||||
|
||||
manager.getSession("../../dangerFile.session");
|
||||
|
||||
Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValidSessionIdRemoval() throws Exception
|
||||
{
|
||||
final HashSessionManager manager = new HashSessionManager();
|
||||
manager.setDeleteUnrestorableSessions(true);
|
||||
manager.setLazyLoad(true);
|
||||
File testDir = MavenTestingUtils.getTargetTestingDir("hashes");
|
||||
testDir.mkdirs();
|
||||
manager.setStoreDirectory(testDir);
|
||||
|
||||
new File(testDir, "validFile.session").createNewFile();
|
||||
|
||||
Assert.assertTrue("File should exist!", new File(testDir, "validFile.session").exists());
|
||||
|
||||
manager.getSession("validFile.session");
|
||||
|
||||
Assert.assertTrue("File shouldn't exist!", !new File(testDir,"validFile.session").exists());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,17 @@ public class IdleSessionTest
|
|||
@Override
|
||||
public SessionManager newSessionManager()
|
||||
{
|
||||
HashSessionManager manager = (HashSessionManager)super.newSessionManager();
|
||||
manager.setStoreDirectory(_storeDir);
|
||||
manager.setIdleSavePeriod(_idlePeriod);
|
||||
return manager;
|
||||
try
|
||||
{
|
||||
HashSessionManager manager = (HashSessionManager)super.newSessionManager();
|
||||
manager.setStoreDirectory(_storeDir);
|
||||
manager.setIdleSavePeriod(_idlePeriod);
|
||||
return manager;
|
||||
}
|
||||
catch ( IOException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue