From 1f1d618dea30a3fe3ac43d1aa2c407f65ea8db9e Mon Sep 17 00:00:00 2001 From: Jon Chambers Date: Wed, 26 Jan 2022 13:54:15 -0500 Subject: [PATCH] Rename `AccountCreationResult` to `AccountIdentityResponse` (since it's not just for account creation any more) --- .../controllers/AccountController.java | 12 +++++------ ...sult.java => AccountIdentityResponse.java} | 4 ++-- .../controllers/AccountControllerTest.java | 20 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) rename service/src/main/java/org/whispersystems/textsecuregcm/entities/{AccountCreationResult.java => AccountIdentityResponse.java} (94%) diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java index 2d7f120d4..4a68e1349 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/controllers/AccountController.java @@ -62,7 +62,7 @@ import org.whispersystems.textsecuregcm.auth.TurnTokenGenerator; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicConfiguration; import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicSignupCaptchaConfiguration; 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.ChangePhoneNumberRequest; import org.whispersystems.textsecuregcm.entities.DeviceName; @@ -334,7 +334,7 @@ public class AccountController { @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @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("X-Signal-Agent") String signalAgent, @HeaderParam("User-Agent") String userAgent, @@ -388,7 +388,7 @@ public class AccountController { .record(Instant.now().toEpochMilli() - storedVerificationCode.get().getTimestamp(), TimeUnit.MILLISECONDS); } - return new AccountCreationResult(account.getUuid(), + return new AccountIdentityResponse(account.getUuid(), account.getNumber(), account.getPhoneNumberIdentifier(), account.getUsername().orElse(null), @@ -595,15 +595,15 @@ public class AccountController { @GET @Path("/me") @Produces(MediaType.APPLICATION_JSON) - public AccountCreationResult getMe(@Auth AuthenticatedAccount auth) { + public AccountIdentityResponse getMe(@Auth AuthenticatedAccount auth) { return whoAmI(auth); } @GET @Path("/whoami") @Produces(MediaType.APPLICATION_JSON) - public AccountCreationResult whoAmI(@Auth AuthenticatedAccount auth) { - return new AccountCreationResult(auth.getAccount().getUuid(), + public AccountIdentityResponse whoAmI(@Auth AuthenticatedAccount auth) { + return new AccountIdentityResponse(auth.getAccount().getUuid(), auth.getAccount().getNumber(), auth.getAccount().getPhoneNumberIdentifier(), auth.getAccount().getUsername().orElse(null), diff --git a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java similarity index 94% rename from service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java rename to service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java index 2e53b978d..7c7a307ba 100644 --- a/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountCreationResult.java +++ b/service/src/main/java/org/whispersystems/textsecuregcm/entities/AccountIdentityResponse.java @@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import javax.annotation.Nullable; import java.util.UUID; -public class AccountCreationResult { +public class AccountIdentityResponse { private final UUID uuid; private final String number; @@ -23,7 +23,7 @@ public class AccountCreationResult { private final boolean storageCapable; @JsonCreator - public AccountCreationResult( + public AccountIdentityResponse( @JsonProperty("uuid") final UUID uuid, @JsonProperty("number") final String number, @JsonProperty("pni") final UUID pni, diff --git a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java index e1d2ef41f..dc6c8310d 100644 --- a/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java +++ b/service/src/test/java/org/whispersystems/textsecuregcm/tests/controllers/AccountControllerTest.java @@ -65,7 +65,7 @@ import org.whispersystems.textsecuregcm.configuration.dynamic.DynamicSignupCaptc import org.whispersystems.textsecuregcm.controllers.AccountController; import org.whispersystems.textsecuregcm.controllers.RateLimitExceededException; 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.ChangePhoneNumberRequest; import org.whispersystems.textsecuregcm.entities.GcmRegistrationId; @@ -1014,7 +1014,7 @@ class AccountControllerTest { .target(String.format("/v1/accounts/code/%s", "1234")) .request() .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()); @@ -1066,13 +1066,13 @@ class AccountControllerTest { @Test void testVerifyRegistrationLock() throws Exception { - AccountCreationResult result = + AccountIdentityResponse result = resources.getJerseyTest() .target(String.format("/v1/accounts/code/%s", "666666")) .request() .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .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(); @@ -1081,13 +1081,13 @@ class AccountControllerTest { @Test void testVerifyRegistrationLockSetsRegistrationLockOnNewAccount() throws Exception { - AccountCreationResult result = + AccountIdentityResponse result = resources.getJerseyTest() .target(String.format("/v1/accounts/code/%s", "666666")) .request() .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .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(); @@ -1105,13 +1105,13 @@ class AccountControllerTest { try { when(senderRegLockAccount.getRegistrationLock()).thenReturn(lock.forTime(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7))); - AccountCreationResult result = + AccountIdentityResponse result = resources.getJerseyTest() .target(String.format("/v1/accounts/code/%s", "666666")) .request() .header("Authorization", AuthHelper.getProvisioningAuthHeader(SENDER_REG_LOCK, "bar")) .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(); @@ -1539,12 +1539,12 @@ class AccountControllerTest { @ParameterizedTest @ValueSource(strings = {"/v1/accounts/whoami/", "/v1/accounts/me/"}) public void testWhoAmI(final String path) { - AccountCreationResult response = + AccountIdentityResponse response = resources.getJerseyTest() .target(path) .request() .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD)) - .get(AccountCreationResult.class); + .get(AccountIdentityResponse.class); assertThat(response.getUuid()).isEqualTo(AuthHelper.VALID_UUID); }