Skip to content

Commit 485afb2

Browse files
committed
Test fixes
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
1 parent e5f7d52 commit 485afb2

File tree

5 files changed

+28
-44
lines changed

5 files changed

+28
-44
lines changed

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

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,7 @@ public void positive_partial() throws Exception {
589589
if (covers(ctx, "data_stream_a11", "data_stream_a12")) {
590590
assertThat(result, isAllowed());
591591
} else if (covers(ctx, "data_stream_a11")) {
592-
assertThat(
593-
result,
594-
isPartiallyOk(
595-
"data_stream_a11"
596-
)
597-
);
592+
assertThat(result, isPartiallyOk("data_stream_a11"));
598593
} else {
599594
assertThat(result, isForbidden(missingPrivileges(requiredActions)));
600595
}
@@ -604,27 +599,17 @@ public void positive_partial() throws Exception {
604599
public void positive_partial_breakDownAliases() throws Exception {
605600
PrivilegesEvaluationContext ctx = ctx().roles("test_role").indexMetadata(INDEX_METADATA).get();
606601
PrivilegesEvaluatorResponse result = subject(true).hasIndexPrivilege(
607-
ctx,
608-
requiredActions,
609-
resolved("data_stream_a11", "data_stream_a12")
602+
ctx,
603+
requiredActions,
604+
resolved("data_stream_a11", "data_stream_a12")
610605
);
611606

612607
if (covers(ctx, "data_stream_a11", "data_stream_a12")) {
613608
assertThat(result, isAllowed());
614609
} else if (covers(ctx, "data_stream_a11")) {
615-
assertThat(
616-
result,
617-
isPartiallyOk(
618-
"data_stream_a11"
619-
)
620-
);
610+
assertThat(result, isPartiallyOk("data_stream_a11"));
621611
} else if (covers(ctx, ".ds-data_stream_a11")) {
622-
assertThat(
623-
result,
624-
isPartiallyOk(
625-
"data_stream_a11"
626-
)
627-
);
612+
assertThat(result, isPartiallyOk("data_stream_a11"));
628613
} else {
629614
assertThat(result, isForbidden(missingPrivileges(requiredActions)));
630615
}
@@ -713,19 +698,19 @@ private RoleBasedActionPrivileges subject(boolean breakDownAliases) {
713698
Settings settings = Settings.EMPTY;
714699
if (statefulness == Statefulness.STATEFUL_LIMITED) {
715700
settings = Settings.builder()
716-
.put(
717-
RoleBasedActionPrivileges.PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE.getKey(),
718-
new ByteSizeValue(10, ByteSizeUnit.BYTES)
719-
)
720-
.build();
701+
.put(
702+
RoleBasedActionPrivileges.PRECOMPUTED_PRIVILEGES_MAX_HEAP_SIZE.getKey(),
703+
new ByteSizeValue(10, ByteSizeUnit.BYTES)
704+
)
705+
.build();
721706
}
722707

723708
RoleBasedActionPrivileges result = new RoleBasedActionPrivileges(
724-
roles,
725-
FlattenedActionGroups.EMPTY,
726-
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
727-
settings,
728-
breakDownAliases
709+
roles,
710+
FlattenedActionGroups.EMPTY,
711+
RuntimeOptimizedActionPrivileges.SpecialIndexProtection.NONE,
712+
settings,
713+
breakDownAliases
729714
);
730715

731716
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,7 @@ public void positive_partial() throws Exception {
421421
if (covers(ctx, "data_stream_a11", "data_stream_a12")) {
422422
assertThat(result, isAllowed());
423423
} else if (covers(ctx, "data_stream_a11")) {
424-
assertThat(
425-
result,
426-
isPartiallyOk(
427-
"data_stream_a11"
428-
)
429-
);
424+
assertThat(result, isPartiallyOk("data_stream_a11"));
430425
} else {
431426
assertThat(result, isForbidden(missingPrivileges(requiredActions)));
432427
}

src/integrationTest/resources/log4j2-test.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ logger.securenetty4transport.name = org.opensearch.transport.netty4.ssl.SecureNe
5555
logger.securenetty4transport.level = error
5656
logger.securenetty4transport.appenderRef.capturing.ref = logCapturingAppender
5757

58+
logger.p.name=org.opensearch.security.privileges
59+
logger.p.level=DEBUG
60+
61+
logger.pi.name=org.opensearch.security.configuration.PrivilegesInterceptorImpl
62+
logger.pi.level=TRACE

src/test/java/org/opensearch/security/multitenancy/test/MultitenancyTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,8 @@ public void testMtMulti() throws Exception {
406406
Assert.assertTrue(res.getBody().contains(dashboardsIndex));
407407

408408
// get
409-
assertThat(res.getBody(),
409+
assertThat(
410+
res.getBody(),
410411
HttpStatus.SC_OK,
411412
is(
412413
(res = rh.executeGetRequest(
@@ -416,10 +417,10 @@ public void testMtMulti() throws Exception {
416417
)).getStatusCode()
417418
)
418419
);
419-
Assert.assertFalse(res.getBody(),res.getBody().contains("exception"));
420-
Assert.assertTrue(res.getBody(),res.getBody().contains("humanresources"));
421-
Assert.assertTrue(res.getBody(),res.getBody().contains("\"found\" : true"));
422-
Assert.assertTrue(res.getBody(),res.getBody().contains(dashboardsIndex));
420+
Assert.assertFalse(res.getBody(), res.getBody().contains("exception"));
421+
Assert.assertTrue(res.getBody(), res.getBody().contains("humanresources"));
422+
Assert.assertTrue(res.getBody(), res.getBody().contains("\"found\" : true"));
423+
Assert.assertTrue(res.getBody(), res.getBody().contains(dashboardsIndex));
423424

424425
// mget
425426
body = "{\"docs\" : [{\"_index\" : \".kibana\",\"_id\" : \"index-pattern:9fbbd1a0-c3c5-11e8-a13f-71b8ea5a4f7b\"}]}";

src/test/java/org/opensearch/security/tools/democonfig/SecuritySettingsConfigurerTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
import java.util.List;
3030
import java.util.Map;
3131

32-
import com.carrotsearch.randomizedtesting.RandomizedRunner;
3332
import org.apache.commons.lang3.RandomStringUtils;
3433
import org.junit.After;
3534
import org.junit.Before;
3635
import org.junit.Test;
37-
import org.junit.runner.RunWith;
3836

3937
import org.opensearch.security.support.ConfigConstants;
4038
import org.opensearch.security.tools.Hasher;

0 commit comments

Comments
 (0)