@GET
  @Produces(MediaType.APPLICATION_JSON)
  public UserRemoteConfigList getAll(@ReadOnly @Auth AuthenticatedDevice auth) {
    try {
      MessageDigest digest = MessageDigest.getInstance("SHA1");

      final Stream<UserRemoteConfig> globalConfigStream = globalConfig.entrySet().stream()
          .map(entry -> new UserRemoteConfig(GLOBAL_CONFIG_PREFIX + entry.getKey(), true, entry.getValue()));
      return new UserRemoteConfigList(Stream.concat(remoteConfigsManager.getAll().stream().map(config -> {
        final byte[] hashKey = config.getHashKey() != null ? config.getHashKey().getBytes(StandardCharsets.UTF_8)
            : config.getName().getBytes(StandardCharsets.UTF_8);
        boolean inBucket = isInBucket(digest, auth.getAccount().getUuid(), hashKey, config.getPercentage(),
            config.getUuids());
        return new UserRemoteConfig(config.getName(), inBucket,
            inBucket ? config.getValue() : config.getDefaultValue());
      }), globalConfigStream).collect(Collectors.toList()), clock.instant());
    } catch (NoSuchAlgorithmException e) {
      throw new AssertionError(e);
    }
  }
@Test
  void testRetrieveConfig() {
    UserRemoteConfigList configuration = resources.getJerseyTest()
                                                  .target("/v1/config/")
                                                  .request()
                                                  .header("Authorization", AuthHelper.getAuthHeader(AuthHelper.VALID_UUID, AuthHelper.VALID_PASSWORD))
                                                  .get(UserRemoteConfigList.class);

    verify(remoteConfigsManager, times(1)).getAll();

    assertThat(configuration.getConfig()).hasSize(11);
    assertThat(configuration.getConfig().get(0).getName()).isEqualTo("android.stickers");
    assertThat(configuration.getConfig().get(1).getName()).isEqualTo("ios.stickers");
    assertThat(configuration.getConfig().get(2).getName()).isEqualTo("always.true");
    assertThat(configuration.getConfig().get(2).isEnabled()).isEqualTo(true);
    assertThat(configuration.getConfig().get(2).getValue()).isNull();
    assertThat(configuration.getConfig().get(3).getName()).isEqualTo("only.special");
    assertThat(configuration.getConfig().get(3).isEnabled()).isEqualTo(true);
    assertThat(configuration.getConfig().get(2).getValue()).isNull();
    assertThat(configuration.getConfig().get(4).getName()).isEqualTo("value.always.true");
    assertThat(configuration.getConfig().get(4).isEnabled()).isEqualTo(true);
    assertThat(configuration.getConfig().get(4).getValue()).isEqualTo("bar");
    assertThat(configuration.getConfig().get(5).getName()).isEqualTo("value.only.special");
    assertThat(configuration.getConfig().get(5).isEnabled()).isEqualTo(true);
    assertThat(configuration.getConfig().get(5).getValue()).isEqualTo("xyz");
    assertThat(configuration.getConfig().get(6).getName()).isEqualTo("value.always.false");
    assertThat(configuration.getConfig().get(6).isEnabled()).isEqualTo(false);
    assertThat(configuration.getConfig().get(6).getValue()).isEqualTo("red");
    assertThat(configuration.getConfig().get(7).getName()).isEqualTo("linked.config.0");
    assertThat(configuration.getConfig().get(8).getName()).isEqualTo("linked.config.1");
    assertThat(configuration.getConfig().get(9).getName()).isEqualTo("unlinked.config");
    assertThat(configuration.getConfig().get(10).getName()).isEqualTo("global.maxGroupSize");
  }