Fix internal server error when sending stories to unknown recipient.

This commit is contained in:
erik-signal
2022-10-06 13:53:57 -04:00
committed by GitHub
parent 0d20b73e76
commit d6c9652a70
2 changed files with 30 additions and 2 deletions

View File

@@ -846,6 +846,23 @@ class MessageControllerTest {
);
}
@Test
void testSendStoryToUnknownAccount() throws Exception {
String accessBytes = Base64.getEncoder().encodeToString(UNIDENTIFIED_ACCESS_BYTES);
String json = jsonFixture("fixtures/current_message_single_device.json");
UUID unknownUUID = UUID.randomUUID();
IncomingMessageList list = SystemMapper.getMapper().readValue(json, IncomingMessageList.class);
Response response =
resources.getJerseyTest()
.target(String.format("/v1/messages/%s", unknownUUID))
.queryParam("story", "true")
.request()
.header(OptionalAccess.UNIDENTIFIED, accessBytes)
.put(Entity.entity(list, MediaType.APPLICATION_JSON_TYPE));
assertThat("200 masks unknown recipient", response.getStatus(), is(equalTo(200)));
}
private void checkBadMultiRecipientResponse(Response response, int expectedCode) throws Exception {
assertThat("Unexpected response", response.getStatus(), is(equalTo(expectedCode)));
verify(messageSender, never()).sendMessage(any(), any(), any(), anyBoolean());