| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -3,7 +3,7 @@ import SampleModel from '../models/sample';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import NoteModel from '../models/note';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import NoteFieldModel from '../models/note_field';
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				import TestHelper from "../test/helper";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// TODO: generate sample number
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				// TODO: think again which parameters are required at POST
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				describe('/sample', () => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -87,7 +87,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '1', type: 'granulate', color: 'black', batch: '', material_id: '100000000000000000000004', notes: {}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'granulate', color: 'black', batch: '', 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: '', material_id: '100000000000000000000004', note_id: null, user_id: '000000000000000000000002'});
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -156,14 +156,14 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end(err => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done (err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        SampleModel.findById('400000000000000000000001').lean().exec((err, data: any) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done (err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'material_id', 'note_id', 'user_id', 'status', '__v');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('_id');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('number', '10');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('number', '1');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('color', 'signalviolet');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('type', 'part');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.property('batch', '114531');
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -228,7 +228,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000002',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '111'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done (err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        NoteModel.findById(res.body.note_id).lean().exec((err, data) => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -263,7 +263,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Color not available for material'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -273,18 +273,18 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '000000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '000000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Material not available'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a sample number in use', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a sample number', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'put',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '21', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Sample number already taken'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 25, type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"number" is not allowed'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects an invalid sample reference', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -293,7 +293,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '000000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '000000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Sample reference not available'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -303,7 +303,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"material_id" with value "10000000000h000000000001" fails to match the required pattern: /[0-9a-f]{24}/'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -313,7 +313,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/10000000000h000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 404,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects an API key', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -322,7 +322,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {key: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects changes for samples from another user for a write user', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -350,7 +350,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'user'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 403,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('returns 404 for an unknown sample', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -359,7 +359,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/000000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 404,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    })
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects unauthorized requests', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -367,7 +367,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'put',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/400000000000000000000001',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '10', type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'part', color: 'signalviolet', batch: '114531', material_id: '100000000000000000000002', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -531,12 +531,12 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{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', 'material_id', 'note_id', 'user_id');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).have.property('_id').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).have.property('number', 'Rng172');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        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('batch', '1560237365');
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -552,15 +552,15 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end(err => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done (err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        SampleModel.find({number: 'Rng172'}).lean().exec((err, data: any) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        SampleModel.find({number: 'Rng34'}).lean().exec((err, data: any) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done (err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data).have.lengthOf(1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.only.keys('_id', 'number', 'color', 'type', 'batch', 'material_id', 'note_id', 'user_id', 'status', '__v');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('_id');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('number', 'Rng172');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('number', 'Rng34');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('color', 'black');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('type', 'granulate');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(data[0]).have.property('batch', '1560237365');
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -587,7 +587,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', 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: 'granulate', 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) => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -618,13 +618,34 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('stores a new sample location as 1', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'johnnydoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{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', 'material_id', 'note_id', 'user_id');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        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('batch', '1560237365');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).have.property('material_id', '100000000000000000000001');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).have.property('note_id').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).have.property('user_id', '000000000000000000000004');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a color not defined for the material', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'green', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'green', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Color not available for material'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -634,18 +655,18 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '000000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '000000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Material not available'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a sample number in use', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a sample number', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: '1', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Sample number already taken'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng34', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"number" is not allowed'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects an invalid sample reference', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -654,7 +675,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '000000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '000000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Sample reference not available'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -664,27 +685,17 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"color" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a missing sample number', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"number" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects a missing type', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"type" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -694,7 +705,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"batch" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -704,7 +715,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"material_id" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -714,7 +725,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '10000000000h000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res: {status: 'Invalid body format', details: '"material_id" with value "10000000000h000000000001" fails to match the required pattern: /[0-9a-f]{24}/'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -724,7 +735,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {key: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects requests from a read user', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -733,7 +744,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'user'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 403,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects unauthorized requests', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -741,7 +752,7 @@ describe('/sample', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/sample/new',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {number: 'Rng172', color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {color: 'black', type: 'granulate', batch: '1560237365', material_id: '100000000000000000000001', notes: {comment: 'Testcomment', sample_references: [{id: '400000000000000000000003', relation: 'part to this sample'}]}}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |