Skip to content

Commit 42c2fa4

Browse files
[Test] Use real instance of ReservedRolesStore to avoid NPE (elastic#97185)
Since ReservedRolesStore must be properly initialized before calling real methods, it is not possible to mock it and then still call real methods. Given that there is no real need for CompositeRolesStoreTests to use mocked ReservedRolesStore, this PR changes the test setup to use real instance and thus avoid NPE when accessing RESERVED_ROLES property. Fixes elastic#97172
1 parent 5486667 commit 42c2fa4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2920,8 +2920,7 @@ private RoleProviders buildRolesProvider(
29202920
}).when(nativeRolesStore).getRoleDescriptors(isASet(), anyActionListener());
29212921
}
29222922
if (reservedRolesStore == null) {
2923-
reservedRolesStore = mock(ReservedRolesStore.class);
2924-
doCallRealMethod().when(reservedRolesStore).accept(anySet(), anyActionListener());
2923+
reservedRolesStore = new ReservedRolesStore();
29252924
}
29262925
if (licenseState == null) {
29272926
licenseState = new XPackLicenseState(() -> 0);

0 commit comments

Comments
 (0)