mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'master' into feature/SEARCH-679
This commit is contained in:
+60
-10
@@ -48,7 +48,9 @@ import org.junit.rules.ExternalResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Files;
|
||||
@@ -524,7 +526,7 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
private JettySolrRunner createJetty(String jettyKey) throws Exception
|
||||
private JettySolrRunner createJetty(String jettyKey, boolean basicAuth) throws Exception
|
||||
{
|
||||
if (jettyContainers.containsKey(jettyKey))
|
||||
{
|
||||
@@ -534,7 +536,7 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
{
|
||||
Path jettySolrHome = testDir.toPath().resolve(jettyKey);
|
||||
seedSolrHome(jettySolrHome);
|
||||
JettySolrRunner jetty = createJetty(jettySolrHome.toFile(), null, null, false, getSchemaFile());
|
||||
JettySolrRunner jetty = createJetty(jettySolrHome.toFile(), null, null, false, getSchemaFile(), basicAuth);
|
||||
return jetty;
|
||||
}
|
||||
}
|
||||
@@ -599,7 +601,9 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
|
||||
protected void createServers(String jettyKey, String[] coreNames, int numShards, Properties additionalProperties) throws Exception
|
||||
{
|
||||
JettySolrRunner jsr = createJetty(jettyKey);
|
||||
boolean basicAuth = additionalProperties != null ? Boolean.parseBoolean(additionalProperties.getProperty("BasicAuth", "false")) : false;
|
||||
|
||||
JettySolrRunner jsr = createJetty(jettyKey, basicAuth);
|
||||
jettyContainers.put(jettyKey, jsr);
|
||||
|
||||
Properties properties = new Properties();
|
||||
@@ -649,7 +653,7 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
}
|
||||
|
||||
String shardKey = jettyKey+"_shard_"+i;
|
||||
JettySolrRunner j = createJetty(shardKey);
|
||||
JettySolrRunner j = createJetty(shardKey, basicAuth);
|
||||
//use the first corename specified as the Share template
|
||||
addCoreToJetty(shardKey, coreNames[0], shardname, props);
|
||||
jettyShards.add(j);
|
||||
@@ -775,9 +779,9 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
jettyClients.clear();
|
||||
}
|
||||
|
||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled, String schemaOverride) throws Exception
|
||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled, String schemaOverride, boolean basicAuth) throws Exception
|
||||
{
|
||||
return createJetty(solrHome, dataDir, shardList, sslEnabled, schemaOverride, useExplicitNodeNames);
|
||||
return createJetty(solrHome, dataDir, shardList, sslEnabled, schemaOverride, useExplicitNodeNames, basicAuth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -792,7 +796,7 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
* @throws Exception
|
||||
*/
|
||||
public JettySolrRunner createJetty(File solrHome, String dataDir, String shardList, boolean sslEnabled,
|
||||
String schemaOverride, boolean explicitCoreNodeName) throws Exception
|
||||
String schemaOverride, boolean explicitCoreNodeName, boolean basicAuth) throws Exception
|
||||
{
|
||||
Properties props = new Properties();
|
||||
if (schemaOverride != null)
|
||||
@@ -809,8 +813,17 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
props.setProperty("coreNodeName", Integer.toString(nodeCnt.incrementAndGet()));
|
||||
}
|
||||
SSLConfig sslConfig = new SSLConfig(sslEnabled, false, null, null, null, null);
|
||||
JettyConfig config = JettyConfig.builder().setContext("/solr").stopAtShutdown(true).withSSLConfig(sslConfig)
|
||||
.build();
|
||||
|
||||
JettyConfig config = null;
|
||||
|
||||
if(basicAuth) {
|
||||
System.out.println("###### adding basic auth ######");
|
||||
config = JettyConfig.builder().setContext("/solr").withFilter(BasicAuthFilter.class, "/sql/*").stopAtShutdown(true).withSSLConfig(sslConfig).build();
|
||||
} else {
|
||||
System.out.println("###### no basic auth ######");
|
||||
config = JettyConfig.builder().setContext("/solr").stopAtShutdown(true).withSSLConfig(sslConfig).build();
|
||||
}
|
||||
|
||||
JettySolrRunner jetty = new JettySolrRunner(solrHome.getAbsolutePath(), props, config);
|
||||
// .stopAtShutdown(true)
|
||||
// .withFilters(getExtraRequestFilters())
|
||||
@@ -1809,4 +1822,41 @@ public abstract class AbstractAlfrescoDistributedTest extends SolrTestCaseJ4
|
||||
return defaultClient;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BasicAuthFilter implements Filter {
|
||||
|
||||
public BasicAuthFilter() {
|
||||
|
||||
}
|
||||
|
||||
public void init(FilterConfig config) {
|
||||
|
||||
}
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
|
||||
throws IOException, ServletException {
|
||||
//Parse the basic auth filter
|
||||
String auth = ((HttpServletRequest)request).getHeader("Authorization");
|
||||
if(auth != null) {
|
||||
auth = auth.replace("Basic ", "");
|
||||
byte[] bytes = Base64.getDecoder().decode(auth);
|
||||
String decodedBytes = new String(bytes);
|
||||
String[] pair = decodedBytes.split(":");
|
||||
String user = pair[0];
|
||||
String password = pair[1];
|
||||
//Just look for the hard coded user and password.
|
||||
if (user.equals("test") && password.equals("pass")) {
|
||||
filterChain.doFilter(request, response);
|
||||
} else {
|
||||
((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
|
||||
}
|
||||
} else {
|
||||
((HttpServletResponse) response).sendError(HttpServletResponse.SC_FORBIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,32 +3,33 @@ set -e
|
||||
|
||||
[ "$DEBUG" ] && set -x
|
||||
|
||||
# set current working directory to the directory of the script
|
||||
cd "$bamboo_working_directory"
|
||||
|
||||
nicebranch=`echo "$bamboo_planRepository_1_branch" | sed 's/\//_/'`
|
||||
dockerImage="quay.io/alfresco/search-services:$bamboo_maven_version"
|
||||
echo "Building $dockerImage from $nicebranch using version $bamboo_maven_version"
|
||||
|
||||
docker build -t $dockerImage target/docker-resources
|
||||
|
||||
echo "Running tests"
|
||||
docker run --rm "$dockerImage" [ -d /opt/alfresco-search-services/solr ] || (echo "solr dir does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -d /opt/alfresco-search-services/data/alfrescoModels ] || (echo "alfrescoModels dir does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -e /opt/alfresco-search-services/solr.in.sh ] || (echo "solr.in.sh does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q Alfresco /opt/alfresco-search-services/solr.in.sh || (echo "solr.in.sh does not contain Alfresco config" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q Alfresco /opt/alfresco-search-services/solr.in.cmd || (echo "solr.in.cmd does not containAlfresco config" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q LOG4J_PROPS /opt/alfresco-search-services/solr.in.sh || (echo "solr.in.sh does not contain LOG4J_PROPS" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q LOG4J_CONFIG /opt/alfresco-search-services/solr.in.cmd || (echo "solr.in.cmd does not contain LOG4J_CONFIG" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -e /opt/alfresco-search-services/solrhome/conf/shared.properties ] || (echo "shared.properties does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" /opt/alfresco-search-services/solr/bin/solr start
|
||||
|
||||
if [ "${nicebranch}" = "local" ]
|
||||
if [ "${nicebranch}" = "master" ]
|
||||
then
|
||||
echo "Skipping docker publish for local build"
|
||||
else
|
||||
echo "Publishing $dockerImage..."
|
||||
docker push "$dockerImage"
|
||||
fi
|
||||
# set current working directory to the directory of the script
|
||||
cd "$bamboo_working_directory"
|
||||
|
||||
echo "Docker SUCCESS"
|
||||
dockerImage="quay.io/alfresco/search-services:$bamboo_maven_version"
|
||||
echo "Building $dockerImage from $nicebranch using version $bamboo_maven_version"
|
||||
|
||||
docker build -t $dockerImage packaging/target/docker-resources
|
||||
|
||||
echo "Running tests"
|
||||
docker run --rm "$dockerImage" [ -d /opt/alfresco-search-services/solr ] || (echo "solr dir does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -d /opt/alfresco-search-services/data/alfrescoModels ] || (echo "alfrescoModels dir does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -e /opt/alfresco-search-services/solr.in.sh ] || (echo "solr.in.sh does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q Alfresco /opt/alfresco-search-services/solr.in.sh || (echo "solr.in.sh does not contain Alfresco config" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q Alfresco /opt/alfresco-search-services/solr.in.cmd || (echo "solr.in.cmd does not containAlfresco config" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q LOG4J_PROPS /opt/alfresco-search-services/solr.in.sh || (echo "solr.in.sh does not contain LOG4J_PROPS" && exit 1)
|
||||
docker run --rm "$dockerImage" grep -q LOG4J_CONFIG /opt/alfresco-search-services/solr.in.cmd || (echo "solr.in.cmd does not contain LOG4J_CONFIG" && exit 1)
|
||||
docker run --rm "$dockerImage" [ -e /opt/alfresco-search-services/solrhome/conf/shared.properties ] || (echo "shared.properties does not exist" && exit 1)
|
||||
docker run --rm "$dockerImage" /opt/alfresco-search-services/solr/bin/solr start
|
||||
|
||||
echo "Publishing $dockerImage..."
|
||||
docker push "$dockerImage"
|
||||
|
||||
echo "Docker SUCCESS"
|
||||
else
|
||||
echo "Only building and publishing docker images from master. Skipping for ${nicebranch}"
|
||||
fi
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<packaging>pom</packaging>
|
||||
<name>Alfresco Solr Search parent</name>
|
||||
<properties>
|
||||
<solr.version>6.7.0-patched</solr.version>
|
||||
<solr.version>6.6.0</solr.version>
|
||||
<alfresco-solrclient.version>6.5</alfresco-solrclient.version>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
|
||||
Reference in New Issue
Block a user