Class SolrCloudAuthTestCase


  • 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 Detail

      • NOT_NULL_PREDICATE

        public static final Predicate NOT_NULL_PREDICATE
    • Constructor Detail

      • SolrCloudAuthTestCase

        public SolrCloudAuthTestCase()
    • Method Detail

      • 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​(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
      • assertAuditMetricsMinimums

        protected void assertAuditMetricsMinimums​(MiniSolrCloudCluster cluster,
                                                  String className,
                                                  int count,
                                                  int errors)
                                           throws InterruptedException
        Common test method to be able to check audit metrics
        Parameters:
        className - the class name to be used for composing prefix, e.g. "SECURITY./auditlogging/SolrLogAuditLoggerPlugin"
        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
      • 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