mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-22 10:08:04 +01:00
Rename AuthenticatedAccount to AuthenticatedDevice
This commit is contained in:
committed by
Jon Chambers
parent
1ea9e38fea
commit
0075e94a42
@@ -166,7 +166,7 @@ class AccountAuthenticatorTest {
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(uuid.toString(), password));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isPresent();
|
||||
@@ -194,7 +194,7 @@ class AccountAuthenticatorTest {
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(uuid + "." + deviceId, password));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isPresent();
|
||||
@@ -231,7 +231,7 @@ class AccountAuthenticatorTest {
|
||||
} else {
|
||||
identifier = uuid.toString() + AccountAuthenticator.DEVICE_ID_SEPARATOR + deviceId;
|
||||
}
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(identifier, password));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isPresent();
|
||||
@@ -259,7 +259,7 @@ class AccountAuthenticatorTest {
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.Version.V1);
|
||||
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(uuid.toString(), password));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isPresent();
|
||||
@@ -294,7 +294,7 @@ class AccountAuthenticatorTest {
|
||||
when(credentials.verify(password)).thenReturn(true);
|
||||
when(credentials.getVersion()).thenReturn(SaltedTokenHash.CURRENT_VERSION);
|
||||
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(uuid + "." + (deviceId + 1), password));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isEmpty();
|
||||
@@ -322,7 +322,7 @@ class AccountAuthenticatorTest {
|
||||
|
||||
final String incorrectPassword = password + "incorrect";
|
||||
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount =
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount =
|
||||
accountAuthenticator.authenticate(new BasicCredentials(uuid.toString(), incorrectPassword));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isEmpty();
|
||||
@@ -332,7 +332,7 @@ class AccountAuthenticatorTest {
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
void testAuthenticateMalformedCredentials(final String username) {
|
||||
final Optional<AuthenticatedAccount> maybeAuthenticatedAccount = assertDoesNotThrow(
|
||||
final Optional<AuthenticatedDevice> maybeAuthenticatedAccount = assertDoesNotThrow(
|
||||
() -> accountAuthenticator.authenticate(new BasicCredentials(username, "password")));
|
||||
|
||||
assertThat(maybeAuthenticatedAccount).isEmpty();
|
||||
|
||||
@@ -112,7 +112,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
|
||||
final WebSocketConfiguration webSocketConfiguration = new WebSocketConfiguration();
|
||||
|
||||
final WebSocketEnvironment<AuthenticatedAccount> webSocketEnvironment =
|
||||
final WebSocketEnvironment<AuthenticatedDevice> webSocketEnvironment =
|
||||
new WebSocketEnvironment<>(environment, webSocketConfiguration);
|
||||
|
||||
environment.jersey().register(testController);
|
||||
@@ -129,13 +129,13 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
});
|
||||
|
||||
|
||||
environment.jersey().register(new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<AuthenticatedAccount>()
|
||||
environment.jersey().register(new AuthDynamicFeature(new BasicCredentialAuthFilter.Builder<AuthenticatedDevice>()
|
||||
.setAuthenticator(AUTHENTICATOR)
|
||||
.buildAuthFilter()));
|
||||
webSocketEnvironment.setAuthenticator(new WebSocketAccountAuthenticator(AUTHENTICATOR, mock(PrincipalSupplier.class)));
|
||||
|
||||
final WebSocketResourceProviderFactory<AuthenticatedAccount> webSocketServlet =
|
||||
new WebSocketResourceProviderFactory<>(webSocketEnvironment, AuthenticatedAccount.class,
|
||||
final WebSocketResourceProviderFactory<AuthenticatedDevice> webSocketServlet =
|
||||
new WebSocketResourceProviderFactory<>(webSocketEnvironment, AuthenticatedDevice.class,
|
||||
webSocketConfiguration, REMOTE_ADDRESS_ATTRIBUTE_NAME);
|
||||
|
||||
JettyWebSocketServletContainerInitializer.configure(environment.getApplicationContext(), null);
|
||||
@@ -160,7 +160,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
private void makeAuthenticatedRequest(
|
||||
final Protocol protocol,
|
||||
final String requestPath) throws IOException {
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedAccount(account1, authenticatedDevice)));
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedDevice(account1, authenticatedDevice)));
|
||||
makeRequest(protocol,requestPath, false);
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
@EnumSource(Protocol.class)
|
||||
void handleRequestChange(final Protocol protocol) throws IOException {
|
||||
when(ACCOUNTS_MANAGER.getByAccountIdentifier(any())).thenReturn(Optional.of(account2));
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedAccount(account1, authenticatedDevice)));
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedDevice(account1, authenticatedDevice)));
|
||||
|
||||
makeAuthenticatedRequest(protocol, "/test/annotated");
|
||||
|
||||
@@ -220,7 +220,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
@Test
|
||||
void handleRequestChangeAsyncEndpoint() throws IOException {
|
||||
when(ACCOUNTS_MANAGER.getByAccountIdentifier(any())).thenReturn(Optional.of(account2));
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedAccount(account1, authenticatedDevice)));
|
||||
when(AUTHENTICATOR.authenticate(any())).thenReturn(Optional.of(new AuthenticatedDevice(account1, authenticatedDevice)));
|
||||
|
||||
// Event listeners with asynchronous HTTP endpoints don't currently correctly maintain state between request and
|
||||
// response
|
||||
@@ -268,7 +268,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
@GET
|
||||
@Path("/annotated")
|
||||
@ChangesPhoneNumber
|
||||
public String annotated(@ReadOnly @Auth final AuthenticatedAccount account) {
|
||||
public String annotated(@ReadOnly @Auth final AuthenticatedDevice account) {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
@Path("/async-annotated")
|
||||
@ChangesPhoneNumber
|
||||
@ManagedAsync
|
||||
public String asyncAnnotated(@ReadOnly @Auth final AuthenticatedAccount account) {
|
||||
public String asyncAnnotated(@ReadOnly @Auth final AuthenticatedDevice account) {
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ class PhoneNumberChangeRefreshRequirementProviderTest {
|
||||
|
||||
@GET
|
||||
@Path("/not-annotated")
|
||||
public String notAnnotated(@ReadOnly @Auth final AuthenticatedAccount account) {
|
||||
public String notAnnotated(@ReadOnly @Auth final AuthenticatedDevice account) {
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user