Add registrationId tests.
This commit is contained in:
parent
f4ecb5d7be
commit
6aaca59020
|
@ -10,6 +10,7 @@ import org.whispersystems.textsecuregcm.entities.AccountAttributes;
|
||||||
import org.whispersystems.textsecuregcm.entities.IncomingMessageList;
|
import org.whispersystems.textsecuregcm.entities.IncomingMessageList;
|
||||||
import org.whispersystems.textsecuregcm.entities.MessageProtos;
|
import org.whispersystems.textsecuregcm.entities.MessageProtos;
|
||||||
import org.whispersystems.textsecuregcm.entities.MismatchedDevices;
|
import org.whispersystems.textsecuregcm.entities.MismatchedDevices;
|
||||||
|
import org.whispersystems.textsecuregcm.entities.StaleDevices;
|
||||||
import org.whispersystems.textsecuregcm.federation.FederatedClientManager;
|
import org.whispersystems.textsecuregcm.federation.FederatedClientManager;
|
||||||
import org.whispersystems.textsecuregcm.limits.RateLimiter;
|
import org.whispersystems.textsecuregcm.limits.RateLimiter;
|
||||||
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
import org.whispersystems.textsecuregcm.limits.RateLimiters;
|
||||||
|
@ -151,4 +152,23 @@ public class MessageControllerTest extends ResourceTest {
|
||||||
verify(pushSender, times(2)).sendMessage(any(Account.class), any(Device.class), any(MessageProtos.OutgoingMessageSignal.class));
|
verify(pushSender, times(2)).sendMessage(any(Account.class), any(Device.class), any(MessageProtos.OutgoingMessageSignal.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testRegistrationIdMismatch() throws Exception {
|
||||||
|
ClientResponse response =
|
||||||
|
client().resource(String.format("/v1/messages/%s", MULTI_DEVICE_RECIPIENT))
|
||||||
|
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||||
|
.entity(mapper.readValue(jsonFixture("fixtures/current_message_registration_id.json"), IncomingMessageList.class))
|
||||||
|
.type(MediaType.APPLICATION_JSON_TYPE)
|
||||||
|
.put(ClientResponse.class);
|
||||||
|
|
||||||
|
assertThat("Good Response Code", response.getStatus(), is(equalTo(410)));
|
||||||
|
|
||||||
|
assertThat("Good Response Body",
|
||||||
|
asJson(response.getEntity(StaleDevices.class)),
|
||||||
|
is(equalTo(jsonFixture("fixtures/mismatched_registration_id.json"))));
|
||||||
|
|
||||||
|
verifyNoMoreInteractions(pushSender);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
"messages" : [{
|
"messages" : [{
|
||||||
"type" : 1,
|
"type" : 1,
|
||||||
"destinationDeviceId" : 1,
|
"destinationDeviceId" : 1,
|
||||||
|
"destinationRegistrationId" : 222,
|
||||||
"body" : "Zm9vYmFyego",
|
"body" : "Zm9vYmFyego",
|
||||||
"timestamp" : 1234
|
"timestamp" : 1234
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type" : 1,
|
"type" : 1,
|
||||||
"destinationDeviceId" : 2,
|
"destinationDeviceId" : 2,
|
||||||
|
"destinationRegistrationId" : 333,
|
||||||
"body" : "Zm9vYmFyego",
|
"body" : "Zm9vYmFyego",
|
||||||
"timestamp" : 1234
|
"timestamp" : 1234
|
||||||
}]
|
}]
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{
|
||||||
|
"messages" : [{
|
||||||
|
"type" : 1,
|
||||||
|
"destinationDeviceId" : 1,
|
||||||
|
"destinationRegistrationId" : 222,
|
||||||
|
"body" : "Zm9vYmFyego",
|
||||||
|
"timestamp" : 1234
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type" : 1,
|
||||||
|
"destinationDeviceId" : 2,
|
||||||
|
"destinationRegistrationId" : 999,
|
||||||
|
"body" : "Zm9vYmFyego",
|
||||||
|
"timestamp" : 1234
|
||||||
|
}]
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"staleDevices" : [2]
|
||||||
|
}
|
Loading…
Reference in New Issue