Update validation for NotNull items in IncomingMessagesList
This commit is contained in:
parent
3608c5bfb0
commit
13447df1e0
|
@ -4,21 +4,17 @@
|
||||||
*/
|
*/
|
||||||
package org.whispersystems.textsecuregcm.entities;
|
package org.whispersystems.textsecuregcm.entities;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import java.util.List;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class IncomingMessageList {
|
public class IncomingMessageList {
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
@JsonInclude(Include.NON_NULL)
|
private List<@NotNull IncomingMessage> messages;
|
||||||
private List<IncomingMessage> messages;
|
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private long timestamp;
|
private long timestamp;
|
||||||
|
|
|
@ -247,6 +247,19 @@ class MessageControllerTest {
|
||||||
assertTrue(captor.getValue().hasSourceDevice());
|
assertTrue(captor.getValue().hasSourceDevice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testNullMessageInList() throws Exception {
|
||||||
|
Response response =
|
||||||
|
resources.getJerseyTest()
|
||||||
|
.target(String.format("/v1/messages/%s", SINGLE_DEVICE_RECIPIENT))
|
||||||
|
.request()
|
||||||
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||||
|
.put(Entity.entity(mapper.readValue(jsonFixture("fixtures/current_message_null_message_in_list.json"), IncomingMessageList.class),
|
||||||
|
MediaType.APPLICATION_JSON_TYPE));
|
||||||
|
|
||||||
|
assertThat("Bad request", response.getStatus(), is(equalTo(422)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testInternationalUnsealedSenderFromRateLimitedHost() throws Exception {
|
void testInternationalUnsealedSenderFromRateLimitedHost() throws Exception {
|
||||||
final String senderHost = "10.0.0.1";
|
final String senderHost = "10.0.0.1";
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"messages" : [ {
|
||||||
|
"type" : 1,
|
||||||
|
"destinationDeviceId" : 1,
|
||||||
|
"body" : "Zm9vYmFyego",
|
||||||
|
"timestamp" : 1234
|
||||||
|
}, null ]
|
||||||
|
}
|
Loading…
Reference in New Issue