Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for /backup #1309

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions test/integration/api/backup.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
const { without } = require('ramda');
const { testService } = require('../setup');

const { httpZipResponseToFiles } = require('../../util/zip');

describe('api: /backup', () => {
describe('POST', () => {
describe('POST', function () {
this.timeout(10000);

it('should reject if the user cannot backup', testService((service) =>
service.login('chelsea', (asChelsea) =>
asChelsea.post('/v1/backup').expect(403))));

it('should return a valid zip file if the user can backup @slow', testService((service) =>
service.login('alice', (asAlice) =>
httpZipResponseToFiles(asAlice.post('/v1/backup').expect(200))
.then(({ filenames, files }) => {
const constantFiles = ['keepalive', 'keys.json', 'toc.dat'];
[ ...files.keys() ].should.containDeep(constantFiles);

const datFiles = without(constantFiles, filenames);
// Because /backup ALWAYS uses config('default.database'), this list
// may be empty in some environments, including CI.
datFiles.should.matchEvery(/\.dat\.gz$/);

const keysJson = JSON.parse(files.get('keys.json'));
keysJson.should.only.have.keys('iv', 'local', 'privkey', 'pubkey', 'salt');
keysJson.iv.should.be.a.String();
keysJson.privkey.should.be.a.String();
keysJson.pubkey.should.be.a.String();
keysJson.salt.should.be.a.String();
keysJson.local.should.only.have.keys('key', 'ivs');
keysJson.local.key.should.be.a.String();
keysJson.local.ivs.should.only.have.keys('toc.dat', ...datFiles);
}))));
});
});

Loading