required changes after merging in upstream branch
This commit is contained in:
parent
1951cdf1cb
commit
0353eb9291
|
@ -77,6 +77,7 @@ public class ClusterPrivilegeResolver {
|
||||||
Collections.unmodifiableSet(Sets.newHashSet("cluster:admin/slm/*", StartILMAction.NAME, StopILMAction.NAME, GetStatusAction.NAME));
|
Collections.unmodifiableSet(Sets.newHashSet("cluster:admin/slm/*", StartILMAction.NAME, StopILMAction.NAME, GetStatusAction.NAME));
|
||||||
private static final Set<String> READ_SLM_PATTERN = Collections.unmodifiableSet(Sets.newHashSet(GetSnapshotLifecycleAction.NAME,
|
private static final Set<String> READ_SLM_PATTERN = Collections.unmodifiableSet(Sets.newHashSet(GetSnapshotLifecycleAction.NAME,
|
||||||
GetStatusAction.NAME));
|
GetStatusAction.NAME));
|
||||||
|
private static final Set<String> MANAGE_ENRICH_AUTOMATON = Collections.unmodifiableSet(Sets.newHashSet("cluster:admin/xpack/enrich/*"));
|
||||||
|
|
||||||
public static final NamedClusterPrivilege NONE = new ActionClusterPrivilege("none", Collections.emptySet(), Collections.emptySet());
|
public static final NamedClusterPrivilege NONE = new ActionClusterPrivilege("none", Collections.emptySet(), Collections.emptySet());
|
||||||
public static final NamedClusterPrivilege ALL = new ActionClusterPrivilege("all", ALL_CLUSTER_PATTERN);
|
public static final NamedClusterPrivilege ALL = new ActionClusterPrivilege("all", ALL_CLUSTER_PATTERN);
|
||||||
|
@ -113,6 +114,7 @@ public class ClusterPrivilegeResolver {
|
||||||
public static final NamedClusterPrivilege READ_ILM = new ActionClusterPrivilege("read_ilm", READ_ILM_PATTERN);
|
public static final NamedClusterPrivilege READ_ILM = new ActionClusterPrivilege("read_ilm", READ_ILM_PATTERN);
|
||||||
public static final NamedClusterPrivilege MANAGE_SLM = new ActionClusterPrivilege("manage_slm", MANAGE_SLM_PATTERN);
|
public static final NamedClusterPrivilege MANAGE_SLM = new ActionClusterPrivilege("manage_slm", MANAGE_SLM_PATTERN);
|
||||||
public static final NamedClusterPrivilege READ_SLM = new ActionClusterPrivilege("read_slm", READ_SLM_PATTERN);
|
public static final NamedClusterPrivilege READ_SLM = new ActionClusterPrivilege("read_slm", READ_SLM_PATTERN);
|
||||||
|
public static final NamedClusterPrivilege MANAGE_ENRICH = new ActionClusterPrivilege("manage_enrich", MANAGE_ENRICH_AUTOMATON);
|
||||||
|
|
||||||
private static final Map<String, NamedClusterPrivilege> VALUES = Collections.unmodifiableMap(
|
private static final Map<String, NamedClusterPrivilege> VALUES = Collections.unmodifiableMap(
|
||||||
Stream.of(
|
Stream.of(
|
||||||
|
@ -143,7 +145,8 @@ public class ClusterPrivilegeResolver {
|
||||||
MANAGE_ILM,
|
MANAGE_ILM,
|
||||||
READ_ILM,
|
READ_ILM,
|
||||||
MANAGE_SLM,
|
MANAGE_SLM,
|
||||||
READ_SLM).collect(Collectors.toMap(cp -> cp.name(), cp -> cp)));
|
READ_SLM,
|
||||||
|
MANAGE_ENRICH).collect(Collectors.toMap(cp -> cp.name(), cp -> cp)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves a {@link NamedClusterPrivilege} from a given name if it exists.
|
* Resolves a {@link NamedClusterPrivilege} from a given name if it exists.
|
||||||
|
|
|
@ -182,14 +182,13 @@ public class PrivilegeTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testManageEnrichPrivilege() {
|
public void testManageEnrichPrivilege() {
|
||||||
Predicate<String> predicate = ClusterPrivilege.MANAGE_ENRICH.predicate();
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, DeleteEnrichPolicyAction.NAME);
|
||||||
assertThat(predicate.test(DeleteEnrichPolicyAction.NAME), is(true));
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, ExecuteEnrichPolicyAction.NAME);
|
||||||
assertThat(predicate.test(ExecuteEnrichPolicyAction.NAME), is(true));
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, GetEnrichPolicyAction.NAME);
|
||||||
assertThat(predicate.test(GetEnrichPolicyAction.NAME), is(true));
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, ListEnrichPolicyAction.NAME);
|
||||||
assertThat(predicate.test(ListEnrichPolicyAction.NAME), is(true));
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, PutEnrichPolicyAction.NAME);
|
||||||
assertThat(predicate.test(PutEnrichPolicyAction.NAME), is(true));
|
verifyClusterActionAllowed(ClusterPrivilegeResolver.MANAGE_ENRICH, "cluster:admin/xpack/enrich/brand_new_api");
|
||||||
assertThat(predicate.test("cluster:admin/xpack/enrich/brand_new_api"), is(true));
|
verifyClusterActionDenied(ClusterPrivilegeResolver.MANAGE_ENRICH, "cluster:admin/xpack/whatever");
|
||||||
assertThat(predicate.test("cluster:admin/xpack/whatever"), is(false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIlmPrivileges() {
|
public void testIlmPrivileges() {
|
||||||
|
|
|
@ -132,11 +132,11 @@ public class EnrichPlugin extends Plugin implements ActionPlugin, IngestPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new RestGetEnrichPolicyAction(settings, restController),
|
new RestGetEnrichPolicyAction(restController),
|
||||||
new RestDeleteEnrichPolicyAction(settings, restController),
|
new RestDeleteEnrichPolicyAction(restController),
|
||||||
new RestListEnrichPolicyAction(settings, restController),
|
new RestListEnrichPolicyAction(restController),
|
||||||
new RestPutEnrichPolicyAction(settings, restController),
|
new RestPutEnrichPolicyAction(restController),
|
||||||
new RestExecuteEnrichPolicyAction(settings, restController)
|
new RestExecuteEnrichPolicyAction(restController)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.enrich.rest;
|
package org.elasticsearch.xpack.enrich.rest;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class RestDeleteEnrichPolicyAction extends BaseRestHandler {
|
public class RestDeleteEnrichPolicyAction extends BaseRestHandler {
|
||||||
|
|
||||||
public RestDeleteEnrichPolicyAction(final Settings settings, final RestController controller) {
|
public RestDeleteEnrichPolicyAction(final RestController controller) {
|
||||||
super(settings);
|
|
||||||
controller.registerHandler(RestRequest.Method.DELETE, "/_enrich/policy/{name}", this);
|
controller.registerHandler(RestRequest.Method.DELETE, "/_enrich/policy/{name}", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.enrich.rest;
|
package org.elasticsearch.xpack.enrich.rest;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class RestExecuteEnrichPolicyAction extends BaseRestHandler {
|
public class RestExecuteEnrichPolicyAction extends BaseRestHandler {
|
||||||
|
|
||||||
public RestExecuteEnrichPolicyAction(final Settings settings, final RestController controller) {
|
public RestExecuteEnrichPolicyAction(final RestController controller) {
|
||||||
super(settings);
|
|
||||||
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}/_execute", this);
|
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}/_execute", this);
|
||||||
controller.registerHandler(RestRequest.Method.POST, "/_enrich/policy/{name}/_execute", this);
|
controller.registerHandler(RestRequest.Method.POST, "/_enrich/policy/{name}/_execute", this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.enrich.rest;
|
package org.elasticsearch.xpack.enrich.rest;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class RestGetEnrichPolicyAction extends BaseRestHandler {
|
public class RestGetEnrichPolicyAction extends BaseRestHandler {
|
||||||
|
|
||||||
public RestGetEnrichPolicyAction(final Settings settings, final RestController controller) {
|
public RestGetEnrichPolicyAction(final RestController controller) {
|
||||||
super(settings);
|
|
||||||
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy/{name}", this);
|
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy/{name}", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.enrich.rest;
|
package org.elasticsearch.xpack.enrich.rest;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
|
@ -17,8 +16,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class RestListEnrichPolicyAction extends BaseRestHandler {
|
public class RestListEnrichPolicyAction extends BaseRestHandler {
|
||||||
|
|
||||||
public RestListEnrichPolicyAction(final Settings settings, final RestController controller) {
|
public RestListEnrichPolicyAction(final RestController controller) {
|
||||||
super(settings);
|
|
||||||
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy", this);
|
controller.registerHandler(RestRequest.Method.GET, "/_enrich/policy", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.enrich.rest;
|
package org.elasticsearch.xpack.enrich.rest;
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.rest.BaseRestHandler;
|
import org.elasticsearch.rest.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
|
@ -18,8 +17,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class RestPutEnrichPolicyAction extends BaseRestHandler {
|
public class RestPutEnrichPolicyAction extends BaseRestHandler {
|
||||||
|
|
||||||
public RestPutEnrichPolicyAction(final Settings settings, final RestController controller) {
|
public RestPutEnrichPolicyAction(final RestController controller) {
|
||||||
super(settings);
|
|
||||||
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}", this);
|
controller.registerHandler(RestRequest.Method.PUT, "/_enrich/policy/{name}", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue