mirror of https://github.com/apache/lucene.git
SOLR-12514: FIxed the test and another bug
This commit is contained in:
parent
73797f60ad
commit
000d0c1364
|
@ -16,8 +16,10 @@
|
|||
*/
|
||||
package org.apache.solr.request;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.Closeable;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.security.Principal;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
@ -40,6 +42,7 @@ public class SolrRequestInfo {
|
|||
protected SolrQueryRequest req;
|
||||
protected SolrQueryResponse rsp;
|
||||
protected Date now;
|
||||
protected HttpServletRequest httpRequest;
|
||||
protected TimeZone tz;
|
||||
protected ResponseBuilder rb;
|
||||
protected List<Closeable> closeHooks;
|
||||
|
@ -83,6 +86,17 @@ public class SolrRequestInfo {
|
|||
this.req = req;
|
||||
this.rsp = rsp;
|
||||
}
|
||||
public SolrRequestInfo(HttpServletRequest httpReq, SolrQueryResponse rsp) {
|
||||
this.httpRequest = httpReq;
|
||||
this.rsp = rsp;
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal() {
|
||||
if (req != null) return req.getUserPrincipal();
|
||||
if (httpRequest != null) return httpRequest.getUserPrincipal();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public Date getNOW() {
|
||||
if (now != null) return now;
|
||||
|
|
|
@ -280,7 +280,7 @@ public class PKIAuthenticationPlugin extends AuthenticationPlugin implements Htt
|
|||
SolrRequestInfo reqInfo = getRequestInfo();
|
||||
String usr;
|
||||
if (reqInfo != null) {
|
||||
Principal principal = reqInfo.getReq().getUserPrincipal();
|
||||
Principal principal = reqInfo.getUserPrincipal();
|
||||
if (principal == null) {
|
||||
log.debug("principal is null");
|
||||
//this had a request but not authenticated
|
||||
|
|
|
@ -496,7 +496,7 @@ public class HttpSolrCall {
|
|||
handleAdminRequest();
|
||||
return RETURN;
|
||||
case REMOTEQUERY:
|
||||
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(solrReq, new SolrQueryResponse()));
|
||||
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, new SolrQueryResponse()));
|
||||
remoteQuery(coreUrl + path, resp);
|
||||
return RETURN;
|
||||
case PROCESS:
|
||||
|
|
|
@ -312,7 +312,6 @@ public class TestSolrCloudWithSecureImpersonation extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
@Test
|
||||
@AwaitsFix(bugUrl = "https://issues.apache.org/jira/browse/SOLR-13098")
|
||||
public void testForwarding() throws Exception {
|
||||
String collectionName = "forwardingCollection";
|
||||
miniCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1");
|
||||
|
|
|
@ -244,12 +244,11 @@ public class BasicAuthIntegrationTest extends SolrCloudAuthTestCase {
|
|||
//Make a request to that jetty and it should fail
|
||||
JettySolrRunner aNewJetty = cluster.startJettySolrRunner();
|
||||
SolrClient aNewClient = aNewJetty.newClient();
|
||||
UpdateRequest delQuery = null;
|
||||
delQuery = new UpdateRequest().deleteByQuery("*:*");
|
||||
delQuery.setBasicAuthCredentials("harry","HarryIsUberCool");
|
||||
delQuery.process(aNewClient, COLLECTION);//this should succeed
|
||||
try {
|
||||
UpdateRequest delQuery = null;
|
||||
delQuery = new UpdateRequest().deleteByQuery("*:*");
|
||||
delQuery.setBasicAuthCredentials("harry","HarryIsUberCool");
|
||||
delQuery.process(aNewClient, COLLECTION);//this should succeed
|
||||
|
||||
delQuery = new UpdateRequest().deleteByQuery("*:*");
|
||||
delQuery.process(aNewClient, COLLECTION);
|
||||
fail("This should not have succeeded without credentials");
|
||||
|
|
|
@ -127,7 +127,7 @@ public class HttpParamDelegationTokenPlugin extends KerberosPlugin {
|
|||
SolrRequestInfo reqInfo = SolrRequestInfo.getRequestInfo();
|
||||
String usr;
|
||||
if (reqInfo != null) {
|
||||
Principal principal = reqInfo.getReq().getUserPrincipal();
|
||||
Principal principal = reqInfo.getUserPrincipal();
|
||||
if (principal == null) {
|
||||
//this had a request but not authenticated
|
||||
//so we don't not need to set a principal
|
||||
|
|
Loading…
Reference in New Issue