Add route to list all blockdevices
This commit is contained in:
@@ -27,7 +27,8 @@ exports = module.exports = {
|
||||
syncExternalLdap,
|
||||
syncDnsRecords,
|
||||
getSystemGraphs,
|
||||
getPlatformStatus
|
||||
getPlatformStatus,
|
||||
getBlockDevices
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
@@ -365,3 +366,10 @@ async function getSystemGraphs(req, res, next) {
|
||||
async function getPlatformStatus(req, res, next) {
|
||||
next(new HttpSuccess(200, platform.getStatus()));
|
||||
}
|
||||
|
||||
async function getBlockDevices(req, res, next) {
|
||||
const [error, devices] = await safe(cloudron.getBlockDevices());
|
||||
if (error) return next(new HttpError(500, error));
|
||||
|
||||
next(new HttpSuccess(200, { devices }));
|
||||
}
|
||||
|
||||
@@ -439,4 +439,16 @@ describe('Cloudron API', function () {
|
||||
expect(response.body.languages.indexOf('en')).to.not.equal(-1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('blockdevices', function () {
|
||||
it('succeeds', async function () {
|
||||
const response = await superagent.get(`${serverUrl}/api/v1/cloudron/block_devices`)
|
||||
.query({ access_token: owner.token });
|
||||
|
||||
expect(response.statusCode).to.equal(200);
|
||||
expect(response.body.devices).to.be.ok();
|
||||
|
||||
expect(response.body.devices.some(d => d.mountpoint === '/')).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user