forked from opensearch-project/security
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix cluster perm classification for msearch template (opensearch-proj…
…ect#2892) * fix cluster perm classification for msearch template Signed-off-by: Derek Ho <[email protected]> * move test to unit test file Signed-off-by: Derek Ho <[email protected]> * fully revert integration test file Signed-off-by: Derek Ho <[email protected]> * Update src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java Signed-off-by: Stephen Crawford <[email protected]> * spotless Signed-off-by: Derek Ho <[email protected]> --------- Signed-off-by: Derek Ho <[email protected]> Signed-off-by: Stephen Crawford <[email protected]> Co-authored-by: Stephen Crawford <[email protected]>
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/test/java/org/opensearch/security/privileges/PrivilegesEvaluatorUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} |