Retire fully-adopted device capabilities

This commit is contained in:
Jon Chambers 2023-08-07 12:28:29 -04:00 committed by Jon Chambers
parent ae61ee5486
commit d868e3075c
10 changed files with 55 additions and 374 deletions

View File

@ -32,9 +32,6 @@ public class BaseAccountAuthenticator {
private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded"; private static final String AUTHENTICATION_SUCCEEDED_TAG_NAME = "succeeded";
private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason"; private static final String AUTHENTICATION_FAILURE_REASON_TAG_NAME = "reason";
private static final String ENABLED_TAG_NAME = "enabled"; 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 DAYS_SINCE_LAST_SEEN_DISTRIBUTION_NAME = name(BaseAccountAuthenticator.class, "daysSinceLastSeen");
private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary"; private static final String IS_PRIMARY_DEVICE_TAG = "isPrimary";
@ -75,7 +72,6 @@ public class BaseAccountAuthenticator {
public Optional<AuthenticatedAccount> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) { public Optional<AuthenticatedAccount> authenticate(BasicCredentials basicCredentials, boolean enabledRequired) {
boolean succeeded = false; boolean succeeded = false;
String failureReason = null; String failureReason = null;
boolean hasStoryCapability = false;
try { try {
final UUID accountUuid; final UUID accountUuid;
@ -94,8 +90,6 @@ public class BaseAccountAuthenticator {
return Optional.empty(); return Optional.empty();
} }
hasStoryCapability = account.map(Account::isStoriesSupported).orElse(false);
Optional<Device> device = account.get().getDevice(deviceId); Optional<Device> device = account.get().getDevice(deviceId);
if (device.isEmpty()) { if (device.isEmpty()) {
@ -150,9 +144,6 @@ public class BaseAccountAuthenticator {
} }
Metrics.counter(AUTHENTICATION_COUNTER_NAME, tags).increment(); 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();
} }
} }

View File

@ -344,16 +344,7 @@ public class DeviceController {
} }
static boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities) { static boolean isCapabilityDowngrade(Account account, DeviceCapabilities capabilities) {
boolean isDowngrade = false; return account.isPniSupported() && !capabilities.isPni();
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;
} }
private Pair<Account, Device> createDevice(final String password, private Pair<Account, Device> createDevice(final String password,

View File

@ -9,11 +9,23 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import org.whispersystems.textsecuregcm.storage.Account; import org.whispersystems.textsecuregcm.storage.Account;
public record UserCapabilities( public record UserCapabilities(
@JsonProperty("gv1-migration") boolean gv1Migration, @Deprecated(forRemoval = true)
@JsonProperty("gv1-migration")
boolean gv1Migration,
@Deprecated(forRemoval = true)
boolean senderKey, boolean senderKey,
@Deprecated(forRemoval = true)
boolean announcementGroup, boolean announcementGroup,
@Deprecated(forRemoval = true)
boolean changeNumber, boolean changeNumber,
@Deprecated(forRemoval = true)
boolean stories, boolean stories,
@Deprecated(forRemoval = true)
boolean giftBadges, boolean giftBadges,
boolean paymentActivation, boolean paymentActivation,
boolean pni) { boolean pni) {
@ -21,11 +33,11 @@ public record UserCapabilities(
public static UserCapabilities createForAccount(Account account) { public static UserCapabilities createForAccount(Account account) {
return new UserCapabilities( return new UserCapabilities(
true, true,
account.isSenderKeySupported(), true,
account.isAnnouncementGroupSupported(), true,
account.isChangeNumberSupported(), true,
account.isStoriesSupported(), true,
account.isGiftBadgesSupported(), true,
// Hardcode payment activation flag to false until all clients support the flow // Hardcode payment activation flag to false until all clients support the flow
false, false,

View File

@ -256,34 +256,10 @@ public class Account {
return getMasterDevice().map(Device::getCapabilities).map(Device.DeviceCapabilities::isTransfer).orElse(false); 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() { public boolean isPniSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPni); 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() { public boolean isPaymentActivationSupported() {
return allEnabledDevicesHaveCapability(DeviceCapabilities::isPaymentActivation); return allEnabledDevicesHaveCapability(DeviceCapabilities::isPaymentActivation);
} }

View File

@ -281,41 +281,19 @@ public class Device {
@JsonProperty @JsonProperty
private boolean transfer; private boolean transfer;
@JsonProperty
private boolean senderKey;
@JsonProperty
private boolean announcementGroup;
@JsonProperty
private boolean changeNumber;
@JsonProperty @JsonProperty
private boolean pni; private boolean pni;
@JsonProperty
private boolean stories;
@JsonProperty
private boolean giftBadges;
@JsonProperty @JsonProperty
private boolean paymentActivation; private boolean paymentActivation;
public DeviceCapabilities() { public DeviceCapabilities() {
} }
public DeviceCapabilities(boolean storage, boolean transfer, public DeviceCapabilities(boolean storage, boolean transfer, final boolean pni, final boolean paymentActivation) {
final boolean senderKey, final boolean announcementGroup, final boolean changeNumber,
final boolean pni, final boolean stories, final boolean giftBadges, final boolean paymentActivation) {
this.storage = storage; this.storage = storage;
this.transfer = transfer; this.transfer = transfer;
this.senderKey = senderKey;
this.announcementGroup = announcementGroup;
this.changeNumber = changeNumber;
this.pni = pni; this.pni = pni;
this.stories = stories;
this.giftBadges = giftBadges;
this.paymentActivation = paymentActivation; this.paymentActivation = paymentActivation;
} }
@ -327,30 +305,10 @@ public class Device {
return transfer; return transfer;
} }
public boolean isSenderKey() {
return senderKey;
}
public boolean isAnnouncementGroup() {
return announcementGroup;
}
public boolean isChangeNumber() {
return changeNumber;
}
public boolean isPni() { public boolean isPni() {
return pni; return pni;
} }
public boolean isStories() {
return stories;
}
public boolean isGiftBadges() {
return giftBadges;
}
public boolean isPaymentActivation() { public boolean isPaymentActivation() {
return paymentActivation; return paymentActivation;
} }

View File

@ -117,12 +117,7 @@ class DeviceControllerTest {
when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID); when(account.getUuid()).thenReturn(AuthHelper.VALID_UUID);
when(account.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI); when(account.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI);
when(account.isEnabled()).thenReturn(false); 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.isPniSupported()).thenReturn(true);
when(account.isStoriesSupported()).thenReturn(true);
when(account.isGiftBadgesSupported()).thenReturn(true);
when(account.isPaymentActivationSupported()).thenReturn(false); when(account.isPaymentActivationSupported()).thenReturn(false);
when(accountsManager.getByAccountIdentifier(AuthHelper.VALID_UUID)).thenReturn(Optional.of(account)); when(accountsManager.getByAccountIdentifier(AuthHelper.VALID_UUID)).thenReturn(Optional.of(account));
@ -638,102 +633,10 @@ class DeviceControllerTest {
verifyNoMoreInteractions(messagesManager); 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 @Test
void deviceDowngradePniTest() { void deviceDowngradePniTest() {
DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true, true, true, true, DeviceCapabilities deviceCapabilities = new DeviceCapabilities(true, true,
false, true, true, true); false, true);
AccountAttributes accountAttributes = AccountAttributes accountAttributes =
new AccountAttributes(false, 1234, null, null, true, deviceCapabilities); new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
@ -748,68 +651,7 @@ class DeviceControllerTest {
.put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE)); .put(Entity.entity(accountAttributes, MediaType.APPLICATION_JSON_TYPE));
assertThat(response.getStatus()).isEqualTo(409); 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()
.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);
accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities); accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
response = resources response = resources
.getJerseyTest() .getJerseyTest()
@ -824,7 +666,7 @@ class DeviceControllerTest {
@Test @Test
void putCapabilitiesSuccessTest() { 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 final Response response = resources
.getJerseyTest() .getJerseyTest()
.target("/v1/devices/capabilities") .target("/v1/devices/capabilities")
@ -852,7 +694,7 @@ class DeviceControllerTest {
@ValueSource(booleans = {true, false}) @ValueSource(booleans = {true, false})
void deviceDowngradePaymentActivationTest(boolean paymentActivation) { void deviceDowngradePaymentActivationTest(boolean paymentActivation) {
// Update when we start returning true value of capability & restricting downgrades // 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); AccountAttributes accountAttributes = new AccountAttributes(false, 1234, null, null, true, deviceCapabilities);
final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID); final String verificationToken = deviceController.generateVerificationToken(AuthHelper.VALID_UUID);

View File

@ -200,9 +200,6 @@ class ProfileControllerTest {
when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO); when(profileAccount.getUuid()).thenReturn(AuthHelper.VALID_UUID_TWO);
when(profileAccount.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI_TWO); when(profileAccount.getPhoneNumberIdentifier()).thenReturn(AuthHelper.VALID_PNI_TWO);
when(profileAccount.isEnabled()).thenReturn(true); 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.getCurrentProfileVersion()).thenReturn(Optional.empty());
when(profileAccount.getUsernameHash()).thenReturn(Optional.of(USERNAME_HASH)); when(profileAccount.getUsernameHash()).thenReturn(Optional.of(USERNAME_HASH));
when(profileAccount.getUnidentifiedAccessKey()).thenReturn(Optional.of("1337".getBytes())); 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.getPhoneNumberIdentityKey()).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
when(capabilitiesAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY); when(capabilitiesAccount.getIdentityKey(IdentityType.PNI)).thenReturn(ACCOUNT_PHONE_NUMBER_IDENTITY_KEY);
when(capabilitiesAccount.isEnabled()).thenReturn(true); 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()); when(accountsManager.getByServiceIdentifier(any())).thenReturn(Optional.empty());
@ -401,29 +395,15 @@ class ProfileControllerTest {
@Test @Test
void testProfileCapabilities() { void testProfileCapabilities() {
{ final BaseProfileResponse profile = resources.getJerseyTest()
final BaseProfileResponse profile = resources.getJerseyTest() .target("/v1/profile/" + AuthHelper.VALID_UUID)
.target("/v1/profile/" + AuthHelper.VALID_UUID) .request()
.request() .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
.header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD)) .get(BaseProfileResponse.class);
.get(BaseProfileResponse.class);
assertThat(profile.getCapabilities().gv1Migration()).isTrue(); assertThat(profile.getCapabilities().gv1Migration()).isTrue();
assertThat(profile.getCapabilities().senderKey()).isTrue(); assertThat(profile.getCapabilities().senderKey()).isTrue();
assertThat(profile.getCapabilities().announcementGroup()).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();
}
} }
@Test @Test

View File

@ -92,86 +92,86 @@ class AccountTest {
when(oldSecondaryDevice.getId()).thenReturn(2L); when(oldSecondaryDevice.getId()).thenReturn(2L);
when(senderKeyCapableDevice.getCapabilities()).thenReturn( 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(senderKeyCapableDevice.isEnabled()).thenReturn(true);
when(senderKeyIncapableDevice.getCapabilities()).thenReturn( 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(senderKeyIncapableDevice.isEnabled()).thenReturn(true);
when(senderKeyIncapableExpiredDevice.getCapabilities()).thenReturn( 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(senderKeyIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(announcementGroupCapableDevice.getCapabilities()).thenReturn( 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(announcementGroupCapableDevice.isEnabled()).thenReturn(true);
when(announcementGroupIncapableDevice.getCapabilities()).thenReturn( 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(announcementGroupIncapableDevice.isEnabled()).thenReturn(true);
when(announcementGroupIncapableExpiredDevice.getCapabilities()).thenReturn( 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(announcementGroupIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(changeNumberCapableDevice.getCapabilities()).thenReturn( 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(changeNumberCapableDevice.isEnabled()).thenReturn(true);
when(changeNumberIncapableDevice.getCapabilities()).thenReturn( 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(changeNumberIncapableDevice.isEnabled()).thenReturn(true);
when(changeNumberIncapableExpiredDevice.getCapabilities()).thenReturn( 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(changeNumberIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(pniCapableDevice.getCapabilities()).thenReturn( 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(pniCapableDevice.isEnabled()).thenReturn(true);
when(pniIncapableDevice.getCapabilities()).thenReturn( 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(pniIncapableDevice.isEnabled()).thenReturn(true);
when(pniIncapableExpiredDevice.getCapabilities()).thenReturn( 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(pniIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(storiesCapableDevice.getId()).thenReturn(1L); when(storiesCapableDevice.getId()).thenReturn(1L);
when(storiesCapableDevice.getCapabilities()).thenReturn( 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.isEnabled()).thenReturn(true);
when(storiesCapableDevice.getId()).thenReturn(2L); when(storiesCapableDevice.getId()).thenReturn(2L);
when(storiesIncapableDevice.getCapabilities()).thenReturn( 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(storiesIncapableDevice.isEnabled()).thenReturn(true);
when(storiesCapableDevice.getId()).thenReturn(3L); when(storiesCapableDevice.getId()).thenReturn(3L);
when(storiesIncapableExpiredDevice.getCapabilities()).thenReturn( 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(storiesIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(giftBadgesCapableDevice.getCapabilities()).thenReturn( 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(giftBadgesCapableDevice.isEnabled()).thenReturn(true);
when(giftBadgesIncapableDevice.getCapabilities()).thenReturn( 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(giftBadgesIncapableDevice.isEnabled()).thenReturn(true);
when(giftBadgesIncapableExpiredDevice.getCapabilities()).thenReturn( 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(giftBadgesIncapableExpiredDevice.isEnabled()).thenReturn(false);
when(paymentActivationCapableDevice.getCapabilities()).thenReturn( 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(paymentActivationCapableDevice.isEnabled()).thenReturn(true);
when(paymentActivationIncapableDevice.getCapabilities()).thenReturn( 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(paymentActivationIncapableDevice.isEnabled()).thenReturn(true);
when(paymentActivationIncapableExpiredDevice.getCapabilities()).thenReturn( 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); when(paymentActivationIncapableExpiredDevice.isEnabled()).thenReturn(false);
} }
@ -261,44 +261,6 @@ class AccountTest {
assertTrue(account.isDiscoverableByPhoneNumber()); 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 @Test
void isPniSupported() { void isPniSupported() {
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(),
@ -312,32 +274,6 @@ class AccountTest {
"1234".getBytes(StandardCharsets.UTF_8)).isPniSupported()).isTrue(); "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 @Test
void isPaymentActivationSupported() { void isPaymentActivationSupported() {
assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(), assertThat(AccountsHelper.generateTestAccount("+18005551234", UUID.randomUUID(), UUID.randomUUID(),

View File

@ -976,7 +976,7 @@ class AccountsManagerTest {
@ValueSource(booleans = {true, false}) @ValueSource(booleans = {true, false})
void testCreateWithStorageCapability(final boolean hasStorage) throws InterruptedException { void testCreateWithStorageCapability(final boolean hasStorage) throws InterruptedException {
final AccountAttributes attributes = new AccountAttributes(false, 0, null, null, true, 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<>()); final Account account = accountsManager.create("+18005550123", "password", null, attributes, new ArrayList<>());

View File

@ -121,12 +121,7 @@ public class AccountsHelper {
case "isEnabled" -> when(updatedAccount.isEnabled()).thenAnswer(stubbing); case "isEnabled" -> when(updatedAccount.isEnabled()).thenAnswer(stubbing);
case "isDiscoverableByPhoneNumber" -> when(updatedAccount.isDiscoverableByPhoneNumber()).thenAnswer(stubbing); case "isDiscoverableByPhoneNumber" -> when(updatedAccount.isDiscoverableByPhoneNumber()).thenAnswer(stubbing);
case "getNextDeviceId" -> when(updatedAccount.getNextDeviceId()).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 "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 "isPaymentActivationSupported" -> when(updatedAccount.isPaymentActivationSupported()).thenAnswer(stubbing);
case "getEnabledDeviceCount" -> when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing); case "getEnabledDeviceCount" -> when(updatedAccount.getEnabledDeviceCount()).thenAnswer(stubbing);
case "getRegistrationLock" -> when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing); case "getRegistrationLock" -> when(updatedAccount.getRegistrationLock()).thenAnswer(stubbing);