-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #1305
- Loading branch information
Showing
1 changed file
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
})))); | ||
}); | ||
}); | ||
|