|
| 1 | +const fs = require('fs') |
| 2 | +const path = require('path') |
| 3 | +const { setupSuperServer } = require('../utils') |
| 4 | + |
| 5 | +const server = setupSuperServer({ |
| 6 | + live: true, |
| 7 | + dataBrowserPath: 'default', |
| 8 | + root: path.join(__dirname, '../resources'), |
| 9 | + auth: 'oidc', |
| 10 | + webid: false |
| 11 | +}) |
| 12 | + |
| 13 | +describe('Validate HTTP requests with Turtle syntax', function () { |
| 14 | + describe('PUT API', function () { |
| 15 | + const putRequestBody = fs.readFileSync(path.join(__dirname, '../resources/sampleContainer/invalid.ttl'), { |
| 16 | + 'encoding': 'utf8' |
| 17 | + }) |
| 18 | + it('should return 400', function (done) { |
| 19 | + server.put('/put-resource-1.ttl') |
| 20 | + .send(putRequestBody) |
| 21 | + .set('content-type', 'text/turtle') |
| 22 | + .expect(400, done) |
| 23 | + }) |
| 24 | + }) |
| 25 | + |
| 26 | + // describe('POST (multipart)', function () { |
| 27 | + // it('should create as many files as the ones passed in multipart', |
| 28 | + // function (done) { |
| 29 | + // server.post('/sampleContainer/') |
| 30 | + // .attach('timbl', path.join(__dirname, '../resources/timbl.jpg')) |
| 31 | + // .attach('nicola', path.join(__dirname, '../resources/nicola.jpg')) |
| 32 | + // .expect(200) |
| 33 | + // .end(function (err) { |
| 34 | + // if (err) return done(err) |
| 35 | + // |
| 36 | + // var sizeNicola = fs.statSync(path.join(__dirname, |
| 37 | + // '../resources/nicola.jpg')).size |
| 38 | + // var sizeTim = fs.statSync(path.join(__dirname, '../resources/timbl.jpg')).size |
| 39 | + // var sizeNicolaLocal = fs.statSync(path.join(__dirname, |
| 40 | + // '../resources/sampleContainer/nicola.jpg')).size |
| 41 | + // var sizeTimLocal = fs.statSync(path.join(__dirname, |
| 42 | + // '../resources/sampleContainer/timbl.jpg')).size |
| 43 | + // |
| 44 | + // if (sizeNicola === sizeNicolaLocal && sizeTim === sizeTimLocal) { |
| 45 | + // return done() |
| 46 | + // } else { |
| 47 | + // return done(new Error('Either the size (remote/local) don\'t match or files are not stored')) |
| 48 | + // } |
| 49 | + // }) |
| 50 | + // }) |
| 51 | + // after(function () { |
| 52 | + // // Clean up after POST (multipart) API tests |
| 53 | + // return Promise.all([ |
| 54 | + // rm('/sampleContainer/nicola.jpg'), |
| 55 | + // rm('/sampleContainer/timbl.jpg') |
| 56 | + // ]) |
| 57 | + // }) |
| 58 | + // }) |
| 59 | +}) |
0 commit comments