Skip to content
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 @@ -28,9 +28,7 @@
import org.elasticsearch.xpack.security.rest.action.SecurityBaseRestHandler;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Set;

import static org.elasticsearch.rest.RestRequest.Method.GET;

Expand All @@ -41,8 +39,6 @@
public class RestGetBuiltinPrivilegesAction extends SecurityBaseRestHandler {

private static final Logger logger = LogManager.getLogger(RestGetBuiltinPrivilegesAction.class);
// TODO remove this once we can update docs tests again
private static final Set<String> FAILURE_STORE_PRIVILEGES_TO_EXCLUDE = Set.of("read_failure_store", "manage_failure_store");
private final GetBuiltinPrivilegesResponseTranslator responseTranslator;

public RestGetBuiltinPrivilegesAction(
Expand Down Expand Up @@ -75,20 +71,14 @@ public RestResponse buildResponse(GetBuiltinPrivilegesResponse response, XConten
final var translatedResponse = responseTranslator.translate(response);
builder.startObject();
builder.array("cluster", translatedResponse.getClusterPrivileges());
builder.array("index", filterOutFailureStorePrivileges(translatedResponse));
builder.array("index", translatedResponse.getIndexPrivileges());
String[] remoteClusterPrivileges = translatedResponse.getRemoteClusterPrivileges();
if (remoteClusterPrivileges.length > 0) { // remote clusters are not supported in stateless mode, so hide entirely
builder.array("remote_cluster", remoteClusterPrivileges);
}
builder.endObject();
return new RestResponse(RestStatus.OK, builder);
}

private static String[] filterOutFailureStorePrivileges(GetBuiltinPrivilegesResponse translatedResponse) {
return Arrays.stream(translatedResponse.getIndexPrivileges())
.filter(p -> false == FAILURE_STORE_PRIVILEGES_TO_EXCLUDE.contains(p))
.toArray(String[]::new);
}
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ setup:
# I would much prefer we could just check that specific entries are in the array, but we don't have
# an assertion for that
- length: { "cluster" : 62 }
- length: { "index" : 22 }
- length: { "index" : 24 }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test has been disabled in release builds for some time. I'll depend on that for now. We can remove it from the blacklist after feature flag removal.