feat(db,schemas): add migration 004, runtime throttle profile, and v1.1 Zod schemas
This commit is contained in:
parent
d7c3e11d7e
commit
afc2d6358a
30 changed files with 792 additions and 118 deletions
|
|
@ -192,7 +192,13 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
).status,
|
||||
).toBe(201);
|
||||
|
||||
// Initialize vault & generate key while default 1h login elevation is active
|
||||
// Explicitly step up before vault mutations (v1.1 default elevateOnLogin=false)
|
||||
vi.setSystemTime(t0 + 31_000);
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp1.generate() } })).status,
|
||||
).toBe(200);
|
||||
|
||||
// Initialize vault & generate key while elevated
|
||||
expect((await api.call('/api/vault/init', { method: 'POST', body: {} })).status).toBe(201);
|
||||
expect(
|
||||
(
|
||||
|
|
@ -231,7 +237,7 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
expect((await api.call('/api/auth/logout', { method: 'POST' })).status).toBe(200);
|
||||
api.clearCsrf();
|
||||
|
||||
vi.setSystemTime(t0 + 31_000);
|
||||
vi.setSystemTime(t0 + 62_000);
|
||||
const anyLogin = await api.call('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
|
|
@ -275,7 +281,7 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
// Logout and test 'all' enforcement
|
||||
expect((await api.call('/api/auth/logout', { method: 'POST' })).status).toBe(200);
|
||||
api.clearCsrf();
|
||||
vi.setSystemTime(t0 + 62_000);
|
||||
vi.setSystemTime(t0 + 93_000);
|
||||
|
||||
const partialPw = await api.call('/api/auth/login', {
|
||||
method: 'POST',
|
||||
|
|
@ -288,7 +294,7 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
});
|
||||
expect(partialPw.status).toBe(401);
|
||||
|
||||
vi.setSystemTime(t0 + 93_000);
|
||||
vi.setSystemTime(t0 + 124_000);
|
||||
const partialTotp = await api.call('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
|
|
@ -300,7 +306,7 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
});
|
||||
expect(partialTotp.status).toBe(401);
|
||||
|
||||
vi.setSystemTime(t0 + 124_000);
|
||||
vi.setSystemTime(t0 + 155_000);
|
||||
const fullAllLogin = await api.call('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
|
|
@ -364,6 +370,24 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
}
|
||||
});
|
||||
|
||||
const curSettings = server.configManager.getSettings();
|
||||
server.configManager.saveConfigText(
|
||||
'settings.json',
|
||||
JSON.stringify(
|
||||
{
|
||||
...curSettings,
|
||||
security: {
|
||||
...curSettings.security,
|
||||
enableEmergencySecretsBackup: true,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
'ui',
|
||||
'Enable emergency recovery for test',
|
||||
);
|
||||
|
||||
let api = createApiClient(server);
|
||||
const bootInfo = await api.call('/api/auth/bootstrap');
|
||||
const secretBase32 = String(bootInfo.data.secretBase32);
|
||||
|
|
@ -382,6 +406,11 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
expect(boot.status).toBe(201);
|
||||
const recoveryCodes = boot.data.recoveryCodes as string[];
|
||||
|
||||
vi.setSystemTime(t0 + 31_000);
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
|
||||
).toBe(200);
|
||||
|
||||
const vInit = await api.call('/api/vault/init', { method: 'POST', body: {} });
|
||||
expect(vInit.status).toBe(201);
|
||||
const masterKeyHex = String(vInit.data.generatedKeyHex);
|
||||
|
|
@ -478,6 +507,11 @@ describe('Configurable Re-Auth Strictness, Multi-Auth Factors & Emergency Secret
|
|||
).status,
|
||||
).toBe(200);
|
||||
|
||||
vi.setSystemTime(t0 + 62_000);
|
||||
expect(
|
||||
(await api.call('/api/auth/step-up', { method: 'POST', body: { code: totp.generate() } })).status,
|
||||
).toBe(200);
|
||||
|
||||
const wipeRes = await api.call('/api/auth/recovery-backup?disable=1', {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue