diff --git a/src/integrationTest/java/org/opensearch/test/SecurityRolesTests.java b/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java similarity index 98% rename from src/integrationTest/java/org/opensearch/test/SecurityRolesTests.java rename to src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java index 22742aea0c..51323bfb25 100644 --- a/src/integrationTest/java/org/opensearch/test/SecurityRolesTests.java +++ b/src/integrationTest/java/org/opensearch/security/SecurityRolesTests.java @@ -24,7 +24,7 @@ * GitHub history for details. */ -package org.opensearch.test; +package org.opensearch.security; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.http.HttpStatus; diff --git a/src/integrationTest/java/org/opensearch/test/PrivilegesEvaluatorTest.java b/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java similarity index 98% rename from src/integrationTest/java/org/opensearch/test/PrivilegesEvaluatorTest.java rename to src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java index 9bd469cabb..c320028b67 100644 --- a/src/integrationTest/java/org/opensearch/test/PrivilegesEvaluatorTest.java +++ b/src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java @@ -9,7 +9,7 @@ * GitHub history for details. */ -package org.opensearch.test; +package org.opensearch.security.privileges; import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; import org.apache.http.HttpStatus; diff --git a/src/integrationTest/java/org/opensearch/test/GenericIntegrationTest.java b/src/integrationTest/java/org/opensearch/test/GenericIntegrationTest.java deleted file mode 100644 index 05346623e9..0000000000 --- a/src/integrationTest/java/org/opensearch/test/GenericIntegrationTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - * - * Modifications Copyright OpenSearch Contributors. See - * GitHub history for details. - */ - -package org.opensearch.test; - -import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import org.apache.http.HttpStatus; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.opensearch.test.framework.TestIndex; -import org.opensearch.test.framework.TestSecurityConfig; -import org.opensearch.test.framework.TestSecurityConfig.Role; -import org.opensearch.test.framework.cluster.ClusterManager; -import org.opensearch.test.framework.cluster.LocalCluster; -import org.opensearch.test.framework.cluster.TestRestClient; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.opensearch.test.framework.TestSecurityConfig.AuthcDomain.AUTHC_HTTPBASIC_INTERNAL; -import static org.opensearch.test.framework.TestSecurityConfig.User.USER_ADMIN; - -/** - * WIP - * Generic test class that demonstrates how to use the test framework to - * set up a test cluster with users, roles, indices and data, and how to - * implement tests. One main goal here is to make tests self-contained. - */ -@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class) -@ThreadLeakScope(ThreadLeakScope.Scope.NONE) -public class GenericIntegrationTest { - - // define indices used in this test - private final static TestIndex INDEX_A = TestIndex.name("index-a").build(); - private final static TestIndex INDEX_B = TestIndex.name("index-b").build(); - - private final static TestSecurityConfig.User INDEX_A_USER = new TestSecurityConfig.User("index_a_user") - .roles(new Role("index_a_role").indexPermissions("*").on(INDEX_A).clusterPermissions("*")); - - - // build our test cluster as a ClassRule - @ClassRule - public static LocalCluster cluster = new LocalCluster.Builder().clusterManager(ClusterManager.THREE_MASTERS) - .authc(AUTHC_HTTPBASIC_INTERNAL) - .users(USER_ADMIN, INDEX_A_USER) - .indices(INDEX_A, INDEX_B).build(); - - @Test - public void testAdminUserHasAccessToAllIndices() throws Exception { - try (TestRestClient client = cluster.getRestClient(USER_ADMIN)) { - assertThat(client.get("*/_search?pretty").getStatusCode(), equalTo(HttpStatus.SC_OK)); - } - } - - @Test - public void testIndexAUserHasOnlyAccessToIndexA() throws Exception { - try (TestRestClient client = cluster.getRestClient(INDEX_A_USER)) { - assertThat(client.get("index-a/_search?pretty").getStatusCode(), equalTo(HttpStatus.SC_OK)); - // demo: work with JSON response body and check values - assertThat(client.get("index-a/_search?pretty").getIntFromJsonBody("/_source/hits/value"), equalTo(0)); - assertThat(client.get("index-b/_search?pretty").getStatusCode(), equalTo(HttpStatus.SC_FORBIDDEN)); - } - } - -} diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java index 2c788598d9..727dd3fbec 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/ContextHeaderDecoratorClient.java @@ -1,3 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + */ package org.opensearch.test.framework.cluster; import java.util.Collections; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/MinimumSecuritySettingsSupplierFactory.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/MinimumSecuritySettingsSupplierFactory.java index f31eb2b440..56bd00a479 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/MinimumSecuritySettingsSupplierFactory.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/MinimumSecuritySettingsSupplierFactory.java @@ -28,8 +28,6 @@ package org.opensearch.test.framework.cluster; -import java.io.IOException; - import org.opensearch.common.settings.Settings; import org.opensearch.test.framework.certificate.TestCertificates; diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/NodeType.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/NodeType.java index 0d7e39c40c..6dc35c81c2 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/NodeType.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/NodeType.java @@ -1,3 +1,13 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ package org.opensearch.test.framework.cluster; enum NodeType { diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/RestClientException.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/RestClientException.java index 78cc158863..55cd0c7f4c 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/RestClientException.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/RestClientException.java @@ -1,3 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + */ package org.opensearch.test.framework.cluster; class RestClientException extends RuntimeException { diff --git a/src/integrationTest/java/org/opensearch/test/framework/cluster/StartStage.java b/src/integrationTest/java/org/opensearch/test/framework/cluster/StartStage.java index 2a0ee0020f..f10077735e 100644 --- a/src/integrationTest/java/org/opensearch/test/framework/cluster/StartStage.java +++ b/src/integrationTest/java/org/opensearch/test/framework/cluster/StartStage.java @@ -1,3 +1,12 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + * + */ package org.opensearch.test.framework.cluster; enum StartStage {