|
|
|
@ -301,15 +301,15 @@ describe('/sample', () => {
|
|
|
|
|
it('filters a sample property', done => { // TODO: implement filters
|
|
|
|
|
TestHelper.request(server, done, {
|
|
|
|
|
method: 'get',
|
|
|
|
|
url: '/samples?status[]=new&status[]=validated&fields[]=number&fields[]=type&filters[]=%7B%22mode%22%3A%22eq%22%2C%22field%22%3A%22type%22%2C%22values%22%3A%5B%22part%22%5D%7D',
|
|
|
|
|
url: '/samples?status[]=new&status[]=validated&fields[]=number&fields[]=type&filters[]=%7B%22mode%22%3A%22eq%22%2C%22field%22%3A%22type%22%2C%22values%22%3A%5B%22processed%22%5D%7D',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
const json = require('../test/db.json');
|
|
|
|
|
should(res.body).have.lengthOf(json.collections.samples.filter(e => e.type === 'part').length);
|
|
|
|
|
should(res.body).have.lengthOf(json.collections.samples.filter(e => e.type === 'processed').length);
|
|
|
|
|
should(res.body).matchEach(sample => {
|
|
|
|
|
should(sample).have.property('type', 'part');
|
|
|
|
|
should(sample).have.property('type', 'processed');
|
|
|
|
|
});
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
@ -459,8 +459,8 @@ describe('/sample', () => {
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
should(res.text).be.eql('"_id","number","type","color","batch","condition.material","condition.weeks","condition.condition_template","material_id","note_id","user_id","added"\r\n' +
|
|
|
|
|
'"400000000000000000000001","1","granulate","black","","copper",3,"200000000000000000000001","100000000000000000000004",,"000000000000000000000002","2004-01-10T13:37:04.000Z"\r\n' +
|
|
|
|
|
'"400000000000000000000002","21","granulate","natural","1560237365","copper",3,"200000000000000000000001","100000000000000000000001","500000000000000000000001","000000000000000000000002","2004-01-10T13:37:04.000Z"');
|
|
|
|
|
'"400000000000000000000001","1","as-delivered/raw","black","","copper",3,"200000000000000000000001","100000000000000000000004",,"000000000000000000000002","2004-01-10T13:37:04.000Z"\r\n' +
|
|
|
|
|
'"400000000000000000000002","21","as-delivered/raw","natural","1560237365","copper",3,"200000000000000000000001","100000000000000000000001","500000000000000000000001","000000000000000000000002","2004-01-10T13:37:04.000Z"');
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -729,7 +729,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000003',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'processed', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'as-delivered/raw to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('works with an API key', done => {
|
|
|
|
@ -738,7 +738,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000003',
|
|
|
|
|
auth: {key: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'processed', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'as-delivered/raw to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it ('filters out spectral data for a write user', done => {
|
|
|
|
@ -747,7 +747,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it ('returns spectral data for an admin user', done => {
|
|
|
|
@ -756,7 +756,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {dpt: [[ 3997.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]],device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {dpt: [[ 3996.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]], device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {dpt: [[ 3997.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]],device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {dpt: [[ 3996.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]], device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('returns a deleted sample for a dev/admin user', done => {
|
|
|
|
@ -765,7 +765,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000005',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000005', number: 'Rng33', type: 'granulate', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {}, measurements: [], status: 'deleted', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000005', number: 'Rng33', type: 'as-delivered/raw', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {}, measurements: [], status: 'deleted', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('returns 403 for a write user when requesting a deleted sample', done => {
|
|
|
|
@ -809,7 +809,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {},
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('keeps unchanged properties', done => {
|
|
|
|
@ -818,17 +818,17 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', notes: {}}
|
|
|
|
|
req: {type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', notes: {}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
SampleModel.findById('400000000000000000000001').lean().exec((err, data: any) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(data).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', '__v');
|
|
|
|
|
should(data).have.property('_id');
|
|
|
|
|
should(data).have.property('number', '1');
|
|
|
|
|
should(data).have.property('color', 'black');
|
|
|
|
|
should(data).have.property('type', 'granulate');
|
|
|
|
|
should(data).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(data).have.property('batch', '');
|
|
|
|
|
should(data).have.property('condition', {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'});
|
|
|
|
|
should(data.material_id.toString()).be.eql('100000000000000000000004');
|
|
|
|
@ -845,10 +845,10 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {type: 'granulate'}
|
|
|
|
|
req: {type: 'as-delivered/raw'}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
SampleModel.findById('400000000000000000000001').lean().exec((err, data: any) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(data).have.property('status','validated');
|
|
|
|
@ -865,7 +865,7 @@ describe('/sample', () => {
|
|
|
|
|
req: {condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
SampleModel.findById('400000000000000000000001').lean().exec((err, data: any) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(data).have.property('status','validated');
|
|
|
|
@ -882,14 +882,14 @@ describe('/sample', () => {
|
|
|
|
|
req: {notes: {comment: 'Stoff gesperrt', sample_references: []}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done(err);
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000002', number: '21', type: 'granulate', color: 'natural', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', note_id: '500000000000000000000001', user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
should(res.body).be.eql({_id: '400000000000000000000002', number: '21', type: 'as-delivered/raw', color: 'natural', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', note_id: '500000000000000000000001', user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'});
|
|
|
|
|
SampleModel.findById('400000000000000000000002').lean().exec((err, data: any) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(data).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', '__v');
|
|
|
|
|
should(data).have.property('_id');
|
|
|
|
|
should(data).have.property('number', '21');
|
|
|
|
|
should(data).have.property('color', 'natural');
|
|
|
|
|
should(data).have.property('type', 'granulate');
|
|
|
|
|
should(data).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(data).have.property('batch', '1560237365');
|
|
|
|
|
should(data.condition).have.property('material', 'copper');
|
|
|
|
|
should(data.condition).have.property('weeks', 3);
|
|
|
|
@ -908,7 +908,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', condition: {condition_template: '200000000000000000000003'}, material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', condition: {condition_template: '200000000000000000000003'}, material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
}).end(err => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
SampleModel.findById('400000000000000000000001').lean().exec((err, data: any) => {
|
|
|
|
@ -917,7 +917,7 @@ describe('/sample', () => {
|
|
|
|
|
should(data).have.property('_id');
|
|
|
|
|
should(data).have.property('number', '1');
|
|
|
|
|
should(data).have.property('color', 'signalviolet');
|
|
|
|
|
should(data).have.property('type', 'part');
|
|
|
|
|
should(data).have.property('type', 'processed');
|
|
|
|
|
should(data).have.property('batch', '114531');
|
|
|
|
|
should(data).have.property('condition', {condition_template: '200000000000000000000003'});
|
|
|
|
|
should(data.material_id.toString()).be.eql('100000000000000000000002');
|
|
|
|
@ -943,7 +943,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', condition: {condition_template: '200000000000000000000003'}, material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', condition: {condition_template: '200000000000000000000003'}, material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
log: {
|
|
|
|
|
collection: 'samples',
|
|
|
|
|
dataAdd: {
|
|
|
|
@ -995,7 +995,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000002',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {type: 'part'}
|
|
|
|
|
req: {type: 'processed'}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
NoteModel.findById(res.body.note_id).lean().exec((err, data) => {
|
|
|
|
@ -1029,7 +1029,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '000000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '000000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Material not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1039,7 +1039,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {number: 25, type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {number: 25, type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"number" is not allowed'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1049,7 +1049,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '000000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '000000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Sample reference not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1059,7 +1059,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: 'Invalid object id'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1069,7 +1069,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/10000000000h000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 404,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects not specified condition parameters', done => {
|
|
|
|
@ -1139,7 +1139,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {type: 'xx'},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"type" must be one of [granulate, part, tension rod]'}
|
|
|
|
|
res: {status: 'Invalid body format', details: '"type" must be one of [as-delivered/raw, processed]'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('allows keeping an empty condition empty', done => {
|
|
|
|
@ -1149,7 +1149,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {condition: {}},
|
|
|
|
|
res: {_id: '400000000000000000000006', number: 'Rng36', type: 'granulate', color: 'black', batch: '', condition: {}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'new', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
res: {_id: '400000000000000000000006', number: 'Rng36', type: 'as-delivered/raw', color: 'black', batch: '', condition: {}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'new', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects an old version of a condition template', done => {
|
|
|
|
@ -1169,7 +1169,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {condition: {p1: 36, condition_template: '200000000000000000000004'}},
|
|
|
|
|
res: {_id: '400000000000000000000004', number: '32', type: 'granulate', color: 'black', batch: '1653000308', condition: {p1: 36, condition_template: '200000000000000000000004'}, material_id: '100000000000000000000005', note_id: '500000000000000000000003', user_id: '000000000000000000000003', status: 'new', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
res: {_id: '400000000000000000000004', number: '32', type: 'as-delivered/raw', color: 'black', batch: '1653000308', condition: {p1: 36, condition_template: '200000000000000000000004'}, material_id: '100000000000000000000005', note_id: '500000000000000000000003', user_id: '000000000000000000000003', status: 'new', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects changing back to an empty condition', done => {
|
|
|
|
@ -1197,7 +1197,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {key: 'janedoe'},
|
|
|
|
|
httpStatus: 401,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects changes for samples from another user for a write user', done => {
|
|
|
|
@ -1216,7 +1216,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {},
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {condition_template: '200000000000000000000001', material: 'copper', weeks: 3}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {condition_template: '200000000000000000000001', material: 'copper', weeks: 3}, material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002', status: 'validated', added: '2004-01-10T13:37:04.000Z'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects requests from a read user', done => {
|
|
|
|
@ -1225,7 +1225,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
auth: {basic: 'user'},
|
|
|
|
|
httpStatus: 403,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('returns 404 for an unknown sample', done => {
|
|
|
|
@ -1234,7 +1234,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/000000000000000000000001',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 404,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
it('rejects unauthorized requests', done => {
|
|
|
|
@ -1242,7 +1242,7 @@ describe('/sample', () => {
|
|
|
|
|
method: 'put',
|
|
|
|
|
url: '/sample/400000000000000000000001',
|
|
|
|
|
httpStatus: 401,
|
|
|
|
|
req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'processed', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1263,7 +1263,7 @@ describe('/sample', () => {
|
|
|
|
|
should(data).have.property('_id');
|
|
|
|
|
should(data).have.property('number', '1');
|
|
|
|
|
should(data).have.property('color', 'black');
|
|
|
|
|
should(data).have.property('type', 'granulate');
|
|
|
|
|
should(data).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(data).have.property('batch', '');
|
|
|
|
|
should(data.condition).have.property('material', 'copper');
|
|
|
|
|
should(data.condition).have.property('weeks', 3);
|
|
|
|
@ -1438,7 +1438,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/number/33',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'processed', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'as-delivered/raw to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('works with an API key', done => {
|
|
|
|
@ -1447,7 +1447,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/number/33',
|
|
|
|
|
auth: {key: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'part', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'granulate to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000003', number: '33', type: 'processed', color: 'black', batch: '1704-005', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {comment: '', sample_references: [{sample_id: '400000000000000000000004', relation: 'as-delivered/raw to sample'}], custom_fields: {'not allowed for new applications': true}}, measurements: [{_id: '800000000000000000000003', sample_id: '400000000000000000000003', values: {val1: 1}, measurement_template: '300000000000000000000003'}], status: 'new', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('returns a deleted sample for a dev/admin user', done => {
|
|
|
|
@ -1456,7 +1456,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/number/Rng33',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000005', number: 'Rng33', type: 'granulate', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {}, measurements: [], status: 'deleted', user: 'admin'}
|
|
|
|
|
res: {_id: '400000000000000000000005', number: 'Rng33', type: 'as-delivered/raw', color: 'black', batch: '1653000308', condition: {condition_template: '200000000000000000000003'}, material: {_id: '100000000000000000000005', name: 'Amodel A 1133 HS', supplier: 'Solvay', group: 'PPA', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 33, carbon_fiber: 0}, numbers: ['5514262406']}, notes: {}, measurements: [], status: 'deleted', user: 'admin'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it ('filters out spectral data for a write user', done => {
|
|
|
|
@ -1465,7 +1465,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/number/1',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it ('returns spectral data for an admin user', done => {
|
|
|
|
@ -1474,7 +1474,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/number/1',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'granulate', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {dpt: [[ 3997.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]],device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {dpt: [[ 3996.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]], device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
res: {_id: '400000000000000000000001', number: '1', type: 'as-delivered/raw', color: 'black', batch: '', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material: {numbers: ['5513933405'], _id: '100000000000000000000004', name: 'Schulamid 66 GF 25 H', properties: {material_template: '130000000000000000000003', mineral: 0, glass_fiber: 25, carbon_fiber: 0}, group: 'PA66', supplier: 'Schulmann'}, user: 'janedoe', notes: {}, measurements: [{_id: '800000000000000000000001', sample_id: '400000000000000000000001', values: {dpt: [[ 3997.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]],device: 'Alpha I'}, measurement_template: '300000000000000000000001'}, {_id: '800000000000000000000007', sample_id: '400000000000000000000001', values: {dpt: [[ 3996.12558, 98.00555 ], [ 3995.08519, 98.03253 ], [ 3993.0448, 98.02657 ]], device: 'Alpha II'}, measurement_template: '300000000000000000000001'}], status: 'validated'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('returns 403 for a write user when requesting a deleted sample', done => {
|
|
|
|
@ -1697,14 +1697,14 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(res.body).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', 'added');
|
|
|
|
|
should(res.body).have.property('_id').be.type('string');
|
|
|
|
|
should(res.body).have.property('number', 'Rng37');
|
|
|
|
|
should(res.body).have.property('color', 'black');
|
|
|
|
|
should(res.body).have.property('type', 'granulate');
|
|
|
|
|
should(res.body).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(res.body).have.property('batch', '1560237365');
|
|
|
|
|
should(res.body).have.property('condition', {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'});
|
|
|
|
|
should(res.body).have.property('material_id', '100000000000000000000001');
|
|
|
|
@ -1722,7 +1722,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
}).end(err => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
SampleModel.find({number: 'Rng37'}).lean().exec((err, data: any) => {
|
|
|
|
@ -1732,7 +1732,7 @@ describe('/sample', () => {
|
|
|
|
|
should(data[0]).have.property('_id');
|
|
|
|
|
should(data[0]).have.property('number', 'Rng37');
|
|
|
|
|
should(data[0]).have.property('color', 'black');
|
|
|
|
|
should(data[0]).have.property('type', 'granulate');
|
|
|
|
|
should(data[0]).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(data[0]).have.property('batch', '1560237365');
|
|
|
|
|
should(data[0]).have.property('condition', {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'});
|
|
|
|
|
should(data[0].material_id.toString()).be.eql('100000000000000000000001');
|
|
|
|
@ -1758,7 +1758,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '200000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
log: {
|
|
|
|
|
collection: 'samples',
|
|
|
|
|
dataAdd: {
|
|
|
|
@ -1776,7 +1776,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [], custom_fields: {field1: 'a', field2: 'b', 'not allowed for new applications': true}}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [], custom_fields: {field1: 'a', field2: 'b', 'not allowed for new applications': true}}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
NoteModel.findById(res.body.note_id).lean().exec((err, data: any) => {
|
|
|
|
@ -1813,14 +1813,14 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'johnnydoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(res.body).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', 'added');
|
|
|
|
|
should(res.body).have.property('_id').be.type('string');
|
|
|
|
|
should(res.body).have.property('number', 'Fe1');
|
|
|
|
|
should(res.body).have.property('color', 'black');
|
|
|
|
|
should(res.body).have.property('type', 'granulate');
|
|
|
|
|
should(res.body).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(res.body).have.property('batch', '1560237365');
|
|
|
|
|
should(res.body).have.property('material_id', '100000000000000000000001');
|
|
|
|
|
should(res.body).have.property('note_id').be.type('string');
|
|
|
|
@ -1837,14 +1837,14 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(res.body).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', 'added');
|
|
|
|
|
should(res.body).have.property('_id').be.type('string');
|
|
|
|
|
should(res.body).have.property('number', 'Rng37');
|
|
|
|
|
should(res.body).have.property('color', 'black');
|
|
|
|
|
should(res.body).have.property('type', 'granulate');
|
|
|
|
|
should(res.body).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(res.body).have.property('batch', '1560237365');
|
|
|
|
|
should(res.body).have.property('condition', {});
|
|
|
|
|
should(res.body).have.property('material_id', '100000000000000000000001');
|
|
|
|
@ -1862,7 +1862,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '000000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '000000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Material not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1872,7 +1872,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {number: 'Rng34', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {number: 'Rng34', color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"number" is not allowed'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1882,14 +1882,14 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 200,
|
|
|
|
|
req: {number: 'Rng34', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {number: 'Rng34', color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
}).end((err, res) => {
|
|
|
|
|
if (err) return done (err);
|
|
|
|
|
should(res.body).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'condition', 'material_id', 'note_id', 'user_id', 'status', 'added');
|
|
|
|
|
should(res.body).have.property('_id').be.type('string');
|
|
|
|
|
should(res.body).have.property('number', 'Rng34');
|
|
|
|
|
should(res.body).have.property('color', 'black');
|
|
|
|
|
should(res.body).have.property('type', 'granulate');
|
|
|
|
|
should(res.body).have.property('type', 'as-delivered/raw');
|
|
|
|
|
should(res.body).have.property('batch', '1560237365');
|
|
|
|
|
should(res.body).have.property('condition', {});
|
|
|
|
|
should(res.body).have.property('material_id', '100000000000000000000001');
|
|
|
|
@ -1907,7 +1907,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'admin'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {number: 'Rng33', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {number: 'Rng33', color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Sample number already taken'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1917,7 +1917,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '000000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '000000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Sample reference not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1927,7 +1927,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '20000h000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '20000h000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1937,7 +1937,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '000000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, condition_template: '000000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1947,7 +1947,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3, xxx: 23, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3, xxx: 23, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1957,7 +1957,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1967,7 +1967,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'xxx', weeks: 3, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'xxx', weeks: 3, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1977,7 +1977,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 0, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 0, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1987,7 +1987,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 11, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 11, condition_template: '20000000000000000000001'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -1997,7 +1997,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {material: 'copper', weeks: 3}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {material: 'copper', weeks: 3}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Condition template not available'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2007,7 +2007,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', condition: {p1: 36, condition_template: '200000000000000000000004'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', condition: {p1: 36, condition_template: '200000000000000000000004'}, material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Old template version not allowed'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2017,7 +2017,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"color" is required'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2037,7 +2037,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"batch" is required'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2047,7 +2047,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"material_id" is required'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2057,7 +2057,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}},
|
|
|
|
|
res: {status: 'Invalid body format', details: 'Invalid object id'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -2068,7 +2068,7 @@ describe('/sample', () => {
|
|
|
|
|
auth: {basic: 'janedoe'},
|
|
|
|
|
httpStatus: 400,
|
|
|
|
|
req: {color: 'black', type: 'xx', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment'}},
|
|
|
|
|
res: {status: 'Invalid body format', details: '"type" must be one of [granulate, part, tension rod]'}
|
|
|
|
|
res: {status: 'Invalid body format', details: '"type" must be one of [as-delivered/raw, part]'}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects an API key', done => {
|
|
|
|
@ -2077,7 +2077,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {key: 'janedoe'},
|
|
|
|
|
httpStatus: 401,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects requests from a read user', done => {
|
|
|
|
@ -2086,7 +2086,7 @@ describe('/sample', () => {
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
auth: {basic: 'user'},
|
|
|
|
|
httpStatus: 403,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
it('rejects unauthorized requests', done => {
|
|
|
|
@ -2094,7 +2094,7 @@ describe('/sample', () => {
|
|
|
|
|
method: 'post',
|
|
|
|
|
url: '/sample/new',
|
|
|
|
|
httpStatus: 401,
|
|
|
|
|
req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
req: {color: 'black', type: 'as-delivered/raw', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{sample_id: '400000000000000000000003', relation: 'part to this sample'}]}}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|