Skip to content

Commit b3e2cca

Browse files
committed
Added new integration tests
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
1 parent fc13f5a commit b3e2cca

File tree

54 files changed

+8089
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+8089
-904
lines changed

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,11 @@ allprojects {
573573
integrationTestImplementation 'org.slf4j:slf4j-api:2.0.12'
574574
integrationTestImplementation 'com.selectivem.collections:special-collections-complete:1.4.0'
575575
integrationTestImplementation "org.opensearch.plugin:lang-painless:${opensearch_version}"
576+
577+
integrationTestImplementation ('com.jayway.jsonpath:json-path:2.9.0') {
578+
exclude(group: 'net.minidev', module: 'json-smart')
579+
}
580+
integrationTestImplementation 'net.minidev:json-smart:2.6.0'
576581
}
577582
}
578583

src/integrationTest/java/org/opensearch/security/PerfTest.java

Lines changed: 0 additions & 146 deletions
This file was deleted.

src/integrationTest/java/org/opensearch/security/SearchOperationTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
import org.opensearch.action.search.SearchRequest;
6868
import org.opensearch.action.search.SearchResponse;
6969
import org.opensearch.action.search.SearchScrollRequest;
70+
import org.opensearch.action.support.IndicesOptions;
7071
import org.opensearch.action.update.UpdateRequest;
7172
import org.opensearch.action.update.UpdateResponse;
7273
import org.opensearch.client.RestHighLevelClient;
@@ -2281,7 +2282,11 @@ public void openIndex_negative() throws IOException {
22812282
.open(new OpenIndexRequest(indexThatUserHasAccessTo, indexThatUserHasNoAccessTo), DEFAULT),
22822283
statusException(FORBIDDEN)
22832284
);
2284-
assertThatThrownBy(() -> restHighLevelClient.indices().open(new OpenIndexRequest("*"), DEFAULT), statusException(FORBIDDEN));
2285+
assertThatThrownBy(
2286+
() -> restHighLevelClient.indices()
2287+
.open(new OpenIndexRequest("*").indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED), DEFAULT),
2288+
statusException(FORBIDDEN)
2289+
);
22852290
}
22862291
}
22872292

src/integrationTest/java/org/opensearch/security/privileges/PrivilegesEvaluatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class PrivilegesEvaluatorTest {
4444
);
4545

4646
protected final static TestSecurityConfig.User NEGATED_REGEX = new TestSecurityConfig.User("negated_regex_user").roles(
47-
new Role("negated_regex_role").indexPermissions("read").on("/^[a-z].*/").clusterPermissions("cluster_composite_ops")
47+
new Role("negated_regex_role").indexPermissions("read").on("/^[a-r].*/").clusterPermissions("cluster_composite_ops")
4848
);
4949

5050
protected final static TestSecurityConfig.User SEARCH_TEMPLATE = new TestSecurityConfig.User("search_template_user").roles(

src/integrationTest/java/org/opensearch/security/privileges/RestEndpointPermissionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ public RestEndpointPermissionTests() throws IOException {
122122
createRolesConfig(),
123123
FlattenedActionGroups.EMPTY,
124124
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
125-
Settings.EMPTY
125+
Settings.EMPTY,
126+
false
126127
);
127128
}
128129

src/integrationTest/java/org/opensearch/security/privileges/actionlevel/RoleBasedActionPrivilegesTest.java

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public void wellKnown() throws Exception {
8686
roles,
8787
FlattenedActionGroups.EMPTY,
8888
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
89-
Settings.EMPTY
89+
Settings.EMPTY,
90+
false
9091
);
9192

9293
assertThat(subject.hasClusterPrivilege(ctx().roles("test_role").get(), "cluster:monitor/nodes/stats"), isAllowed());
@@ -110,7 +111,8 @@ public void notWellKnown() throws Exception {
110111
roles,
111112
FlattenedActionGroups.EMPTY,
112113
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
113-
Settings.EMPTY
114+
Settings.EMPTY,
115+
false
114116
);
115117

