Make storageCapable a boolean result rather than an auth token
This commit is contained in:
parent
c641abc7cd
commit
1408ac77f9
|
@ -21,7 +21,6 @@ import com.codahale.metrics.MetricRegistry;
|
|||
import com.codahale.metrics.SharedMetricRegistries;
|
||||
import com.codahale.metrics.annotation.Timed;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.dropwizard.auth.Auth;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.whispersystems.textsecuregcm.auth.AuthenticationCredentials;
|
||||
|
@ -84,6 +83,7 @@ import java.util.Optional;
|
|||
import java.util.UUID;
|
||||
|
||||
import static com.codahale.metrics.MetricRegistry.name;
|
||||
import io.dropwizard.auth.Auth;
|
||||
|
||||
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
|
||||
@Path("/v1/accounts")
|
||||
|
@ -299,7 +299,7 @@ public class AccountController {
|
|||
|
||||
metricRegistry.meter(name(AccountController.class, "verify", Util.getCountryCode(number))).mark();
|
||||
|
||||
return new AccountCreationResult(account.getUuid(), existingAccount.map(Account::isStorageSupported).orElse(false) ? existingBackupCredentials.orElse(null) : null);
|
||||
return new AccountCreationResult(account.getUuid(), existingAccount.map(Account::isStorageSupported).orElse(false));
|
||||
} catch (InvalidAuthorizationHeaderException e) {
|
||||
logger.info("Bad Authorization Header", e);
|
||||
throw new WebApplicationException(Response.status(401).build());
|
||||
|
@ -481,7 +481,7 @@ public class AccountController {
|
|||
@Path("/whoami")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public AccountCreationResult whoAmI(@Auth Account account) {
|
||||
return new AccountCreationResult(account.getUuid(), backupServiceCredentialGenerator.generateFor(account.getUuid().toString()));
|
||||
return new AccountCreationResult(account.getUuid(), account.isStorageSupported());
|
||||
}
|
||||
|
||||
@DELETE
|
||||
|
|
|
@ -12,20 +12,20 @@ public class AccountCreationResult {
|
|||
private UUID uuid;
|
||||
|
||||
@JsonProperty
|
||||
private ExternalServiceCredentials backupCredentials;
|
||||
private boolean storageCapable;
|
||||
|
||||
public AccountCreationResult() {}
|
||||
|
||||
public AccountCreationResult(UUID uuid, ExternalServiceCredentials backupCredentials) {
|
||||
this.uuid = uuid;
|
||||
this.backupCredentials = backupCredentials;
|
||||
public AccountCreationResult(UUID uuid, boolean storageCapable) {
|
||||
this.uuid = uuid;
|
||||
this.storageCapable = storageCapable;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public ExternalServiceCredentials getBackupCredentials() {
|
||||
return backupCredentials;
|
||||
public boolean isStorageCapable() {
|
||||
return storageCapable;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -502,7 +502,7 @@ public class AccountControllerTest {
|
|||
MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class);
|
||||
|
||||
assertThat(result.getUuid()).isNotNull();
|
||||
assertThat(result.getBackupCredentials()).isNull();
|
||||
assertThat(result.isStorageCapable()).isFalse();
|
||||
|
||||
verify(accountsManager, times(1)).create(isA(Account.class));
|
||||
verify(directoryQueue, times(1)).deleteRegisteredUser(notNull(), eq(SENDER));
|
||||
|
@ -519,7 +519,7 @@ public class AccountControllerTest {
|
|||
MediaType.APPLICATION_JSON_TYPE), AccountCreationResult.class);
|
||||
|
||||
assertThat(result.getUuid()).isNotNull();
|
||||
assertThat(result.getBackupCredentials()).isNotNull();
|
||||
assertThat(result.isStorageCapable()).isTrue();
|
||||
|
||||
verify(accountsManager, times(1)).create(isA(Account.class));
|
||||
verify(directoryQueue, times(1)).deleteRegisteredUser(notNull(), eq(SENDER_HAS_STORAGE));
|
||||
|
|
Loading…
Reference in New Issue