test: ensure the roles store is called when verifying mock interations
The CompositeRolesStoreTests#testNegativeLookupsAreCached test had a bug where it was expected to retrieve the superuser role but the mockito verification on the call failed. This was because there is also randomization on the number of times to call, which could be 0. Closes elastic/elasticsearch#4562 Original commit: elastic/x-pack-elasticsearch@5c62df15b7
This commit is contained in:
parent
a86b112f1e
commit
a0090ac556
|
@ -178,7 +178,7 @@ public class CompositeRolesStoreTests extends ESTestCase {
|
|||
verify(nativeRolesStore).getRoleDescriptors(isA(String[].class), any(ActionListener.class));
|
||||
|
||||
final int numberOfTimesToCall = scaledRandomIntBetween(0, 32);
|
||||
final boolean getSuperuserRole = randomBoolean();
|
||||
final boolean getSuperuserRole = randomBoolean() && roleName.equals(ReservedRolesStore.SUPERUSER_ROLE.name()) == false;
|
||||
final Set<String> names = getSuperuserRole ? Sets.newHashSet(roleName, ReservedRolesStore.SUPERUSER_ROLE.name()) :
|
||||
Collections.singleton(roleName);
|
||||
for (int i = 0; i < numberOfTimesToCall; i++) {
|
||||
|
@ -187,7 +187,7 @@ public class CompositeRolesStoreTests extends ESTestCase {
|
|||
future.actionGet();
|
||||
}
|
||||
|
||||
if (getSuperuserRole) {
|
||||
if (getSuperuserRole && numberOfTimesToCall > 0) {
|
||||
// the superuser role was requested so we get the role descriptors again
|
||||
verify(reservedRolesStore, times(2)).roleDescriptors();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue