Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"bugs": "https://github.com/solid/node-solid-server/issues",
"dependencies": {
"@solid/oidc-auth-manager": "^0.17.1",
"@solid/acl-check": "^0.1.2",
"@solid/acl-check": "^0.1.3",
"body-parser": "^1.18.3",
"bootstrap": "^3.3.7",
"busboy": "^0.2.12",
Expand Down
51 changes: 44 additions & 7 deletions test/integration/acl-oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,13 @@ describe('ACL with WebID+OIDC over HTTP', function () {
' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
' <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n'
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n' +
'<#Somebody> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
' <http://www.w3.org/ns/auth/acl#agent> <' + user2 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#default> <./>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Write> .\n'
request.put(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 201)
Expand All @@ -290,6 +296,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it('user2 should be able to access public test directory with wrong origin', function (done) {
var options = createOptions('/origin/test-folder/', 'user2')
options.headers.origin = origin2

request.head(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 200)
done()
})
})
it('user1 should be able to access to test directory when origin is valid',
function (done) {
var options = createOptions('/origin/test-folder/', 'user1')
Expand All @@ -301,15 +317,14 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it('user1 should not be able to access test directory when origin is invalid',
it('user1 should be able to access public test directory even when origin is invalid',
function (done) {
var options = createOptions('/origin/test-folder/', 'user1')
options.headers.origin = origin2

request.head(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 403)
assert.equal(response.statusMessage, 'Forbidden') // TODO: Should be Origin Unauthorized
assert.equal(response.statusCode, 200)
done()
})
})
Expand All @@ -334,21 +349,43 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it('agent should not be able to access test directory when origin is invalid',
it('agent should be able to access public test directory even when origin is invalid',
function (done) {
var options = createOptions('/origin/test-folder/')
options.headers.origin = origin2

request.head(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 403)
assert.equal(response.statusMessage, 'Forbidden') // TODO: Should be Origin Unauthorized
assert.equal(response.statusCode, 200)
done()
})
})
it('user2 should be able to write to test directory with correct origin', function (done) {
var options = createOptions('/origin/test-folder/test1.txt', 'user2', 'text/plain')
options.headers.origin = origin1
options.body = 'DAAAAAHUUUT'
request.put(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 201)
done()
})
})
it('user2 should not be able to write to test directory with wrong origin', function (done) {
var options = createOptions('/origin/test-folder/test2.txt', 'user2', 'text/plain')
options.headers.origin = origin2
options.body = 'ARRRRGH'
request.put(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 403)
assert.equal(response.statusMessage, 'Forbidden') // TODO: Should be Origin Unauthorized
done()
})
})

after(function () {
rm('/accounts-acl/tim.localhost/origin/test-folder/.acl')
rm('/accounts-acl/tim.localhost/origin/test-folder/test1.txt')
rm('/accounts-acl/tim.localhost/origin/test-folder/test2.txt')
})
})

Expand Down
18 changes: 9 additions & 9 deletions test/integration/acl-tls-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ describe('ACL with WebID+TLS', function () {
'content-type': 'text/turtle'
}
options.body = '<#Owner> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/.acl>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/>;\n' +
' <http://www.w3.org/ns/auth/acl#agent> <' + user1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .\n' +
'<#Public> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
' <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;\n' +
' <http://www.w3.org/ns/auth/acl#agentClass> <http://www.w3.org/ns/auth/acl#AuthenticatedAgent>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n'
request.put(options, function (error, response, body) {
Expand Down Expand Up @@ -326,13 +326,13 @@ describe('ACL with WebID+TLS', function () {
done()
})
})
it('agent should be able to access test directory', function (done) {
it('agent not should be able to access test directory', function (done) {
var options = createOptions('/acl-tls/origin/test-folder/')
options.headers.origin = origin1

request.head(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 200)
assert.equal(response.statusCode, 403)
done()
})
})
Expand Down Expand Up @@ -375,16 +375,16 @@ describe('ACL with WebID+TLS', function () {
'content-type': 'text/turtle'
}
options.body = '<#Owner1> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/.acl>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/>;\n' +
' <http://www.w3.org/ns/auth/acl#agent> <' + user1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .\n' +
'<#Owner2> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/.acl>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <https://localhost:3456/test/acl-tls/origin/test-folder/>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Write>, <http://www.w3.org/ns/auth/acl#Control> .\n' +
'<#Public> a <http://www.w3.org/ns/auth/acl#Authorization>;\n' +
' <http://www.w3.org/ns/auth/acl#accessTo> <./>;\n' +
' <http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;\n' +
' <http://www.w3.org/ns/auth/acl#agentClass> <http://www.w3.org/ns/auth/acl#AuthenticatedAgent>;\n' +
' <http://www.w3.org/ns/auth/acl#origin> <' + origin1 + '>;\n' +
' <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> .\n'
request.put(options, function (error, response, body) {
Expand Down Expand Up @@ -427,13 +427,13 @@ describe('ACL with WebID+TLS', function () {
done()
})
})
it('agent should be able to access test directory', function (done) {
it('agent should not be able to access test directory for logged in users', function (done) {
var options = createOptions('/acl-tls/origin/test-folder/')
options.headers.origin = origin1

request.head(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 200)
assert.equal(response.statusCode, 403)
done()
})
})
Expand Down