Skip to content

Commit

Permalink
Applied spotless rules
Browse files Browse the repository at this point in the history
Signed-Off-By: Nils Bandener <[email protected]>
  • Loading branch information
nibix authored and lukasz-soszynski-eliatra committed Sep 13, 2022
1 parent 0757c08 commit 08d6500
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@
import org.opensearch.test.framework.cluster.OpenSearchClientProvider.UserCredentialsHolder;

/**
* This class allows the declarative specification of the security configuration; in particular:
*
* - config.yml
* - internal_users.yml
* - roles.yml
* - roles_mapping.yml
*
* The class does the whole round-trip, i.e., the configuration is serialized to YAML/JSON and then written to
* the configuration index of the security plugin.
*/
* This class allows the declarative specification of the security configuration; in particular:
*
* - config.yml
* - internal_users.yml
* - roles.yml
* - roles_mapping.yml
*
* The class does the whole round-trip, i.e., the configuration is serialized to YAML/JSON and then written to
* the configuration index of the security plugin.
*/
public class TestSecurityConfig {

private static final Logger log = LogManager.getLogger(TestSecurityConfig.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@
import org.opensearch.test.framework.certificate.TestCertificates;

/**
* This class allows to you start and manage a local cluster in an integration test. In contrast to the
* OpenSearchIntegTestCase class, this class can be used in a composite way and allows the specification
* of the security plugin configuration.
*
* This class can be both used as a JUnit @ClassRule (preferred) or in a try-with-resources block. The latter way should
* be only sparingly used, as starting a cluster is not a particularly fast operation.
*/
* This class allows to you start and manage a local cluster in an integration test. In contrast to the
* OpenSearchIntegTestCase class, this class can be used in a composite way and allows the specification
* of the security plugin configuration.
*
* This class can be both used as a JUnit @ClassRule (preferred) or in a try-with-resources block. The latter way should
* be only sparingly used, as starting a cluster is not a particularly fast operation.
*/
public class LocalCluster extends ExternalResource implements AutoCloseable, OpenSearchClientProvider {

private static final Logger log = LogManager.getLogger(LocalCluster.class);
Expand Down Expand Up @@ -153,24 +153,24 @@ public InetSocketAddress getTransportAddress() {
}

/**
* Returns a Client object that performs cluster-internal requests. As these requests are regard as cluster-internal,
* no authentication is performed and no user-information is attached to these requests. Thus, this client should
* be only used for preparing test environments, but not as a test subject.
*/
* Returns a Client object that performs cluster-internal requests. As these requests are regard as cluster-internal,
* no authentication is performed and no user-information is attached to these requests. Thus, this client should
* be only used for preparing test environments, but not as a test subject.
*/
public Client getInternalNodeClient() {
return localOpenSearchCluster.clientNode().getInternalNodeClient();
}

/**
* Returns a random node of this cluster.
*/
* Returns a random node of this cluster.
*/
public PluginAwareNode node() {
return this.localOpenSearchCluster.clusterManagerNode().esNode();
}

/**
* Returns all nodes of this cluster.
*/
* Returns all nodes of this cluster.
*/
public List<LocalOpenSearchCluster.Node> nodes() {
return this.localOpenSearchCluster.getNodes();
}
Expand Down Expand Up @@ -248,18 +248,18 @@ public Builder clusterManager(ClusterManager clusterManager) {
}

/**
* Starts a cluster with only one node and thus saves some resources during startup. This shall be only used
* for tests where the node interactions are not relevant to the test. An example for this would be
* authentication tests, as authentication is always done on the directly connected node.
*/
* Starts a cluster with only one node and thus saves some resources during startup. This shall be only used
* for tests where the node interactions are not relevant to the test. An example for this would be
* authentication tests, as authentication is always done on the directly connected node.
*/
public Builder singleNode() {
this.clusterManager = ClusterManager.SINGLENODE;
return this;
}

/**
* Specifies the configuration of the security plugin that shall be used by this cluster.
*/
* Specifies the configuration of the security plugin that shall be used by this cluster.
*/
public Builder config(TestSecurityConfig testSecurityConfig) {
this.testSecurityConfig = testSecurityConfig;
return this;
Expand All @@ -279,18 +279,18 @@ public Builder nodeSettings(Map<String, Object> settings) {
}

/**
* Adds additional plugins to the cluster
*/
* Adds additional plugins to the cluster
*/
public Builder plugin(Class<? extends Plugin> plugin) {
this.plugins.add(plugin);

return this;
}

/**
* Specifies a remote cluster and its name. The remote cluster can be then used in Cross Cluster Search
* operations with the specified name.
*/
* Specifies a remote cluster and its name. The remote cluster can be then used in Cross Cluster Search
* operations with the specified name.
*/
public Builder remote(String name, LocalCluster anotherCluster) {
remoteClusters.put(name, anotherCluster);

Expand All @@ -300,8 +300,8 @@ public Builder remote(String name, LocalCluster anotherCluster) {
}

/**
* Specifies test indices that shall be created upon startup of the cluster.
*/
* Specifies test indices that shall be created upon startup of the cluster.
*/
public Builder indices(TestIndex... indices) {
this.testIndices.addAll(Arrays.asList(indices));
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@
import static org.opensearch.test.framework.cluster.PortAllocator.TCP;

/**
* Encapsulates all the logic to start a local OpenSearch cluster - without any configuration of the security plugin.
*
* The security plugin configuration is the job of LocalCluster, which uses this class under the hood. Thus, test code
* for the security plugin should always use LocalCluster.
*/
* Encapsulates all the logic to start a local OpenSearch cluster - without any configuration of the security plugin.
*
* The security plugin configuration is the job of LocalCluster, which uses this class under the hood. Thus, test code
* for the security plugin should always use LocalCluster.
*/
public class LocalOpenSearchCluster {

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
import org.opensearch.test.framework.certificate.TestCertificates;

/**
* OpenSearchClientProvider provides methods to get a REST client for an underlying cluster or node.
*
* This interface is implemented by both LocalCluster and LocalOpenSearchCluster.Node. Thus, it is possible to get a
* REST client for a whole cluster (without choosing the node it is operating on) or to get a REST client for a specific
* node.
*/
* OpenSearchClientProvider provides methods to get a REST client for an underlying cluster or node.
*
* This interface is implemented by both LocalCluster and LocalOpenSearchCluster.Node. Thus, it is possible to get a
* REST client for a whole cluster (without choosing the node it is operating on) or to get a REST client for a specific
* node.
*/
public interface OpenSearchClientProvider {

String getClusterName();
Expand All @@ -72,23 +72,23 @@ default URI getHttpAddressAsURI() {
}

/**
* Returns a REST client that sends requests with basic authentication for the specified User object. Optionally,
* additional HTTP headers can be specified which will be sent with each request.
*
* This method should be usually preferred. The other getRestClient() methods shall be only used for specific
* situations.
*/
* Returns a REST client that sends requests with basic authentication for the specified User object. Optionally,
* additional HTTP headers can be specified which will be sent with each request.
*
* This method should be usually preferred. The other getRestClient() methods shall be only used for specific
* situations.
*/
default TestRestClient getRestClient(UserCredentialsHolder user, Header... headers) {
return getRestClient(user.getName(), user.getPassword(), headers);
}

/**
* Returns a REST client that sends requests with basic authentication for the specified user name and password. Optionally,
* additional HTTP headers can be specified which will be sent with each request.
*
* Normally, you should use the method with the User object argument instead. Use this only if you need more
* control over username and password - for example, when you want to send a wrong password.
*/
* Returns a REST client that sends requests with basic authentication for the specified user name and password. Optionally,
* additional HTTP headers can be specified which will be sent with each request.
*
* Normally, you should use the method with the User object argument instead. Use this only if you need more
* control over username and password - for example, when you want to send a wrong password.
*/
default TestRestClient getRestClient(String user, String password, Header... headers) {
BasicHeader basicAuthHeader = getBasicAuthHeader(user, password);
if (headers != null && headers.length > 0) {
Expand All @@ -99,9 +99,9 @@ default TestRestClient getRestClient(String user, String password, Header... hea
}

/**
* Returns a REST client. You can specify additional HTTP headers that will be sent with each request. Use this
* method to test non-basic authentication, such as JWT bearer authentication.
*/
* Returns a REST client. You can specify additional HTTP headers that will be sent with each request. Use this
* method to test non-basic authentication, such as JWT bearer authentication.
*/
default TestRestClient getRestClient(Header... headers) {
return getRestClient(Arrays.asList(headers));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
import org.opensearch.test.framework.cluster.SocketUtils.SocketType;

/**
* Helper class that allows you to allocate ports. This helps with avoiding port conflicts when running tests.
*
* NOTE: This class shall be only considered as a heuristic; ports allocated by this class are just likely to be unused;
* however, there is no guarantee that these will be unused. Thus, you still need to be prepared for port-conflicts
* and retry the procedure in such a case. If you notice a port conflict, you can use the method reserve() to mark the
* port as used.
*/
* Helper class that allows you to allocate ports. This helps with avoiding port conflicts when running tests.
*
* NOTE: This class shall be only considered as a heuristic; ports allocated by this class are just likely to be unused;
* however, there is no guarantee that these will be unused. Thus, you still need to be prepared for port-conflicts
* and retry the procedure in such a case. If you notice a port conflict, you can use the method reserve() to mark the
* port as used.
*/
public class PortAllocator {

public static final PortAllocator TCP = new PortAllocator(SocketType.TCP, Duration.ofSeconds(100));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
import org.opensearch.security.DefaultObjectMapper;

/**
* A OpenSearch REST client, which is tailored towards use in integration tests. Instances of this class can be
* obtained via the OpenSearchClientProvider interface, which is implemented by LocalCluster and Node.
*
* Usually, an instance of this class sends constant authentication headers which are defined when obtaining the
* instance from OpenSearchClientProvider.
*/
* A OpenSearch REST client, which is tailored towards use in integration tests. Instances of this class can be
* obtained via the OpenSearchClientProvider interface, which is implemented by LocalCluster and Node.
*
* Usually, an instance of this class sends constant authentication headers which are defined when obtaining the
* instance from OpenSearchClientProvider.
*/
public class TestRestClient implements AutoCloseable {

private static final Logger log = LogManager.getLogger(TestRestClient.class);
Expand Down

0 comments on commit 08d6500

Please sign in to comment.