Skip to content

Commit 2b4250d

Browse files
committed
Properly handle creation and removal of root .acl files in tests
1 parent 7dd8465 commit 2b4250d

File tree

12 files changed

+56
-21
lines changed

12 files changed

+56
-21
lines changed

test/integration/acl-tls-test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,18 @@ describe('ACL with WebID+TLS', function () {
8888
}
8989

9090
describe('no ACL', function () {
91-
before(() => {
92-
rm(path.join(rootPath, '.acl'))
93-
})
94-
95-
it('should return 403 for any resource', function (done) {
91+
it('should return 500 for any resource', function (done) {
92+
rm('.acl')
9693
var options = createOptions('/acl-tls/no-acl/', 'user1')
9794
request(options, function (error, response, body) {
9895
assert.equal(error, null)
99-
assert.equal(response.statusCode, 403)
96+
assert.equal(response.statusCode, 500)
10097
done()
10198
})
10299
})
103100

104101
it('should have `User` set in the Response Header', function (done) {
102+
rm('.acl')
105103
var options = createOptions('/acl-tls/no-acl/', 'user1')
106104
request(options, function (error, response, body) {
107105
assert.equal(error, null)
@@ -111,6 +109,7 @@ describe('ACL with WebID+TLS', function () {
111109
})
112110

113111
it.skip('should return a 401 and WWW-Authenticate header without credentials', (done) => {
112+
rm('.acl')
114113
let options = {
115114
url: address + '/acl-tls/no-acl/',
116115
headers: { accept: 'text/turtle' }

test/integration/authentication-oidc-test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const localStorage = require('localstorage-memory')
1010
const URL = require('whatwg-url').URL
1111
global.URL = URL
1212
global.URLSearchParams = require('whatwg-url').URLSearchParams
13-
const { cleanDir } = require('../utils')
13+
const { cleanDir, cp } = require('../utils')
1414

1515
const supertest = require('supertest')
1616
const chai = require('chai')
@@ -68,14 +68,16 @@ describe('Authentication API (OIDC)', () => {
6868
})
6969
}
7070

71-
before(() => {
72-
return Promise.all([
71+
before(async () => {
72+
await Promise.all([
7373
startServer(alicePod, 7000),
7474
startServer(bobPod, 7001)
7575
]).then(() => {
7676
alice = supertest(aliceServerUri)
7777
bob = supertest(bobServerUri)
7878
})
79+
cp(path.join('accounts-scenario/alice', '.acl-override'), path.join('accounts-scenario/alice', '.acl'))
80+
cp(path.join('accounts-scenario/bob', '.acl-override'), path.join('accounts-scenario/bob', '.acl'))
7981
})
8082

8183
after(() => {

test/integration/errors-oidc-test.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const supertest = require('supertest')
22
const ldnode = require('../../index')
33
const path = require('path')
4-
const { cleanDir } = require('../utils')
4+
const { cleanDir, cp } = require('../utils')
55
const expect = require('chai').expect
66

77
describe('OIDC error handling', function () {
@@ -25,7 +25,10 @@ describe('OIDC error handling', function () {
2525
})
2626

2727
before(function (done) {
28-
ldpHttpsServer = ldp.listen(3457, done)
28+
ldpHttpsServer = ldp.listen(3457, () => {
29+
cp(path.join('accounts/errortests', '.acl-override'), path.join('accounts/errortests', '.acl'))
30+
done()
31+
})
2932
})
3033

3134
after(function () {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Root ACL resource for the root
2+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
3+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
4+
5+
<#public>
6+
a acl:Authorization;
7+
acl:agentClass foaf:Agent; # everyone
8+
acl:accessTo </>;
9+
acl:default </common/>;
10+
acl:mode acl:Read.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Root ACL resource for the root
2+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
3+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
4+
5+
<#public>
6+
a acl:Authorization;
7+
acl:agentClass foaf:Agent; # everyone
8+
acl:accessTo </>;
9+
acl:default </common/>;
10+
acl:mode acl:Read.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/resources/accounts/localhost/.acl

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Root ACL resource for the root
2+
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
3+
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
4+
5+
<#public>
6+
a acl:Authorization;
7+
acl:agentClass foaf:Agent; # everyone
8+
acl:accessTo <./>;
9+
acl:default <./>;
10+
acl:mode acl:Read.

0 commit comments

Comments
 (0)