lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject [lucene-solr] branch master updated: Revert "SOLR-15073: Fix ClassCastException in SystemInfoHandler.getSecurityInfo (#2210)"
Date Fri, 22 Jan 2021 17:56:37 GMT
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 64d445b  Revert "SOLR-15073: Fix ClassCastException in SystemInfoHandler.getSecurityInfo
(#2210)"
64d445b is described below

commit 64d445bbaab2a81dc57cde0394681970709b2251
Author: Christine Poerschke <cpoerschke@apache.org>
AuthorDate: Fri Jan 22 17:48:25 2021 +0000

    Revert "SOLR-15073: Fix ClassCastException in SystemInfoHandler.getSecurityInfo (#2210)"
    
    This reverts commit fb88b0268aa0c7f14d77ae425b4851a8bedd2327.
    
    Resolved Conflicts:
    	solr/CHANGES.txt
---
 solr/CHANGES.txt                                   |  2 -
 .../solr/handler/admin/SystemInfoHandler.java      | 10 +--
 .../solr/handler/admin/SystemInfoHandlerTest.java  | 83 ----------------------
 3 files changed, 1 insertion(+), 94 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 5e8a254..b367c08 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -364,8 +364,6 @@ Bug Fixes
 
 * SOLR-15070: Suggester requests made with SolrJ can now use XMLResponseParser (Jason Gerlowski)
 
-* SOLR-15073: Fix ClassCastException in SystemInfoHandler.getSecurityInfo. (Nikolay Ivanov,
Christine Poerschke)
-
 * SOLR-15071: Fix ArrayIndexOutOfBoundsException in contrib/ltr SolrFeatureScorer.
   (Florin Babes, Ovidiu Mihalcea, David Smiley, Christine Poerschke)
 
diff --git a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
index 3cf8469..eb11b66 100644
--- a/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/admin/SystemInfoHandler.java
@@ -324,14 +324,6 @@ public class SystemInfoHandler extends RequestHandlerBase
    */
   public SimpleOrderedMap<Object> getSecurityInfo(SolrQueryRequest req)
   {
-    return getSecurityInfo(cc, req);
-  }
-
-  /**
-   * Get Security Info
-   */
-  public static SimpleOrderedMap<Object> getSecurityInfo(CoreContainer cc, SolrQueryRequest
req)
-  {
     SimpleOrderedMap<Object> info = new SimpleOrderedMap<>();
 
     if (cc != null) {
@@ -352,7 +344,7 @@ public class SystemInfoHandler extends RequestHandlerBase
       // Mapped roles for this principal
       @SuppressWarnings("resource")
       AuthorizationPlugin auth = cc==null? null: cc.getAuthorizationPlugin();
-      if (auth instanceof RuleBasedAuthorizationPluginBase) {
+      if (auth != null) {
         RuleBasedAuthorizationPluginBase rbap = (RuleBasedAuthorizationPluginBase) auth;
         Set<String> roles = rbap.getUserRoles(req.getUserPrincipal());
         info.add("roles", roles);
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/SystemInfoHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/SystemInfoHandlerTest.java
index 035e1c2..f012699 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/SystemInfoHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/SystemInfoHandlerTest.java
@@ -18,27 +18,12 @@ package org.apache.solr.handler.admin;
 
 import java.lang.management.ManagementFactory;
 import java.lang.management.OperatingSystemMXBean;
-import java.security.Principal;
 import java.util.Arrays;
-import java.util.Collections;
 
 import com.codahale.metrics.Gauge;
 import org.apache.solr.SolrTestCase;
-import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.util.SimpleOrderedMap;
-import org.apache.solr.core.CoreContainer;
-import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.request.SolrQueryRequestBase;
-import org.apache.solr.security.AuthenticationPlugin;
-import org.apache.solr.security.AuthorizationPlugin;
-import org.apache.solr.security.JWTPrincipal;
-import org.apache.solr.security.MockAuthenticationPlugin;
-import org.apache.solr.security.MockAuthorizationPlugin;
-import org.apache.solr.security.RuleBasedAuthorizationPlugin;
-import org.apache.solr.security.RuleBasedAuthorizationPluginBase;
 import org.apache.solr.util.stats.MetricUtils;
-import org.mockito.ArgumentMatchers;
-import org.mockito.Mockito;
 
 
 public class SystemInfoHandlerTest extends SolrTestCase {
@@ -65,72 +50,4 @@ public class SystemInfoHandlerTest extends SolrTestCase {
     }
   }
 
-  private static final String userName = "foobar";
-
-  public void testGetSecurityInfoAuthorizationPlugin() throws Exception {
-    final AuthorizationPlugin authorizationPlugin = new MockAuthorizationPlugin();
-    doTestGetSecurityInfo(authorizationPlugin);
-  }
-
-  public void testGetSecurityInfoRuleBasedAuthorizationPlugin() throws Exception {
-    SolrTestCaseJ4.assumeWorkingMockito();
-    final RuleBasedAuthorizationPluginBase ruleBasedAuthorizationPlugin = Mockito.mock(RuleBasedAuthorizationPlugin.class);
-    Mockito.doReturn(Collections.EMPTY_SET).when(ruleBasedAuthorizationPlugin).getUserRoles(ArgumentMatchers.any(Principal.class));
-    doTestGetSecurityInfo(ruleBasedAuthorizationPlugin);
-  }
-
-  private static void doTestGetSecurityInfo(AuthorizationPlugin authorizationPlugin) throws
Exception {
-    final AuthenticationPlugin authenticationPlugin = new MockAuthenticationPlugin() {
-      @Override
-      public String getName() {
-        return "mock authentication plugin name";
-      }
-    };
-    doTestGetSecurityInfo(null, null);
-    doTestGetSecurityInfo(authenticationPlugin, null);
-    doTestGetSecurityInfo(null, authorizationPlugin);
-    doTestGetSecurityInfo(authenticationPlugin, authorizationPlugin);
-  }
-
-  private static void doTestGetSecurityInfo(AuthenticationPlugin authenticationPlugin, AuthorizationPlugin
authorizationPlugin) throws Exception {
-
-    SolrTestCaseJ4.assumeWorkingMockito();
-
-    final CoreContainer cc = Mockito.mock(CoreContainer.class);
-    {
-      Mockito.doReturn(authenticationPlugin).when(cc).getAuthenticationPlugin();
-      Mockito.doReturn(authorizationPlugin).when(cc).getAuthorizationPlugin();
-    }
-
-    final SolrQueryRequest req = Mockito.mock(SolrQueryRequestBase.class);
-    {
-      final Principal principal = Mockito.mock(JWTPrincipal.class);
-      Mockito.doReturn(userName).when(principal).getName();
-      Mockito.doReturn(principal).when(req).getUserPrincipal();
-    }
-
-    final SimpleOrderedMap<Object> si = SystemInfoHandler.getSecurityInfo(cc, req);
-
-    if (authenticationPlugin != null) {
-      assertEquals(authenticationPlugin.getName(), si.remove("authenticationPlugin"));
-    } else {
-      assertNull(si.remove("authenticationPlugin"));
-    }
-
-    if (authorizationPlugin != null) {
-      assertEquals(authorizationPlugin.getClass().getName(), si.remove("authorizationPlugin"));
-      if (authorizationPlugin instanceof RuleBasedAuthorizationPluginBase) {
-        assertNotNull(si.remove("roles"));
-      } else {
-        assertNull(si.remove("roles"));
-      }
-    } else {
-      assertNull(si.remove("authorizationPlugin"));
-    }
-
-    assertEquals(userName, si.remove("username"));
-
-    assertEquals("Unexpected additional info: " + si, 0, si.size());
-  }
-
 }


Mime
View raw message