Skip to content

Commit

Permalink
Adds integration tests for non-default RAC plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Dec 20, 2024
1 parent eee5ce1 commit 77c56be
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.accesscontrol.resources;

import org.opensearch.accesscontrol.resources.testplugins.TestRACPlugin;
import org.opensearch.accesscontrol.resources.testplugins.TestResourcePlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.ResourceAccessControlPlugin;
import org.opensearch.test.OpenSearchIntegTestCase;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;

import java.util.Collection;
import java.util.List;

public class NonDefaultResourceAccessControlPluginIT extends OpenSearchIntegTestCase {
@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return List.of(TestResourcePlugin.class, TestRACPlugin.class);
}

public void testSampleResourcePluginCallsTestRACPluginToManageResourceAccess() {
ResourceAccessControlPlugin racPlugin = TestResourcePlugin.GuiceHolder.getResourceService().getResourceAccessControlPlugin();
MatcherAssert.assertThat(racPlugin.getClass(), Matchers.is(TestRACPlugin.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.opensearch.accesscontrol.resources.ResourceSharing;
import org.opensearch.accesscontrol.resources.ShareWith;
import org.opensearch.accesscontrol.resources.SharedWithScope;
import org.opensearch.accesscontrol.resources.testplugins.TestResourcePlugin;
import org.opensearch.client.Client;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.plugins.Plugin;
Expand All @@ -26,7 +27,7 @@
import java.util.Map;
import java.util.Set;

import static org.opensearch.accesscontrol.resources.fallback.TestResourcePlugin.SAMPLE_TEST_INDEX;
import static org.opensearch.accesscontrol.resources.testplugins.TestResourcePlugin.SAMPLE_TEST_INDEX;
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasProperty;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* 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.accesscontrol.resources.testplugins;

import org.opensearch.plugins.Plugin;
import org.opensearch.plugins.ResourceAccessControlPlugin;

public class TestRACPlugin extends Plugin implements ResourceAccessControlPlugin {}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.accesscontrol.resources.fallback;
package org.opensearch.accesscontrol.resources.testplugins;

import org.opensearch.accesscontrol.resources.ResourceService;
import org.opensearch.common.inject.Inject;
Expand Down

0 comments on commit 77c56be

Please sign in to comment.