mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 02:08:03 +01:00
Update credentials and calling gRPC services to new error model
This commit is contained in:
@@ -6,13 +6,16 @@
|
||||
package org.whispersystems.textsecuregcm.grpc;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.google.i18n.phonenumbers.PhoneNumberUtil;
|
||||
import io.grpc.Status;
|
||||
import io.grpc.StatusRuntimeException;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.IntStream;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mock;
|
||||
@@ -59,8 +62,7 @@ class ExternalServiceCredentialsAnonymousGrpcServiceTest extends
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
Mockito.when(accountsManager.getByE164Async(USER_E164))
|
||||
.thenReturn(CompletableFuture.completedFuture(Optional.of(account(USER_UUID))));
|
||||
Mockito.when(accountsManager.getByE164(USER_E164)).thenReturn(Optional.of(account(USER_UUID)));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -125,6 +127,17 @@ class ExternalServiceCredentialsAnonymousGrpcServiceTest extends
|
||||
), day(25));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTooManyPasswords() {
|
||||
final CheckSvrCredentialsRequest request = CheckSvrCredentialsRequest.newBuilder()
|
||||
.setNumber(USER_E164)
|
||||
.addAllPasswords(IntStream.range(0, 12).mapToObj(i -> token(UUID.randomUUID(), day(10))).toList())
|
||||
.build();
|
||||
final StatusRuntimeException status = assertThrows(StatusRuntimeException.class,
|
||||
() -> unauthenticatedServiceStub().checkSvrCredentials(request));
|
||||
assertEquals(Status.INVALID_ARGUMENT.getCode(), status.getStatus().getCode());
|
||||
}
|
||||
|
||||
private void assertExpectedCredentialCheckResponse(
|
||||
final Map<String, AuthCheckResult> expected,
|
||||
final long nowMillis) throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user