Skip to content

Commit 2283a33

Browse files
committed
[TEST] Fix bit indexing in test mutator
There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors. -- Leon Bambrick (@secretGeek) Fixes: #34610
1 parent 7cc3ac0 commit 2283a33

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/action/user/GetUserPrivilegesResponseTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public void testEqualsAndHashCode() throws IOException {
7474
@Override
7575
public GetUserPrivilegesResponse mutate(GetUserPrivilegesResponse original) {
7676
final int random = randomIntBetween(1, 0b11111);
77-
final Set<String> cluster = maybeMutate(random, 1, original.getClusterPrivileges(), () -> randomAlphaOfLength(5));
78-
final Set<ConditionalClusterPrivilege> conditionalCluster = maybeMutate(random, 2,
77+
final Set<String> cluster = maybeMutate(random, 0, original.getClusterPrivileges(), () -> randomAlphaOfLength(5));
78+
final Set<ConditionalClusterPrivilege> conditionalCluster = maybeMutate(random, 1,
7979
original.getConditionalClusterPrivileges(), () -> new ManageApplicationPrivileges(randomStringSet(3)));
80-
final Set<GetUserPrivilegesResponse.Indices> index = maybeMutate(random, 3, original.getIndexPrivileges(),
80+
final Set<GetUserPrivilegesResponse.Indices> index = maybeMutate(random, 2, original.getIndexPrivileges(),
8181
() -> new GetUserPrivilegesResponse.Indices(randomStringSet(1), randomStringSet(1), emptySet(), emptySet()));
82-
final Set<ApplicationResourcePrivileges> application = maybeMutate(random, 4, original.getApplicationPrivileges(),
82+
final Set<ApplicationResourcePrivileges> application = maybeMutate(random, 3, original.getApplicationPrivileges(),
8383
() -> ApplicationResourcePrivileges.builder().resources(generateRandomStringArray(3, 3, false, false))
8484
.application(randomAlphaOfLength(5)).privileges(generateRandomStringArray(3, 5, false, false)).build());
85-
final Set<String> runAs = maybeMutate(random, 5, original.getRunAs(), () -> randomAlphaOfLength(8));
85+
final Set<String> runAs = maybeMutate(random, 4, original.getRunAs(), () -> randomAlphaOfLength(8));
8686
return new GetUserPrivilegesResponse(cluster, conditionalCluster, index, application, runAs);
8787
}
8888

0 commit comments

Comments
 (0)