Add `@E164` to `ChangeNumberRequest`
This commit is contained in:
parent
1c3cf39b8a
commit
cba56f3263
|
@ -20,6 +20,7 @@ import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import org.signal.libsignal.protocol.IdentityKey;
|
import org.signal.libsignal.protocol.IdentityKey;
|
||||||
import org.whispersystems.textsecuregcm.util.ByteArrayAdapter;
|
import org.whispersystems.textsecuregcm.util.ByteArrayAdapter;
|
||||||
|
import org.whispersystems.textsecuregcm.util.E164;
|
||||||
import org.whispersystems.textsecuregcm.util.IdentityKeyAdapter;
|
import org.whispersystems.textsecuregcm.util.IdentityKeyAdapter;
|
||||||
import org.whispersystems.textsecuregcm.util.RegistrationIdValidator;
|
import org.whispersystems.textsecuregcm.util.RegistrationIdValidator;
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ public record ChangeNumberRequest(
|
||||||
Must not be combined with `sessionId`.""")
|
Must not be combined with `sessionId`.""")
|
||||||
@JsonDeserialize(using = ByteArrayAdapter.Deserializing.class) byte[] recoveryPassword,
|
@JsonDeserialize(using = ByteArrayAdapter.Deserializing.class) byte[] recoveryPassword,
|
||||||
|
|
||||||
|
@E164
|
||||||
@Schema(description="the new phone number for this account")
|
@Schema(description="the new phone number for this account")
|
||||||
@NotBlank String number,
|
@NotBlank String number,
|
||||||
|
|
||||||
|
|
|
@ -217,6 +217,24 @@ class AccountControllerV2Test {
|
||||||
assertEquals(AuthHelper.VALID_PNI, accountIdentityResponse.pni());
|
assertEquals(AuthHelper.VALID_PNI, accountIdentityResponse.pni());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void changeNumberNonNormalizedNumber() throws Exception {
|
||||||
|
try (Response response = resources.getJerseyTest()
|
||||||
|
.target("/v2/accounts/number")
|
||||||
|
.request()
|
||||||
|
.header(HttpHeaders.AUTHORIZATION,
|
||||||
|
AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||||
|
.put(Entity.entity(
|
||||||
|
// +4407700900111 is a valid number but not normalized - it has an optional '0' after the country code
|
||||||
|
new ChangeNumberRequest(encodeSessionId("session"), null, "+4407700900111", null,
|
||||||
|
new IdentityKey(Curve.generateKeyPair().getPublicKey()),
|
||||||
|
Collections.emptyList(),
|
||||||
|
Collections.emptyMap(), null, Collections.emptyMap()),
|
||||||
|
MediaType.APPLICATION_JSON_TYPE))) {
|
||||||
|
assertEquals(422, response.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void unprocessableRequestJson() {
|
void unprocessableRequestJson() {
|
||||||
final Invocation.Builder request = resources.getJerseyTest()
|
final Invocation.Builder request = resources.getJerseyTest()
|
||||||
|
|
Loading…
Reference in New Issue