Skip to content

Commit

Permalink
fix cluster perm classification for msearch template (opensearch-proj…
Browse files Browse the repository at this point in the history
…ect#2892)

* fix cluster perm classification for msearch template

Signed-off-by: Derek Ho <dxho@amazon.com>

* move test to unit test file

Signed-off-by: Derek Ho <dxho@amazon.com>

* fully revert integration test file

Signed-off-by: Derek Ho <dxho@amazon.com>

* Update src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java

Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>

* spotless

Signed-off-by: Derek Ho <dxho@amazon.com>

---------

Signed-off-by: Derek Ho <dxho@amazon.com>
Signed-off-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
Co-authored-by: Stephen Crawford <65832608+scrawfor99@users.noreply.github.com>
  • Loading branch information
2 people authored and RyanL1997 committed Jun 29, 2023
1 parent 37f277e commit c1d2127
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
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;

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));
}
}

0 comments on commit c1d2127

Please sign in to comment.