mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(redshift-serverless): ensure generated admin password contains uppercase, lowercase, and digit (#7200)
* fix(redshift-serverless): ensure generated admin password contains uppercase, lowercase, and digit - Dam bao mat khau ngau nhien sinh ra luon chua it nhat mot chu hoa, mot chu thuong va mot chu so, dap ung quy tac mat khau cua Redshift * test(redshift-serverless): verify password complexity retry with deterministic candidates - Bo sung test xac dinh (deterministic) kiem tra generatePassword bo qua cac candidate thieu chu hoa, chu thuong, chu so va chi tra ve khi du ca 3 dieu kien - Tach generatePassword(Supplier<String>) de inject candidate trong test va tien bien dich cac Pattern kiem tra regex
This commit is contained in:
1 parent
fd4abd365b
commit
9fe670a5de
2 files changed
+42
-3
No files matched your search
+16
@@ -14,6 +14,7 @@ import org.mockito.InOrder;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -286,6 +287,20 @@ class RedshiftServerlessRuntimeTest {
|
||||
assertTrue(BACKEND_ID.contains("_"), "cluster identifiers cannot contain an underscore");
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatePasswordRetriesUntilAllRequiredCharacterClassesArePresent() {
|
||||
Iterator<String> candidates = List.of(
|
||||
"abcdefghijklmnopqrstuvwxyz123456",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ123456",
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef",
|
||||
"AdminPassword123WithAllClassesOk"
|
||||
).iterator();
|
||||
|
||||
String password = runtime.generatePassword(candidates::next);
|
||||
|
||||
assertEquals("AdminPassword123WithAllClassesOk", password);
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatedPasswordsAreLongAlphanumericAndDifferEachTime() {
|
||||
String first = runtime.generatePassword();
|
||||
@@ -293,6 +308,7 @@ class RedshiftServerlessRuntimeTest {
|
||||
|
||||
assertEquals(32, first.length());
|
||||
assertTrue(first.matches("[A-Za-z0-9]+"), first);
|
||||
assertTrue(first.matches(".*[A-Z].*") && first.matches(".*[a-z].*") && first.matches(".*[0-9].*"), first);
|
||||
assertNotEquals(first, second);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user