Add env and debug mode tests
This commit is contained in:
@@ -1122,6 +1122,159 @@ describe('App API', function () {
|
||||
});
|
||||
});
|
||||
|
||||
describe('configure debug mode', function () {
|
||||
it('fails with missing mode', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/debug_mode')
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails with bad debug mode', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/debug_mode')
|
||||
.query({ access_token: token })
|
||||
.send({ debugMode: 'sleep' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can set debug mode', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/debug_mode')
|
||||
.query({ access_token: token })
|
||||
.send({ debugMode: { readonlyRootfs: 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 change readonly rootfs', function (done) {
|
||||
apps.get(APP_ID, function (error, app) {
|
||||
if (error) return done(error);
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
|
||||
expect(data.HostConfig.ReadonlyRootfs).to.be(false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('can reset debug mode', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/debug_mode')
|
||||
.query({ access_token: token })
|
||||
.send({ debugMode: null })
|
||||
.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 change readonly rootfs', function (done) {
|
||||
apps.get(APP_ID, function (error, app) {
|
||||
if (error) return done(error);
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
|
||||
expect(data.HostConfig.ReadonlyRootfs).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('configure env', function () {
|
||||
it('fails with missing env', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/env')
|
||||
.query({ access_token: token })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('fails with bad env mode', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/env')
|
||||
.query({ access_token: token })
|
||||
.send({ env: 'ok' })
|
||||
.end(function (err, res) {
|
||||
expect(res.statusCode).to.equal(400);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can set env', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/env')
|
||||
.query({ access_token: token })
|
||||
.send({ env: { 'OPM': 'SAITAMA' } })
|
||||
.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 env', function (done) {
|
||||
apps.get(APP_ID, function (error, app) {
|
||||
if (error) return done(error);
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
|
||||
expect(data.Config.Env).to.contain('OPM=SAITAMA');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('can reset env', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/configure/env')
|
||||
.query({ access_token: token })
|
||||
.send({ env: {} })
|
||||
.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 reset env', function (done) {
|
||||
apps.get(APP_ID, function (error, app) {
|
||||
if (error) return done(error);
|
||||
|
||||
docker.getContainer(app.containerId).inspect(function (error, data) {
|
||||
expect(error).to.not.be.ok();
|
||||
expect(data.Config.Env).to.not.contain('OPM=SAITAMA');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('start/stop', function () {
|
||||
it('non admin cannot stop app', function (done) {
|
||||
superagent.post(SERVER_URL + '/api/v1/apps/' + APP_ID + '/stop')
|
||||
|
||||
Reference in New Issue
Block a user