forbid condition_template as parameter name for template
This commit is contained in:
parent
90c8898391
commit
ea336f4ebc
@ -5,7 +5,6 @@ import TemplateMeasurementModel from '../models/measurement_template';
|
||||
import TestHelper from "../test/helper";
|
||||
|
||||
// TODO: do not allow usage of old templates for new samples
|
||||
// TODO: template parameters are not allowed to be condition_template
|
||||
|
||||
describe('/template', () => {
|
||||
let server;
|
||||
@ -218,6 +217,16 @@ describe('/template', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('rejects `condition_template` as parameter name', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'put',
|
||||
url: '/template/condition/200000000000000000000001',
|
||||
auth: {basic: 'admin'},
|
||||
httpStatus: 400,
|
||||
req: {parameters: [{name: 'condition_template', range: {}}]},
|
||||
res: {status: 'Invalid body format', details: '"parameters[0].name" contains an invalid value'}
|
||||
});
|
||||
});
|
||||
it('rejects not specified parameters', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'put',
|
||||
@ -227,7 +236,7 @@ describe('/template', () => {
|
||||
req: {name: 'heat treatment', parameters: [{name: 'material', range: {xx: 5}}]},
|
||||
res: {status: 'Invalid body format', details: '"parameters[0].range.xx" is not allowed'}
|
||||
});
|
||||
})
|
||||
});
|
||||
it('rejects an invalid id', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'put',
|
||||
@ -327,6 +336,16 @@ describe('/template', () => {
|
||||
res: {status: 'Invalid body format', details: '"name" is required'}
|
||||
});
|
||||
});
|
||||
it('rejects `condition_template` as parameter name', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'post',
|
||||
url: '/template/condition/new',
|
||||
auth: {basic: 'admin'},
|
||||
httpStatus: 400,
|
||||
req: {name: 'heat aging', parameters: [{name: 'condition_template', range: {min: 1}}]},
|
||||
res: {status: 'Invalid body format', details: '"parameters[0].name" contains an invalid value'}
|
||||
});
|
||||
});
|
||||
it('rejects a number prefix', done => {
|
||||
TestHelper.request(server, done, {
|
||||
method: 'post',
|
||||
|
@ -2,7 +2,6 @@ import should from 'should/as-function';
|
||||
import UserModel from '../models/user';
|
||||
import TestHelper from "../test/helper";
|
||||
|
||||
// TODO: reject usernames containing admin, etc.
|
||||
|
||||
describe('/user', () => {
|
||||
let server;
|
||||
|
@ -14,6 +14,7 @@ export default class TemplateValidate {
|
||||
Joi.object({
|
||||
name: Joi.string()
|
||||
.max(128)
|
||||
.invalid('condition_template')
|
||||
.required(),
|
||||
|
||||
range: Joi.object({
|
||||
|
Reference in New Issue
Block a user