mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 07:58:07 +01:00
Rename "master device" to "primary device"
This commit is contained in:
committed by
Jon Chambers
parent
e8cebad27e
commit
f0ab52eb5d
@@ -171,7 +171,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
void testDeviceEnabledChanged(final Map<Long, Boolean> initialEnabled, final Map<Long, Boolean> finalEnabled) {
|
||||
assert initialEnabled.size() == finalEnabled.size();
|
||||
|
||||
assert account.getMasterDevice().orElseThrow().isEnabled();
|
||||
assert account.getPrimaryDevice().orElseThrow().isEnabled();
|
||||
|
||||
initialEnabled.forEach((deviceId, enabled) ->
|
||||
DevicesHelper.setEnabled(account.getDevice(deviceId).orElseThrow(), enabled));
|
||||
@@ -211,7 +211,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
|
||||
@Test
|
||||
void testDeviceAdded() {
|
||||
assert account.getMasterDevice().orElseThrow().isEnabled();
|
||||
assert account.getPrimaryDevice().orElseThrow().isEnabled();
|
||||
|
||||
final int initialDeviceCount = account.getDevices().size();
|
||||
|
||||
@@ -235,7 +235,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = {1, 2})
|
||||
void testDeviceRemoved(final int removedDeviceCount) {
|
||||
assert account.getMasterDevice().orElseThrow().isEnabled();
|
||||
assert account.getPrimaryDevice().orElseThrow().isEnabled();
|
||||
|
||||
final List<Long> initialDeviceIds = account.getDevices().stream().map(Device::getId).collect(Collectors.toList());
|
||||
|
||||
@@ -266,8 +266,8 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMasterDeviceDisabledAndDeviceRemoved() {
|
||||
assert account.getMasterDevice().orElseThrow().isEnabled();
|
||||
void testPrimaryDeviceDisabledAndDeviceRemoved() {
|
||||
assert account.getPrimaryDevice().orElseThrow().isEnabled();
|
||||
|
||||
final Set<Long> initialDeviceIds = account.getDevices().stream().map(Device::getId).collect(Collectors.toSet());
|
||||
|
||||
@@ -275,7 +275,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
assertTrue(initialDeviceIds.remove(deletedDeviceId));
|
||||
|
||||
final Response response = resources.getJerseyTest()
|
||||
.target("/v1/test/account/disableMasterDeviceAndDeleteDevice/" + deletedDeviceId)
|
||||
.target("/v1/test/account/disablePrimaryDeviceAndDeleteDevice/" + deletedDeviceId)
|
||||
.request()
|
||||
.header("Authorization",
|
||||
"Basic " + Base64.getEncoder().encodeToString("user:pass".getBytes(StandardCharsets.UTF_8)))
|
||||
@@ -415,7 +415,7 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
@ChangesDeviceEnabledState
|
||||
public String setAccountEnabled(@Auth TestPrincipal principal, @PathParam("enabled") final boolean enabled) {
|
||||
|
||||
final Device device = principal.getAccount().getMasterDevice().orElseThrow();
|
||||
final Device device = principal.getAccount().getPrimaryDevice().orElseThrow();
|
||||
|
||||
DevicesHelper.setEnabled(device, enabled);
|
||||
|
||||
@@ -469,11 +469,11 @@ class AuthEnablementRefreshRequirementProviderTest {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/account/disableMasterDeviceAndDeleteDevice/{deviceId}")
|
||||
@Path("/account/disablePrimaryDeviceAndDeleteDevice/{deviceId}")
|
||||
@ChangesDeviceEnabledState
|
||||
public String disableMasterDeviceAndRemoveDevice(@Auth TestPrincipal auth, @PathParam("deviceId") long deviceId) {
|
||||
public String disablePrimaryDeviceAndRemoveDevice(@Auth TestPrincipal auth, @PathParam("deviceId") long deviceId) {
|
||||
|
||||
DevicesHelper.setEnabled(auth.getAccount().getMasterDevice().orElseThrow(), false);
|
||||
DevicesHelper.setEnabled(auth.getAccount().getPrimaryDevice().orElseThrow(), false);
|
||||
|
||||
auth.getAccount().removeDevice(deviceId);
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class BaseAccountAuthenticatorTest {
|
||||
|
||||
private static Device generateTestDevice(final long lastSeen) {
|
||||
final Device device = new Device();
|
||||
device.setId(Device.MASTER_ID);
|
||||
device.setId(Device.PRIMARY_ID);
|
||||
device.setLastSeen(lastSeen);
|
||||
|
||||
return device;
|
||||
@@ -374,8 +374,8 @@ class BaseAccountAuthenticatorTest {
|
||||
|
||||
private static Stream<Arguments> testGetIdentifierAndDeviceId() {
|
||||
return Stream.of(
|
||||
Arguments.of("", "", Device.MASTER_ID),
|
||||
Arguments.of("test", "test", Device.MASTER_ID),
|
||||
Arguments.of("", "", Device.PRIMARY_ID),
|
||||
Arguments.of("test", "test", Device.PRIMARY_ID),
|
||||
Arguments.of("test.7", "test", 7));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class BasicAuthorizationHeaderTest {
|
||||
|
||||
assertEquals("aladdin", header.getUsername());
|
||||
assertEquals("opensesame", header.getPassword());
|
||||
assertEquals(Device.MASTER_ID, header.getDeviceId());
|
||||
assertEquals(Device.PRIMARY_ID, header.getDeviceId());
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
||||
when(account.getNumber()).thenReturn(NUMBER);
|
||||
when(account.getDevices()).thenReturn(List.of(device));
|
||||
when(device.getId()).thenReturn(Device.MASTER_ID);
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
|
||||
request = mock(ContainerRequest.class);
|
||||
|
||||
@@ -81,7 +81,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
|
||||
provider.handleRequestFiltered(requestEvent);
|
||||
when(account.getNumber()).thenReturn(CHANGED_NUMBER);
|
||||
assertEquals(List.of(new Pair<>(ACCOUNT_UUID, Device.MASTER_ID)), provider.handleRequestFinished(requestEvent));
|
||||
assertEquals(List.of(new Pair<>(ACCOUNT_UUID, Device.PRIMARY_ID)), provider.handleRequestFinished(requestEvent));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -69,7 +69,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
.thenReturn(mock(ExternalServiceCredentials.class));
|
||||
|
||||
final Device device = mock(Device.class);
|
||||
when(device.getId()).thenReturn(Device.MASTER_ID);
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
|
||||
AccountsHelper.setupMockUpdate(accountsManager);
|
||||
|
||||
@@ -104,7 +104,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
} else {
|
||||
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
|
||||
}
|
||||
verify(clientPresenceManager).disconnectAllPresences(account.getUuid(), List.of(Device.MASTER_ID));
|
||||
verify(clientPresenceManager).disconnectAllPresences(account.getUuid(), List.of(Device.PRIMARY_ID));
|
||||
try {
|
||||
verify(pushNotificationManager).sendAttemptLoginNotification(any(), eq("failedRegistrationLock"));
|
||||
} catch (NotPushRegisteredException npre) {}
|
||||
@@ -127,7 +127,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
verify(pushNotificationManager, never()).sendAttemptLoginNotification(any(), eq("failedRegistrationLock"));
|
||||
} catch (NotPushRegisteredException npre) {}
|
||||
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
|
||||
verify(clientPresenceManager, never()).disconnectAllPresences(account.getUuid(), List.of(Device.MASTER_ID));
|
||||
verify(clientPresenceManager, never()).disconnectAllPresences(account.getUuid(), List.of(Device.PRIMARY_ID));
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -165,7 +165,7 @@ class RegistrationLockVerificationManagerTest {
|
||||
|
||||
verify(account, never()).lockAuthTokenHash();
|
||||
verify(registrationRecoveryPasswordsManager, never()).removeForNumber(account.getNumber());
|
||||
verify(clientPresenceManager, never()).disconnectAllPresences(account.getUuid(), List.of(Device.MASTER_ID));
|
||||
verify(clientPresenceManager, never()).disconnectAllPresences(account.getUuid(), List.of(Device.PRIMARY_ID));
|
||||
}
|
||||
|
||||
static Stream<Arguments> testSuccess() {
|
||||
|
||||
@@ -85,7 +85,7 @@ class BasicCredentialAuthenticationInterceptorTest {
|
||||
when(account.getUuid()).thenReturn(UUID.randomUUID());
|
||||
|
||||
final Device device = mock(Device.class);
|
||||
when(device.getId()).thenReturn(Device.MASTER_ID);
|
||||
when(device.getId()).thenReturn(Device.PRIMARY_ID);
|
||||
|
||||
when(baseAccountAuthenticator.authenticate(any(), anyBoolean()))
|
||||
.thenReturn(Optional.of(new AuthenticatedAccount(() -> new Pair<>(account, device))));
|
||||
|
||||
Reference in New Issue
Block a user