diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/BufferingInterceptorIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/BufferingInterceptorIntegrationTest.java index b785a0732..a56009ffd 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/BufferingInterceptorIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/BufferingInterceptorIntegrationTest.java @@ -64,14 +64,14 @@ public class BufferingInterceptorIntegrationTest { @Path("/virtual/{size}") @ManagedAsync public String getVirtual(@PathParam("size") int size) { - return RandomStringUtils.randomAscii(size); + return RandomStringUtils.secure().nextAscii(size); } @GET @Produces(MediaType.APPLICATION_JSON) @Path("/platform/{size}") public String getPlatform(@PathParam("size") int size) { - return RandomStringUtils.randomAscii(size); + return RandomStringUtils.secure().nextAscii(size); } } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/WebsocketResourceProviderIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/WebsocketResourceProviderIntegrationTest.java index 8d30d203f..fd68380c5 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/WebsocketResourceProviderIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/WebsocketResourceProviderIntegrationTest.java @@ -123,7 +123,7 @@ public class WebsocketResourceProviderIntegrationTest { @Path("/{size}") @ManagedAsync public String get(@PathParam("size") int size) { - return RandomStringUtils.randomAscii(size); + return RandomStringUtils.secure().nextAscii(size); } @PUT diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/auth/OptionalAccessTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/auth/OptionalAccessTest.java index 515c7999a..601a374f0 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/auth/OptionalAccessTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/auth/OptionalAccessTest.java @@ -51,7 +51,7 @@ class OptionalAccessTest { } private static List verify() { - final String unidentifiedAccessKey = RandomStringUtils.randomAlphanumeric(16); + final String unidentifiedAccessKey = RandomStringUtils.secure().nextAlphanumeric(16); final Anonymous correctUakHeader = new Anonymous(Base64.getEncoder().encodeToString(unidentifiedAccessKey.getBytes())); @@ -180,7 +180,7 @@ class OptionalAccessTest { @Test void testTargetIdentifierIllegalArgument() { - final String unidentifiedAccessKey = RandomStringUtils.randomAlphanumeric(16); + final String unidentifiedAccessKey = RandomStringUtils.secure().nextAlphanumeric(16); final Anonymous correctUakHeader = new Anonymous(Base64.getEncoder().encodeToString(unidentifiedAccessKey.getBytes())); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java index d1192cbd7..c45bbc40c 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/controllers/DeviceControllerTest.java @@ -1005,8 +1005,8 @@ class DeviceControllerTest { } private static List waitForLinkedDeviceBadTokenIdentifierLength() { - return List.of(RandomStringUtils.randomAlphanumeric(DeviceController.MIN_TOKEN_IDENTIFIER_LENGTH - 1), - RandomStringUtils.randomAlphanumeric(DeviceController.MAX_TOKEN_IDENTIFIER_LENGTH + 1)); + return List.of(RandomStringUtils.secure().nextAlphanumeric(DeviceController.MIN_TOKEN_IDENTIFIER_LENGTH - 1), + RandomStringUtils.secure().nextAlphanumeric(DeviceController.MAX_TOKEN_IDENTIFIER_LENGTH + 1)); } @Test @@ -1177,7 +1177,7 @@ class DeviceControllerTest { @Test void recordRestoreAccountRequest() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(RestoreAccountRequest.Method.LOCAL_BACKUP); @@ -1195,7 +1195,7 @@ class DeviceControllerTest { @Test void recordRestoreAccountRequestBadToken() { - final String token = RandomStringUtils.randomAlphanumeric(128); + final String token = RandomStringUtils.secure().nextAlphanumeric(128); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(RestoreAccountRequest.Method.LOCAL_BACKUP); @@ -1210,7 +1210,7 @@ class DeviceControllerTest { @Test void recordRestoreAccountRequestInvalidRequest() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(null); try (final Response response = resources.getJerseyTest() @@ -1224,7 +1224,7 @@ class DeviceControllerTest { @Test void waitForDeviceTransferRequest() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(RestoreAccountRequest.Method.LOCAL_BACKUP); @@ -1243,7 +1243,7 @@ class DeviceControllerTest { @Test void waitForDeviceTransferRequestNoRequestIssued() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); when(accountsManager.waitForRestoreAccountRequest(eq(token), any())) .thenReturn(CompletableFuture.completedFuture(Optional.empty())); @@ -1260,7 +1260,7 @@ class DeviceControllerTest { @ParameterizedTest @ValueSource(ints = {0, -1, 3601}) void waitForDeviceTransferRequestBadTimeout(final int timeoutSeconds) { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); try (final Response response = resources.getJerseyTest() .target("/v1/devices/restore_account/" + token) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ValidatingInterceptorTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ValidatingInterceptorTest.java index 257b91ef3..99a3d222c 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ValidatingInterceptorTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/ValidatingInterceptorTest.java @@ -104,7 +104,7 @@ public class ValidatingInterceptorTest { @ParameterizedTest @ValueSource(ints = {0, 1, 2, 3, 4, 6, 1000}) public void testExactlySizeValidationFailure(final int size) throws Exception { - final String stringValue = RandomStringUtils.randomAlphanumeric(size); + final String stringValue = RandomStringUtils.secure().nextAlphanumeric(size); assertStatusException(Status.INVALID_ARGUMENT, () -> stub.validationsEndpoint( builderWithValidDefaults() .setFixedSizeString(stringValue) @@ -119,7 +119,7 @@ public class ValidatingInterceptorTest { )); final List listValue = IntStream.range(0, size) - .mapToObj(i -> RandomStringUtils.randomAlphabetic(10)) + .mapToObj(i -> RandomStringUtils.secure().nextAlphabetic(10)) .toList(); assertStatusException(Status.INVALID_ARGUMENT, () -> stub.validationsEndpoint( builderWithValidDefaults() @@ -181,7 +181,7 @@ public class ValidatingInterceptorTest { @ParameterizedTest @MethodSource public void testRangeSizeValidationFailure(final int size, final Status expectedStatus) throws Exception { - final String stringValue = RandomStringUtils.randomAlphanumeric(size); + final String stringValue = RandomStringUtils.secure().nextAlphanumeric(size); assertEquals(expectedStatus.getCode(), requestStatus(() -> stub.validationsEndpoint( builderWithValidDefaults() .setRangeSizeString(stringValue) @@ -196,7 +196,7 @@ public class ValidatingInterceptorTest { )).getCode()); final List listValue = IntStream.range(0, size) - .mapToObj(i -> RandomStringUtils.randomAlphabetic(10)) + .mapToObj(i -> RandomStringUtils.secure().nextAlphabetic(10)) .toList(); assertEquals(expectedStatus.getCode(), requestStatus(() -> stub.validationsEndpoint( builderWithValidDefaults() diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/NoiseWebSocketTunnelServerIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/NoiseWebSocketTunnelServerIntegrationTest.java index c637f7ac0..5a28b617a 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/NoiseWebSocketTunnelServerIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/NoiseWebSocketTunnelServerIntegrationTest.java @@ -101,7 +101,7 @@ class NoiseWebSocketTunnelServerIntegrationTest extends AbstractLeakDetectionTes private static final UUID ACCOUNT_IDENTIFIER = UUID.randomUUID(); private static final byte DEVICE_ID = Device.PRIMARY_ID; - private static final String RECOGNIZED_PROXY_SECRET = RandomStringUtils.randomAlphanumeric(16); + private static final String RECOGNIZED_PROXY_SECRET = RandomStringUtils.secure().nextAlphanumeric(16); // Please note that this certificate/key are used only for testing and are not used anywhere outside of this test. // They were generated with: diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/WebsocketHandshakeCompleteHandlerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/WebsocketHandshakeCompleteHandlerTest.java index 9c33db141..24436a593 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/WebsocketHandshakeCompleteHandlerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/grpc/net/WebsocketHandshakeCompleteHandlerTest.java @@ -38,7 +38,7 @@ class WebsocketHandshakeCompleteHandlerTest extends AbstractLeakDetectionTest { private UserEventRecordingHandler userEventRecordingHandler; private MutableRemoteAddressEmbeddedChannel embeddedChannel; - private static final String RECOGNIZED_PROXY_SECRET = RandomStringUtils.randomAlphanumeric(16); + private static final String RECOGNIZED_PROXY_SECRET = RandomStringUtils.secure().nextAlphanumeric(16); private static class UserEventRecordingHandler extends ChannelInboundHandlerAdapter { diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java index f3805a7e4..250ff3285 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/push/APNSenderTest.java @@ -37,7 +37,7 @@ import org.whispersystems.textsecuregcm.tests.util.SynchronousExecutorService; class APNSenderTest { - private static final String DESTINATION_DEVICE_TOKEN = RandomStringUtils.randomAlphanumeric(32); + private static final String DESTINATION_DEVICE_TOKEN = RandomStringUtils.secure().nextAlphanumeric(32); private static final String BUNDLE_ID = "org.signal.test"; private Account destinationAccount; diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/push/MessageSenderTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/push/MessageSenderTest.java index bbca79b13..a5772bcaf 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/push/MessageSenderTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/push/MessageSenderTest.java @@ -128,7 +128,7 @@ class MessageSenderTest { return MessageProtos.Envelope.newBuilder() .setClientTimestamp(System.currentTimeMillis()) .setServerTimestamp(System.currentTimeMillis()) - .setContent(ByteString.copyFromUtf8(RandomStringUtils.randomAlphanumeric(256))) + .setContent(ByteString.copyFromUtf8(RandomStringUtils.secure().nextAlphanumeric(256))) .setType(MessageProtos.Envelope.Type.CIPHERTEXT) .setServerGuid(UUID.randomUUID().toString()) .build(); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationSchedulerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationSchedulerTest.java index 15245f9e3..ebfb7f259 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationSchedulerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/push/PushNotificationSchedulerTest.java @@ -55,7 +55,7 @@ class PushNotificationSchedulerTest { private static final UUID ACCOUNT_UUID = UUID.randomUUID(); private static final String ACCOUNT_NUMBER = "+18005551234"; private static final byte DEVICE_ID = 1; - private static final String APN_ID = RandomStringUtils.randomAlphanumeric(32); + private static final String APN_ID = RandomStringUtils.secure().nextAlphanumeric(32); @BeforeEach void setUp() throws Exception { diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/securestorage/SecureStorageClientTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/securestorage/SecureStorageClientTest.java index 44e9ddf58..2868dd84a 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/securestorage/SecureStorageClientTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/securestorage/SecureStorageClientTest.java @@ -122,8 +122,8 @@ class SecureStorageClientTest { @Test void deleteStoredData() { - final String username = RandomStringUtils.randomAlphabetic(16); - final String password = RandomStringUtils.randomAlphanumeric(32); + final String username = RandomStringUtils.secure().nextAlphabetic(16); + final String password = RandomStringUtils.secure().nextAlphanumeric(32); when(credentialsGenerator.generateForUuid(accountUuid)).thenReturn( new ExternalServiceCredentials(username, password)); @@ -139,8 +139,8 @@ class SecureStorageClientTest { @Test void deleteStoredDataFailure() { - final String username = RandomStringUtils.randomAlphabetic(16); - final String password = RandomStringUtils.randomAlphanumeric(32); + final String username = RandomStringUtils.secure().nextAlphabetic(16); + final String password = RandomStringUtils.secure().nextAlphanumeric(32); when(credentialsGenerator.generateForUuid(accountUuid)).thenReturn( new ExternalServiceCredentials(username, password)); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/securevaluerecovery/SecureValueRecovery2ClientTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/securevaluerecovery/SecureValueRecovery2ClientTest.java index 9e21628d8..29097956d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/securevaluerecovery/SecureValueRecovery2ClientTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/securevaluerecovery/SecureValueRecovery2ClientTest.java @@ -121,8 +121,8 @@ class SecureValueRecovery2ClientTest { @Test void deleteStoredData() { - final String username = RandomStringUtils.randomAlphabetic(16); - final String password = RandomStringUtils.randomAlphanumeric(32); + final String username = RandomStringUtils.secure().nextAlphabetic(16); + final String password = RandomStringUtils.secure().nextAlphanumeric(32); when(credentialsGenerator.generateForUuid(accountUuid)).thenReturn( new ExternalServiceCredentials(username, password)); @@ -136,8 +136,8 @@ class SecureValueRecovery2ClientTest { @Test void deleteStoredDataFailure() { - final String username = RandomStringUtils.randomAlphabetic(16); - final String password = RandomStringUtils.randomAlphanumeric(32); + final String username = RandomStringUtils.secure().nextAlphabetic(16); + final String password = RandomStringUtils.secure().nextAlphanumeric(32); when(credentialsGenerator.generateForUuid(accountUuid)).thenReturn( new ExternalServiceCredentials(username, password)); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountCreationDeletionIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountCreationDeletionIntegrationTest.java index 809ee1976..146d849cc 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountCreationDeletionIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountCreationDeletionIntegrationTest.java @@ -23,7 +23,6 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadLocalRandom; @@ -182,12 +181,12 @@ public class AccountCreationDeletionIntegrationTest { PhoneNumberUtil.getInstance().getExampleNumber("US"), PhoneNumberUtil.PhoneNumberFormat.E164); - final String password = RandomStringUtils.randomAlphanumeric(16); - final String signalAgent = RandomStringUtils.randomAlphabetic(3); + final String password = RandomStringUtils.secure().nextAlphanumeric(16); + final String signalAgent = RandomStringUtils.secure().nextAlphabetic(3); final int registrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); final int pniRegistrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); - final byte[] deviceName = RandomStringUtils.randomAlphabetic(16).getBytes(StandardCharsets.UTF_8); - final String registrationLockSecret = RandomStringUtils.randomAlphanumeric(16); + final byte[] deviceName = RandomStringUtils.secure().nextAlphabetic(16).getBytes(StandardCharsets.UTF_8); + final String registrationLockSecret = RandomStringUtils.secure().nextAlphanumeric(16); final Set deviceCapabilities = Set.of(); @@ -200,7 +199,7 @@ public class AccountCreationDeletionIntegrationTest { deviceCapabilities); final List badges = new ArrayList<>(List.of(new AccountBadge( - RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.secure().nextAlphabetic(8), CLOCK.instant().plus(Duration.ofDays(7)), true))); @@ -323,12 +322,12 @@ public class AccountCreationDeletionIntegrationTest { existingAccountUuid = originalAccount.getUuid(); } - final String password = RandomStringUtils.randomAlphanumeric(16); - final String signalAgent = RandomStringUtils.randomAlphabetic(3); + final String password = RandomStringUtils.secure().nextAlphanumeric(16); + final String signalAgent = RandomStringUtils.secure().nextAlphabetic(3); final int registrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); final int pniRegistrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); - final byte[] deviceName = RandomStringUtils.randomAlphabetic(16).getBytes(StandardCharsets.UTF_8); - final String registrationLockSecret = RandomStringUtils.randomAlphanumeric(16); + final byte[] deviceName = RandomStringUtils.secure().nextAlphabetic(16).getBytes(StandardCharsets.UTF_8); + final String registrationLockSecret = RandomStringUtils.secure().nextAlphanumeric(16); final Set deviceCapabilities = Set.of(); @@ -341,7 +340,7 @@ public class AccountCreationDeletionIntegrationTest { deviceCapabilities); final List badges = new ArrayList<>(List.of(new AccountBadge( - RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.secure().nextAlphabetic(8), CLOCK.instant().plus(Duration.ofDays(7)), true))); @@ -412,12 +411,12 @@ public class AccountCreationDeletionIntegrationTest { PhoneNumberUtil.getInstance().getExampleNumber("US"), PhoneNumberUtil.PhoneNumberFormat.E164); - final String password = RandomStringUtils.randomAlphanumeric(16); - final String signalAgent = RandomStringUtils.randomAlphabetic(3); + final String password = RandomStringUtils.secure().nextAlphanumeric(16); + final String signalAgent = RandomStringUtils.secure().nextAlphabetic(3); final int registrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); final int pniRegistrationId = ThreadLocalRandom.current().nextInt(Device.MAX_REGISTRATION_ID); - final byte[] deviceName = RandomStringUtils.randomAlphabetic(16).getBytes(StandardCharsets.UTF_8); - final String registrationLockSecret = RandomStringUtils.randomAlphanumeric(16); + final byte[] deviceName = RandomStringUtils.secure().nextAlphabetic(16).getBytes(StandardCharsets.UTF_8); + final String registrationLockSecret = RandomStringUtils.secure().nextAlphanumeric(16); final Set deviceCapabilities = Set.of(); @@ -430,7 +429,7 @@ public class AccountCreationDeletionIntegrationTest { deviceCapabilities); final List badges = new ArrayList<>(List.of(new AccountBadge( - RandomStringUtils.randomAlphabetic(8), + RandomStringUtils.secure().nextAlphabetic(8), CLOCK.instant().plus(Duration.ofDays(7)), true))); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerDeviceTransferIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerDeviceTransferIntegrationTest.java index 28916b73e..60f898421 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerDeviceTransferIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/AccountsManagerDeviceTransferIntegrationTest.java @@ -151,7 +151,7 @@ public class AccountsManagerDeviceTransferIntegrationTest { @Test void waitForRestoreAccountRequest() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(RestoreAccountRequest.Method.DEVICE_TRANSFER); @@ -170,7 +170,7 @@ public class AccountsManagerDeviceTransferIntegrationTest { @Test void waitForRestoreAccountRequestAlreadyRequested() { - final String token = RandomStringUtils.randomAlphanumeric(16); + final String token = RandomStringUtils.secure().nextAlphanumeric(16); final RestoreAccountRequest restoreAccountRequest = new RestoreAccountRequest(RestoreAccountRequest.Method.DEVICE_TRANSFER); @@ -183,6 +183,7 @@ public class AccountsManagerDeviceTransferIntegrationTest { @Test void waitForRestoreAccountRequestTimeout() { assertEquals(Optional.empty(), - accountsManager.waitForRestoreAccountRequest(RandomStringUtils.randomAlphanumeric(16), Duration.ofMillis(1)).join()); + accountsManager.waitForRestoreAccountRequest(RandomStringUtils.secure().nextAlphanumeric(16), + Duration.ofMillis(1)).join()); } } diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterIntegrationTest.java index cfb873ae7..bd2af221b 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterIntegrationTest.java @@ -197,7 +197,7 @@ class MessagePersisterIntegrationTest { return MessageProtos.Envelope.newBuilder() .setClientTimestamp(serverTimestamp * 2) // client timestamp may not be accurate .setServerTimestamp(serverTimestamp) - .setContent(ByteString.copyFromUtf8(RandomStringUtils.randomAlphanumeric(256))) + .setContent(ByteString.copyFromUtf8(RandomStringUtils.secure().nextAlphanumeric(256))) .setType(MessageProtos.Envelope.Type.CIPHERTEXT) .setServerGuid(messageGuid.toString()) .setDestinationServiceId(UUID.randomUUID().toString()) diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterTest.java index 07d6a6a9f..56c32ffd7 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagePersisterTest.java @@ -353,7 +353,7 @@ class MessagePersisterTest { .setDestinationServiceId(accountUuid.toString()) .setClientTimestamp(firstMessageTimestamp.toEpochMilli() + i) .setServerTimestamp(firstMessageTimestamp.toEpochMilli() + i) - .setContent(ByteString.copyFromUtf8(RandomStringUtils.randomAlphanumeric(256))) + .setContent(ByteString.copyFromUtf8(RandomStringUtils.secure().nextAlphanumeric(256))) .setType(MessageProtos.Envelope.Type.CIPHERTEXT) .setServerGuid(messageGuid.toString()) .build(); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagesCacheTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagesCacheTest.java index fbee9514c..6c0f2a8d9 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagesCacheTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/storage/MessagesCacheTest.java @@ -827,7 +827,7 @@ class MessagesCacheTest { final MessageProtos.Envelope.Builder envelopeBuilder = MessageProtos.Envelope.newBuilder() .setClientTimestamp(timestamp) .setServerTimestamp(timestamp) - .setContent(ByteString.copyFromUtf8(RandomStringUtils.randomAlphanumeric(256))) + .setContent(ByteString.copyFromUtf8(RandomStringUtils.secure().nextAlphanumeric(256))) .setType(MessageProtos.Envelope.Type.CIPHERTEXT) .setServerGuid(messageGuid.toString()) .setDestinationServiceId(destinationServiceId.toServiceIdentifierString()); diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnectionIntegrationTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnectionIntegrationTest.java index 065ec7dc5..576a4cbed 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnectionIntegrationTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/websocket/WebSocketConnectionIntegrationTest.java @@ -389,7 +389,7 @@ class WebSocketConnectionIntegrationTest { return MessageProtos.Envelope.newBuilder() .setClientTimestamp(timestamp) .setServerTimestamp(timestamp) - .setContent(ByteString.copyFromUtf8(RandomStringUtils.randomAlphanumeric(256))) + .setContent(ByteString.copyFromUtf8(RandomStringUtils.secure().nextAlphanumeric(256))) .setType(MessageProtos.Envelope.Type.CIPHERTEXT) .setServerGuid(messageGuid.toString()) .setDestinationServiceId(UUID.randomUUID().toString())