[Test] fix bug where random byte may be the same as the byte being changed
Original commit: elastic/x-pack-elasticsearch@657d38fbca
This commit is contained in:
parent
03a00201ab
commit
7366c95994
|
@ -223,7 +223,12 @@ public class InternalCryptoServiceTests extends ElasticsearchTestCase {
|
|||
assertThat(Arrays.equals(encrypted, bytes), is(false));
|
||||
|
||||
int tamperedIndex = randomIntBetween(0, encrypted.length - 1);
|
||||
encrypted[tamperedIndex] = randomByte();
|
||||
final byte untamperedByte = encrypted[tamperedIndex];
|
||||
byte tamperedByte = randomByte();
|
||||
while (tamperedByte == untamperedByte) {
|
||||
tamperedByte = randomByte();
|
||||
}
|
||||
encrypted[tamperedIndex] = tamperedByte;
|
||||
final byte[] decrypted = service.decrypt(encrypted);
|
||||
assertThat(Arrays.equals(bytes, decrypted), is(false));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue