Don't allow updates to title when PUTting index-patterns

This commit is contained in:
Matthew Bargar 2015-11-19 11:05:34 -05:00
parent 68d3be8b8d
commit 526e8e7e74
2 changed files with 15 additions and 0 deletions

View file

@ -171,6 +171,9 @@ export default function (server) {
path: '/api/index-patterns/{id}',
method: 'PUT',
handler: function (req, reply) {
if (_.isEmpty(req.payload)) { return reply(Boom.badRequest('Payload required')); }
if (req.payload.title !== req.params.id) { return reply(Boom.badRequest('Updates to title not supported')); }
let client = server.plugins.elasticsearch.client;
const indexPattern = _.cloneDeep(req.payload);
const isWildcard = _.contains(indexPattern.title, '*') || (indexPattern.title.match(/\[.*]/) !== null);

View file

@ -38,6 +38,18 @@ define(function (require) {
});
});
bdd.it('should return 400 if you try to modify the title', function () {
var pattern = createTestData().indexPatternWithMappings;
pattern.fields = _.map(pattern.fields, function (field) {
return _.omit(field, 'mapping');
});
pattern.title = 'foo';
return request.put('/index-patterns/logstash-*')
.send(pattern)
.expect(400);
});
});
};