Retire fully-adopted device capabilities
This commit is contained in:
parent
ae61ee5486
commit
d868e3075c
|
@ -32,9 +32,6 @@ public class BaseAccountAuthenticator {
|
|||
private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded";
|
||||
private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason";
|
||||
private static final String ENABLED_TAG_NAME = "enabled";
|
||||
private static final String AUTHENTICATION_HAS_STORY_CAPABILITY = "hasStoryCapability";
|
||||
|
||||
private static final String STORY_ADOPTION_COUNTER_NAME = name(BaseAccountAuthenticator.class, "storyAdoption");
|
||||
|
||||
private static final String DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME = name(BaseAccountAuthenticator.class, "daysSinceLastSeen");
|
||||
private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary";
|
||||
|
@ -75,7 +72,6 @@ public class BaseAccountAuthenticator {
|
|||
public Optional<AuthenticatedAccount> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) {
|
||||
boolean succeeded = false;
|
||||
String failureReason = null;
|
||||
boolean hasStoryCapability = false;
|
||||
|
||||
try {
|
||||
final UUID accountUuid;
|
||||
|
@ -94,8 +90,6 @@ public class BaseAccountAuthenticator {
|
|||
return Optional.empty();
|
||||
}
|
||||
|
||||
hasStoryCapability = account.map(Account::isStoriesSupported).orElse(false);
|
||||
|
||||
Optional<Device> device = account.get().getDevice(deviceId);
|
||||
|
||||
if (device.isEmpty()) {
|
||||
|
@ -150,9 +144,6 @@ public class BaseAccountAuthenticator {
|
|||
}
|
||||
|
||||
Metrics.counter(AUTHENTICATION_COUNTER_NAME, tags).increment();
|
||||
|
||||
Tags storyTags = Tags.of(AUTHENTICATION_HAS_STORY_CAPABILITY, String.valueOf(hasStoryCapability));
|
||||
Metrics.counter(STORY_ADOPTION_COUNTER_NAME, storyTags).increment();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -344,16 +344,7 @@ public class DeviceController {
|
|||
}
|
||||
|
||||
static boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities) {
|
||||
boolean isDowngrade = false;
|
||||
|
||||
isDowngrade |= account.isStoriesSupported() && !capabilities.isStories();
|
||||
isDowngrade |= account.isPniSupported() && !capabilities.isPni();
|
||||
isDowngrade |= account.isChangeNumberSupported() && !capabilities.isChangeNumber();
|
||||
isDowngrade |= account.isAnnouncementGroupSupported() && !capabilities.isAnnouncementGroup();
|
||||
isDowngrade |= account.isSenderKeySupported() && !capabilities.isSenderKey();
|
||||
isDowngrade |= account.isGiftBadgesSupported() && !capabilities.isGiftBadges();
|
||||
|
||||
return isDowngrade;
|
||||
return account.isPniSupported() && !capabilities.isPni();
|
||||
}
|
||||
|
||||
private Pair<Account, Device> createDevice(final String password,
|
||||
|
|
|
@ -9,11 +9,23 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||
import org.whispersystems.textsecuregcm.storage.Account;
|
||||
|
||||
public record UserCapabilities(
|
||||
@JsonProperty("gv1-migration") boolean gv1Migration,
|
||||
@Deprecated(forRemoval = true)
|
||||
@JsonProperty("gv1-migration")
|
||||
boolean gv1Migration,
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
boolean senderKey,
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
boolean announcementGroup,
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
boolean changeNumber,
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
boolean stories,
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
boolean giftBadges,
|
||||
boolean paymentActivation,
|
||||
boolean pni) {
|
||||
|
@ -21,11 +33,11 @@ public record UserCapabilities(
|
|||
public static UserCapabilities createForAccount(Account account) {
|
||||
return new UserCapabilities(
|
||||
true,
|
||||
account.isSenderKeySupported(),
|
||||
account.isAnnouncementGroupSupported(),
|
||||
account.isChangeNumberSupported(),
|
||||
account.isStoriesSupported(),
|
||||
account.isGiftBadgesSupported(),
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
|
||||
// Hardcode payment activation flag to false until all clients support the flow
|
||||
false,
|
||||
|
|
|
@ -256,34 +256,10 @@ public class Account {
|
|||
return getMasterDevice().map(Device::getCapabilities).map(Device.DeviceCapabilities::isTransfer).orElse(false);
|
||||
}
|
||||
|
||||
public boolean isSenderKeySupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isSenderKey);
|
||||
}
|
||||
|
||||
public boolean isAnnouncementGroupSupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isAnnouncementGroup);
|
||||
}
|
||||
|
||||
public boolean isChangeNumberSupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isChangeNumber);
|
||||
}
|
||||
|
||||
public boolean isPniSupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPni);
|
||||
}
|
||||
|
||||
public boolean isStoriesSupported() {
|
||||
requireNotStale();
|
||||
|
||||
return devices.stream()
|
||||
.filter(Device::isEnabled)
|
||||
.allMatch(device -> device.getCapabilities() != null && device.getCapabilities().isStories());
|
||||
}
|
||||
|
||||
public boolean isGiftBadgesSupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isGiftBadges);
|
||||
}
|
||||
|
||||
public boolean isPaymentActivationSupported() {
|
||||
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPaymentActivation);
|
||||
}
|
||||
|
|
|
@ -281,41 +281,19 @@ public class Device {
|
|||
@JsonProperty
|
||||
private boolean transfer;
|
||||
|
||||
@JsonProperty
|
||||
private boolean senderKey;
|
||||
|
||||
@JsonProperty
|
||||
private boolean announcementGroup;
|
||||
|
||||
@JsonProperty
|
||||
private boolean changeNumber;
|
||||
|
||||
@JsonProperty
|
||||
private boolean pni;
|
||||
|
||||
@JsonProperty
|
||||
private boolean stories;
|
||||
|
||||
@JsonProperty
|
||||
private boolean giftBadges;
|
||||
|
||||
@JsonProperty
|
||||
private boolean paymentActivation;
|
||||
|
||||
public DeviceCapabilities() {
|
||||
}
|
||||
|
||||
public DeviceCapabilities(boolean storage, boolean transfer,
|
||||
final boolean senderKey, final boolean announcementGroup, final boolean changeNumber,
|
||||
final boolean pni, final boolean stories, final boolean giftBadges, final boolean paymentActivation) {
|
||||
public DeviceCapabilities(boolean storage, boolean transfer, final boolean pni, final boolean paymentActivation) {
|
||||
this.storage = storage;
|
||||
this.transfer = transfer;
|
||||
this.senderKey = senderKey;
|
||||
this.announcementGroup = announcementGroup;
|
||||
this.changeNumber = changeNumber;
|
||||
this.pni = pni;
|
||||
this.stories = stories;
|
||||
this.giftBadges = giftBadges;
|
||||
this.paymentActivation = paymentActivation;
|
||||
}
|
||||
|
||||
|
@ -327,30 +305,10 @@ public class Device {
|
|||
return transfer;
|
||||
}
|
||||
|
||||
public boolean isSenderKey() {
|
||||
return senderKey;
|
||||
}
|
||||
|
||||
public boolean isAnnouncementGroup() {
|
||||
return announcementGroup;
|
||||
}
|
||||
|
||||
public boolean isChangeNumber() {
|
||||
return changeNumber;
|
||||
}
|
||||
|
||||
public boolean isPni() {
|
||||
return pni;
|
||||
}
|
||||
|
||||
public boolean isStories() {
|
||||
return stories;
|
||||
}
|
||||
|
||||
public boolean isGiftBadges() {
|
||||
return giftBadges;
|
||||
}
|
||||
|
||||
public boolean isPaymentActivation() {
|
||||
return paymentActivation;
|
||||
}
|
||||
|
|
|
@ -117,12 +117,7 @@ class DeviceControllerTest {
|
|||
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
|
||||
when(account.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI);
|
||||
when(account.isEnabled()).thenReturn(false);
|
||||
when(account.isSenderKeySupported()).thenReturn(true);
|
||||
when(account.isAnnouncementGroupSupported()).thenReturn(true);
|
||||
when(account.isChangeNumberSupported()).thenReturn(true);
|
||||
when(account.isPniSupported()).thenReturn(true);
|
||||
when(account.isStoriesSupported()).thenReturn(true);
|
||||
when(account.isGiftBadgesSupported()).thenReturn(true);
|
||||
when(account.isPaymentActivationSupported()).thenReturn(false);
|
||||
|
||||
when(accountsManager.getByAccountIdentifier(AuthHelper.VALID_UUID)).thenReturn(Optional.of(account));
|
||||
|
@ -638,102 +633,10 @@ class DeviceControllerTest {
|
|||
verifyNoMoreInteractions(messagesManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradeSenderKeyTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, false, true,
|
||||
true, true, true, true, true);
|
||||
AccountAttributes accountAttributes =
|
||||
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
||||
Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradeAnnouncementGroupTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, false,
|
||||
true, true, true, true, true);
|
||||
AccountAttributes accountAttributes =
|
||||
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
||||
Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradeChangeNumberTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true,
|
||||
false, true, true, true, true);
|
||||
AccountAttributes accountAttributes =
|
||||
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
||||
Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradePniTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true,
|
||||
false, true, true, true);
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true,
|
||||
false, true);
|
||||
AccountAttributes accountAttributes =
|
||||
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
|
@ -748,68 +651,7 @@ class DeviceControllerTest {
|
|||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradeStoriesTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true,
|
||||
true, false, true, true);
|
||||
AccountAttributes accountAttributes =
|
||||
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
||||
Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deviceDowngradeGiftBadgesTest() {
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, false, true);
|
||||
AccountAttributes accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
||||
Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/" + verificationToken)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getProvisioningAuthHeader(AuthHelper.VALID_NUMBER, AuthHelper.VALID_PASSWORD))
|
||||
.header(HttpHeaders.USER_AGENT, "Signal-Android/5.42.8675309 Android/30")
|
||||
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
|
||||
assertThat(response.getStatus()).isEqualTo(409);
|
||||
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
deviceCapabilities = new DeviceCapabilities(true, true, true, true);
|
||||
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
response = resources
|
||||
.getJerseyTest()
|
||||
|
@ -824,7 +666,7 @@ class DeviceControllerTest {
|
|||
|
||||
@Test
|
||||
void putCapabilitiesSuccessTest() {
|
||||
final DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, true);
|
||||
final DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true);
|
||||
final Response response = resources
|
||||
.getJerseyTest()
|
||||
.target("/v1/devices/capabilities")
|
||||
|
@ -852,7 +694,7 @@ class DeviceControllerTest {
|
|||
@ValueSource(booleans = {true, false})
|
||||
void deviceDowngradePaymentActivationTest(boolean paymentActivation) {
|
||||
// Update when we start returning true value of capability & restricting downgrades
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, true, true, true, paymentActivation);
|
||||
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, paymentActivation);
|
||||
AccountAttributes accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
|
||||
|
||||
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);
|
||||
|
|
|
@ -200,9 +200,6 @@ class ProfileControllerTest {
|
|||
when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO);
|
||||
when(profileAccount.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI_TWO);
|
||||
when(profileAccount.isEnabled()).thenReturn(true);
|
||||
when(profileAccount.isSenderKeySupported()).thenReturn(false);
|
||||
when(profileAccount.isAnnouncementGroupSupported()).thenReturn(false);
|
||||
when(profileAccount.isChangeNumberSupported()).thenReturn(false);
|
||||
when(profileAccount.getCurrentProfileVersion()).thenReturn(Optional.empty());
|
||||
when(profileAccount.getUsernameHash()).thenReturn(Optional.of(USERNAME_HASH));
|
||||
when(profileAccount.getUnidentifiedAccessKey()).thenReturn(Optional.of("1337".getBytes()));
|
||||
|
@ -215,9 +212,6 @@ class ProfileControllerTest {
|
|||
when(capabilitiesAccount.getPhoneNumberIdentityKey()).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
|
||||
when(capabilitiesAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
|
||||
when(capabilitiesAccount.isEnabled()).thenReturn(true);
|
||||
when(capabilitiesAccount.isSenderKeySupported()).thenReturn(true);
|
||||
when(capabilitiesAccount.isAnnouncementGroupSupported()).thenReturn(true);
|
||||
when(capabilitiesAccount.isChangeNumberSupported()).thenReturn(true);
|
||||
|
||||
when(accountsManager.getByServiceIdentifier(any())).thenReturn(Optional.empty());
|
||||
|
||||
|
@ -401,29 +395,15 @@ class ProfileControllerTest {
|
|||
|
||||
@Test
|
||||
void testProfileCapabilities() {
|
||||
{
|
||||
final BaseProfileResponse profile = resources.getJerseyTest()
|
||||
.target("/v1/profile/" + AuthHelper.VALID_UUID)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||
.get(BaseProfileResponse.class);
|
||||
final BaseProfileResponse profile = resources.getJerseyTest()
|
||||
.target("/v1/profile/" + AuthHelper.VALID_UUID)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
|
||||
.get(BaseProfileResponse.class);
|
||||
|
||||
assertThat(profile.getCapabilities().gv1Migration()).isTrue();
|
||||
assertThat(profile.getCapabilities().senderKey()).isTrue();
|
||||
assertThat(profile.getCapabilities().announcementGroup()).isTrue();
|
||||
}
|
||||
|
||||
{
|
||||
final BaseProfileResponse profile = resources.getJerseyTest()
|
||||
.target("/v1/profile/" + AuthHelper.VALID_UUID_TWO)
|
||||
.request()
|
||||
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID_TWO, AuthHelper.VALID_PASSWORD_TWO))
|
||||
.get(BaseProfileResponse.class);
|
||||
|
||||
assertThat(profile.getCapabilities().gv1Migration()).isTrue();
|
||||
assertThat(profile.getCapabilities().senderKey()).isFalse();
|
||||
assertThat(profile.getCapabilities().announcementGroup()).isFalse();
|
||||
}
|
||||
assertThat(profile.getCapabilities().gv1Migration()).isTrue();
|
||||
assertThat(profile.getCapabilities().senderKey()).isTrue();
|
||||
assertThat(profile.getCapabilities().announcementGroup()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -92,86 +92,86 @@ class AccountTest {
|
|||
when(oldSecondaryDevice.getId()).thenReturn(2L);
|
||||
|
||||
when(senderKeyCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(senderKeyCapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(senderKeyIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, false, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(senderKeyIncapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(senderKeyIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, false, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(senderKeyIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(announcementGroupCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(announcementGroupCapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(announcementGroupIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(announcementGroupIncapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(announcementGroupIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(announcementGroupIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(changeNumberCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, true, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(changeNumberCapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(changeNumberIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(changeNumberIncapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(changeNumberIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(changeNumberIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(pniCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, true, false, false, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(pniCapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(pniIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(pniIncapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(pniIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(pniIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(storiesCapableDevice.getId()).thenReturn(1L);
|
||||
when(storiesCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, true, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(storiesCapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(storiesCapableDevice.getId()).thenReturn(2L);
|
||||
when(storiesIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(storiesIncapableDevice.isEnabled()).thenReturn(true);
|
||||
|
||||
when(storiesCapableDevice.getId()).thenReturn(3L);
|
||||
when(storiesIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(true, true, false, false));
|
||||
when(storiesIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(giftBadgesCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, true, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(giftBadgesCapableDevice.isEnabled()).thenReturn(true);
|
||||
when(giftBadgesIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, false, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(giftBadgesIncapableDevice.isEnabled()).thenReturn(true);
|
||||
when(giftBadgesIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, false, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(giftBadgesIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
when(paymentActivationCapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, true, true));
|
||||
new DeviceCapabilities(true, true, true, true));
|
||||
when(paymentActivationCapableDevice.isEnabled()).thenReturn(true);
|
||||
when(paymentActivationIncapableDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, false, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(paymentActivationIncapableDevice.isEnabled()).thenReturn(true);
|
||||
when(paymentActivationIncapableExpiredDevice.getCapabilities()).thenReturn(
|
||||
new DeviceCapabilities(true, true, true, true, true, true, true, false, false));
|
||||
new DeviceCapabilities(true, true, true, false));
|
||||
when(paymentActivationIncapableExpiredDevice.isEnabled()).thenReturn(false);
|
||||
|
||||
}
|
||||
|
@ -261,44 +261,6 @@ class AccountTest {
|
|||
assertTrue(account.isDiscoverableByPhoneNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
void isSenderKeySupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), List.of(senderKeyCapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isSenderKeySupported()).isTrue();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
|
||||
List.of(senderKeyCapableDevice, senderKeyIncapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isSenderKeySupported()).isFalse();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(senderKeyCapableDevice, senderKeyIncapableExpiredDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isSenderKeySupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isAnnouncementGroupSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(announcementGroupCapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isAnnouncementGroupSupported()).isTrue();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(announcementGroupCapableDevice, announcementGroupIncapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isAnnouncementGroupSupported()).isFalse();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(announcementGroupCapableDevice, announcementGroupIncapableExpiredDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isAnnouncementGroupSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isChangeNumberSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(changeNumberCapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isChangeNumberSupported()).isTrue();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(changeNumberCapableDevice, changeNumberIncapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isChangeNumberSupported()).isFalse();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(changeNumberCapableDevice, changeNumberIncapableExpiredDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isChangeNumberSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isPniSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
|
@ -312,32 +274,6 @@ class AccountTest {
|
|||
"1234".getBytes(StandardCharsets.UTF_8)).isPniSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isStoriesSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(storiesCapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isTrue();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(storiesCapableDevice, storiesIncapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isFalse();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
|
||||
UUID.randomUUID(), List.of(storiesCapableDevice, storiesIncapableExpiredDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isStoriesSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isGiftBadgesSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
|
||||
List.of(giftBadgesCapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isGiftBadgesSupported()).isTrue();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
|
||||
List.of(giftBadgesCapableDevice, giftBadgesIncapableDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isGiftBadgesSupported()).isFalse();
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
|
||||
List.of(giftBadgesCapableDevice, giftBadgesIncapableExpiredDevice),
|
||||
"1234".getBytes(StandardCharsets.UTF_8)).isGiftBadgesSupported()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void isPaymentActivationSupported() {
|
||||
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),
|
||||
|
|
|
@ -976,7 +976,7 @@ class AccountsManagerTest {
|
|||
@ValueSource(booleans = {true, false})
|
||||
void testCreateWithStorageCapability(final boolean hasStorage) throws InterruptedException {
|
||||
final AccountAttributes attributes = new AccountAttributes(false, 0, null, null, true,
|
||||
new DeviceCapabilities(hasStorage, false, false, false, false, false, false, false, false));
|
||||
new DeviceCapabilities(hasStorage, false, false, false));
|
||||
|
||||
final Account account = accountsManager.create("+18005550123", "password", null, attributes, new ArrayList<>());
|
||||
|
||||
|
|
|
@ -121,12 +121,7 @@ public class AccountsHelper {
|
|||
case "isEnabled" -> when(updatedAccount.isEnabled()).thenAnswer(stubbing);
|
||||
case "isDiscoverableByPhoneNumber" -> when(updatedAccount.isDiscoverableByPhoneNumber()).thenAnswer(stubbing);
|
||||
case "getNextDeviceId" -> when(updatedAccount.getNextDeviceId()).thenAnswer(stubbing);
|
||||
case "isSenderKeySupported" -> when(updatedAccount.isSenderKeySupported()).thenAnswer(stubbing);
|
||||
case "isAnnouncementGroupSupported" -> when(updatedAccount.isAnnouncementGroupSupported()).thenAnswer(stubbing);
|
||||
case "isChangeNumberSupported" -> when(updatedAccount.isChangeNumberSupported()).thenAnswer(stubbing);
|
||||
case "isPniSupported" -> when(updatedAccount.isPniSupported()).thenAnswer(stubbing);
|
||||
case "isStoriesSupported" -> when(updatedAccount.isStoriesSupported()).thenAnswer(stubbing);
|
||||
case "isGiftBadgesSupported" -> when(updatedAccount.isGiftBadgesSupported()).thenAnswer(stubbing);
|
||||
case "isPaymentActivationSupported" -> when(updatedAccount.isPaymentActivationSupported()).thenAnswer(stubbing);
|
||||
case "getEnabledDeviceCount" -> when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
|
||||
case "getRegistrationLock" -> when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);
|
||||
|
|
Loading…
Reference in New Issue