Merge branch 'jetty-8'
This commit is contained in:
commit
2cbb630f8e
|
@ -469,6 +469,8 @@ public class HashSessionManager extends AbstractSessionManager
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
public void setStoreDirectory (File dir) throws IOException
|
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();
|
_storeDir=dir.getCanonicalFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,37 @@ import java.io.File;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.SessionManager;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
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;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class HashSessionManagerTest
|
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
|
@Test
|
||||||
public void testDangerousSessionId() throws Exception
|
public void testDangerousSessionIdRemoval() throws Exception
|
||||||
{
|
{
|
||||||
final HashSessionManager manager = new HashSessionManager();
|
final HashSessionManager manager = new HashSessionManager();
|
||||||
manager.setDeleteUnrestorableSessions(true);
|
manager.setDeleteUnrestorableSessions(true);
|
||||||
|
@ -47,4 +70,24 @@ public class HashSessionManagerTest
|
||||||
Assert.assertTrue("File should exist!", MavenTestingUtils.getTargetFile("dangerFile.session").exists());
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,12 +63,19 @@ public class IdleSessionTest
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SessionManager newSessionManager()
|
public SessionManager newSessionManager()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
HashSessionManager manager = (HashSessionManager)super.newSessionManager();
|
HashSessionManager manager = (HashSessionManager)super.newSessionManager();
|
||||||
manager.setStoreDirectory(_storeDir);
|
manager.setStoreDirectory(_storeDir);
|
||||||
manager.setIdleSavePeriod(_idlePeriod);
|
manager.setIdleSavePeriod(_idlePeriod);
|
||||||
return manager;
|
return manager;
|
||||||
}
|
}
|
||||||
|
catch ( IOException e)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue