mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
require leading slash on basePath
This commit is contained in:
parent
13021c6534
commit
f54095600a
2 changed files with 39 additions and 1 deletions
38
src/server/config/__tests__/schema.js
Normal file
38
src/server/config/__tests__/schema.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
import schemaProvider from '../schema';
|
||||
import expect from 'expect.js';
|
||||
import Joi from 'joi';
|
||||
|
||||
describe('Config schema', function () {
|
||||
let schema;
|
||||
beforeEach(() => schema = schemaProvider());
|
||||
|
||||
function validate(data, options) {
|
||||
return Joi.validate(data, schema, options);
|
||||
}
|
||||
|
||||
describe('server', function () {
|
||||
describe('basePath', function () {
|
||||
it('accepts empty strings', function () {
|
||||
const { error } = validate({ server: { basePath: '' }});
|
||||
expect(error == null).to.be.ok();
|
||||
});
|
||||
|
||||
it('accepts strings with leading slashes', function () {
|
||||
const { error } = validate({ server: { basePath: '/path' }});
|
||||
expect(error == null).to.be.ok();
|
||||
});
|
||||
|
||||
it('rejects strings with trailing slashes', function () {
|
||||
const { error } = validate({ server: { basePath: '/path/' }});
|
||||
expect(error).to.have.property('details');
|
||||
expect(error.details[0]).to.have.property('path', 'server.basePath');
|
||||
});
|
||||
|
||||
it('rejects strings without leading slashes', function () {
|
||||
const { error } = validate({ server: { basePath: 'path' }});
|
||||
expect(error).to.have.property('details');
|
||||
expect(error.details[0]).to.have.property('path', 'server.basePath');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -30,7 +30,7 @@ module.exports = () => Joi.object({
|
|||
port: Joi.number().default(5601),
|
||||
autoListen: Joi.boolean().default(true),
|
||||
defaultRoute: Joi.string(),
|
||||
basePath: Joi.string().default('').allow('').regex(/[^\/]$/, 'no trailing slashes'),
|
||||
basePath: Joi.string().default('').allow('').regex(/(^$|^\/.*[^\/]$)/, `start with a slash, don't end with one`),
|
||||
ssl: Joi.object({
|
||||
cert: Joi.string(),
|
||||
key: Joi.string()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue