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

fix cluster perm classification for msearch template #2892

Merged
merged 5 commits into from
Jun 28, 2023
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 @@ -668,7 +668,7 @@ public static boolean isClusterPerm(String action0) {
|| action0.startsWith(SearchScrollAction.NAME)
|| (action0.equals(BulkAction.NAME))
|| (action0.equals(MultiGetAction.NAME))
|| (action0.equals(MultiSearchAction.NAME))
|| (action0.startsWith(MultiSearchAction.NAME))
|| (action0.equals(MultiTermVectorsAction.NAME))
|| (action0.equals(ReindexAction.NAME))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.security.privileges;
stephen-crawford marked this conversation as resolved.
Show resolved Hide resolved

import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.opensearch.security.privileges.PrivilegesEvaluator.isClusterPerm;

public class PrivilegesEvaluatorUnitTest {

@Test
public void testClusterPerm() {
String multiSearchTemplate = "indices:data/read/msearch/template";
String monitorHealth = "cluster:monitor/health";
String writeIndex = "indices:data/write/reindex";
String adminClose = "indices:admin/close";
String monitorUpgrade = "indices:monitor/upgrade";

// Cluster Permissions
assertTrue(isClusterPerm(multiSearchTemplate));
assertTrue(isClusterPerm(writeIndex));
assertTrue(isClusterPerm(monitorHealth));

// Index Permissions
assertFalse(isClusterPerm(adminClose));
assertFalse(isClusterPerm(monitorUpgrade));
}
}