Obfuscate { public static String secure(String value, String delim) { if (null == value) { return null; } return Stream.of(value.split("/", -1)) .map(it -> it.isEmpty() ? it : secure(it)) .collect(Collectors.joining(delim)); }  static String secure(String value, String delim); static String secure(String value); static String secureSensitiveChar(char[] value); static String secureSensitive(String value);  }
@Test void disabledHidingLog() { Obfuscate.secureLogs = "OFF"; assertThat(Obfuscate.secure(TEST_STRING)).isEqualTo(TEST_STRING); }
@Test void hidingWithStars() { Obfuscate.secureLogs = "STARS"; assertThat(Obfuscate.secure(TEST_STRING)).isEqualTo("/p****le"); }
@Test void hidingWithHash() { Obfuscate.secureLogs = ""; String out = Obfuscate.secure(TEST_STRING); assertThat(out).isNotEqualTo(TEST_STRING); assertThat(out.length()).isEqualTo(44); }
@Test void secureSlashes() { assertThat(Obfuscate.secure("/", "/")).isEqualTo("/"); assertThat(Obfuscate.secure(" assertThat(Obfuscate.secure(" }