Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append patch new document #1745

Merged
merged 29 commits into from
Dec 17, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
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
4 changes: 2 additions & 2 deletions lib/handlers/patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ async function checkPermission (request, patchObject, resourceExists) {
// Now that we know the details of the patch,
// we might need to perform additional checks.
let modes = []
// acl:default Write is required for create
if (!resourceExists) modes = ['Write']
// acl:default Write is required for create when resource exists
if (!resourceExists) modes = ['Append']
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
const { acl, session: { userId } } = request
// Read access is required for DELETE and WHERE.
// If we would allows users without read access,
Expand Down
13 changes: 12 additions & 1 deletion test/integration/acl-oidc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it.skip('user1 should be able to PATCH a resource', function (done) {
it('user1 should be able to PATCH a non existing resource', function (done) {
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
const options = createOptions('/append-inherited/test.ttl', 'user1')
options.body = 'INSERT DATA { :test :hello 456 .}'
options.headers['content-type'] = 'application/sparql-update'
Expand Down Expand Up @@ -589,6 +589,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
done()
})
})
it('user2 should be able to PATCH insert on a non existing resource', function (done) {
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
const options = createOptions('/append-inherited/new.ttl', 'user2')
options.body = 'INSERT DATA { :test :hello 789 .}'
options.headers['content-type'] = 'application/sparql-update'
request.patch(options, function (error, response, body) {
assert.equal(error, null)
assert.equal(response.statusCode, 200)
done()
})
})
it('user2 should not be able to access test file\'s ACL file', function (done) {
const options = createOptions('/append-acl/abc.ttl.acl', 'user2', 'text/turtle')
request.head(options, function (error, response, body) {
Expand Down Expand Up @@ -648,6 +658,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
})
after(function () {
rm('/accounts-acl/tim.localhost/append-inherited/test.ttl')
rm('/accounts-acl/tim.localhost/append-inherited/new.ttl')
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

acl:default <./>.

<#AppendOnly>
a <http://www.w3.org/ns/auth/acl#Authorization>;
<http://www.w3.org/ns/auth/acl#accessTo> <./>;
acl:default <./>;
<http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Append> .
Loading