fix(e2e): require ADMIN_* env for UI acceptance credentials
Drop the hardcoded admin password fallback so secrets never ship in the spec; missing ADMIN_USERNAME/ADMIN_PASSWORD fails the suite explicitly. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -133,8 +133,18 @@ function readPhaseSecrets(): PhaseSecrets {
|
||||
return JSON.parse(fs.readFileSync(PHASE_SECRETS_FILE, 'utf-8')) as PhaseSecrets;
|
||||
}
|
||||
|
||||
const ADMIN_USER = process.env.ADMIN_USERNAME || 'admin';
|
||||
const ADMIN_PASS = process.env.ADMIN_PASSWORD || 'admin-secret-password-123';
|
||||
const ADMIN_USER = process.env.ADMIN_USERNAME?.trim() || '';
|
||||
const ADMIN_PASS = process.env.ADMIN_PASSWORD?.trim() || '';
|
||||
|
||||
/** Admin creds must come from env — never hardcode or fallback secrets into the repo/runtime. */
|
||||
function requireAdminCreds(): { username: string; password: string } {
|
||||
if (!ADMIN_USER || !ADMIN_PASS) {
|
||||
fail(
|
||||
'ADMIN_USERNAME and ADMIN_PASSWORD environment variables are required for UI acceptance (no credential fallbacks)',
|
||||
);
|
||||
}
|
||||
return { username: ADMIN_USER, password: ADMIN_PASS };
|
||||
}
|
||||
const suffix = `${Date.now().toString(36)}`;
|
||||
const USER_A = `uia_${suffix}`;
|
||||
const USER_B = `uib_${suffix}`;
|
||||
@@ -345,9 +355,10 @@ test.describe.serial('document-revision-runtime UI acceptance', () => {
|
||||
test('UI-00 bootstrap: admin creates A/B/C via page', async () => {
|
||||
const t0 = Date.now();
|
||||
logs = [];
|
||||
const admin = requireAdminCreds();
|
||||
await page.goto('/');
|
||||
await page.fill('input[placeholder*="系统用户名"]', ADMIN_USER);
|
||||
await page.fill('input[placeholder*="登录密码"]', ADMIN_PASS);
|
||||
await page.fill('input[placeholder*="系统用户名"]', admin.username);
|
||||
await page.fill('input[placeholder*="登录密码"]', admin.password);
|
||||
await page.click('button:has-text("进入医疗协同工作台")');
|
||||
await expect(page.getByText('新建立项会话')).toBeVisible({ timeout: 30_000 });
|
||||
await openAdminConsole(page);
|
||||
|
||||
Reference in New Issue
Block a user