Skip to content

Commit 274d728

Browse files
authored
Increase test password length in FIPS (elastic#66844)
This changes the ESNativeMigrateToolTests to generate a random password instead of a fixed-length password when creating test users. When on a FIPS JVM the random password will have at least 14 characters (to allow it to work with the PBKDF2 hasher), in regular mode it will have at least 6 characters (the ES security minimum)
1 parent 0eb25ca commit 274d728

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/xpack/security/authc/esnative/ESNativeMigrateToolTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
*/
3636
public class ESNativeMigrateToolTests extends NativeRealmIntegTestCase {
3737

38+
private static final int MIN_PASSWORD_LENGTH = inFipsJvm() ? 14 : 6;
39+
3840
// Randomly use SSL (or not)
3941
private static boolean useSSL;
4042

@@ -81,8 +83,9 @@ public void testRetrieveUsers() throws Exception {
8183
int numToAdd = randomIntBetween(1,10);
8284
Set<String> addedUsers = new HashSet<>(numToAdd);
8385
for (int i = 0; i < numToAdd; i++) {
84-
String uname = randomAlphaOfLength(5);
85-
c.preparePutUser(uname, "s3kirt".toCharArray(), getFastStoredHashAlgoForTests(), "role1", "user").get();
86+
final String uname = randomAlphaOfLength(5);
87+
final char[] password = randomAlphaOfLengthBetween(MIN_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH * 2).toCharArray();
88+
c.preparePutUser(uname, password, getFastStoredHashAlgoForTests(), "role1", "user").get();
8689
addedUsers.add(uname);
8790
}
8891
logger.error("--> waiting for .security index");

0 commit comments

Comments
 (0)