mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 11:58:04 +01:00
Correct envelope types for certain iOS builds
This commit is contained in:
committed by
Jon Chambers
parent
11f1cf80bd
commit
1461bcc2c2
@@ -218,6 +218,38 @@ class MessageControllerTest {
|
||||
assertTrue(captor.getValue().hasSourceDevice());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void testSingleDeviceCurrentBadType(final String userAgentString, final boolean expectAcceptMessage) throws Exception {
|
||||
Response response =
|
||||
resources.getJerseyTest()
|
||||
.target(String.format("/v1/messages/%s", SINGLE_DEVICE_UUID))
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||
.header("User-Agent", userAgentString)
|
||||
.put(Entity.entity(mapper.readValue(jsonFixture("fixtures/current_message_single_device_bad_type.json"), IncomingMessageList.class),
|
||||
MediaType.APPLICATION_JSON_TYPE));
|
||||
|
||||
if (expectAcceptMessage) {
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
final ArgumentCaptor<Envelope> captor = ArgumentCaptor.forClass(Envelope.class);
|
||||
verify(messageSender).sendMessage(any(Account.class), any(Device.class), captor.capture(), eq(false));
|
||||
} else {
|
||||
assertEquals(400, response.getStatus());
|
||||
verify(messageSender, never()).sendMessage(any(), any(), any(), anyBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
private static Stream<Arguments> testSingleDeviceCurrentBadType() {
|
||||
return Stream.of(
|
||||
Arguments.of(String.format("Signal-iOS/%s iOS/14.2", MessageController.FIRST_IOS_VERSION_WITH_INCORRECT_ENVELOPE_TYPE), true),
|
||||
Arguments.of(String.format("Signal-iOS/%s iOS/14.2", MessageController.FIRST_IOS_VERSION_WITH_INCORRECT_ENVELOPE_TYPE.nextPatch()), true),
|
||||
Arguments.of(String.format("Signal-iOS/%s iOS/14.2", MessageController.IOS_VERSION_WITH_FIXED_ENVELOPE_TYPE.withIncMinor(-1)), true),
|
||||
Arguments.of(String.format("Signal-iOS/%s iOS/14.2", MessageController.IOS_VERSION_WITH_FIXED_ENVELOPE_TYPE), false)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullMessageInList() throws Exception {
|
||||
Response response =
|
||||
|
||||
Reference in New Issue
Block a user