|
| 1 | +const assert = require('chai').assert |
| 2 | +const request = require('request') |
| 3 | +const path = require('path') |
| 4 | +const { checkDnsSettings, cleanDir } = require('../utils') |
| 5 | + |
| 6 | +const ldnode = require('../../index') |
| 7 | + |
| 8 | +const port = 7777 |
| 9 | +const serverUri = `https://localhost:${port}` |
| 10 | +const root = path.join(__dirname, '../resources/accounts-acl') |
| 11 | +const dbPath = path.join(root, 'db') |
| 12 | +const configPath = path.join(root, 'config') |
| 13 | + |
| 14 | +function createOptions (path = '') { |
| 15 | + return { |
| 16 | + url: `https://nicola.localhost:${port}${path}` |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +describe('Special handling: Root ACL does not give READ access to root', () => { |
| 21 | + let ldp, ldpHttpsServer |
| 22 | + |
| 23 | + before(checkDnsSettings) |
| 24 | + |
| 25 | + before(done => { |
| 26 | + ldp = ldnode.createServer({ |
| 27 | + root, |
| 28 | + serverUri, |
| 29 | + dbPath, |
| 30 | + port, |
| 31 | + configPath, |
| 32 | + sslKey: path.join(__dirname, '../keys/key.pem'), |
| 33 | + sslCert: path.join(__dirname, '../keys/cert.pem'), |
| 34 | + webid: true, |
| 35 | + multiuser: true, |
| 36 | + auth: 'oidc', |
| 37 | + strictOrigin: true, |
| 38 | + host: { serverUri } |
| 39 | + }) |
| 40 | + ldpHttpsServer = ldp.listen(port, done) |
| 41 | + }) |
| 42 | + |
| 43 | + after(() => { |
| 44 | + if (ldpHttpsServer) ldpHttpsServer.close() |
| 45 | + cleanDir(root) |
| 46 | + }) |
| 47 | + |
| 48 | + describe('should still grant READ access to everyone because of index.html.acl', () => { |
| 49 | + it('for root with /', function (done) { |
| 50 | + var options = createOptions('/') |
| 51 | + request.get(options, function (error, response, body) { |
| 52 | + assert.equal(error, null) |
| 53 | + assert.equal(response.statusCode, 200) |
| 54 | + done() |
| 55 | + }) |
| 56 | + }) |
| 57 | + it('for root without /', function (done) { |
| 58 | + var options = createOptions() |
| 59 | + request.get(options, function (error, response, body) { |
| 60 | + assert.equal(error, null) |
| 61 | + assert.equal(response.statusCode, 200) |
| 62 | + done() |
| 63 | + }) |
| 64 | + }) |
| 65 | + }) |
| 66 | +}) |
0 commit comments