fix: make server discovery and audits read-only
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import backupModule from '../src/main/configuration-backup.cjs';
|
||||
import configModule from '../src/main/config-store.cjs';
|
||||
|
||||
const { sanitizeConfiguration, createEncryptedBackup, readEncryptedBackup } = backupModule;
|
||||
const { ConfigStore } = configModule;
|
||||
|
||||
test('configuration backups exclude credentials and operation history', () => {
|
||||
const clean = sanitizeConfiguration({
|
||||
@@ -25,3 +30,16 @@ test('configuration backups round-trip with authenticated encryption', () => {
|
||||
assert.equal(restored.configuration.gitea.encryptedToken, null);
|
||||
assert.throws(() => readEncryptedBackup(serialized, 'incorrect passphrase'), /could not be decrypted/i);
|
||||
});
|
||||
|
||||
test('recovery snapshots preserve the exact in-memory configuration before a mutation', async (context) => {
|
||||
const directory = await mkdtemp(path.join(tmpdir(), 'forgeflow-config-snapshot-'));
|
||||
context.after(() => rm(directory, { recursive: true, force: true }));
|
||||
const store = new ConfigStore(directory);
|
||||
store.data.workspaceRoots = ['C:/Projects'];
|
||||
store.data.deploymentProfiles = { 'jens/example': [{ id: 'production', provider: 'gitea-actions' }] };
|
||||
await store.save();
|
||||
const before = `${JSON.stringify(store.data, null, 2)}\n`;
|
||||
const snapshot = await store.createRecoverySnapshot('server reconciliation / production');
|
||||
assert.equal(await readFile(snapshot.filePath, 'utf8'), before);
|
||||
assert.equal(snapshot.reason, 'server-reconciliation-production');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user