File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
src/test/java/org/opensearch/flowframework Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -356,6 +356,9 @@ protected boolean preserveClusterSettings() {
356356 * @return a random password.
357357 */
358358 public static String generatePassword (String username ) {
359+
360+ String lowerName = username .toLowerCase (Locale .ROOT );
361+
359362 String upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
360363 String lowerCase = "abcdefghijklmnopqrstuvwxyz" ;
361364 String digits = "0123456789" ;
@@ -371,11 +374,12 @@ public static String generatePassword(String username) {
371374 password [2 ] = digits .charAt (rng .nextInt (digits .length ()));
372375 password [3 ] = special .charAt (rng .nextInt (special .length ()));
373376
377+ // Reject characters that appear in username (case-insensitive)
374378 for (int i = 4 ; i < 15 ; i ++) {
375379 char nextChar ;
376380 do {
377381 nextChar = characters .charAt (rng .nextInt (characters .length ()));
378- } while (username .indexOf (nextChar ) > -1 );
382+ } while (lowerName .indexOf (Character . toLowerCase ( nextChar ) ) > -1 );
379383 password [i ] = nextChar ;
380384 }
381385
You can’t perform that action at this time.
0 commit comments