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

This commit is contained in:
Jan Høydahl 2016-10-31 00:57:34 +01:00
parent 42eab7035e
commit dbc2bc7ce8
3 changed files with 11 additions and 1 deletions

View File

@ -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);
}
}
}

View File

@ -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();
}

View File

@ -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" +