diff --git a/run-tests b/run-tests index 611230ec0..c6954371b 100755 --- a/run-tests +++ b/run-tests @@ -23,7 +23,7 @@ mkdir -p ${DATA_DIR} cd ${DATA_DIR} mkdir -p appsdata mkdir -p boxdata/box boxdata/mail boxdata/certs boxdata/mail/dkim/localhost boxdata/mail/dkim/foobar.com -mkdir -p platformdata/addons/mail/banner platformdata/nginx/cert platformdata/nginx/applications/dashboard platformdata/collectd/collectd.conf.d platformdata/addons platformdata/logrotate.d platformdata/backup platformdata/logs/tasks platformdata/sftp/ssh platformdata/firewall platformdata/update +mkdir -p platformdata/addons/mail/banner platformdata/nginx/cert platformdata/nginx/applications/dashboard platformdata/collectd/collectd.conf.d platformdata/addons platformdata/logrotate.d platformdata/backup platformdata/logs/tasks platformdata/sftp/ssh platformdata/firewall platformdata/update platformdata/diskusage sudo mkdir -p /mnt/cloudron-test-music /media/cloudron-test-music # volume test # put cert diff --git a/src/applinks.js b/src/applinks.js index 5c882ca75..f4bd4f078 100644 --- a/src/applinks.js +++ b/src/applinks.js @@ -6,7 +6,7 @@ exports = module.exports = { add, get, update, - remove, + del, getIcon }; @@ -193,7 +193,7 @@ async function update(applinkId, applink) { debug(`update: ${applink.upstreamUri}`); - let error = validateUpstreamUri(applink.upstreamUri); + const error = validateUpstreamUri(applink.upstreamUri); if (error) throw error; if (applink.icon) { @@ -217,7 +217,7 @@ async function update(applinkId, applink) { if (result.affectedRows !== 1) throw new BoxError(BoxError.NOT_FOUND, 'Applink not found'); } -async function remove(applinkId) { +async function del(applinkId) { assert.strictEqual(typeof applinkId, 'string'); const result = await database.query('DELETE FROM applinks WHERE id = ?', [ applinkId ]); diff --git a/src/groups.js b/src/groups.js index addea4d70..d1a523589 100644 --- a/src/groups.js +++ b/src/groups.js @@ -2,7 +2,7 @@ exports = module.exports = { add, - remove, + del, get, getByName, @@ -80,11 +80,11 @@ async function add(group) { return { id, name, source }; } -async function remove(id) { +async function del(id) { assert.strictEqual(typeof id, 'string'); // also cleanup the groupMembers table - let queries = []; + const queries = []; queries.push({ query: 'DELETE FROM groupMembers WHERE groupId = ?', args: [ id ] }); queries.push({ query: 'DELETE FROM userGroups WHERE id = ?', args: [ id ] }); diff --git a/src/routes/applinks.js b/src/routes/applinks.js index 53ee57e9e..4ba0d8456 100644 --- a/src/routes/applinks.js +++ b/src/routes/applinks.js @@ -5,7 +5,7 @@ exports = module.exports = { add, get, update, - remove, + del, getIcon }; @@ -71,10 +71,10 @@ async function update(req, res, next) { next(new HttpSuccess(202, {})); } -async function remove(req, res, next) { +async function del(req, res, next) { assert.strictEqual(typeof req.params.id, 'string'); - const [error] = await safe(applinks.remove(req.params.id)); + const [error] = await safe(applinks.del(req.params.id)); if (error) return next(BoxError.toHttpError(error)); next(new HttpSuccess(204)); diff --git a/src/routes/groups.js b/src/routes/groups.js index de126ab90..6c3531dcb 100644 --- a/src/routes/groups.js +++ b/src/routes/groups.js @@ -7,7 +7,7 @@ exports = module.exports = { list, add, setName, - remove, + del, setMembers }; @@ -78,10 +78,10 @@ async function list(req, res, next) { next(new HttpSuccess(200, { groups: result })); } -async function remove(req, res, next) { +async function del(req, res, next) { assert.strictEqual(typeof req.params.groupId, 'string'); - const [error] = await safe(groups.remove(req.params.groupId)); + const [error] = await safe(groups.del(req.params.groupId)); if (error) return next(BoxError.toHttpError(error)); next(new HttpSuccess(204)); diff --git a/src/server.js b/src/server.js index 5237d689c..649b06cc8 100644 --- a/src/server.js +++ b/src/server.js @@ -211,7 +211,7 @@ async function initializeExpressSync() { router.get ('/api/v1/groups/:groupId', token, authorizeUserManager, routes.groups.load, routes.groups.get); router.put ('/api/v1/groups/:groupId/members', json, token, authorizeUserManager, routes.groups.load, routes.groups.setMembers); router.put ('/api/v1/groups/:groupId/name', json, token, authorizeUserManager, routes.groups.load, routes.groups.setName); - router.del ('/api/v1/groups/:groupId', token, authorizeUserManager, routes.groups.load, routes.groups.remove); + router.del ('/api/v1/groups/:groupId', token, authorizeUserManager, routes.groups.load, routes.groups.del); // User directory router.get ('/api/v1/user_directory/profile_config', token, authorizeAdmin, routes.userDirectory.getProfileConfig); @@ -300,7 +300,7 @@ async function initializeExpressSync() { router.post('/api/v1/applinks', json, token, authorizeAdmin, routes.applinks.add); router.get ('/api/v1/applinks/:id', token, authorizeAdmin, routes.applinks.get); router.post('/api/v1/applinks/:id', json, token, authorizeAdmin, routes.applinks.update); - router.del ('/api/v1/applinks/:id', token, authorizeAdmin, routes.applinks.remove); + router.del ('/api/v1/applinks/:id', token, authorizeAdmin, routes.applinks.del); router.get ('/api/v1/applinks/:id/icon', token, authorizeUser, routes.applinks.getIcon); // branding routes diff --git a/src/test/applinks-test.js b/src/test/applinks-test.js index b4aff5044..3be22bee4 100644 --- a/src/test/applinks-test.js +++ b/src/test/applinks-test.js @@ -112,14 +112,14 @@ describe('Applinks', function () { expect(result.toString('base64')).to.eql(APPLINK_1.icon); }); - it('cannot remove applink with wrong id', async function () { - const [error] = await safe(applinks.remove('doesnotexist')); + it('cannot del applink with wrong id', async function () { + const [error] = await safe(applinks.del('doesnotexist')); expect(error).to.be.a(BoxError); expect(error.reason).to.eql(BoxError.NOT_FOUND); }); - it('can remove applink', async function () { - await applinks.remove(APPLINK_0.id); + it('can del applink', async function () { + await applinks.del(APPLINK_0.id); const result = await applinks.get(APPLINK_0.id); expect(result).to.be(null); diff --git a/src/test/groups-test.js b/src/test/groups-test.js index a74cf51b1..41720b726 100644 --- a/src/test/groups-test.js +++ b/src/test/groups-test.js @@ -172,13 +172,13 @@ describe('Groups', function () { describe('delete', function () { it('cannot delete invalid group', async function () { - const [error] = await safe(groups.remove('random')); + const [error] = await safe(groups.del('random')); expect(error.reason).to.be(BoxError.NOT_FOUND); }); it('can delete valid group', async function () { await groups.setMembers(group0Object, [ admin.id, user.id ], {}); // ensure group has some members - await groups.remove(group0Object.id); + await groups.del(group0Object.id); }); });