116118
assertThat(
@@ -137,7 +139,8 @@ public void wildcard() throws Exception {
137139
roles,
138140
FlattenedActionGroups.EMPTY,
139141
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
140-
Settings.EMPTY
142+
Settings.EMPTY,
143+
false
141144
);
142145

143146
assertThat(subject.hasClusterPrivilege(ctx().roles("test_role").get(), "cluster:whatever"), isAllowed());
@@ -165,7 +168,8 @@ public void explicit_wellKnown() throws Exception {
165168
roles,
166169
FlattenedActionGroups.EMPTY,
167170
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
168-
Settings.EMPTY
171+
Settings.EMPTY,
172+
false
169173
);
170174

171175
assertThat(subject.hasExplicitClusterPrivilege(ctx().roles("explicit_role").get(), "cluster:monitor/nodes/stats"), isAllowed());
@@ -201,7 +205,8 @@ public void explicit_notWellKnown() throws Exception {
201205
roles,
202206
FlattenedActionGroups.EMPTY,
203207
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
204-
Settings.EMPTY
208+
Settings.EMPTY,
209+
false
205210
);
206211

207212
assertThat(
@@ -232,7 +237,8 @@ public void hasAny_wellKnown() throws Exception {
232237
roles,
233238
FlattenedActionGroups.EMPTY,
234239
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
235-
Settings.EMPTY
240+
Settings.EMPTY,
241+
false
236242
);
237243

238244
assertThat(
@@ -267,7 +273,8 @@ public void hasAny_notWellKnown() throws Exception {
267273
roles,
268274
FlattenedActionGroups.EMPTY,
269275
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
270-
Settings.EMPTY
276+
Settings.EMPTY,
277+
false
271278
);
272279

273280
assertThat(
@@ -309,7 +316,8 @@ public void hasAny_wildcard() throws Exception {
309316
roles,
310317
FlattenedActionGroups.EMPTY,
311318
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
312-
Settings.EMPTY
319+
Settings.EMPTY,
320+
false
313321
);
314322

315323
assertThat(subject.hasAnyClusterPrivilege(ctx().roles("test_role").get(), ImmutableSet.of("cluster:whatever")), isAllowed());
@@ -508,7 +516,8 @@ public IndicesAndAliases(IndexSpec indexSpec, ActionSpec actionSpec, Statefulnes
508516
roles,
509517
FlattenedActionGroups.EMPTY,
510518
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
511-
settings
519+
settings,
520+
false
512521
);
513522

514523
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {
@@ -682,7 +691,8 @@ public DataStreams(IndexSpec indexSpec, ActionSpec actionSpec, Statefulness stat
682691
roles,
683692
FlattenedActionGroups.EMPTY,
684693
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
685-
settings
694+
settings,
695+
false
686696
);
687697

688698
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {
@@ -918,7 +928,8 @@ public void hasIndexPrivilege_errors() throws Exception {
918928
roles,
919929
FlattenedActionGroups.EMPTY,
920930
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
921-
Settings.EMPTY
931+
Settings.EMPTY,
932+
false
922933
);
923934

924935
PrivilegesEvaluatorResponse result = subject.hasIndexPrivilege(
@@ -949,7 +960,8 @@ public void hasExplicitIndexPrivilege_positive() throws Exception {
949960
roles,
950961
FlattenedActionGroups.EMPTY,
951962
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
952-
Settings.EMPTY
963+
Settings.EMPTY,
964+
false
953965
);
954966

955967
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -974,7 +986,8 @@ public void hasExplicitIndexPrivilege_positive_wildcard() throws Exception {
974986
roles,
975987
FlattenedActionGroups.EMPTY,
976988
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
977-
Settings.EMPTY
989+
Settings.EMPTY,
990+
false
978991
);
979992

980993
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -996,7 +1009,8 @@ public void hasExplicitIndexPrivilege_noWildcard() throws Exception {
9961009
roles,
9971010
FlattenedActionGroups.EMPTY,
9981011
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
999-
Settings.EMPTY
1012+
Settings.EMPTY,
1013+
false
10001014
);
10011015

10021016
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1021,7 +1035,8 @@ public void hasExplicitIndexPrivilege_negative_wrongAction() throws Exception {
10211035
roles,
10221036
FlattenedActionGroups.EMPTY,
10231037
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
1024-
Settings.EMPTY
1038+
Settings.EMPTY,
1039+
false
10251040
);
10261041

10271042
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1046,7 +1061,8 @@ public void hasExplicitIndexPrivilege_errors() throws Exception {
10461061
roles,
10471062
FlattenedActionGroups.EMPTY,
10481063
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
1049-
Settings.EMPTY
1064+
Settings.EMPTY,
1065+
false
10501066
);
10511067

10521068
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1080,7 +1096,8 @@ public void aliasesOnDataStreamBackingIndices() throws Exception {
10801096
roles,
10811097
FlattenedActionGroups.EMPTY,
10821098
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
1083-
Settings.EMPTY
1099+
Settings.EMPTY,
1100+
false
10841101
);
10851102
subject.updateStatefulIndexPrivileges(metadata.getIndicesLookup(), 2);
10861103

@@ -1113,7 +1130,8 @@ public void statefulDisabled() throws Exception {
11131130
roles,
11141131
FlattenedActionGroups.EMPTY,
11151132
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
1116-
Settings.builder().put(RoleBasedActionPrivileges.PRECOMPUTED_PRIVILEGES_ENABLED.getKey(), false).build()
1133+
Settings.builder().put(RoleBasedActionPrivileges.PRECOMPUTED_PRIVILEGES_ENABLED.getKey(), false).build(),
1134+
false
11171135
);
11181136
subject.updateStatefulIndexPrivileges(metadata, 1);
11191137
assertEquals(0, subject.getEstimatedStatefulIndexByteSize());
@@ -1136,7 +1154,8 @@ public void estimatedSize() throws Exception {
11361154
roles,
11371155
FlattenedActionGroups.EMPTY,
11381156
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
1139-
Settings.EMPTY
1157+
Settings.EMPTY,
1158+
false
11401159
);
11411160

11421161
subject.updateStatefulIndexPrivileges(indices, 1);

0 commit comments

Comments
 (0)