Files
qinglong/cli/test/linux/panel-account.cjs
T
whyour c5458596c8 feat(cron): expose run receipts and modularize execution
Return committed trigger IDs and add CLI wait and trigger-specific logs while
preserving API, CLI, transaction, deduplication and unknown-result semantics.

Move scheduling, lifecycle, settlement, queries and legacy adapters into
back/cron; remove obsolete internal import paths and circular dependencies.

Apply project formatting across the repository, cover CJS/MJS in formatting
hooks, add prettier:check and require formatting checks in AGENTS.md.

Validation: backend build; 1398 backend/frontend tests passed (17 platform
skips); 327 CLI tests passed (6 platform skips); 670 files pass format checks.
2026-11-22 12:24:29 +08:00

71 lines
2.1 KiB
JavaScript

const assert = require('node:assert/strict');
const path = require('node:path');
const os = require('node:os');
const { randomUUID } = require('node:crypto');
const { spawnSync } = require('node:child_process');
exports.verifyAccountMaintenance = async function verifyAccountMaintenance(
api,
) {
const credentials = {
username: `renamed-${randomUUID()}`,
password: `--${randomUUID()}`,
};
const local = (action, value) => {
const result = spawnSync(
path.join(os.homedir(), 'bin/ql'),
[action, ...(value ? ['--', value] : [])],
{
env: { ...process.env, QL_DIR: '/ql' },
encoding: 'utf8',
timeout: 15000,
},
);
assert.equal(result.status, 0, `${action} failed: ${result.stderr}`);
assert.equal(JSON.parse(result.stdout).data.completed, true);
};
const login = async (password = credentials.password) => {
const response = await fetch('http://127.0.0.1:5700/api/user/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ...credentials, password }),
signal: AbortSignal.timeout(5000),
});
return response.json();
};
local('resetname', credentials.username);
local('resetpwd', credentials.password);
assert.equal((await login()).code, 200, 'New credentials were not saved');
const incorrect = randomUUID();
for (let attempt = 0; attempt < 3; attempt++) {
assert.equal(
(await login(incorrect)).code,
400,
'Expected a rejected password before throttling',
);
}
assert.equal(
(await login()).code,
410,
'Fixture failed to activate login limit',
);
local('resetlet');
const session = await login();
assert.equal(session.code, 200, 'Login limit was not cleared');
assert.ok(session.data.token, 'Fresh owner session required');
await api(
'system/auth/reset',
'PUT',
{ twoFactorActivated: true },
session.data.token,
);
assert.equal(
(await login()).code,
420,
'Fixture failed to activate second factor',
);
local('resettfa');
assert.equal((await login()).code, 200, 'Second factor was not cleared');
return true;
};