Class SolrCloudAuthTestCase

java.lang.Object
org.junit.Assert
org.apache.lucene.tests.util.LuceneTestCase

public class SolrCloudAuthTestCase extends SolrCloudTestCase
Base test class for cloud tests wanting to track authentication metrics. The assertions provided by this base class require a *minimum* count, not exact count from metrics. Warning: Make sure that your test case does not break when beasting.
  • Field Details

    • NOT_NULL_PREDICATE

      public static final Predicate NOT_NULL_PREDICATE
  • Constructor Details

    • SolrCloudAuthTestCase

      public SolrCloudAuthTestCase()
  • Method Details

    • enableMetrics

      public static void enableMetrics()
    • disableMetrics

      public static void disableMetrics()
    • assertPkiAuthMetricsMinimums

      protected void assertPkiAuthMetricsMinimums(int requests, int authenticated, int passThrough, int failWrongCredentials, int failMissingCredentials, int errors) throws InterruptedException
      Used to check metric counts for PKI auth
      Throws:
      InterruptedException
    • assertAuthMetricsMinimums

      protected void assertAuthMetricsMinimums(Class<? extends org.apache.solr.security.AuthenticationPlugin> authPluginClass, int requests, int authenticated, int passThrough, int failWrongCredentials, int failMissingCredentials, int errors) throws InterruptedException
      Used to check metric counts for the AuthPlugin in use (except PKI)

      TODO: many of these params have to be under specified - this should wait a bit to see the desired params and timeout

      Throws:
      InterruptedException
    • verifySecurityStatus

      public static void verifySecurityStatus(org.apache.http.client.HttpClient cl, String url, String objPath, Object expected, int count) throws Exception
      Throws:
      Exception
    • verifySecurityStatus

      public static void verifySecurityStatus(org.apache.http.client.HttpClient cl, String url, String objPath, Object expected, int count, String user, String pwd) throws Exception
      Throws:
      Exception
    • verifySecurityStatus

      protected static void verifySecurityStatus(org.apache.http.client.HttpClient cl, String url, String objPath, Object expected, int count, String authHeader) throws IOException, InterruptedException
      Throws:
      IOException
      InterruptedException
    • makeBasicAuthHeader

      protected static String makeBasicAuthHeader(String user, String pwd)
    • setAuthorizationHeader

      public static void setAuthorizationHeader(org.apache.http.message.AbstractHttpMessage httpMsg, String headerString)
    • getAuthPluginsInUseForCluster

      public static Map<String,Object> getAuthPluginsInUseForCluster(String url)
      This helper method can be used by tests to monitor the current state of either "authentication" or "authorization" plugins in use each node of the current cluster.

      This can be useful in a TimeOut.waitFor(java.lang.String, java.util.function.Supplier<java.lang.Boolean>) loop to monitor a cluster and "wait for" A change in security settings to affect all nodes by comparing the objects in the current Map with the one in use prior to executing some test command. (providing a work around for the security user experienence limitations identified in SOLR-13464 )

      Parameters:
      url - A REST url (or any arbitrary String) ending in "authentication" or "authorization" used to specify the type of plugins to introspect
      Returns:
      A Map from nodeName to auth plugin