-
Notifications
You must be signed in to change notification settings - Fork 337
Thorough integration tests for index API authorization #5632
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
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6ef6481
Thorough integration tests for index API authorization
nibix 95d2fdc
Fixes
nibix ec898fa
Fixed JSON path dependency
nibix 6415df3
Fixed path names
nibix c43fe89
Introduced more tests targeting system index privilege behavior
nibix 85107ef
JSON format
nibix fa0a8ed
Deleted leftovers
nibix 05686ea
Deleted leftovers
nibix ca52b52
Deleted leftovers
nibix b1c78cb
More tests
nibix 571c6e7
Rollover tests
nibix 5cb5036
PIT tests
nibix ba1ae0e
Adaption to legacy version
nibix 7601c63
Adaption to legacy version
nibix 6fd7108
Cleanup
nibix e3cc113
Cleanup
nibix 2c0a701
Moved user.indexMatcher() to user.reference()
nibix 0f6517b
Moved test data classes to .data package
nibix 48b6517
Fixes
nibix 2c321d6
Fixes
nibix 66f19f0
Review remarks
nibix f2538e8
Added comment
nibix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
86 changes: 86 additions & 0 deletions
86
src/integrationTest/java/org/opensearch/security/privileges/int_tests/ClusterConfig.java
This file contains hidden or 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,86 @@ | ||
/* | ||
* 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. | ||
* | ||
* Modifications Copyright OpenSearch Contributors. See | ||
* GitHub history for details. | ||
*/ | ||
|
||
package org.opensearch.security.privileges.int_tests; | ||
|
||
import java.util.Map; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
import org.opensearch.test.framework.cluster.LocalCluster; | ||
|
||
/** | ||
* This is one of the test parameter dimensions used by the *Authorization*IntTests test suites. | ||
* The test suites run on different cluster configurations; the possible cluster configurations are defined here. | ||
*/ | ||
public enum ClusterConfig { | ||
LEGACY_PRIVILEGES_EVALUATION( | ||
cwperks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"legacy", | ||
c -> c.doNotFailOnForbidden(true).nodeSettings(Map.of("plugins.security.system_indices.enabled", true)), | ||
true, | ||
false, | ||
false | ||
), | ||
LEGACY_PRIVILEGES_EVALUATION_SYSTEM_INDEX_PERMISSION( | ||
"legacy_system_index_perm", | ||
c -> c.doNotFailOnForbidden(true) | ||
.nodeSettings( | ||
Map.of("plugins.security.system_indices.enabled", true, "plugins.security.system_indices.permission.enabled", true) | ||
), | ||
true, | ||
true, | ||
false | ||
); | ||
|
||
final String name; | ||
final Function<LocalCluster.Builder, LocalCluster.Builder> clusterConfiguration; | ||
final boolean legacyPrivilegeEvaluation; | ||
final boolean systemIndexPrivilegeEnabled; | ||
final boolean allowsEmptyResultSets; | ||
|
||
private LocalCluster cluster; | ||
|
||
ClusterConfig( | ||
String name, | ||
Function<LocalCluster.Builder, LocalCluster.Builder> clusterConfiguration, | ||
boolean legacyPrivilegeEvaluation, | ||
boolean systemIndexPrivilegeEnabled, | ||
boolean allowsEmptyResultSets | ||
) { | ||
this.name = name; | ||
this.clusterConfiguration = clusterConfiguration; | ||
this.legacyPrivilegeEvaluation = legacyPrivilegeEvaluation; | ||
this.systemIndexPrivilegeEnabled = systemIndexPrivilegeEnabled; | ||
this.allowsEmptyResultSets = allowsEmptyResultSets; | ||
} | ||
|
||
LocalCluster cluster(Supplier<LocalCluster.Builder> clusterBuilder) { | ||
if (cluster == null) { | ||
cluster = this.clusterConfiguration.apply(clusterBuilder.get()).build(); | ||
cluster.before(); | ||
} | ||
return cluster; | ||
} | ||
|
||
void shutdown() { | ||
if (cluster != null) { | ||
try { | ||
cluster.close(); | ||
} catch (Exception e) {} | ||
cluster = null; | ||
} | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.