Revert "add volume support"
This reverts commit b8bb69f730.
Revert this for now, we will try a simpler non-object volume first
This commit is contained in:
@@ -1479,52 +1479,6 @@ describe('App API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('volumes', function () {
|
||||
let volumeId;
|
||||
|
||||
it('can add volume', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ name: 'videos', hostPath: '/media/cloudron-test' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(201);
|
||||
expect(res.body.id).to.be.a('string');
|
||||
volumeId = res.body.id;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can set volume', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ volumes: [ {id: volumeId, readOnly: false} ] })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(202);
|
||||
taskId = res.body.taskId;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('wait for task', function (done) {
|
||||
waitForTask(taskId, done);
|
||||
});
|
||||
|
||||
it('did set volume', function (done) {
|
||||
apps.get(APP_ID, function (error, appEntry) {
|
||||
if (error) return done(error);
|
||||
|
||||
docker.getContainer(appEntry.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].Type).to.eql('volume');
|
||||
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].Name).to.eql(volumeId);
|
||||
expect(data.Mounts.filter(function (mount) { return mount.Destination === '/media/videos'; })[0].RW).to.eql(true);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('start/stop', function () {
|
||||
it('non admin cannot stop app', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
/* global it:false */
|
||||
/* global describe:false */
|
||||
/* global before:false */
|
||||
/* global after:false */
|
||||
|
||||
var async = require('async'),
|
||||
constants = require('../../constants.js'),
|
||||
database = require('../../database.js'),
|
||||
expect = require('expect.js'),
|
||||
server = require('../../server.js'),
|
||||
superagent = require('superagent');
|
||||
|
||||
var SERVER_URL = 'http://localhost:' + constants.PORT;
|
||||
|
||||
var USERNAME = 'superadmin', PASSWORD = 'Foobar?1337', EMAIL ='silly@me.com';
|
||||
var token = null;
|
||||
|
||||
function setup(done) {
|
||||
async.series([
|
||||
server.start.bind(null),
|
||||
database._clear.bind(null),
|
||||
|
||||
function createAdmin(callback) {
|
||||
superagent.post(SERVER_URL + '/api/v1/cloudron/activate')
|
||||
.query({ setupToken: 'somesetuptoken' })
|
||||
.send({ username: USERNAME, password: PASSWORD, email: EMAIL })
|
||||
.end(function (error, result) {
|
||||
expect(result).to.be.ok();
|
||||
expect(result.statusCode).to.eql(201);
|
||||
|
||||
// stash token for further use
|
||||
token = result.body.token;
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
], done);
|
||||
}
|
||||
|
||||
function cleanup(done) {
|
||||
database._clear(function (error) {
|
||||
expect(!error).to.be.ok();
|
||||
|
||||
server.stop(done);
|
||||
});
|
||||
}
|
||||
|
||||
describe('Volume API', function () {
|
||||
before(setup);
|
||||
after(cleanup);
|
||||
let volumeId;
|
||||
|
||||
describe('add', function () {
|
||||
it('bad name', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ name: 'som*', hostPath: '/media/cloudron-test' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('name');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('bad path', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ name: 'videos', hostPath: '/tmp/cloudron-test' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
expect(res.body.message).to.contain('hostPath');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can add volume', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ name: 'videos', hostPath: '/media/cloudron-test' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(201);
|
||||
expect(res.body.id).to.be.a('string');
|
||||
volumeId = res.body.id;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot add conflicting path', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.send({ name: 'videos2', hostPath: '/media/cloudron-test' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(409);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('get', function () {
|
||||
it('cannot get random volume', function (done) {
|
||||
superagent.get(SERVER_URL + '/api/v1/volumes/someid')
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can get valid volume', function (done) {
|
||||
superagent.get(SERVER_URL + `/api/v1/volumes/${volumeId}`)
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.body.hostPath).to.be('/media/cloudron-test');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('list', function () {
|
||||
it('can list', function (done) {
|
||||
superagent.get(SERVER_URL + '/api/v1/volumes')
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.body.volumes.length).to.be(1);
|
||||
expect(res.body.volumes[0].name).to.be('videos');
|
||||
expect(res.body.volumes[0].hostPath).to.be('/media/cloudron-test');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('del', function () {
|
||||
it('cannot del random volume', function (done) {
|
||||
superagent.del(SERVER_URL + '/api/v1/volumes/someid')
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(404);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can del valid volume', function (done) {
|
||||
superagent.del(SERVER_URL + `/api/v1/volumes/${volumeId}`)
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(204);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user