Apache Lucene open-source search software
SOLR-9481: Uppering debug level on the failing test and inserting extra logging. Also throw instead of swallow in case of problems parsing local security.json file
Jan Høydahldbc2bc7ce8f7
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.javaindex 1fea4312adb..88e4b018e26 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandler.java@@ -234,6 +234,10 @@ public abstract class SecurityConfHandler extends RequestHandlerBase implementspublic SecurityConfig setData(InputStream securityJsonInputStream) {return setData(Utils.fromJSON(securityJsonInputStream));}++ public String toString() {+ return "SecurityConfig: version=" + version + ", data=" + Utils.toJSONString(data);+ }}}diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.javaindex 34a635f69b3..852d501cb12 100644--- a/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java+++ b/solr/core/src/java/org/apache/solr/handler/admin/SecurityConfHandlerLocal.java@@ -56,7 +56,9 @@ public class SecurityConfHandlerLocal extends SecurityConfHandler {if (Files.exists(securityJsonPath)) {try (InputStream securityJsonIs = Files.newInputStream(securityJsonPath)) {return new SecurityConfig().setData(securityJsonIs);- } catch (IOException e) { /* Fall through */ }+ } catch (Exception e) {+ throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Failed opening existing security.json file: " + securityJsonPath, e);+ }}return new SecurityConfig();}diff --git a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.javaindex 55e78e7cdf1..e5fec06db0e 100644--- a/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java+++ b/solr/core/src/test/org/apache/solr/security/BasicAuthStandaloneTest.java@@ -42,6 +42,7 @@ import org.apache.solr.common.util.Utils;import org.apache.solr.handler.admin.SecurityConfHandler;import org.apache.solr.handler.admin.SecurityConfHandlerLocalForTesting;import org.apache.solr.util.AbstractSolrTestCase;+import org.apache.solr.util.LogLevel;import org.junit.After;import org.junit.Before;import org.junit.Test;@@ -82,6 +83,7 @@ public class BasicAuthStandaloneTest extends AbstractSolrTestCase {}@Test+ @LogLevel("org.apache.solr=DEBUG")public void testBasicAuth() throws Exception {String authcPrefix = "/admin/authentication";@@ -99,6 +101,8 @@ public class BasicAuthStandaloneTest extends AbstractSolrTestCase {securityConfHandler.persistConf(new SecurityConfHandler.SecurityConfig().setData(Utils.fromJSONString(STD_CONF.replaceAll("'", "\""))));securityConfHandler.securityConfEdited();+ log.debug("Newly written security.json is " + securityConfHandler.getSecurityConfig(false) ++ " and baseUrl is " + baseUrl);verifySecurityStatus(cl, baseUrl + authcPrefix, "authentication/class", "solr.BasicAuthPlugin", 20);String command = "{\n" +