SecretValidation { public static boolean isValidSecretValue(String value) { Preconditions.checkNotNull(value); return value.getBytes(UTF_8).length <= MAX_SECRET_VALUE_LENGTH; } private  SecretValidation(); static boolean isValidSecretKey(String key); static boolean isValidSecretValue(String value); static boolean isValidSecret(String key, String value);  }
@Test public void isValidSecretValue() throws Exception { assertThat(SecretValidation.isValidSecretValue(""), is(true)); assertThat(SecretValidation.isValidSecretValue("foobar"), is(true)); assertThat(SecretValidation.isValidSecretValue("\uD83D\uDCA9"), is(true)); assertThat(SecretValidation.isValidSecretValue("r\u00e4ksm\u00f6rg\u00e5s"), is(true)); assertThat(SecretValidation.isValidSecretValue(Strings.repeat(".", 16 * 1024)), is(true)); assertThat(SecretValidation.isValidSecretValue(Strings.repeat(".", 16 * 1024 + 1)), is(false)); assertThat(SecretValidation.isValidSecretValue(Strings.repeat("\u2603", 16 * 1024 / 3 + 1)), is(false)); }