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'),
|
|
|
|
|
config = require('../config.js'),
|
2017-01-10 16:44:28 -08:00
|
|
|
database = require('../database.js'),
|
2015-07-20 00:09:47 -07:00
|
|
|
expect = require('expect.js'),
|
2016-10-13 15:28:05 -07:00
|
|
|
settings = require('../settings.js');
|
2015-07-20 00:09:47 -07:00
|
|
|
|
|
|
|
|
function setup(done) {
|
2017-04-14 01:13:42 -07:00
|
|
|
config.set('provider', 'caas');
|
|
|
|
|
|
2017-02-07 10:30:52 -08:00
|
|
|
async.series([
|
|
|
|
|
database.initialize,
|
|
|
|
|
settings.initialize,
|
|
|
|
|
function (callback) {
|
|
|
|
|
// a cloudron must have a backup config to startup
|
|
|
|
|
settings.setBackupConfig({ provider: 'caas', token: 'foo', key: 'key'}, function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
callback();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], done);
|
2015-07-20 00:09:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cleanup(done) {
|
2017-02-07 10:30:52 -08:00
|
|
|
async.series([
|
|
|
|
|
settings.uninitialize,
|
|
|
|
|
database._clear
|
|
|
|
|
], 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
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get default autoupdate_pattern', function (done) {
|
|
|
|
|
settings.getAutoupdatePattern(function (error, pattern) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(pattern).to.be('00 00 1,3,5,23 * * *');
|
|
|
|
|
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 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-10-28 14:35:39 +01:00
|
|
|
it('can get default developer mode', function (done) {
|
|
|
|
|
settings.getDeveloperMode(function (error, enabled) {
|
|
|
|
|
expect(error).to.be(null);
|
2016-06-01 23:13:12 -07:00
|
|
|
expect(enabled).to.equal(true);
|
2015-10-28 14:35:39 +01:00
|
|
|
done();
|
|
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can set developer mode', function (done) {
|
|
|
|
|
settings.setDeveloperMode(true, function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get developer mode', function (done) {
|
|
|
|
|
settings.getDeveloperMode(function (error, enabled) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(enabled).to.equal(true);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-07-23 12:42:52 +02:00
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can set dns config', function (done) {
|
2017-06-15 20:05:31 -07:00
|
|
|
settings.setDnsConfig({ provider: 'route53', accessKeyId: 'accessKeyId', secretAccessKey: 'secretAccessKey' }, config.fqdn(), config.zoneName(), function (error) {
|
2015-10-28 14:35:39 +01:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-10-26 00:44:54 -07:00
|
|
|
});
|
|
|
|
|
|
2015-10-28 14:35:39 +01:00
|
|
|
it('can get dns config', function (done) {
|
|
|
|
|
settings.getDnsConfig(function (error, dnsConfig) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(dnsConfig.provider).to.be('route53');
|
|
|
|
|
expect(dnsConfig.accessKeyId).to.be('accessKeyId');
|
|
|
|
|
expect(dnsConfig.secretAccessKey).to.be('secretAccessKey');
|
|
|
|
|
expect(dnsConfig.region).to.be('us-east-1');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-12-11 22:32:34 -08:00
|
|
|
it('can set tls config', function (done) {
|
|
|
|
|
settings.setTlsConfig({ provider: 'caas' }, function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can get tls config', function (done) {
|
|
|
|
|
settings.getTlsConfig(function (error, dnsConfig) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(dnsConfig.provider).to.be('caas');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2015-11-07 22:17:08 -08:00
|
|
|
it('can set backup config', function (done) {
|
|
|
|
|
settings.setBackupConfig({ provider: 'caas', token: 'TOKEN' }, function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
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);
|
2016-01-23 05:06:09 -08:00
|
|
|
expect(backupConfig.provider).to.be('caas');
|
|
|
|
|
expect(backupConfig.token).to.be('TOKEN');
|
|
|
|
|
done();
|
2016-01-23 05:07:12 -08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can get default update config config', function (done) {
|
|
|
|
|
settings.getUpdateConfig(function (error, updateConfig) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(updateConfig.prerelease).to.be(false);
|
|
|
|
|
done();
|
2016-01-23 05:06:09 -08:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-30 21:12:14 -07:00
|
|
|
it('can set update config', function (done) {
|
2016-01-23 05:06:09 -08:00
|
|
|
settings.setUpdateConfig({ prerelease: true }, function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-30 21:12:14 -07:00
|
|
|
it('can get update config', function (done) {
|
2016-01-23 05:06:09 -08:00
|
|
|
settings.getUpdateConfig(function (error, updateConfig) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(updateConfig.prerelease).to.be(true);
|
2015-11-07 22:17:08 -08:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-30 21:08:29 -07:00
|
|
|
it('can set mail config', function (done) {
|
2016-08-30 21:12:14 -07:00
|
|
|
settings.setMailConfig({ enabled: true }, function (error) {
|
2016-08-30 21:08:29 -07:00
|
|
|
expect(error).to.be(null);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2016-08-30 21:12:14 -07:00
|
|
|
it('can get mail config', function (done) {
|
|
|
|
|
settings.getMailConfig(function (error, mailConfig) {
|
2016-08-30 21:08:29 -07:00
|
|
|
expect(error).to.be(null);
|
2016-08-30 21:12:14 -07:00
|
|
|
expect(mailConfig.enabled).to.be(true);
|
2016-08-30 21:08:29 -07:00
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-06-11 17:51:08 -07:00
|
|
|
it('can get catch all address', function (done) {
|
|
|
|
|
settings.getCatchAllAddress(function (error, address) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(address).to.eql([ ]);
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('can set catch all address', function (done) {
|
|
|
|
|
settings.setCatchAllAddress([ "user1", "user2" ], function (error) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
|
|
|
|
|
settings.getCatchAllAddress(function (error, address) {
|
|
|
|
|
expect(error).to.be(null);
|
|
|
|
|
expect(address).to.eql([ "user1", "user2" ]);
|
|
|
|
|
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');
|
|
|
|
|
expect(allSettings[settings.AUTOUPDATE_PATTERN_KEY]).to.be.a('string');
|
|
|
|
|
expect(allSettings[settings.CLOUDRON_NAME_KEY]).to.be.a('string');
|
|
|
|
|
done();
|
|
|
|
|
});
|
2015-10-26 00:44:54 -07:00
|
|
|
});
|
|
|
|
|
});
|
2015-07-20 00:09:47 -07:00
|
|
|
});
|