dsmiley commented on code in PR #2276: URL: https://github.com/apache/solr/pull/2276#discussion_r1592989945
########## solr/core/src/test/org/apache/solr/handler/TestUserManagedReplicationWithAuth.java: ########## @@ -0,0 +1,267 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.handler; + +import static org.apache.solr.common.params.CommonParams.JAVABIN; +import static org.apache.solr.handler.ReplicationHandler.CMD_DISABLE_POLL; +import static org.apache.solr.handler.ReplicationHandler.CMD_FETCH_INDEX; +import static org.apache.solr.handler.ReplicationHandler.COMMAND; +import static org.apache.solr.handler.ReplicationTestHelper.createAndStartJetty; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.SolrTestCaseJ4.SuppressSSL; +import org.apache.solr.client.solrj.SolrClient; +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.client.solrj.SolrRequest; +import org.apache.solr.client.solrj.SolrResponse; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.request.HealthCheckRequest; +import org.apache.solr.client.solrj.request.QueryRequest; +import org.apache.solr.client.solrj.request.UpdateRequest; +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.common.SolrInputDocument; +import org.apache.solr.common.params.CommonParams; +import org.apache.solr.common.params.ModifiableSolrParams; +import org.apache.solr.embedded.JettySolrRunner; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +@SuppressSSL +public class TestUserManagedReplicationWithAuth extends SolrTestCaseJ4 { + JettySolrRunner leaderJetty, followerJetty, followerJettyWithAuth; + SolrClient leaderClient, followerClient, followerClientWithAuth; + ReplicationTestHelper.SolrInstance leader = null, follower = null, followerWithAuth = null; + + private static String user = "solr"; + private static String pass = "SolrRocks"; + private static String securityJson = + "{\n" + + "\"authentication\":{ \n" + + " \"blockUnknown\": true, \n" + + " \"class\":\"solr.BasicAuthPlugin\",\n" + + " \"credentials\":{\"solr\":\"IV0EHq1OnNrj6gvRCwvFwTrZ1+z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c=\"}, \n" + + " \"realm\":\"My Solr users\", \n" + + " \"forwardCredentials\": false \n" + + "},\n" + + "\"authorization\":{\n" + + " \"class\":\"solr.RuleBasedAuthorizationPlugin\",\n" + + " \"permissions\":[{\"name\":\"security-edit\",\n" + + " \"role\":\"admin\"}],\n" + + " \"user-role\":{\"solr\":\"admin\"}\n" + + "}}"; + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + systemSetPropertySolrDisableUrlAllowList("true"); + // leader with Basic auth enabled via security.json + leader = + new ReplicationTestHelper.SolrInstance( + createTempDir("solr-instance").toFile(), "leader", null); + leader.setUp(); + // Configuring basic auth for Leader + Path solrLeaderHome = Path.of(leader.getHomeDir()); + Files.write( + solrLeaderHome.resolve("security.json"), securityJson.getBytes(StandardCharsets.UTF_8)); + leaderJetty = ReplicationTestHelper.createAndStartJetty(leader); + leaderClient = + ReplicationTestHelper.createNewSolrClient( + buildUrl(leaderJetty.getLocalPort()), DEFAULT_TEST_CORENAME); + + // follower with no basic auth credentials for leader configured. + follower = + new ReplicationTestHelper.SolrInstance( + createTempDir("solr-instance").toFile(), "follower", leaderJetty.getLocalPort()); + follower.setUp(); + followerJetty = createAndStartJetty(follower); + followerClient = + ReplicationTestHelper.createNewSolrClient( + buildUrl(followerJetty.getLocalPort()), DEFAULT_TEST_CORENAME); + + // follower with basic auth credentials for leader configured in solrconfig.xml. + followerWithAuth = + new ReplicationTestHelper.SolrInstance( + createTempDir("solr-instance").toFile(), "follower-auth", leaderJetty.getLocalPort()); Review Comment: The second arg "follower-auth" is a partial file name to "solrconfig-follower-auth.xml"; are you sure this works? I didn't notice this approach elsewhere; I've seen a whole file name. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org For additional commands, e-mail: issues-h...@solr.apache.org