Skip to content

[Transform] mark old data frame transform roles deprecated #57655

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

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
new RoleDescriptor.ApplicationResourcePrivileges[] {
RoleDescriptor.ApplicationResourcePrivileges.builder()
.application("kibana-*").resources("*").privileges("reserved_ml_user").build()
}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA, null))
}, null, null, MetadataUtils.getDeprecatedReservedMetadata("Please use the [transform_admin] role instead"), null))
// DEPRECATED: to be removed in 9.0.0
.put("data_frame_transforms_user", new RoleDescriptor("data_frame_transforms_user",
new String[] { "monitor_data_frame_transforms" },
Expand All @@ -221,7 +221,7 @@ private static Map<String, RoleDescriptor> initializeReservedRoles() {
new RoleDescriptor.ApplicationResourcePrivileges[] {
RoleDescriptor.ApplicationResourcePrivileges.builder()
.application("kibana-*").resources("*").privileges("reserved_ml_user").build()
}, null, null, MetadataUtils.DEFAULT_RESERVED_METADATA, null))
}, null, null, MetadataUtils.getDeprecatedReservedMetadata("Please use the [transform_user] role instead"), null))
.put("transform_admin", new RoleDescriptor("transform_admin",
new String[] { "manage_transform" },
new RoleDescriptor.IndicesPrivileges[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.transport.TransportRequest;
import org.elasticsearch.xpack.core.action.XPackInfoAction;
import org.elasticsearch.xpack.core.ilm.action.GetLifecycleAction;
import org.elasticsearch.xpack.core.ilm.action.DeleteLifecycleAction;
import org.elasticsearch.xpack.core.ilm.action.GetLifecycleAction;
import org.elasticsearch.xpack.core.ilm.action.PutLifecycleAction;
import org.elasticsearch.xpack.core.ilm.action.StartILMAction;
import org.elasticsearch.xpack.core.ilm.action.StopILMAction;
Expand Down Expand Up @@ -1277,6 +1277,11 @@ public void testTransformAdminRole() {
for (RoleDescriptor roleDescriptor : roleDescriptors) {
assertNotNull(roleDescriptor);
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
if (roleDescriptor.getName().equals("data_frame_transforms_admin")) {
assertThat(roleDescriptor.getMetadata(), hasEntry("_deprecated", true));
} else {
assertThat(roleDescriptor.getMetadata(), not(hasEntry("_deprecated", true)));
}

Role role = Role.builder(roleDescriptor, null).build();
assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(true));
Expand Down Expand Up @@ -1318,7 +1323,7 @@ public void testTransformAdminRole() {
}
}

public void testDataFrameTransformsUserRole() {
public void testTransformUserRole() {
final TransportRequest request = mock(TransportRequest.class);
final Authentication authentication = mock(Authentication.class);

Expand All @@ -1330,6 +1335,11 @@ public void testDataFrameTransformsUserRole() {
for (RoleDescriptor roleDescriptor : roleDescriptors) {
assertNotNull(roleDescriptor);
assertThat(roleDescriptor.getMetadata(), hasEntry("_reserved", true));
if (roleDescriptor.getName().equals("data_frame_transforms_user")) {
assertThat(roleDescriptor.getMetadata(), hasEntry("_deprecated", true));
} else {
assertThat(roleDescriptor.getMetadata(), not(hasEntry("_deprecated", true)));
}

Role role = Role.builder(roleDescriptor, null).build();
assertThat(role.cluster().check(DeleteTransformAction.NAME, request, authentication), is(false));
Expand Down