@Override
  public Mono<LookupUsernameLinkResponse> lookupUsernameLink(final LookupUsernameLinkRequest request) {
    final UUID linkHandle;

    try {
      linkHandle = UUIDUtil.fromByteString(request.getUsernameLinkHandle());
    } catch (final IllegalArgumentException e) {
      throw Status.INVALID_ARGUMENT
          .withDescription("Could not interpret link handle as UUID")
          .withCause(e)
          .asRuntimeException();
    }

    return RateLimitUtil.rateLimitByRemoteAddress(rateLimiters.getUsernameLinkLookupLimiter())
        .then(Mono.fromFuture(() -> accountsManager.getByUsernameLinkHandle(linkHandle)))
        .map(maybeAccount -> maybeAccount
            .flatMap(Account::getEncryptedUsername)
            .orElseThrow(Status.NOT_FOUND::asRuntimeException))
        .map(usernameCiphertext -> LookupUsernameLinkResponse.newBuilder()
            .setUsernameCiphertext(ByteString.copyFrom(usernameCiphertext))
            .build());
  }
@Test
  void lookupUsernameLinkRateLimited() {
    final Duration retryAfter = Duration.ofSeconds(17);

    when(rateLimiter.validateReactive(anyString()))
        .thenReturn(Mono.error(new RateLimitExceededException(retryAfter)));

    //noinspection ResultOfMethodCallIgnored
    GrpcTestUtils.assertRateLimitExceeded(retryAfter,
        () -> unauthenticatedServiceStub().lookupUsernameLink(LookupUsernameLinkRequest.newBuilder()
            .setUsernameLinkHandle(UUIDUtil.toByteString(UUID.randomUUID()))
            .build()),
        accountsManager);
  }