feat(gateway): add accountable admin controls

This commit is contained in:
2026-08-06 12:52:40 +00:00
parent 228fa62f67
commit 3be3e3b307
22 changed files with 1617 additions and 20 deletions
+34
View File
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';
import { buildAdminAuditTarget, sanitizeAdminAuditValue } from '../src/adminAudit.js';
describe('administrator audit sanitization', () => {
it('redacts credentials recursively while preserving operational context', () => {
expect(
sanitizeAdminAuditValue({
username: 'target',
password: 'secret',
nested: { authorization: 'Bearer token', notes: 'approved' },
})
).toEqual({
username: 'target',
password: '[REDACTED]',
nested: { authorization: '[REDACTED]', notes: 'approved' },
});
});
it('extracts a user target and reason without retaining the supplied password', () => {
expect(
buildAdminAuditTarget({
userId: 'user-1',
reason: 'account recovery',
newPassword: 'replacement-secret',
})
).toMatchObject({
targetType: 'USER',
targetId: 'user-1',
reason: 'account recovery',
summary: { newPassword: '[REDACTED]' },
});
});
});