eventlog: add backup target eventlog
This commit is contained in:
@@ -93,7 +93,7 @@ async function add(req, res, next) {
|
||||
// testing the backup using put/del takes a bit of time at times
|
||||
req.clearTimeout();
|
||||
|
||||
const [error, id] = await safe(backupTargets.add(req.body));
|
||||
const [error, id] = await safe(backupTargets.add(req.body, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, { id }));
|
||||
@@ -139,7 +139,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(backupTargets.setLimits(req.resources.backupTarget, limits));
|
||||
const [error] = await safe(backupTargets.setLimits(req.resources.backupTarget, limits, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -153,7 +153,7 @@ async function setConfig(req, res, next) {
|
||||
// testing the backup using put/del takes a bit of time at times
|
||||
req.clearTimeout();
|
||||
|
||||
const [error] = await safe(backupTargets.setConfig(req.resources.backupTarget, req.body.config));
|
||||
const [error] = await safe(backupTargets.setConfig(req.resources.backupTarget, req.body.config, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -164,7 +164,7 @@ async function setSchedule(req, res, next) {
|
||||
|
||||
if (typeof req.body.schedule !== 'string') return next(new HttpError(400, 'schedule is required'));
|
||||
|
||||
const [error] = await safe(backupTargets.setSchedule(req.resources.backupTarget, req.body.schedule));
|
||||
const [error] = await safe(backupTargets.setSchedule(req.resources.backupTarget, req.body.schedule, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -175,7 +175,7 @@ async function setRetention(req, res, next) {
|
||||
|
||||
if (!req.body.retention || typeof req.body.retention !== 'object') return next(new HttpError(400, 'retention is required'));
|
||||
|
||||
const [error] = await safe(backupTargets.setRetention(req.resources.backupTarget, req.body.retention));
|
||||
const [error] = await safe(backupTargets.setRetention(req.resources.backupTarget, req.body.retention, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
@@ -184,7 +184,7 @@ async function setRetention(req, res, next) {
|
||||
async function setPrimary(req, res, next) {
|
||||
assert.strictEqual(typeof req.body, 'object');
|
||||
|
||||
const [error] = await safe(backupTargets.setPrimary(req.resources.backupTarget));
|
||||
const [error] = await safe(backupTargets.setPrimary(req.resources.backupTarget, AuditSource.fromRequest(req)));
|
||||
if (error) return next(BoxError.toHttpError(error));
|
||||
|
||||
next(new HttpSuccess(200, {}));
|
||||
|
||||
@@ -100,7 +100,6 @@ describe('Backups API', function () {
|
||||
expect(response.body.format).to.be(encryptedTarget.format);
|
||||
expect(response.body.label).to.be(encryptedTarget.label);
|
||||
expect(response.body.primary).to.be(false);
|
||||
console.log(response.body);
|
||||
expect(response.body.password).to.be.ok();
|
||||
expect(response.body.encryptedFilenames).to.be(true);
|
||||
});
|
||||
|
||||
@@ -125,8 +125,8 @@ async function setupServer() {
|
||||
format: 'tgz',
|
||||
retention: { keepWithinSecs: 2 * 24 * 60 * 60 },
|
||||
schedule: '00 00 23 * * *'
|
||||
});
|
||||
await backupTargets.setPrimary({ id });
|
||||
}, exports.auditSource);
|
||||
await backupTargets.setPrimary({ id }, exports.auditSource);
|
||||
await oidcServer.stop();
|
||||
await server.start();
|
||||
debug('Set up server complete');
|
||||
|
||||
Reference in New Issue
Block a user