2021-06-28 16:27:22 +03:00
|
|
|
const should = require('should');
|
2021-10-22 17:22:43 +03:00
|
|
|
const configUtils = require('../../../utils/configUtils');
|
2021-06-28 16:27:22 +03:00
|
|
|
|
|
|
|
describe('vhost utils', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
configUtils.set('url', 'http://ghost.blog');
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
configUtils.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
// url = 'https://ghost.blog'
|
|
|
|
describe('without separate admin url', function () {
|
|
|
|
it('uses the default arg for both backend and frontend', function () {
|
2021-10-22 17:22:43 +03:00
|
|
|
configUtils.config.getBackendMountPath().should.eql(/.*/);
|
|
|
|
configUtils.config.getFrontendMountPath().should.eql(/.*/);
|
2021-06-28 16:27:22 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// url = 'https://ghost.blog'
|
|
|
|
// admin.url = 'https://admin.ghost.blog'
|
|
|
|
describe('with separate admin url', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
configUtils.set('admin:url', 'https://admin.ghost.blog');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use admin url and inverse as args', function () {
|
2021-10-22 17:22:43 +03:00
|
|
|
configUtils.config.getBackendMountPath().should.eql('admin.ghost.blog');
|
|
|
|
configUtils.config.getFrontendMountPath().should.eql(/^(?!admin\.ghost\.blog).*/);
|
2021-06-28 16:27:22 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should have regex that excludes admin traffic on front-end', function () {
|
2021-10-22 17:22:43 +03:00
|
|
|
const frontendRegex = configUtils.config.getFrontendMountPath();
|
2021-06-28 16:27:22 +03:00
|
|
|
|
|
|
|
frontendRegex.test('localhost').should.be.true();
|
|
|
|
frontendRegex.test('ghost.blog').should.be.true();
|
|
|
|
frontendRegex.test('admin.ghost.blog').should.be.false();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// url = 'http://ghost.blog'
|
|
|
|
// admin.url = 'https://ghost.blog'
|
|
|
|
describe('with separate admin protocol', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
configUtils.set('admin:url', 'https://ghost.blog');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should mount and assign correct routes', function () {
|
2021-10-22 17:22:43 +03:00
|
|
|
configUtils.config.getBackendMountPath().should.eql(/.*/);
|
|
|
|
configUtils.config.getFrontendMountPath().should.eql(/.*/);
|
2021-06-28 16:27:22 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|