Skip to content

Commit 2900218

Browse files
committed
fixes
Signed-off-by: Nils Bandener <[email protected]>
1 parent b8a316d commit 2900218

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4040
- [GRPC] Fix compilation errors from core protobuf version bump to 0.23.0 ([#5763](https://github.com/opensearch-project/security/pull/5763))
4141
- Modularized PrivilegesEvaluator ([#5791](https://github.com/opensearch-project/security/pull/5791))
4242
- [Resource Sharing] Adds post support for update sharing info API ([#5799](https://github.com/opensearch-project/security/pull/5799))
43+
- Cleaned up use of PrivilegesEvaluatorResponse ([#5804](https://github.com/opensearch-project/security/pull/5804))
4344

4445
### Maintenance
4546
- Bump `org.junit.jupiter:junit-jupiter` from 5.13.4 to 5.14.1 ([#5678](https://github.com/opensearch-project/security/pull/5678), [#5764](https://github.com/opensearch-project/security/pull/5764))

src/test/java/org/opensearch/security/privileges/SystemIndexAccessEvaluatorTest.java

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ PrivilegesEvaluationContext ctx(String action) {
179179

180180
@After
181181
public void after() {
182-
verifyNoMoreInteractions(auditLog, irr, request, task, log);
182+
verifyNoMoreInteractions(auditLog, irr, request, task);
183183
}
184184

185185
@Test
@@ -316,7 +316,7 @@ public void testUnprotectedActionOnSystemIndex_systemIndexPermissionEnabled_With
316316
user
317317
);
318318
// unprotected action is not allowed on a system index
319-
assertThat(response.isAllowed(), is(false));
319+
assertThat(response, is(nullValue()));
320320
}
321321

322322
@Test
@@ -394,18 +394,12 @@ public void testDisableCacheOrRealtimeOnSystemIndex_systemIndexPermissionEnabled
394394
actionPrivileges,
395395
user
396396
);
397-
assertThat(response, is(nullValue()));
397+
assertThat(response.isAllowed(), is(false));
398398
response = evaluator.evaluate(searchRequest, null, UNPROTECTED_ACTION, resolved, ctx(UNPROTECTED_ACTION), actionPrivileges, user);
399-
assertThat(response, is(nullValue()));
399+
assertThat(response.isAllowed(), is(false));
400400
response = evaluator.evaluate(realtimeRequest, null, UNPROTECTED_ACTION, resolved, ctx(UNPROTECTED_ACTION), actionPrivileges, user);
401-
assertThat(response, is(nullValue()));
402-
403-
verify(searchRequest).requestCache(Boolean.FALSE);
404-
verify(realtimeRequest).realtime(Boolean.FALSE);
401+
assertThat(response.isAllowed(), is(false));
405402

406-
verify(log, times(2)).isDebugEnabled();
407-
verify(log).debug("Disable search request cache for this request");
408-
verify(log).debug("Disable realtime for this request");
409403
verify(auditLog).logSecurityIndexAttempt(request, UNPROTECTED_ACTION, null);
410404
verify(auditLog).logSecurityIndexAttempt(searchRequest, UNPROTECTED_ACTION, null);
411405
verify(auditLog).logSecurityIndexAttempt(realtimeRequest, UNPROTECTED_ACTION, null);
@@ -415,8 +409,6 @@ public void testDisableCacheOrRealtimeOnSystemIndex_systemIndexPermissionEnabled
415409
user.getSecurityRoles(),
416410
TEST_SYSTEM_INDEX
417411
);
418-
verify(log).debug("Disable search request cache for this request");
419-
verify(log).debug("Disable realtime for this request");
420412
}
421413

422414
@Test
@@ -529,7 +521,7 @@ public void testProtectedActionOnRegularIndex_systemIndexDisabled() {
529521
user
530522
);
531523

532-
assertThat(response.isAllowed(), is(false));
524+
assertThat(response, is(nullValue()));
533525
}
534526

535527
@Test
@@ -548,7 +540,7 @@ public void testProtectedActionOnRegularIndex_systemIndexPermissionDisabled() {
548540
user
549541
);
550542

551-
assertThat(response.isAllowed(), is(false));
543+
assertThat(response, is(nullValue()));
552544
}
553545

554546
@Test
@@ -567,7 +559,7 @@ public void testProtectedActionOnRegularIndex_systemIndexPermissionEnabled() {
567559
user
568560
);
569561

570-
assertThat(response.isAllowed(), is(false));
562+
assertThat(response, is(nullValue()));
571563
}
572564

573565
@Test
@@ -586,7 +578,7 @@ public void testProtectedActionOnSystemIndex_systemIndexDisabled() {
586578
user
587579
);
588580

589-
assertThat(response.isAllowed(), is(false));
581+
assertThat(response, is(nullValue()));
590582
}
591583

592584
@Test
@@ -654,7 +646,7 @@ public void testProtectedActionOnSystemIndex_systemIndexPermissionEnabled_withSy
654646
user
655647
);
656648

657-
assertThat(response.isAllowed(), is(false));
649+
assertThat(response, is(nullValue()));
658650
}
659651

660652
@Test

0 commit comments

Comments
 (0)