From dbc2bc7ce8f76b30138fc47bc5e0a98b2028d504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B8ydahl?= Date: Mon, 31 Oct 2016 00:57:34 +0100 Subject: [PATCH] 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 --- .../org/apache/solr/handler/admin/SecurityConfHandler.java | 4 ++++ .../apache/solr/handler/admin/SecurityConfHandlerLocal.java | 4 +++- .../org/apache/solr/security/BasicAuthStandaloneTest.java | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) 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.java index 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 implements public 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.java index 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.java index 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" +