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