Skip to content

Commit faf23a6

Browse files
committed
wip
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
1 parent 11bd365 commit faf23a6

23 files changed

+854
-593
lines changed

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

Lines changed: 305 additions & 277 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
package org.opensearch.security.privileges;
1313

14-
1514
import org.apache.http.HttpStatus;
1615
import org.junit.ClassRule;
1716
import org.junit.Test;
18-
import org.junit.runner.RunWith;
1917

2018
import org.opensearch.script.mustache.MustacheModulePlugin;
2119
import org.opensearch.script.mustache.RenderSearchTemplateAction;
@@ -36,7 +34,6 @@
3634
* framework for direct comparison
3735
*/
3836

39-
4037
public class PrivilegesEvaluatorTest {
4138

4239
protected final static TestSecurityConfig.User NEGATIVE_LOOKAHEAD = new TestSecurityConfig.User("negative_lookahead_user").roles(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public RestEndpointPermissionTests() throws IOException {
123123
FlattenedActionGroups.EMPTY,
124124
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
125125
Settings.EMPTY,
126-
false
126+
false
127127
);
128128
}
129129

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void wellKnown() throws Exception {
8787
FlattenedActionGroups.EMPTY,
8888
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
8989
Settings.EMPTY,
90-
false
90+
false
9191
);
9292

9393
assertThat(subject.hasClusterPrivilege(ctx().roles("test_role").get(), "cluster:monitor/nodes/stats"), isAllowed());
@@ -112,7 +112,7 @@ public void notWellKnown() throws Exception {
112112
FlattenedActionGroups.EMPTY,
113113
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
114114
Settings.EMPTY,
115-
false
115+
false
116116
);
117117

118118
assertThat(
@@ -140,7 +140,7 @@ public void wildcard() throws Exception {
140140
FlattenedActionGroups.EMPTY,
141141
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
142142
Settings.EMPTY,
143-
false
143+
false
144144
);
145145

146146
assertThat(subject.hasClusterPrivilege(ctx().roles("test_role").get(), "cluster:whatever"), isAllowed());
@@ -169,7 +169,7 @@ public void explicit_wellKnown() throws Exception {
169169
FlattenedActionGroups.EMPTY,
170170
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
171171
Settings.EMPTY,
172-
false
172+
false
173173
);
174174

175175
assertThat(subject.hasExplicitClusterPrivilege(ctx().roles("explicit_role").get(), "cluster:monitor/nodes/stats"), isAllowed());
@@ -206,7 +206,7 @@ public void explicit_notWellKnown() throws Exception {
206206
FlattenedActionGroups.EMPTY,
207207
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
208208
Settings.EMPTY,
209-
false
209+
false
210210
);
211211

212212
assertThat(
@@ -238,7 +238,7 @@ public void hasAny_wellKnown() throws Exception {
238238
FlattenedActionGroups.EMPTY,
239239
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
240240
Settings.EMPTY,
241-
false
241+
false
242242
);
243243

244244
assertThat(
@@ -274,7 +274,7 @@ public void hasAny_notWellKnown() throws Exception {
274274
FlattenedActionGroups.EMPTY,
275275
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
276276
Settings.EMPTY,
277-
false
277+
false
278278
);
279279

280280
assertThat(
@@ -317,7 +317,7 @@ public void hasAny_wildcard() throws Exception {
317317
FlattenedActionGroups.EMPTY,
318318
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
319319
Settings.EMPTY,
320-
false
320+
false
321321
);
322322

323323
assertThat(subject.hasAnyClusterPrivilege(ctx().roles("test_role").get(), ImmutableSet.of("cluster:whatever")), isAllowed());
@@ -517,7 +517,7 @@ public IndicesAndAliases(IndexSpec indexSpec, ActionSpec actionSpec, Statefulnes
517517
FlattenedActionGroups.EMPTY,
518518
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
519519
settings,
520-
false
520+
false
521521
);
522522

523523
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {
@@ -692,7 +692,7 @@ public DataStreams(IndexSpec indexSpec, ActionSpec actionSpec, Statefulness stat
692692
FlattenedActionGroups.EMPTY,
693693
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
694694
settings,
695-
false
695+
false
696696
);
697697

698698
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {
@@ -929,7 +929,7 @@ public void hasIndexPrivilege_errors() throws Exception {
929929
FlattenedActionGroups.EMPTY,
930930
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
931931
Settings.EMPTY,
932-
false
932+
false
933933
);
934934

935935
PrivilegesEvaluatorResponse result = subject.hasIndexPrivilege(
@@ -961,7 +961,7 @@ public void hasExplicitIndexPrivilege_positive() throws Exception {
961961
FlattenedActionGroups.EMPTY,
962962
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
963963
Settings.EMPTY,
964-
false
964+
false
965965
);
966966

967967
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -987,7 +987,7 @@ public void hasExplicitIndexPrivilege_positive_wildcard() throws Exception {
987987
FlattenedActionGroups.EMPTY,
988988
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
989989
Settings.EMPTY,
990-
false
990+
false
991991
);
992992

993993
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1010,7 +1010,7 @@ public void hasExplicitIndexPrivilege_noWildcard() throws Exception {
10101010
FlattenedActionGroups.EMPTY,
10111011
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
10121012
Settings.EMPTY,
1013-
false
1013+
false
10141014
);
10151015

10161016
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1036,7 +1036,7 @@ public void hasExplicitIndexPrivilege_negative_wrongAction() throws Exception {
10361036
FlattenedActionGroups.EMPTY,
10371037
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
10381038
Settings.EMPTY,
1039-
false
1039+
false
10401040
);
10411041

10421042
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1062,7 +1062,7 @@ public void hasExplicitIndexPrivilege_errors() throws Exception {
10621062
FlattenedActionGroups.EMPTY,
10631063
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
10641064
Settings.EMPTY,
1065-
false
1065+
false
10661066
);
10671067

10681068
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -1097,7 +1097,7 @@ public void aliasesOnDataStreamBackingIndices() throws Exception {
10971097
FlattenedActionGroups.EMPTY,
10981098
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
10991099
Settings.EMPTY,
1100-
false
1100+
false
11011101
);
11021102
subject.updateStatefulIndexPrivileges(metadata.getIndicesLookup(), 2);
11031103

@@ -1131,7 +1131,7 @@ public void statefulDisabled() throws Exception {
11311131
FlattenedActionGroups.EMPTY,
11321132
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
11331133
Settings.builder().put(RoleBasedActionPrivileges.PRECOMPUTED_PRIVILEGES_ENABLED.getKey(), false).build(),
1134-
false
1134+
false
11351135
);
11361136
subject.updateStatefulIndexPrivileges(metadata, 1);
11371137
assertEquals(0, subject.getEstimatedStatefulIndexByteSize());
@@ -1155,7 +1155,7 @@ public void estimatedSize() throws Exception {
11551155
FlattenedActionGroups.EMPTY,
11561156
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
11571157
Settings.EMPTY,
1158-
false
1158+
false
11591159
);
11601160

11611161
subject.updateStatefulIndexPrivileges(indices, 1);

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void wellKnown() throws Exception {
7676
config,
7777
FlattenedActionGroups.EMPTY,
7878
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
79-
false
79+
false
8080
);
8181
assertThat(subject.hasClusterPrivilege(ctx().get(), "cluster:monitor/nodes/stats"), isAllowed());
8282
}
@@ -92,7 +92,7 @@ public void notWellKnown() throws Exception {
9292
config,
9393
FlattenedActionGroups.EMPTY,
9494
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
95-
false
95+
false
9696
);
9797
assertThat(subject.hasClusterPrivilege(ctx().get(), "cluster:monitor/nodes/stats/somethingnotwellknown"), isAllowed());
9898
}
@@ -108,7 +108,7 @@ public void negative() throws Exception {
108108
config,
109109
FlattenedActionGroups.EMPTY,
110110
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
111-
false
111+
false
112112
);
113113
assertThat(subject.hasClusterPrivilege(ctx().get(), "cluster:monitor/nodes/foo"), isForbidden());
114114
}
@@ -124,7 +124,7 @@ public void wildcard() throws Exception {
124124
config,
125125
FlattenedActionGroups.EMPTY,
126126
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
127-
false
127+
false
128128
);
129129
assertThat(subject.hasClusterPrivilege(ctx().get(), "cluster:whatever"), isAllowed());
130130
}
@@ -140,7 +140,7 @@ public void explicit_wellKnown() throws Exception {
140140
config,
141141
FlattenedActionGroups.EMPTY,
142142
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
143-
false
143+
false
144144
);
145145
assertThat(subject.hasExplicitClusterPrivilege(ctx().get(), "cluster:monitor/nodes/stats"), isAllowed());
146146
}
@@ -156,7 +156,7 @@ public void explicit_notWellKnown() throws Exception {
156156
config,
157157
FlattenedActionGroups.EMPTY,
158158
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
159-
false
159+
false
160160
);
161161
assertThat(subject.hasExplicitClusterPrivilege(ctx().get(), "cluster:monitor/nodes/notwellknown"), isAllowed());
162162
}
@@ -172,7 +172,7 @@ public void explicit_notExplicit() throws Exception {
172172
config,
173173
FlattenedActionGroups.EMPTY,
174174
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
175-
false
175+
false
176176
);
177177
assertThat(
178178
subject.hasExplicitClusterPrivilege(ctx().get(), "cluster:monitor/nodes/stats"),
@@ -191,7 +191,7 @@ public void hasAny_wellKnown() throws Exception {
191191
config,
192192
FlattenedActionGroups.EMPTY,
193193
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
194-
false
194+
false
195195
);
196196
assertThat(subject.hasAnyClusterPrivilege(ctx().get(), ImmutableSet.of("cluster:monitor/nodes/stats")), isAllowed());
197197
}
@@ -207,7 +207,7 @@ public void hasAny_wildcard() throws Exception {
207207
config,
208208
FlattenedActionGroups.EMPTY,
209209
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
210-
false
210+
false
211211
);
212212
assertThat(subject.hasAnyClusterPrivilege(ctx().get(), ImmutableSet.of("cluster:monitor/nodes/stats")), isAllowed());
213213
}
@@ -366,7 +366,7 @@ public IndicesAndAliases(IndexSpec indexSpec, ActionSpec actionSpec) throws Exce
366366
config,
367367
FlattenedActionGroups.EMPTY,
368368
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
369-
false
369+
false
370370
);
371371
}
372372

