ImportEtherpad: Don't make any changes if data is bad

This commit is contained in:
Richard Hansen 2021-11-26 01:35:02 -05:00
parent a2e77a7128
commit 23f8a12922
2 changed files with 22 additions and 2 deletions

View file

@ -62,6 +62,16 @@ describe(__filename, function () {
assert(await db.get(badKey) == null);
});
it('changes are all or nothing', async function () {
const authorId = makeAuthorId();
const data = makeExport(authorId);
data['pad:differentPadId:revs:0'] = data['pad:testing:revs:0'];
delete data['pad:testing:revs:0'];
assert.rejects(importEtherpad.setPadRaw(padId, JSON.stringify(data)), /unexpected pad ID/);
assert(!await authorManager.doesAuthorExist(authorId));
assert(!await padManager.doesPadExist(padId));
});
describe('author pad IDs', function () {
let existingAuthorId;
let newAuthorId;