2015-07-20 00:09:47 -07:00
|
|
|
/* global it:false */
|
|
|
|
|
/* global describe:false */
|
|
|
|
|
/* global before:false */
|
|
|
|
|
/* global after:false */
|
|
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
2017-02-07 10:30:52 -08:00
|
|
|
var async = require('async'),
|
2017-01-10 16:44:28 -08:00
|
|
|
database = require('../database.js'),
|
2015-07-20 00:09:47 -07:00
|
|
|
expect = require('expect.js'),
|
2017-09-27 10:25:36 -07:00
|
|
|
MockS3 = require('mock-aws-s3'),
|
|
|
|
|
nock = require('nock'),
|
|
|
|
|
os = require('os'),
|
|
|
|
|
path = require('path'),
|
|
|
|
|
rimraf = require('rimraf'),
|
|
|
|
|
s3 = require('../storage/s3.js'),
|
2019-07-26 10:49:29 -07:00
|
|
|
settings = require('../settings.js');
|
2018-01-23 15:47:41 -08:00
|
|
|
|
2015-07-20 00:09:47 -07:00
|
|
|
function setup(done) {
|
2017-09-27 10:25:36 -07:00
|
|
|
nock.cleanAll();
|
2017-04-14 01:13:42 -07:00
|
|
|
|
2017-02-07 10:30:52 -08:00
|
|
|
async.series([
|
|
|
|
|
database.initialize,
|
|
|
|
|
function (callback) {
|
2017-09-27 10:25:36 -07:00
|
|
|
MockS3.config.basePath = path.join(os.tmpdir(), 's3-settings-test-buckets/');
|
|
|
|
|
|
|
|
|
|
s3._mockInject(MockS3);
|
|
|
|
|
|
2019-05-08 17:30:41 -07:00
|
|
|
callback();
|
2017-02-07 10:30:52 -08:00
|
|
|
}
|
|
|
|
|
], done);
|
2015-07-20 00:09:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cleanup(done) {
|
2017-09-27 10:25:36 -07:00
|
|
|
s3._mockRestore();
|
|
|
|
|
rimraf.sync(MockS3.config.basePath);
|
|
|
|
|
|
2017-02-07 10:30:52 -08:00
|
|
|
async.series([
|
2017-11-27 11:48:36 -08:00
|
|
|
database._clear,
|
|
|
|
|
database.uninitialize
|
2017-02-07 10:30:52 -08:00
|
|
|
], done);
|
2015-07-20 00:09:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('Settings', function () {
|
2015-10-28 14:35:39 +01:00
|
|
|
describe('values', function () {
|
|
|
|
|
before(setup);
|
|
|
|
|
after(cleanup);
|
2015-07-20 00:09:47 -07:00
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get default timezone', function (done) {
|
|
|
|
|
settings.getTimeZone(function (error, tz) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(tz.length).to.not.be(0);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
|
2018-02-06 18:57:30 +01:00
|
|
|
it('can get default app_autoupdate_pattern', function (done) {
|
|
|
|
|
settings.getAppAutoupdatePattern(function (error, pattern) {
|
2015-10-28 14:35:39 +01:00
|
|
|
expect(error).to.be(null);
|
2018-03-06 01:35:38 -08:00
|
|
|
expect(pattern).to.be('00 30 1,3,5,23 * * *');
|
2015-10-28 14:35:39 +01:00
|
|
|
done();
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
|
2018-02-06 18:57:30 +01:00
|
|
|
it('can get default box_autoupdate_pattern', function (done) {
|
|
|
|
|
settings.getBoxAutoupdatePattern(function (error, pattern) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(pattern).to.be('00 00 1,3,5,23 * * *');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it ('can get default cloudron name', function (done) {
|
|
|
|
|
settings.getCloudronName(function (error, name) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(name).to.be('Cloudron');
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get default cloudron avatar', function (done) {
|
|
|
|
|
settings.getCloudronAvatar(function (error, gravatar) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(gravatar).to.be.a(Buffer);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
|
2015-11-07 22:17:08 -08:00
|
|
|
it('can get backup config', function (done) {
|
2016-01-23 05:06:09 -08:00
|
|
|
settings.getBackupConfig(function (error, backupConfig) {
|
2015-11-07 22:17:08 -08:00
|
|
|
expect(error).to.be(null);
|
2019-05-08 17:30:41 -07:00
|
|
|
expect(backupConfig.provider).to.be('filesystem');
|
|
|
|
|
expect(backupConfig.backupFolder).to.be('/var/backups');
|
2016-01-23 05:06:09 -08:00
|
|
|
done();
|
2016-01-23 05:07:12 -08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2019-04-27 22:34:52 +02:00
|
|
|
it('can get default unstable apps setting', function (done) {
|
|
|
|
|
settings.getUnstableAppsConfig(function (error, enabled) {
|
|
|
|
|
expect(error).to.be(null);
|
2019-11-11 11:06:03 -08:00
|
|
|
expect(enabled).to.be(true);
|
2019-04-27 22:34:52 +02:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can set unstable apps setting', function (done) {
|
2019-11-11 11:06:03 -08:00
|
|
|
settings.setUnstableAppsConfig(false, function (error) {
|
2019-04-27 22:34:52 +02:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
|
|
|
|
|
settings.getUnstableAppsConfig(function (error, enabled) {
|
|
|
|
|
expect(error).to.be(null);
|
2019-11-11 11:06:03 -08:00
|
|
|
expect(enabled).to.be(false);
|
2019-04-27 22:34:52 +02:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get all values', function (done) {
|
|
|
|
|
settings.getAll(function (error, allSettings) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(allSettings[settings.TIME_ZONE_KEY]).to.be.a('string');
|
2018-02-06 18:57:30 +01:00
|
|
|
expect(allSettings[settings.APP_AUTOUPDATE_PATTERN_KEY]).to.be.a('string');
|
|
|
|
|
expect(allSettings[settings.BOX_AUTOUPDATE_PATTERN_KEY]).to.be.a('string');
|
2015-10-28 14:35:39 +01:00
|
|
|
expect(allSettings[settings.CLOUDRON_NAME_KEY]).to.be.a('string');
|
2019-04-27 22:34:52 +02:00
|
|
|
expect(allSettings[settings.UNSTABLE_APPS_KEY]).to.be.a('boolean');
|
2015-10-28 14:35:39 +01:00
|
|
|
done();
|
|
|
|
|
});
|
2015-10-26 00:44:54 -07:00
|
|
|
});
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|