fix: mark backup snapshots without metadata invalid
This commit is contained in:
@@ -372,7 +372,7 @@ export async function listBossStateBackups(limit = 20): Promise<BossStateBackupS
|
|||||||
fileName,
|
fileName,
|
||||||
absolutePath,
|
absolutePath,
|
||||||
bytes: typeof meta.bytes === "number" ? meta.bytes : stat.size,
|
bytes: typeof meta.bytes === "number" ? meta.bytes : stat.size,
|
||||||
sha256: typeof meta.sha256 === "string" ? meta.sha256 : createHash("sha256").update(text).digest("hex"),
|
sha256: typeof meta.sha256 === "string" ? meta.sha256 : "",
|
||||||
createdAt: typeof meta.createdAt === "string" ? meta.createdAt : stat.mtime.toISOString(),
|
createdAt: typeof meta.createdAt === "string" ? meta.createdAt : stat.mtime.toISOString(),
|
||||||
actorAccount: typeof meta.actorAccount === "string" ? meta.actorAccount : undefined,
|
actorAccount: typeof meta.actorAccount === "string" ? meta.actorAccount : undefined,
|
||||||
reason: typeof meta.reason === "string" ? meta.reason : undefined,
|
reason: typeof meta.reason === "string" ? meta.reason : undefined,
|
||||||
|
|||||||
@@ -234,6 +234,15 @@ test("backup actions reject snapshots with missing or mismatched metadata", asyn
|
|||||||
assert.equal(missingMetaPayload.verification.ok, false);
|
assert.equal(missingMetaPayload.verification.ok, false);
|
||||||
assert.equal(missingMetaPayload.verification.message, "snapshot metadata is missing");
|
assert.equal(missingMetaPayload.verification.message, "snapshot metadata is missing");
|
||||||
|
|
||||||
|
const listAfterMissingMeta = await getBackups(await requestFor("owner@boss.com", "highest_admin"));
|
||||||
|
assert.equal(listAfterMissingMeta.status, 200);
|
||||||
|
const listAfterMissingMetaPayload = await listAfterMissingMeta.json();
|
||||||
|
const missingMetaListedSnapshot = listAfterMissingMetaPayload.snapshots.find(
|
||||||
|
(snapshot: { snapshotId: string }) => snapshot.snapshotId === snapshotId,
|
||||||
|
);
|
||||||
|
assert.equal(missingMetaListedSnapshot.verification.ok, false);
|
||||||
|
assert.equal(missingMetaListedSnapshot.status, "error");
|
||||||
|
|
||||||
const missingMetaPreview = await postBackups(
|
const missingMetaPreview = await postBackups(
|
||||||
await requestFor("owner@boss.com", "highest_admin", {
|
await requestFor("owner@boss.com", "highest_admin", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|||||||
Reference in New Issue
Block a user