Skip to content

Commit acf53e5

Browse files
authored
Merge pull request #1745 from nodeSolidServer/appendPatchNewDocument
Append patch new document
2 parents 74ad47b + b985182 commit acf53e5

File tree

8 files changed

+3458
-1153
lines changed

8 files changed

+3458
-1153
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
node-version: [14.x, 16.x]
20+
node-version: [16.x, 18.x]
2121
os: [ubuntu-latest]
2222

2323
steps:

lib/handlers/patch.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ async function checkPermission (request, patchObject, resourceExists) {
143143
// Now that we know the details of the patch,
144144
// we might need to perform additional checks.
145145
let modes = []
146-
// acl:default Write is required for create
147-
if (!resourceExists) modes = ['Write']
148146
const { acl, session: { userId } } = request
149147
// Read access is required for DELETE and WHERE.
150148
// If we would allows users without read access,

package-lock.json

Lines changed: 3424 additions & 1146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"ip-range-check": "0.2.0",
9090
"is-ip": "^3.1.0",
9191
"li": "^1.3.0",
92-
"mashlib": "^1.8.8",
92+
"mashlib": "^1.8.9",
9393
"mime-types": "^2.1.35",
9494
"negotiator": "^0.6.3",
9595
"node-fetch": "^2.6.9",

test/integration/acl-oidc-test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
551551
done()
552552
})
553553
})
554-
it.skip('user1 should be able to PATCH a resource', function (done) {
554+
it('user1 should be able to PATCH (which CREATEs) a nonexistent resource', function (done) {
555555
const options = createOptions('/append-inherited/test.ttl', 'user1')
556556
options.body = 'INSERT DATA { :test :hello 456 .}'
557557
options.headers['content-type'] = 'application/sparql-update'
@@ -589,6 +589,16 @@ describe('ACL with WebID+OIDC over HTTP', function () {
589589
done()
590590
})
591591
})
592+
it('user2 should be able to PATCH INSERT to (which CREATEs) a nonexistent resource', function (done) {
593+
const options = createOptions('/append-inherited/new.ttl', 'user2')
594+
options.body = 'INSERT DATA { :test :hello 789 .}'
595+
options.headers['content-type'] = 'application/sparql-update'
596+
request.patch(options, function (error, response, body) {
597+
assert.equal(error, null)
598+
assert.equal(response.statusCode, 200)
599+
done()
600+
})
601+
})
592602
it('user2 should not be able to access test file\'s ACL file', function (done) {
593603
const options = createOptions('/append-acl/abc.ttl.acl', 'user2', 'text/turtle')
594604
request.head(options, function (error, response, body) {
@@ -648,6 +658,7 @@ describe('ACL with WebID+OIDC over HTTP', function () {
648658
})
649659
after(function () {
650660
rm('/accounts-acl/tim.localhost/append-inherited/test.ttl')
661+
rm('/accounts-acl/tim.localhost/append-inherited/new.ttl')
651662
})
652663
})
653664

test/resources/accounts-acl/tim.localhost/append-inherited/.acl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@
1111

1212
acl:default <./>.
1313

14+
<#AppendOnly>
15+
a <http://www.w3.org/ns/auth/acl#Authorization>;
16+
<http://www.w3.org/ns/auth/acl#accessTo> <./>;
17+
acl:default <./>;
18+
<http://www.w3.org/ns/auth/acl#agentClass> <http://xmlns.com/foaf/0.1/Agent>;
19+
<http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read>, <http://www.w3.org/ns/auth/acl#Append> .

test/surface/run-solid-test-suite.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,26 @@ function runTests {
4141
--env-file test/surface/$1-env.list solidtestsuite/$1:$2
4242
}
4343

44+
function runTestsFromGit {
45+
docker build https://github.com/solid-contrib/$1.git#$2 -t $1
46+
47+
echo "Running web-access-control-tests against server with cookie $COOKIE_server"
48+
docker run --rm --network=testnet \
49+
--env COOKIE="$COOKIE_server" \
50+
--env COOKIE_ALICE="$COOKIE_server" \
51+
--env COOKIE_BOB="$COOKIE_thirdparty" \
52+
--env-file test/surface/$1-env.list $1
53+
}
54+
4455
# ...
4556
teardown || true
4657
setup $1
4758
waitForNss server
4859
runTests webid-provider-tests v2.0.3
4960
runTests solid-crud-tests v6.0.0
5061
waitForNss thirdparty
51-
runTests web-access-control-tests v7.1.0
62+
# runTests web-access-control-tests v7.1.0
63+
runTestsFromGit web-access-control-tests patchAppendNewDocument
5264
teardown
5365

5466
# To debug, e.g. running web-access-control-tests jest interactively,

test/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ exports.checkDnsSettings = function () {
5555
return Promise.all(TEST_HOSTS.map(hostname => {
5656
return new Promise((resolve, reject) => {
5757
dns.lookup(hostname, (error, ip) => {
58-
if (error || ip !== '127.0.0.1') {
58+
if (error || (ip !== '127.0.0.1' && ip !== '::1')) {
5959
reject(error)
6060
} else {
6161
resolve(true)

0 commit comments

Comments
 (0)