Util { public static String maskPassword(String key, String value) { if (key.contains("PASSWORD")) { return "********"; } else { return value; } }  static Future<T> async(Vertx vertx, Supplier<T> supplier); static Future<Void> waitFor(Vertx vertx, String logContext, String logState, long pollIntervalMs, long timeoutMs, BooleanSupplier completed); static Future<Void> waitFor(Vertx vertx, String logContext, String logState, long pollIntervalMs, long timeoutMs, BooleanSupplier completed,
                                       Predicate<Throwable> failOnError); static Map<String, String> parseMap(String str); static RuntimeException missingSecretException(String namespace, String secretName); static File createFileStore(String prefix, String suffix, byte[] bytes); static byte[] decodeFromSecret(Secret secret, String key); static File createFileTrustStore(String prefix, String suffix, X509Certificate certificate, char[] password); static void printEnvInfo(); static String maskPassword(String key, String value); @SafeVarargs static Map<String, String> mergeLabelsOrAnnotations(Map<String, String> base, Map<String, String>... overrides); static Future<T> kafkaFutureToVertxFuture(Vertx vertx, KafkaFuture<T> kf); static ConfigResource getBrokersConfig(int podId); static ConfigResource getBrokersLogging(int podId); static ConfigResource getBrokersConfig(String podId); static ConfigResource getBrokersLogging(String podId); static String stringHash(String toBeHashed); static String getLoggingDynamicallyUnmodifiableEntries(String loggingConfiguration); static String expandVars(String env); static String expandVar(String value, Map<String, String> env);  }
@Test public void testMaskedPasswords() { String noPassword = "SOME_VARIABLE"; String passwordAtTheEnd = "SOME_PASSWORD"; String passwordInTheMiddle = "SOME_PASSWORD_TO_THE_BIG_SECRET"; assertThat(Util.maskPassword(noPassword, "123456"), is("123456")); assertThat(Util.maskPassword(passwordAtTheEnd, "123456"), is("********")); assertThat(Util.maskPassword(passwordInTheMiddle, "123456"), is("********")); }