Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor entitlement IT test to allow dynamic policy #120443

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions libs/entitlement/qa/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'

dependencies {
javaRestTestImplementation project(':libs:entitlement:qa:common')
clusterModules project(':libs:entitlement:qa:entitlement-allowed')
clusterModules project(':libs:entitlement:qa:entitlement-allowed-nonmodular')
clusterPlugins project(':libs:entitlement:qa:entitlement-denied')
clusterPlugins project(':libs:entitlement:qa:entitlement-denied-nonmodular')
javaRestTestImplementation project(':libs:entitlement:qa:test-plugin')
clusterModules project(':libs:entitlement:qa:test-plugin')
}
24 changes: 0 additions & 24 deletions libs/entitlement/qa/entitlement-allowed-nonmodular/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions libs/entitlement/qa/entitlement-allowed/build.gradle

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions libs/entitlement/qa/entitlement-denied-nonmodular/build.gradle

This file was deleted.

This file was deleted.

25 changes: 0 additions & 25 deletions libs/entitlement/qa/entitlement-denied/build.gradle

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,34 @@

import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.entitlement.qa.common.RestEntitlementsCheckAction;
import org.elasticsearch.entitlement.qa.test.RestEntitlementsCheckAction;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.junit.ClassRule;

import java.io.IOException;
import java.util.stream.Stream;

import static org.elasticsearch.entitlement.qa.EntitlementsUtil.ALLOWED_ENTITLEMENTS;
import static org.hamcrest.Matchers.equalTo;

public class EntitlementsAllowedIT extends ESRestTestCase {

@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.module("entitlement-allowed")
.module("entitlement-allowed-nonmodular")
.module("test-plugin", spec -> EntitlementsUtil.setupEntitlements(spec, true, ALLOWED_ENTITLEMENTS))
.systemProperty("es.entitlements.enabled", "true")
.setting("xpack.security.enabled", "false")
.build();

private final String pathPrefix;
private final String actionName;

public EntitlementsAllowedIT(@Name("pathPrefix") String pathPrefix, @Name("actionName") String actionName) {
this.pathPrefix = pathPrefix;
public EntitlementsAllowedIT(@Name("actionName") String actionName) {
this.actionName = actionName;
}

@ParametersFactory
public static Iterable<Object[]> data() {
return Stream.of("allowed", "allowed_nonmodular")
.flatMap(
path -> RestEntitlementsCheckAction.getCheckActionsAllowedInPlugins().stream().map(action -> new Object[] { path, action })
)
.toList();
return RestEntitlementsCheckAction.getCheckActionsAllowedInPlugins().stream().map(action -> new Object[] { action }).toList();
}

@Override
Expand All @@ -57,8 +50,8 @@ protected String getTestRestCluster() {
}

public void testCheckActionWithPolicyPass() throws IOException {
logger.info("Executing Entitlement test [{}] for [{}]", pathPrefix, actionName);
var request = new Request("GET", "/_entitlement/" + pathPrefix + "/_check");
logger.info("Executing Entitlement test for [{}]", actionName);
var request = new Request("GET", "/_entitlement_check");
request.addParameter("action", actionName);
Response result = client().performRequest(request);
assertThat(result.getStatusLine().getStatusCode(), equalTo(200));
Expand Down
Loading