Renamed 'device key' to 'signed prekey'.
This commit is contained in:
parent
06f80c320d
commit
b724ea8d3b
|
@ -130,7 +130,7 @@ public class FederationController {
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
return keysControllerV2.getDeviceKey(new NonLimitedAccount("Unknown", -1, peer.getName()),
|
return keysControllerV2.getDeviceKeys(new NonLimitedAccount("Unknown", -1, peer.getName()),
|
||||||
number, device, Optional.<String>absent());
|
number, device, Optional.<String>absent());
|
||||||
} catch (RateLimitExceededException e) {
|
} catch (RateLimitExceededException e) {
|
||||||
logger.warn("Rate limiting on federated channel", e);
|
logger.warn("Rate limiting on federated channel", e);
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.whispersystems.textsecuregcm.controllers;
|
||||||
|
|
||||||
import com.codahale.metrics.annotation.Timed;
|
import com.codahale.metrics.annotation.Timed;
|
||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
import org.whispersystems.textsecuregcm.entities.DeviceKey;
|
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseItemV2;
|
import org.whispersystems.textsecuregcm.entities.PreKeyResponseItemV2;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV2;
|
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV2;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyStateV2;
|
import org.whispersystems.textsecuregcm.entities.PreKeyStateV2;
|
||||||
|
@ -66,8 +66,8 @@ public class KeysControllerV2 extends KeysController {
|
||||||
Device device = account.getAuthenticatedDevice().get();
|
Device device = account.getAuthenticatedDevice().get();
|
||||||
boolean updateAccount = false;
|
boolean updateAccount = false;
|
||||||
|
|
||||||
if (!preKeys.getDeviceKey().equals(device.getDeviceKey())) {
|
if (!preKeys.getSignedPreKey().equals(device.getSignedPreKey())) {
|
||||||
device.setDeviceKey(preKeys.getDeviceKey());
|
device.setSignedPreKey(preKeys.getSignedPreKey());
|
||||||
updateAccount = true;
|
updateAccount = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +85,11 @@ public class KeysControllerV2 extends KeysController {
|
||||||
|
|
||||||
@Timed
|
@Timed
|
||||||
@PUT
|
@PUT
|
||||||
@Path("/device")
|
@Path("/signed")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public void setDeviceKey(@Auth Account account, @Valid DeviceKey deviceKey) {
|
public void setSignedKey(@Auth Account account, @Valid SignedPreKey signedPreKey) {
|
||||||
Device device = account.getAuthenticatedDevice().get();
|
Device device = account.getAuthenticatedDevice().get();
|
||||||
device.setDeviceKey(deviceKey);
|
device.setSignedPreKey(signedPreKey);
|
||||||
accounts.update(account);
|
accounts.update(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class KeysControllerV2 extends KeysController {
|
||||||
@GET
|
@GET
|
||||||
@Path("/{number}/{device_id}")
|
@Path("/{number}/{device_id}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Optional<PreKeyResponseV2> getDeviceKey(@Auth Account account,
|
public Optional<PreKeyResponseV2> getDeviceKeys(@Auth Account account,
|
||||||
@PathParam("number") String number,
|
@PathParam("number") String number,
|
||||||
@PathParam("device_id") String deviceId,
|
@PathParam("device_id") String deviceId,
|
||||||
@QueryParam("relay") Optional<String> relay)
|
@QueryParam("relay") Optional<String> relay)
|
||||||
|
@ -118,7 +118,7 @@ public class KeysControllerV2 extends KeysController {
|
||||||
|
|
||||||
for (Device device : destination.getDevices()) {
|
for (Device device : destination.getDevices()) {
|
||||||
if (device.isActive() && (deviceId.equals("*") || device.getId() == Long.parseLong(deviceId))) {
|
if (device.isActive() && (deviceId.equals("*") || device.getId() == Long.parseLong(deviceId))) {
|
||||||
DeviceKey deviceKey = device.getDeviceKey();
|
SignedPreKey signedPreKey = device.getSignedPreKey();
|
||||||
PreKeyV2 preKey = null;
|
PreKeyV2 preKey = null;
|
||||||
|
|
||||||
if (targetKeys.getKeys().isPresent()) {
|
if (targetKeys.getKeys().isPresent()) {
|
||||||
|
@ -129,8 +129,8 @@ public class KeysControllerV2 extends KeysController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceKey != null || preKey != null) {
|
if (signedPreKey != null || preKey != null) {
|
||||||
devices.add(new PreKeyResponseItemV2(device.getId(), device.getRegistrationId(), deviceKey, preKey));
|
devices.add(new PreKeyResponseItemV2(device.getId(), device.getRegistrationId(), signedPreKey, preKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,23 +28,23 @@ public class PreKeyResponseItemV2 {
|
||||||
private int registrationId;
|
private int registrationId;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private DeviceKey deviceKey;
|
private SignedPreKey signedPreKey;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private PreKeyV2 preKey;
|
private PreKeyV2 preKey;
|
||||||
|
|
||||||
public PreKeyResponseItemV2() {}
|
public PreKeyResponseItemV2() {}
|
||||||
|
|
||||||
public PreKeyResponseItemV2(long deviceId, int registrationId, DeviceKey deviceKey, PreKeyV2 preKey) {
|
public PreKeyResponseItemV2(long deviceId, int registrationId, SignedPreKey signedPreKey, PreKeyV2 preKey) {
|
||||||
this.deviceId = deviceId;
|
this.deviceId = deviceId;
|
||||||
this.registrationId = registrationId;
|
this.registrationId = registrationId;
|
||||||
this.deviceKey = deviceKey;
|
this.signedPreKey = signedPreKey;
|
||||||
this.preKey = preKey;
|
this.preKey = preKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public DeviceKey getDeviceKey() {
|
public SignedPreKey getSignedPreKey() {
|
||||||
return deviceKey;
|
return signedPreKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PreKeyStateV2 {
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotNull
|
@NotNull
|
||||||
@Valid
|
@Valid
|
||||||
private DeviceKey deviceKey;
|
private SignedPreKey signedPreKey;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -49,9 +49,11 @@ public class PreKeyStateV2 {
|
||||||
public PreKeyStateV2() {}
|
public PreKeyStateV2() {}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public PreKeyStateV2(String identityKey, DeviceKey deviceKey, List<PreKeyV2> keys, PreKeyV2 lastResortKey) {
|
public PreKeyStateV2(String identityKey, SignedPreKey signedPreKey,
|
||||||
|
List<PreKeyV2> keys, PreKeyV2 lastResortKey)
|
||||||
|
{
|
||||||
this.identityKey = identityKey;
|
this.identityKey = identityKey;
|
||||||
this.deviceKey = deviceKey;
|
this.signedPreKey = signedPreKey;
|
||||||
this.preKeys = keys;
|
this.preKeys = keys;
|
||||||
this.lastResortKey = lastResortKey;
|
this.lastResortKey = lastResortKey;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +62,8 @@ public class PreKeyStateV2 {
|
||||||
return preKeys;
|
return preKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceKey getDeviceKey() {
|
public SignedPreKey getSignedPreKey() {
|
||||||
return deviceKey;
|
return signedPreKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIdentityKey() {
|
public String getIdentityKey() {
|
||||||
|
|
|
@ -5,15 +5,15 @@ import org.hibernate.validator.constraints.NotEmpty;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
public class DeviceKey extends PreKeyV2 implements Serializable {
|
public class SignedPreKey extends PreKeyV2 implements Serializable {
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String signature;
|
private String signature;
|
||||||
|
|
||||||
public DeviceKey() {}
|
public SignedPreKey() {}
|
||||||
|
|
||||||
public DeviceKey(long keyId, String publicKey, String signature) {
|
public SignedPreKey(long keyId, String publicKey, String signature) {
|
||||||
super(keyId, publicKey);
|
super(keyId, publicKey);
|
||||||
this.signature = signature;
|
this.signature = signature;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ public class DeviceKey extends PreKeyV2 implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (object == null || !(object instanceof DeviceKey)) return false;
|
if (object == null || !(object instanceof SignedPreKey)) return false;
|
||||||
DeviceKey that = (DeviceKey) object;
|
SignedPreKey that = (SignedPreKey) object;
|
||||||
|
|
||||||
if (signature == null) {
|
if (signature == null) {
|
||||||
return super.equals(object) && that.signature == null;
|
return super.equals(object) && that.signature == null;
|
|
@ -19,8 +19,7 @@ package org.whispersystems.textsecuregcm.storage;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
|
import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
|
||||||
import org.whispersystems.textsecuregcm.entities.DeviceKey;
|
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyV2;
|
|
||||||
import org.whispersystems.textsecuregcm.util.Util;
|
import org.whispersystems.textsecuregcm.util.Util;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
@ -54,14 +53,14 @@ public class Device implements Serializable {
|
||||||
private int registrationId;
|
private int registrationId;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
private DeviceKey deviceKey;
|
private SignedPreKey signedPreKey;
|
||||||
|
|
||||||
public Device() {}
|
public Device() {}
|
||||||
|
|
||||||
public Device(long id, String authToken, String salt,
|
public Device(long id, String authToken, String salt,
|
||||||
String signalingKey, String gcmId, String apnId,
|
String signalingKey, String gcmId, String apnId,
|
||||||
boolean fetchesMessages, int registrationId,
|
boolean fetchesMessages, int registrationId,
|
||||||
DeviceKey deviceKey)
|
SignedPreKey signedPreKey)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.authToken = authToken;
|
this.authToken = authToken;
|
||||||
|
@ -71,7 +70,7 @@ public class Device implements Serializable {
|
||||||
this.apnId = apnId;
|
this.apnId = apnId;
|
||||||
this.fetchesMessages = fetchesMessages;
|
this.fetchesMessages = fetchesMessages;
|
||||||
this.registrationId = registrationId;
|
this.registrationId = registrationId;
|
||||||
this.deviceKey = deviceKey;
|
this.signedPreKey = signedPreKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getApnId() {
|
public String getApnId() {
|
||||||
|
@ -139,11 +138,11 @@ public class Device implements Serializable {
|
||||||
this.registrationId = registrationId;
|
this.registrationId = registrationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceKey getDeviceKey() {
|
public SignedPreKey getSignedPreKey() {
|
||||||
return deviceKey;
|
return signedPreKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceKey(DeviceKey deviceKey) {
|
public void setSignedPreKey(SignedPreKey signedPreKey) {
|
||||||
this.deviceKey = deviceKey;
|
this.signedPreKey = signedPreKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.junit.Test;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.whispersystems.textsecuregcm.controllers.KeysControllerV1;
|
import org.whispersystems.textsecuregcm.controllers.KeysControllerV1;
|
||||||
import org.whispersystems.textsecuregcm.controllers.KeysControllerV2;
|
import org.whispersystems.textsecuregcm.controllers.KeysControllerV2;
|
||||||
import org.whispersystems.textsecuregcm.entities.DeviceKey;
|
import org.whispersystems.textsecuregcm.entities.SignedPreKey;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyCount;
|
import org.whispersystems.textsecuregcm.entities.PreKeyCount;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV1;
|
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV1;
|
||||||
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV2;
|
import org.whispersystems.textsecuregcm.entities.PreKeyResponseV2;
|
||||||
|
@ -48,9 +48,9 @@ public class KeyControllerTest {
|
||||||
private final KeyRecord SAMPLE_KEY4 = new KeyRecord(4, EXISTS_NUMBER, 4, 336, "test6", false );
|
private final KeyRecord SAMPLE_KEY4 = new KeyRecord(4, EXISTS_NUMBER, 4, 336, "test6", false );
|
||||||
|
|
||||||
|
|
||||||
private final DeviceKey SAMPLE_DEVICE_KEY = new DeviceKey(1111, "foofoo", "sig11");
|
private final SignedPreKey SAMPLE_SIGNED_KEY = new SignedPreKey(1111, "foofoo", "sig11");
|
||||||
private final DeviceKey SAMPLE_DEVICE_KEY2 = new DeviceKey(2222, "foobar", "sig22");
|
private final SignedPreKey SAMPLE_SIGNED_KEY2 = new SignedPreKey(2222, "foobar", "sig22");
|
||||||
private final DeviceKey SAMPLE_DEVICE_KEY3 = new DeviceKey(3333, "barfoo", "sig33");
|
private final SignedPreKey SAMPLE_SIGNED_KEY3 = new SignedPreKey(3333, "barfoo", "sig33");
|
||||||
|
|
||||||
private final Keys keys = mock(Keys.class );
|
private final Keys keys = mock(Keys.class );
|
||||||
private final AccountsManager accounts = mock(AccountsManager.class);
|
private final AccountsManager accounts = mock(AccountsManager.class);
|
||||||
|
@ -88,10 +88,10 @@ public class KeyControllerTest {
|
||||||
when(sampleDevice2.isActive()).thenReturn(true);
|
when(sampleDevice2.isActive()).thenReturn(true);
|
||||||
when(sampleDevice3.isActive()).thenReturn(false);
|
when(sampleDevice3.isActive()).thenReturn(false);
|
||||||
when(sampleDevice4.isActive()).thenReturn(true);
|
when(sampleDevice4.isActive()).thenReturn(true);
|
||||||
when(sampleDevice.getDeviceKey()).thenReturn(SAMPLE_DEVICE_KEY);
|
when(sampleDevice.getSignedPreKey()).thenReturn(SAMPLE_SIGNED_KEY);
|
||||||
when(sampleDevice2.getDeviceKey()).thenReturn(SAMPLE_DEVICE_KEY2);
|
when(sampleDevice2.getSignedPreKey()).thenReturn(SAMPLE_SIGNED_KEY2);
|
||||||
when(sampleDevice3.getDeviceKey()).thenReturn(SAMPLE_DEVICE_KEY3);
|
when(sampleDevice3.getSignedPreKey()).thenReturn(SAMPLE_SIGNED_KEY3);
|
||||||
when(sampleDevice4.getDeviceKey()).thenReturn(null);
|
when(sampleDevice4.getSignedPreKey()).thenReturn(null);
|
||||||
when(sampleDevice.getId()).thenReturn(1L);
|
when(sampleDevice.getId()).thenReturn(1L);
|
||||||
when(sampleDevice2.getId()).thenReturn(2L);
|
when(sampleDevice2.getId()).thenReturn(2L);
|
||||||
when(sampleDevice3.getId()).thenReturn(3L);
|
when(sampleDevice3.getId()).thenReturn(3L);
|
||||||
|
@ -126,7 +126,7 @@ public class KeyControllerTest {
|
||||||
|
|
||||||
when(keys.getCount(eq(AuthHelper.VALID_NUMBER), eq(1L))).thenReturn(5);
|
when(keys.getCount(eq(AuthHelper.VALID_NUMBER), eq(1L))).thenReturn(5);
|
||||||
|
|
||||||
when(AuthHelper.VALID_DEVICE.getDeviceKey()).thenReturn(new DeviceKey(89898, "zoofarb", "sigvalid"));
|
when(AuthHelper.VALID_DEVICE.getSignedPreKey()).thenReturn(new SignedPreKey(89898, "zoofarb", "sigvalid"));
|
||||||
when(AuthHelper.VALID_ACCOUNT.getIdentityKey()).thenReturn(null);
|
when(AuthHelper.VALID_ACCOUNT.getIdentityKey()).thenReturn(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ public class KeyControllerTest {
|
||||||
assertThat(result.getDevices().size()).isEqualTo(1);
|
assertThat(result.getDevices().size()).isEqualTo(1);
|
||||||
assertThat(result.getDevices().get(0).getPreKey().getKeyId()).isEqualTo(SAMPLE_KEY.getKeyId());
|
assertThat(result.getDevices().get(0).getPreKey().getKeyId()).isEqualTo(SAMPLE_KEY.getKeyId());
|
||||||
assertThat(result.getDevices().get(0).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
assertThat(result.getDevices().get(0).getPreKey().getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||||
assertThat(result.getDevices().get(0).getDeviceKey()).isEqualTo(existsAccount.getDevice(1).get().getDeviceKey());
|
assertThat(result.getDevices().get(0).getSignedPreKey()).isEqualTo(existsAccount.getDevice(1).get().getSignedPreKey());
|
||||||
|
|
||||||
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
verify(keys).get(eq(EXISTS_NUMBER), eq(1L));
|
||||||
verifyNoMoreInteractions(keys);
|
verifyNoMoreInteractions(keys);
|
||||||
|
@ -226,7 +226,7 @@ public class KeyControllerTest {
|
||||||
assertThat(results.getDevices().size()).isEqualTo(3);
|
assertThat(results.getDevices().size()).isEqualTo(3);
|
||||||
assertThat(results.getIdentityKey()).isEqualTo(existsAccount.getIdentityKey());
|
assertThat(results.getIdentityKey()).isEqualTo(existsAccount.getIdentityKey());
|
||||||
|
|
||||||
PreKeyV2 deviceKey = results.getDevices().get(0).getDeviceKey();
|
PreKeyV2 signedPreKey = results.getDevices().get(0).getSignedPreKey();
|
||||||
PreKeyV2 preKey = results.getDevices().get(0).getPreKey();
|
PreKeyV2 preKey = results.getDevices().get(0).getPreKey();
|
||||||
long registrationId = results.getDevices().get(0).getRegistrationId();
|
long registrationId = results.getDevices().get(0).getRegistrationId();
|
||||||
long deviceId = results.getDevices().get(0).getDeviceId();
|
long deviceId = results.getDevices().get(0).getDeviceId();
|
||||||
|
@ -234,11 +234,11 @@ public class KeyControllerTest {
|
||||||
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY.getKeyId());
|
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY.getKeyId());
|
||||||
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY.getPublicKey());
|
||||||
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID);
|
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID);
|
||||||
assertThat(deviceKey.getKeyId()).isEqualTo(SAMPLE_DEVICE_KEY.getKeyId());
|
assertThat(signedPreKey.getKeyId()).isEqualTo(SAMPLE_SIGNED_KEY.getKeyId());
|
||||||
assertThat(deviceKey.getPublicKey()).isEqualTo(SAMPLE_DEVICE_KEY.getPublicKey());
|
assertThat(signedPreKey.getPublicKey()).isEqualTo(SAMPLE_SIGNED_KEY.getPublicKey());
|
||||||
assertThat(deviceId).isEqualTo(1);
|
assertThat(deviceId).isEqualTo(1);
|
||||||
|
|
||||||
deviceKey = results.getDevices().get(1).getDeviceKey();
|
signedPreKey = results.getDevices().get(1).getSignedPreKey();
|
||||||
preKey = results.getDevices().get(1).getPreKey();
|
preKey = results.getDevices().get(1).getPreKey();
|
||||||
registrationId = results.getDevices().get(1).getRegistrationId();
|
registrationId = results.getDevices().get(1).getRegistrationId();
|
||||||
deviceId = results.getDevices().get(1).getDeviceId();
|
deviceId = results.getDevices().get(1).getDeviceId();
|
||||||
|
@ -246,11 +246,11 @@ public class KeyControllerTest {
|
||||||
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY2.getKeyId());
|
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY2.getKeyId());
|
||||||
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY2.getPublicKey());
|
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY2.getPublicKey());
|
||||||
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID2);
|
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID2);
|
||||||
assertThat(deviceKey.getKeyId()).isEqualTo(SAMPLE_DEVICE_KEY2.getKeyId());
|
assertThat(signedPreKey.getKeyId()).isEqualTo(SAMPLE_SIGNED_KEY2.getKeyId());
|
||||||
assertThat(deviceKey.getPublicKey()).isEqualTo(SAMPLE_DEVICE_KEY2.getPublicKey());
|
assertThat(signedPreKey.getPublicKey()).isEqualTo(SAMPLE_SIGNED_KEY2.getPublicKey());
|
||||||
assertThat(deviceId).isEqualTo(2);
|
assertThat(deviceId).isEqualTo(2);
|
||||||
|
|
||||||
deviceKey = results.getDevices().get(2).getDeviceKey();
|
signedPreKey = results.getDevices().get(2).getSignedPreKey();
|
||||||
preKey = results.getDevices().get(2).getPreKey();
|
preKey = results.getDevices().get(2).getPreKey();
|
||||||
registrationId = results.getDevices().get(2).getRegistrationId();
|
registrationId = results.getDevices().get(2).getRegistrationId();
|
||||||
deviceId = results.getDevices().get(2).getDeviceId();
|
deviceId = results.getDevices().get(2).getDeviceId();
|
||||||
|
@ -258,7 +258,7 @@ public class KeyControllerTest {
|
||||||
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY4.getKeyId());
|
assertThat(preKey.getKeyId()).isEqualTo(SAMPLE_KEY4.getKeyId());
|
||||||
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY4.getPublicKey());
|
assertThat(preKey.getPublicKey()).isEqualTo(SAMPLE_KEY4.getPublicKey());
|
||||||
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID4);
|
assertThat(registrationId).isEqualTo(SAMPLE_REGISTRATION_ID4);
|
||||||
assertThat(deviceKey).isNull();
|
assertThat(signedPreKey).isNull();
|
||||||
assertThat(deviceId).isEqualTo(4);
|
assertThat(deviceId).isEqualTo(4);
|
||||||
|
|
||||||
verify(keys).get(eq(EXISTS_NUMBER));
|
verify(keys).get(eq(EXISTS_NUMBER));
|
||||||
|
@ -367,14 +367,14 @@ public class KeyControllerTest {
|
||||||
public void putKeysTestV2() throws Exception {
|
public void putKeysTestV2() throws Exception {
|
||||||
final PreKeyV2 preKey = new PreKeyV2(31337, "foobar");
|
final PreKeyV2 preKey = new PreKeyV2(31337, "foobar");
|
||||||
final PreKeyV2 lastResortKey = new PreKeyV2(31339, "barbar");
|
final PreKeyV2 lastResortKey = new PreKeyV2(31339, "barbar");
|
||||||
final DeviceKey deviceKey = new DeviceKey(31338, "foobaz", "myvalidsig");
|
final SignedPreKey signedPreKey = new SignedPreKey(31338, "foobaz", "myvalidsig");
|
||||||
final String identityKey = "barbar";
|
final String identityKey = "barbar";
|
||||||
|
|
||||||
List<PreKeyV2> preKeys = new LinkedList<PreKeyV2>() {{
|
List<PreKeyV2> preKeys = new LinkedList<PreKeyV2>() {{
|
||||||
add(preKey);
|
add(preKey);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
PreKeyStateV2 preKeyState = new PreKeyStateV2(identityKey, deviceKey, preKeys, lastResortKey);
|
PreKeyStateV2 preKeyState = new PreKeyStateV2(identityKey, signedPreKey, preKeys, lastResortKey);
|
||||||
|
|
||||||
ClientResponse response =
|
ClientResponse response =
|
||||||
resources.client().resource("/v2/keys")
|
resources.client().resource("/v2/keys")
|
||||||
|
@ -393,7 +393,7 @@ public class KeyControllerTest {
|
||||||
assertThat(capturedList.get(0).getPublicKey().equals("foobar"));
|
assertThat(capturedList.get(0).getPublicKey().equals("foobar"));
|
||||||
|
|
||||||
verify(AuthHelper.VALID_ACCOUNT).setIdentityKey(eq("barbar"));
|
verify(AuthHelper.VALID_ACCOUNT).setIdentityKey(eq("barbar"));
|
||||||
verify(AuthHelper.VALID_DEVICE).setDeviceKey(eq(deviceKey));
|
verify(AuthHelper.VALID_DEVICE).setSignedPreKey(eq(signedPreKey));
|
||||||
verify(accounts).update(AuthHelper.VALID_ACCOUNT);
|
verify(accounts).update(AuthHelper.VALID_ACCOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue