test for missing payload with POST

This commit is contained in:
Matthew Bargar 2015-11-17 13:37:32 -05:00
parent 07e3a33b55
commit a2ba98c360
2 changed files with 13 additions and 0 deletions

View file

@ -96,6 +96,8 @@ export default function (server) {
path: '/api/index-patterns',
method: 'POST',
handler: function (req, reply) {
if (_.isEmpty(req.payload)) { reply(Boom.badRequest('Payload required')); }
const client = server.plugins.elasticsearch.client;
const indexPattern = _.cloneDeep(req.payload);
const isWildcard = _.contains(indexPattern.title, '*') || (indexPattern.title.match(/\[.*]/) !== null);

View file

@ -24,5 +24,16 @@ define(function (require) {
});
});
bdd.describe('POST index-patterns', function postIndexPatterns() {
bdd.it('missing payload should return 400', function missingPayload() {
return request.post('/index-patterns')
.send({})
.expect(400);
});
});
});
});