backup site: add contents

it is a json that can be one of the three:

* null - include everything
* include - only include these ids
* exclude - everything except these ids
This commit is contained in:
Girish Ramakrishnan
2025-09-22 13:27:26 +02:00
parent 0d5c1b99df
commit 4c3a8e1fd7
8 changed files with 146 additions and 20 deletions
+56 -1
View File
@@ -19,7 +19,8 @@ describe('Backups API', function () {
config: { backupDir: '/tmp/boxtest-newsite' },
format: 'tgz',
retention: { keepWithinSecs: 60 * 60 },
schedule: '00 01 * * * *'
schedule: '00 01 * * * *',
contents: null
};
const encryptedSite = {
@@ -29,6 +30,7 @@ describe('Backups API', function () {
format: 'rsync',
retention: { keepMonthly: 60 },
schedule: '* 1 * * * *',
contents: { exclude: [ 'thatapp' ] }
};
describe('add', function () {
@@ -210,6 +212,59 @@ describe('Backups API', function () {
});
});
describe('contents', function () {
it('cannot set invalid contents', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}/configure/contents`)
.query({ access_token: owner.token })
.send({ contents: 'garbage' })
.ok(() => true);
expect(response.status).to.equal(400);
});
it('cannot set invalid include', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}/configure/contents`)
.query({ access_token: owner.token })
.send({ contents: { include: 'something' } })
.ok(() => true);
expect(response.status).to.equal(400);
});
it('can set include', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}/configure/contents`)
.query({ access_token: owner.token })
.send({ contents: { include: [ 'something' ]} })
.ok(() => true);
expect(response.status).to.equal(200);
const result = await backupSites.get(newSite.id);
expect(result.contents).to.eql({ include: [ 'something' ]});
});
it('can set exclude', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}/configure/contents`)
.query({ access_token: owner.token })
.send({ contents: { exclude: [ 'something' ]} })
.ok(() => true);
expect(response.status).to.equal(200);
const result = await backupSites.get(newSite.id);
expect(result.contents).to.eql({ exclude: [ 'something' ] });
});
it('can set null', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}/configure/contents`)
.query({ access_token: owner.token })
.send({ contents: null })
.ok(() => true);
expect(response.status).to.equal(200);
const result = await backupSites.get(newSite.id);
expect(result.contents).to.eql(null);
});
});
describe('primary', function () {
it('cannot set invalid id', async function () {
const response = await superagent.post(`${serverUrl}/api/v1/backup_sites/${newSite.id}xx/configure/primary`)