@@ -516,7 +516,7 @@ public DataStreams(IndexSpec indexSpec, ActionSpec actionSpec) throws Exception
516516
config,
517517
FlattenedActionGroups.EMPTY,
518518
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
519-
false
519+
false
520520
);
521521
}
522522

@@ -684,7 +684,7 @@ public void hasExplicitIndexPrivilege_positive() throws Exception {
684684
config,
685685
FlattenedActionGroups.EMPTY,
686686
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
687-
false
687+
false
688688
);
689689

690690
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -707,7 +707,7 @@ public void hasExplicitIndexPrivilege_positive_pattern() throws Exception {
707707
config,
708708
FlattenedActionGroups.EMPTY,
709709
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
710-
false
710+
false
711711
);
712712

713713
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -729,7 +729,7 @@ public void hasExplicitIndexPrivilege_noWildcard() throws Exception {
729729
config,
730730
FlattenedActionGroups.EMPTY,
731731
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
732-
false
732+
false
733733
);
734734

735735
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -751,7 +751,7 @@ public void hasExplicitIndexPrivilege_negative_wrongAction() throws Exception {
751751
config,
752752
FlattenedActionGroups.EMPTY,
753753
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
754-
false
754+
false
755755
);
756756

757757
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(
@@ -773,7 +773,7 @@ public void hasExplicitIndexPrivilege_errors() throws Exception {
773773
config,
774774
FlattenedActionGroups.EMPTY,
775775
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
776-
false
776+
false
777777
);
778778

779779
PrivilegesEvaluatorResponse result = subject.hasExplicitIndexPrivilege(

src/integrationTest/java/org/opensearch/security/rest/WhoAmITests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@
2121
import java.util.Set;
2222
import java.util.stream.Collectors;
2323

24-
2524
import org.apache.http.HttpStatus;
2625
import org.junit.ClassRule;
2726
import org.junit.Rule;
2827
import org.junit.Test;
29-
import org.junit.runner.RunWith;
3028

3129
import org.opensearch.security.auditlog.impl.AuditMessage;
3230
import org.opensearch.test.framework.AuditCompliance;
@@ -54,8 +52,6 @@
5452
import static org.opensearch.test.framework.audit.AuditMessagePredicate.userAuthenticatedPredicate;
5553
import static org.junit.Assert.assertTrue;
5654

57-
58-
5955
public class WhoAmITests {
6056
protected final static TestSecurityConfig.User WHO_AM_I = new TestSecurityConfig.User("who_am_i_user").roles(
6157
new Role("who_am_i_role").clusterPermissions("security:whoamiprotected")

0 commit comments

Comments
 (0)