Rename `AccountCreationResult` to `AccountIdentityResponse` (since it's not just for account creation any more)

This commit is contained in:
Jon Chambers 2022-01-26 13:54:15 -05:00 committed by Jon Chambers
parent b18117ef89
commit 1f1d618dea
3 changed files with 18 additions and 18 deletions

View File

@ -62,7 +62,7 @@ import org.whispersystems.textsecuregcm.auth.TurnTokenGenerator;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration;
import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicSignupCaptchaConfiguration; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicSignupCaptchaConfiguration;
import org.whispersystems.textsecuregcm.entities.AccountAttributes; import org.whispersystems.textsecuregcm.entities.AccountAttributes;
import org.whispersystems.textsecuregcm.entities.AccountCreationResult; import org.whispersystems.textsecuregcm.entities.AccountIdentityResponse;
import org.whispersystems.textsecuregcm.entities.ApnRegistrationId; import org.whispersystems.textsecuregcm.entities.ApnRegistrationId;
import org.whispersystems.textsecuregcm.entities.ChangePhoneNumberRequest; import org.whispersystems.textsecuregcm.entities.ChangePhoneNumberRequest;
import org.whispersystems.textsecuregcm.entities.DeviceName; import org.whispersystems.textsecuregcm.entities.DeviceName;
@ -334,7 +334,7 @@ public class AccountController {
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
@Path("/code/{verification_code}") @Path("/code/{verification_code}")
public AccountCreationResult verifyAccount(@PathParam("verification_code") String verificationCode, public AccountIdentityResponse verifyAccount(@PathParam("verification_code") String verificationCode,
@HeaderParam("Authorization") BasicAuthorizationHeader authorizationHeader, @HeaderParam("Authorization") BasicAuthorizationHeader authorizationHeader,
@HeaderParam("X-Signal-Agent") String signalAgent, @HeaderParam("X-Signal-Agent") String signalAgent,
@HeaderParam("User-Agent") String userAgent, @HeaderParam("User-Agent") String userAgent,
@ -388,7 +388,7 @@ public class AccountController {
.record(Instant.now().toEpochMilli() - storedVerificationCode.get().getTimestamp(), TimeUnit.MILLISECONDS); .record(Instant.now().toEpochMilli() - storedVerificationCode.get().getTimestamp(), TimeUnit.MILLISECONDS);
} }
return new AccountCreationResult(account.getUuid(), return new AccountIdentityResponse(account.getUuid(),
account.getNumber(), account.getNumber(),
account.getPhoneNumberIdentifier(), account.getPhoneNumberIdentifier(),
account.getUsername().orElse(null), account.getUsername().orElse(null),
@ -595,15 +595,15 @@ public class AccountController {
@GET @GET
@Path("/me") @Path("/me")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public AccountCreationResult getMe(@Auth AuthenticatedAccount auth) { public AccountIdentityResponse getMe(@Auth AuthenticatedAccount auth) {
return whoAmI(auth); return whoAmI(auth);
} }
@GET @GET
@Path("/whoami") @Path("/whoami")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
public AccountCreationResult whoAmI(@Auth AuthenticatedAccount auth) { public AccountIdentityResponse whoAmI(@Auth AuthenticatedAccount auth) {
return new AccountCreationResult(auth.getAccount().getUuid(), return new AccountIdentityResponse(auth.getAccount().getUuid(),
auth.getAccount().getNumber(), auth.getAccount().getNumber(),
auth.getAccount().getPhoneNumberIdentifier(), auth.getAccount().getPhoneNumberIdentifier(),
auth.getAccount().getUsername().orElse(null), auth.getAccount().getUsername().orElse(null),

View File

@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID; import java.util.UUID;
public class AccountCreationResult { public class AccountIdentityResponse {
private final UUID uuid; private final UUID uuid;
private final String number; private final String number;
@ -23,7 +23,7 @@ public class AccountCreationResult {
private final boolean storageCapable; private final boolean storageCapable;
@JsonCreator @JsonCreator
public AccountCreationResult( public AccountIdentityResponse(
@JsonProperty("uuid") final UUID uuid, @JsonProperty("uuid") final UUID uuid,
@JsonProperty("number") final String number, @JsonProperty("number") final String number,
@JsonProperty("pni") final UUID pni, @JsonProperty("pni") final UUID pni,

View File

@ -65,7 +65,7 @@ import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicSignupCaptc
import org.whispersystems.textsecuregcm.controllers.AccountController; import org.whispersystems.textsecuregcm.controllers.AccountController;
import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException; import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException;
import org.whispersystems.textsecuregcm.entities.AccountAttributes; import org.whispersystems.textsecuregcm.entities.AccountAttributes;
import org.whispersystems.textsecuregcm.entities.AccountCreationResult; import org.whispersystems.textsecuregcm.entities.AccountIdentityResponse;
import org.whispersystems.textsecuregcm.entities.ApnRegistrationId; import org.whispersystems.textsecuregcm.entities.ApnRegistrationId;
import org.whispersystems.textsecuregcm.entities.ChangePhoneNumberRequest; import org.whispersystems.textsecuregcm.entities.ChangePhoneNumberRequest;
import org.whispersystems.textsecuregcm.entities.GcmRegistrationId; import org.whispersystems.textsecuregcm.entities.GcmRegistrationId;
@ -1014,7 +1014,7 @@ class AccountControllerTest {
.target(String.format("/v1/accounts/code/%s", "1234")) .target(String.format("/v1/accounts/code/%s", "1234"))
.request() .request()
.header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER, "bar")) .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER, "bar"))
.put(Entity.entity(new AccountAttributes(), MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class); .put(Entity.entity(new AccountAttributes(), MediaType.APPLICATION_JSON_TYPE), AccountIdentityResponse.class);
verify(accountsManager).create(eq(SENDER), eq("bar"), any(), any(), anyList()); verify(accountsManager).create(eq(SENDER), eq("bar"), any(), any(), anyList());
@ -1066,13 +1066,13 @@ class AccountControllerTest {
@Test @Test
void testVerifyRegistrationLock() throws Exception { void testVerifyRegistrationLock() throws Exception {
AccountCreationResult result = AccountIdentityResponse result =
resources.getJerseyTest() resources.getJerseyTest()
.target(String.format("/v1/accounts/code/%s", "666666")) .target(String.format("/v1/accounts/code/%s", "666666"))
.request() .request()
.header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar"))
.put(Entity.entity(new AccountAttributes(false, 3333, null, Hex.toStringCondensed(registration_lock_key), true, null), .put(Entity.entity(new AccountAttributes(false, 3333, null, Hex.toStringCondensed(registration_lock_key), true, null),
MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class); MediaType.APPLICATION_JSON_TYPE), AccountIdentityResponse.class);
assertThat(result.getUuid()).isNotNull(); assertThat(result.getUuid()).isNotNull();
@ -1081,13 +1081,13 @@ class AccountControllerTest {
@Test @Test
void testVerifyRegistrationLockSetsRegistrationLockOnNewAccount() throws Exception { void testVerifyRegistrationLockSetsRegistrationLockOnNewAccount() throws Exception {
AccountCreationResult result = AccountIdentityResponse result =
resources.getJerseyTest() resources.getJerseyTest()
.target(String.format("/v1/accounts/code/%s", "666666")) .target(String.format("/v1/accounts/code/%s", "666666"))
.request() .request()
.header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar"))
.put(Entity.entity(new AccountAttributes(false, 3333, null, Hex.toStringCondensed(registration_lock_key), true, null), .put(Entity.entity(new AccountAttributes(false, 3333, null, Hex.toStringCondensed(registration_lock_key), true, null),
MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class); MediaType.APPLICATION_JSON_TYPE), AccountIdentityResponse.class);
assertThat(result.getUuid()).isNotNull(); assertThat(result.getUuid()).isNotNull();
@ -1105,13 +1105,13 @@ class AccountControllerTest {
try { try {
when(senderRegLockAccount.getRegistrationLock()).thenReturn(lock.forTime(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7))); when(senderRegLockAccount.getRegistrationLock()).thenReturn(lock.forTime(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7)));
AccountCreationResult result = AccountIdentityResponse result =
resources.getJerseyTest() resources.getJerseyTest()
.target(String.format("/v1/accounts/code/%s", "666666")) .target(String.format("/v1/accounts/code/%s", "666666"))
.request() .request()
.header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar"))
.put(Entity.entity(new AccountAttributes(false, 3333, null, null, true, null), .put(Entity.entity(new AccountAttributes(false, 3333, null, null, true, null),
MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class); MediaType.APPLICATION_JSON_TYPE), AccountIdentityResponse.class);
assertThat(result.getUuid()).isNotNull(); assertThat(result.getUuid()).isNotNull();
@ -1539,12 +1539,12 @@ class AccountControllerTest {
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = {"/v1/accounts/whoami/", "/v1/accounts/me/"}) @ValueSource(strings = {"/v1/accounts/whoami/", "/v1/accounts/me/"})
public void testWhoAmI(final String path) { public void testWhoAmI(final String path) {
AccountCreationResult response = AccountIdentityResponse response =
resources.getJerseyTest() resources.getJerseyTest()
.target(path) .target(path)
.request() .request()
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD)) .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
.get(AccountCreationResult.class); .get(AccountIdentityResponse.class);
assertThat(response.getUuid()).isEqualTo(AuthHelper.VALID_UUID); assertThat(response.getUuid()).isEqualTo(AuthHelper.VALID_UUID);
} }