fix: remove minimum length requirement for bootstrap admin password

This commit is contained in:
wlx committed 2026-09-17 20:19:03 +08:00
1 parent 386d15cde2
commit f5ba6cb255
3 files changed
+34 -2

No files matched your search

+30 -1
View File
@@ -74,6 +74,34 @@ class DeploymentTests(unittest.TestCase):
def test_tunnel_config(self):
deploy.validate_config(configuration(), "tunnel")
def test_admin_password_has_no_minimum_length(self):
for mode in ("tunnel", "https"):
for password in ("x", "Test7!", "Qa-Test42!"):
with self.subTest(mode=mode, length=len(password)):
cfg = configuration()
api = cfg["services"]["moyi-api"]["environment"]
api["ADMIN_PASSWORD"] = password
api["AUTH_SECURE_COOKIE"] = "true" if mode == "https" else "false"
deploy.validate_config(cfg, mode)
def test_admin_password_still_rejects_empty_blank_and_placeholder(self):
for password in ("", " ", "\t\r\n", "GENERATE_ADMIN_PASSWORD"):
with self.subTest(password=password):
cfg = configuration()
cfg["services"]["moyi-api"]["environment"]["ADMIN_PASSWORD"] = password
with self.assertRaisesRegex(ValueError, "ADMIN_PASSWORD"):
deploy.validate_config(cfg, "tunnel")
def test_cryptographic_secrets_keep_minimum_length(self):
for key in ("AUTH_PASSWORD_PEPPER", "CREDENTIAL_ENCRYPTION_KEY"):
with self.subTest(key=key):
cfg = configuration()
cfg["services"]["moyi-api"]["environment"][key] = "s" * 31
with self.assertRaisesRegex(ValueError, key + " is too short"):
deploy.validate_config(cfg, "tunnel")
cfg["services"]["moyi-api"]["environment"][key] = "s" * 32
deploy.validate_config(cfg, "tunnel")
def test_reject_placeholder(self):
cfg = configuration()
cfg["services"]["moyi-api"]["environment"]["MOYI_REDIS_HOST"] = "CHANGE_ME_TAIR_HOST"
@@ -146,7 +174,7 @@ class DeploymentTests(unittest.TestCase):
"CHANGE_ME_RDS_HOST": "rds.internal", "CHANGE_ME_RDS_PASSWORD": "test-db-$value#literal",
"CHANGE_ME_TAIR_HOST": "redis.internal", "CHANGE_ME_TAIR_PASSWORD": "test-cache-$value#literal",
"GENERATE_AUTH_PEPPER": "p" * 64, "GENERATE_CREDENTIAL_KEY": "k" * 64,
"GENERATE_ADMIN_PASSWORD": "test-only-admin-password",
"GENERATE_ADMIN_PASSWORD": "Qa-Test42!",
}
for before, after in replacements.items():
content = content.replace(before, after)
@@ -160,6 +188,7 @@ class DeploymentTests(unittest.TestCase):
api = cfg["services"]["moyi-api"]["environment"]
self.assertEqual(api["MOYI_REDIS_PASSWORD"], "test-cache-$value#literal")
self.assertEqual(api["SPRING_DATASOURCE_PASSWORD"], "test-db-$value#literal")
self.assertEqual(api["ADMIN_PASSWORD"], "Qa-Test42!")
self.assertNotIn("MOYI_REDIS_PASSWORD", cfg["services"]["frontend"].get("environment", {}))
self.assertNotIn("OSS_ACCESS_KEY_SECRET", api)
if mode == "https":