2017-08-02 13:45:21 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const Utils = require('../../src/lib/utils');
|
|
|
|
const Config = require('../../src/lib/config');
|
|
|
|
const path = require('path');
|
|
|
|
const _ = require('lodash');
|
|
|
|
|
2017-08-02 13:46:06 -05:00
|
|
|
const resolveConf = (conf) => path.join(__dirname, `../../conf/${conf}.yaml`);
|
|
|
|
|
|
|
|
const checkUplink = (config) => {
|
|
|
|
assert.equal(_.isObject(config.uplinks['npmjs']), true);
|
|
|
|
assert.equal(config.uplinks['npmjs'].url, 'https://registry.npmjs.org');
|
2017-08-02 13:45:21 -05:00
|
|
|
};
|
|
|
|
|
2017-08-02 13:46:06 -05:00
|
|
|
const checkPackages = (config) => {
|
|
|
|
assert.equal(_.isObject(config.packages), true);
|
|
|
|
assert.equal(Object.keys(config.packages).join('|'), '@*/*|**');
|
|
|
|
assert.equal(config.packages['@*/*'].access, '$all');
|
|
|
|
assert.equal(config.packages['@*/*'].publish, '$authenticated');
|
|
|
|
assert.equal(config.packages['@*/*'].proxy, 'npmjs');
|
|
|
|
assert.equal(config.packages['**'].access, '$all');
|
|
|
|
assert.equal(config.packages['**'].publish, '$authenticated');
|
|
|
|
assert.equal(config.packages['**'].proxy, 'npmjs');
|
|
|
|
assert.equal(config.uplinks['npmjs'].url, 'https://registry.npmjs.org');
|
|
|
|
};
|
2017-08-02 13:45:21 -05:00
|
|
|
|
|
|
|
describe('Config file', function() {
|
|
|
|
before(function() {
|
|
|
|
|
|
|
|
this.config = new Config(Utils.parseConfigFile(resolveConf('full')));
|
|
|
|
});
|
|
|
|
|
2017-08-02 13:46:06 -05:00
|
|
|
describe('Config file', () => {
|
|
|
|
it('parse full.yaml', () => {
|
2017-08-02 13:45:21 -05:00
|
|
|
const config = new Config(Utils.parseConfigFile(resolveConf('full')));
|
2017-08-02 13:46:06 -05:00
|
|
|
checkUplink(config);
|
|
|
|
assert.equal(config.storage, './storage');
|
|
|
|
assert.equal(config.web.title, 'Verdaccio');
|
|
|
|
checkPackages(config);
|
2017-08-02 13:45:21 -05:00
|
|
|
});
|
|
|
|
|
2017-08-02 13:46:06 -05:00
|
|
|
it('parse docker.yaml', () => {
|
2017-08-02 13:45:21 -05:00
|
|
|
const config = new Config(Utils.parseConfigFile(resolveConf('docker')));
|
2017-08-02 13:46:06 -05:00
|
|
|
checkUplink(config);
|
|
|
|
assert.equal(config.storage, '/verdaccio/storage');
|
|
|
|
assert.equal(config.auth.htpasswd.file, '/verdaccio/conf/htpasswd');
|
2017-08-02 13:45:21 -05:00
|
|
|
});
|
|
|
|
|
2017-08-02 13:46:06 -05:00
|
|
|
it('parse default.yaml', () => {
|
2017-08-02 13:45:21 -05:00
|
|
|
const config = new Config(Utils.parseConfigFile(resolveConf('default')));
|
2017-08-02 13:46:06 -05:00
|
|
|
checkUplink(config);
|
|
|
|
assert.equal(config.storage, './storage');
|
|
|
|
assert.equal(config.auth.htpasswd.file, './htpasswd');
|
2017-08-02 13:45:21 -05:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|