diff --git a/src/routes/test/volumes-test.js b/src/routes/test/volumes-test.js index d5ee37342..ca5e584d3 100644 --- a/src/routes/test/volumes-test.js +++ b/src/routes/test/volumes-test.js @@ -7,6 +7,7 @@ const common = require('./common.js'), expect = require('expect.js'), + safe = require('safetydance'), superagent = require('superagent'); describe('Volumes API', function () { @@ -67,17 +68,13 @@ describe('Volumes API', function () { expect(response.body.hostPath).to.be('/media/cloudron-test-music'); }); - it('can update volume', async function () { - let response = await superagent.post(`${serverUrl}/api/v1/volumes/${volumeId}`) + it('cannot update volume', async function () { + let [error, response] = await safe(superagent.post(`${serverUrl}/api/v1/volumes/${volumeId}`) .query({ access_token: owner.token }) - .send({ mountOptions: { hostPath: '/media/cloudron-test-music-2' }}); - expect(response.statusCode).to.equal(204); + .send({ mountOptions: { hostPath: '/media/cloudron-test-music-2' }}) + .ok(() => true)); - response = await superagent.get(`${serverUrl}/api/v1/volumes/${volumeId}`) - .query({ access_token: owner.token }); - expect(response.statusCode).to.equal(200); - expect(response.body.id).to.be(volumeId); - expect(response.body.hostPath).to.be('/media/cloudron-test-music-2'); + expect(response.statusCode).to.equal(400); // cannot update filesytem }); it('can delete volume', async function () { diff --git a/src/volumes.js b/src/volumes.js index e5348bdd0..2d5edbf24 100644 --- a/src/volumes.js +++ b/src/volumes.js @@ -142,10 +142,9 @@ async function update(id, mountOptions, auditSource) { assert.strictEqual(typeof auditSource, 'object'); const volume = await get(id); - const mountType = volume.mountType; - const name = volume.name; + const { name, mountType } = volume; - if (mountType !== 'cifs' && mountType !== 'sshfs' && mountType !== 'nfs') return; + if (mountType !== 'cifs' && mountType !== 'sshfs' && mountType !== 'nfs') throw new BoxError(BoxError.BAD_FIELD, 'Only network mounts can be updated'); const error = mounts.validateMountOptions(mountType, mountOptions); if (error) throw error;