rename backups to backuptargets
This commit is contained in:
@@ -16,44 +16,44 @@ exports = module.exports = {
|
||||
|
||||
const assert = require('assert'),
|
||||
AuditSource = require('../auditsource.js'),
|
||||
backups = require('../backups.js'),
|
||||
backupTargets = require('../backuptargets.js'),
|
||||
BoxError = require('../boxerror.js'),
|
||||
HttpError = require('@cloudron/connect-lastmile').HttpError,
|
||||
HttpSuccess = require('@cloudron/connect-lastmile').HttpSuccess,
|
||||
safe = require('safetydance');
|
||||
|
||||
async function create(req, res, next) {
|
||||
const [error, taskId] = await safe(backups.startBackupTask(AuditSource.fromRequest(req)));
|
||||
const [error, taskId] = await safe(backupTargets.startBackupTask(AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
|
||||
async function cleanup(req, res, next) {
|
||||
const [error, taskId] = await safe(backups.startCleanupTask(AuditSource.fromRequest(req)));
|
||||
const [error, taskId] = await safe(backupTargets.startCleanupTask(AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, { taskId }));
|
||||
}
|
||||
|
||||
async function remount(req, res, next) {
|
||||
const [error] = await safe(backups.remount());
|
||||
const [error] = await safe(backupTargets.remount());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(202, {}));
|
||||
}
|
||||
|
||||
async function getMountStatus(req, res, next) {
|
||||
const [error, mountStatus] = await safe(backups.getMountStatus());
|
||||
const [error, mountStatus] = await safe(backupTargets.getMountStatus());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
next(new HttpSuccess(200, mountStatus));
|
||||
}
|
||||
|
||||
async function getConfig(req, res, next) {
|
||||
const [error, backupConfig] = await safe(backups.getConfig());
|
||||
const [error, backupConfig] = await safe(backupTargets.getConfig());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, backups.removePrivateFields(backupConfig)));
|
||||
next(new HttpSuccess(200, backupTargets.removePrivateFields(backupConfig)));
|
||||
}
|
||||
|
||||
async function setLimits(req, res, next) {
|
||||
@@ -84,7 +84,7 @@ async function setLimits(req, res, next) {
|
||||
|
||||
if ('memoryLimit' in limits && typeof limits.memoryLimit !== 'number') return next(new HttpError(400, 'memoryLimit must be a positive integer'));
|
||||
|
||||
const [error] = await safe(backups.setLimits(req.body));
|
||||
const [error] = await safe(backupTargets.setLimits(req.body));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -113,14 +113,14 @@ async function setStorage(req, res, next) {
|
||||
// testing the backup using put/del takes a bit of time at times
|
||||
req.clearTimeout();
|
||||
|
||||
const [error] = await safe(backups.setStorage(req.body));
|
||||
const [error] = await safe(backupTargets.setStorage(req.body));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
}
|
||||
|
||||
async function getPolicy(req, res, next) {
|
||||
const [error, policy] = await safe(backups.getPolicy());
|
||||
const [error, policy] = await safe(backupTargets.getPolicy());
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { policy }));
|
||||
@@ -132,7 +132,7 @@ async function setPolicy(req, res, next) {
|
||||
if (typeof req.body.schedule !== 'string') return next(new HttpError(400, 'schedule is required'));
|
||||
if (!req.body.retention || typeof req.body.retention !== 'object') return next(new HttpError(400, 'retention is required'));
|
||||
|
||||
const [error] = await safe(backups.setPolicy(req.body));
|
||||
const [error] = await safe(backupTargets.setPolicy(req.body));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
+1
-1
@@ -9,7 +9,7 @@ exports = module.exports = {
|
||||
archives: require('./archives.js'),
|
||||
auth: require('./auth.js'),
|
||||
backupListing: require('./backuplisting.js'),
|
||||
backups: require('./backups.js'),
|
||||
backupTargets: require('./backuptargets.js'),
|
||||
branding: require('./branding.js'),
|
||||
cloudron: require('./cloudron.js'),
|
||||
dashboard: require('./dashboard.js'),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const backups = require('../../backups.js'),
|
||||
const backupTargets = require('../../backuptargets.js'),
|
||||
common = require('./common.js'),
|
||||
expect = require('expect.js'),
|
||||
superagent = require('@cloudron/superagent');
|
||||
@@ -111,7 +111,7 @@ describe('Backups API', function () {
|
||||
|
||||
describe('backup_config', function () {
|
||||
// keep in sync with defaults in settings.js
|
||||
let defaultConfig = {
|
||||
const defaultConfig = {
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/var/backups',
|
||||
format: 'tgz',
|
||||
@@ -127,7 +127,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config without provider', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
delete tmp.provider;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -139,7 +139,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid provider', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.provider = 'invalid provider';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -151,7 +151,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config without format', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
delete tmp.format;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -163,7 +163,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid format', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.format = 'invalid format';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -175,7 +175,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid password', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.password = 1234;
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -187,7 +187,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid syncConcurrency', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.limits = { syncConcurrency: 'not a number' };
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -199,7 +199,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid syncConcurrency', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.limits = { syncConcurrency: 0 };
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -211,7 +211,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('cannot set backup_config with invalid acceptSelfSignedCerts', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.acceptSelfSignedCerts = 'not a boolean';
|
||||
|
||||
const response = await superagent.post(`${serverUrl}/api/v1/backups/config`)
|
||||
@@ -223,7 +223,7 @@ describe('Backups API', function () {
|
||||
});
|
||||
|
||||
it('can set backup_config', async function () {
|
||||
let tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
const tmp = JSON.parse(JSON.stringify(defaultConfig));
|
||||
tmp.format = 'rsync';
|
||||
tmp.backupFolder = BACKUP_FOLDER;
|
||||
tmp.limits = { copyConcurrency: 34 };
|
||||
@@ -247,7 +247,7 @@ describe('Backups API', function () {
|
||||
|
||||
describe('create', function () {
|
||||
before(async function () {
|
||||
await backups.setStorage({
|
||||
await backupTargets.setStorage({
|
||||
provider: 'filesystem',
|
||||
backupFolder: '/tmp/backups',
|
||||
format: 'tgz',
|
||||
@@ -282,7 +282,7 @@ describe('Backups API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.backups.length).to.be(1);
|
||||
expect(response.body.backupTargets.length).to.be(1);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -293,7 +293,7 @@ describe('Backups API', function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/backups`)
|
||||
.query({ access_token: owner.token });
|
||||
expect(response.status).to.equal(200);
|
||||
expect(response.body.backups.length).to.be(1);
|
||||
expect(response.body.backupTargets.length).to.be(1);
|
||||
someBackup = response.body.backups[0];
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
const apps = require('../../apps.js'),
|
||||
appstore = require('../../appstore.js'),
|
||||
backups = require('../../backups.js'),
|
||||
backupTargets = require('../../backuptargets.js'),
|
||||
debug = require('debug')('box:test/common'),
|
||||
constants = require('../../constants.js'),
|
||||
database = require('../../database.js'),
|
||||
@@ -115,7 +115,7 @@ async function setupServer() {
|
||||
await database.initialize();
|
||||
await database._clear();
|
||||
await appstore._setApiServerOrigin(exports.mockApiServerOrigin);
|
||||
await backups._addDefaultTarget();
|
||||
await backupTargets._addDefaultTarget();
|
||||
await oidcServer.stop();
|
||||
await server.start();
|
||||
debug('Set up server complete');
|
||||
|
||||
Reference in New Issue
Block a user