Merge pull request from GHSA-g3wg-6mcf-8jj6
This commit is contained in:
parent
53e0e0e9b2
commit
9ad6beb805
|
@ -20,9 +20,13 @@ package org.eclipse.jetty.server.session;
|
|||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||
import org.eclipse.jetty.toolchain.test.FS;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDir;
|
||||
import org.eclipse.jetty.toolchain.test.jupiter.WorkDirExtension;
|
||||
import org.eclipse.jetty.util.IO;
|
||||
import org.hibernate.search.cfg.Environment;
|
||||
import org.hibernate.search.cfg.SearchMapping;
|
||||
|
@ -33,6 +37,7 @@ import org.infinispan.configuration.cache.Index;
|
|||
import org.infinispan.configuration.global.GlobalConfigurationBuilder;
|
||||
import org.infinispan.manager.DefaultCacheManager;
|
||||
import org.infinispan.manager.EmbeddedCacheManager;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
@ -40,8 +45,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
|||
/**
|
||||
* InfinispanTestSupport
|
||||
*/
|
||||
@ExtendWith(WorkDirExtension.class)
|
||||
public class InfinispanTestSupport
|
||||
{
|
||||
public WorkDir workDir;
|
||||
public static final String DEFAULT_CACHE_NAME = "session_test_cache";
|
||||
public Cache _cache;
|
||||
|
||||
|
@ -95,22 +102,20 @@ public class InfinispanTestSupport
|
|||
|
||||
public void setup() throws Exception
|
||||
{
|
||||
File testdir = MavenTestingUtils.getTargetTestingDir();
|
||||
File tmp = new File(testdir, "indexes");
|
||||
IO.delete(tmp);
|
||||
tmp.mkdirs();
|
||||
Path root = workDir.getEmptyPathDir();
|
||||
Path indexesDir = root.resolve("indexes");
|
||||
FS.ensureDirExists(indexesDir);
|
||||
|
||||
SearchMapping mapping = new SearchMapping();
|
||||
mapping.entity(SessionData.class).indexed().providedId().property("expiry", ElementType.FIELD).field();
|
||||
Properties properties = new Properties();
|
||||
properties.put(Environment.MODEL_MAPPING, mapping);
|
||||
properties.put("hibernate.search.default.indexBase", tmp.getAbsolutePath());
|
||||
properties.put("hibernate.search.default.indexBase", indexesDir.toString());
|
||||
|
||||
if (_useFileStore)
|
||||
{
|
||||
_tmpdir = File.createTempFile("infini", "span");
|
||||
_tmpdir.delete();
|
||||
_tmpdir.mkdir();
|
||||
Path tmpDir = Files.createTempDirectory("infinispan");
|
||||
_tmpdir = tmpDir.toFile();
|
||||
|
||||
ConfigurationChildBuilder b = _builder.indexing()
|
||||
.index(Index.ALL)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.nio.file.FileSystems;
|
||||
|
@ -116,8 +115,8 @@ public class TestServer
|
|||
login.setConfig(jettyRoot.resolve("tests/test-webapps/test-jetty-webapp/src/main/config/demo-base/etc/realm.properties").toString());
|
||||
server.addBean(login);
|
||||
|
||||
File log = File.createTempFile("jetty-yyyy_mm_dd", "log");
|
||||
CustomRequestLog requestLog = new CustomRequestLog(log.toString());
|
||||
Path logPath = Files.createTempFile("jetty-yyyy_mm_dd", "log");
|
||||
CustomRequestLog requestLog = new CustomRequestLog(logPath.toString());
|
||||
server.setRequestLog(requestLog);
|
||||
|
||||
server.setStopAtShutdown(true);
|
||||
|
@ -127,15 +126,11 @@ public class TestServer
|
|||
webapp.setParentLoaderPriority(true);
|
||||
webapp.setResourceBase(jettyRoot.resolve("tests/test-webapps/test-jetty-webapp/src/main/webapp").toString());
|
||||
webapp.setAttribute("testAttribute", "testValue");
|
||||
File sessiondir = File.createTempFile("sessions", null);
|
||||
if (sessiondir.exists())
|
||||
sessiondir.delete();
|
||||
sessiondir.mkdir();
|
||||
sessiondir.deleteOnExit();
|
||||
Path sessionDir = Files.createTempDirectory("sessions");
|
||||
DefaultSessionCache ss = new DefaultSessionCache(webapp.getSessionHandler());
|
||||
FileSessionDataStore sds = new FileSessionDataStore();
|
||||
ss.setSessionDataStore(sds);
|
||||
sds.setStoreDir(sessiondir);
|
||||
sds.setStoreDir(sessionDir.toFile());
|
||||
webapp.getSessionHandler().setSessionCache(ss);
|
||||
|
||||
contexts.addHandler(webapp);
|
||||
|
|
Loading…
Reference in New Issue