From a5672313ec5fbdddcfa2bd47ccc921c2a771d709 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Thu, 30 Nov 2023 16:23:39 +0100 Subject: [PATCH 1/8] PATCH Append on new file --- test/surface/create.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 25a92e3..cdee1c0 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -313,7 +313,7 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { + it(`is allowed with Append on c/r`, async () => { const testing = `test-disallowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: @@ -350,7 +350,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(result.status).toEqual(200); }); it(`is disallowed without Write or Append on c/`, async () => { @@ -554,7 +554,7 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { + it(`is allowed with Append on c/r`, async () => { const testing = `disallowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: @@ -589,10 +589,10 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(result.status).toEqual(200); }); - it(`is disallowed without Write or Append on c/`, async () => { + it(`is allowed with Append on c/`, async () => { const testing = `disallowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: @@ -627,7 +627,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(result.status).toEqual(200); }); }); }); From ca44c67816c594952e3f1025f4fc0bad69efb34c Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Tue, 19 Dec 2023 16:53:25 +0100 Subject: [PATCH 2/8] update tests for PUT with Append --- test/surface/create.test.ts | 42 ++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index cdee1c0..4939c9b 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -196,7 +196,43 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { + it(`is allowed with Append on c/r (create new resource)`, async () => { + const testing = `test-disallowed-default`; + const containerUrl = makeContainerUrl(testFolderUrl, using, testing); + // This will do mkdir-p: + await solidLogicAlice.fetch(`${containerUrl}test.txt`, { + method: 'PUT', + body: 'hello', + headers: { + 'Content-Type': 'text/plain', + 'If-None-Match': '*' + } + }); + const aclDocUrl = await solidLogicAlice.findAclDocUrl(containerUrl); + await solidLogicAlice.fetch(aclDocUrl, { + method: 'PUT', + body: makeBody({ + containerModes: 'acl:Read, acl:Append, acl:Write, acl:Control', + resourceModes: 'acl:Read, acl:Append, acl:Control', + target: containerUrl + }), + headers: { + 'Content-Type': 'text/turtle', + // 'If-None-Match': '*' - work around a bug in some servers that don't support If-None-Match on ACL doc URLs + } + }); + const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, { + method: 'PUT', + body: 'hello', + headers: { + 'Content-Type': 'text/plain', + 'If-None-Match': '*' + } + }); + expect(result.status).toEqual(201); + }); + + it(`is disallowed with Append on c/r (existing resource)`, async () => { const testing = `test-disallowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: @@ -435,7 +471,7 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { + it(`is allowed with Append on c/r (create new resource)`, async () => { const testing = `disallowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: @@ -468,7 +504,7 @@ describe('Create', () => { 'If-None-Match': '*' } }); - expect(result.status).toEqual(403); + expect(result.status).toEqual(201); }); it(`is disallowed without Write or Append on c/`, async () => { From 8dcf691983aa15023755f471598a8e782102d90d Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Tue, 19 Dec 2023 17:37:47 +0100 Subject: [PATCH 3/8] update testing --- test/surface/create.test.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 4939c9b..2266771 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -197,7 +197,7 @@ describe('Create', () => { testAllowed('Append', 'Write'); it(`is allowed with Append on c/r (create new resource)`, async () => { - const testing = `test-disallowed-default`; + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -350,7 +350,7 @@ describe('Create', () => { testAllowed('Append', 'Write'); it(`is allowed with Append on c/r`, async () => { - const testing = `test-disallowed-default`; + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -472,7 +472,7 @@ describe('Create', () => { testAllowed('Append', 'Write'); it(`is allowed with Append on c/r (create new resource)`, async () => { - const testing = `disallowed-default`; + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -591,7 +591,7 @@ describe('Create', () => { testAllowed('Append', 'Write'); it(`is allowed with Append on c/r`, async () => { - const testing = `disallowed-default`; + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -629,7 +629,7 @@ describe('Create', () => { }); it(`is allowed with Append on c/`, async () => { - const testing = `disallowed-default`; + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { From 59278f41a44217d275ef3d8cf7f0a96ccec4fc42 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sun, 31 Dec 2023 09:23:46 +0100 Subject: [PATCH 4/8] wrong test --- test/surface/create.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 2266771..84aa0d9 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -257,7 +257,7 @@ describe('Create', () => { // 'If-None-Match': '*' - work around a bug in some servers that don't support If-None-Match on ACL doc URLs } }); - const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, { + const result = await solidLogicBob.fetch(`${containerUrl}test.txt`, { method: 'PUT', body: 'hello', headers: { From e63fc5c5bb13fbde339cbc57846afe82990ab0f2 Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sun, 28 Jan 2024 13:37:19 +0100 Subject: [PATCH 5/8] precondition if-none-match 412 --- test/surface/create.test.ts | 2 +- test/surface/update.test.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 84aa0d9..1b91542 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -262,7 +262,7 @@ describe('Create', () => { body: 'hello', headers: { 'Content-Type': 'text/plain', - 'If-None-Match': '*' + // 'If-None-Match': '*' // precondition may be tested before and return 412 } }); expect(result.status).toEqual(403); diff --git a/test/surface/update.test.ts b/test/surface/update.test.ts index 6ee2ac2..64f96a0 100644 --- a/test/surface/update.test.ts +++ b/test/surface/update.test.ts @@ -211,6 +211,7 @@ describe('Update', () => { 'If-None-Match': '*' } }); + // expect(creationResult.status).toEqual(201); const etagInQuotes = creationResult.headers.get('etag'); // console.log({ etag: etagInQuotes }); const aclDocUrl = await solidLogicAlice.findAclDocUrl(resourceUrl); @@ -235,6 +236,19 @@ describe('Update', () => { }); expect(responseCodeGroup(result.status)).toEqual("2xx"); }); + it('Fails on if-none-match asterisk precondition on existing resource', async () => { + const resourceUrl = `${testFolderUrl}5/test.txt`; + // This will do mkdir-p: + const creationResult = await solidLogicAlice.fetch(resourceUrl, { + method: 'PUT', + body: 'hello', + headers: { + 'Content-Type': 'text/plain', + 'If-None-Match': '*' + } + }); + expect(creationResult.status).toEqual(412); + }) it('Is disallowed with accessTo Read+Append+Control access on resource', async () => { const resourceUrl = `${testFolderUrl}6/test.txt`; // This will do mkdir-p: From 312494ca0aba617a60e05d6c85809dc816c9916a Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sat, 24 Feb 2024 21:52:49 +0100 Subject: [PATCH 6/8] fails on dot file .dummy --- run-against-nss.sh | 2 +- test/surface/read-logged_in.test.ts | 8 ++++---- test/surface/read-public.test.ts | 8 ++++---- test/surface/read.test.ts | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/run-against-nss.sh b/run-against-nss.sh index d587f3d..6e69981 100755 --- a/run-against-nss.sh +++ b/run-against-nss.sh @@ -47,4 +47,4 @@ export STORAGE_ROOT_ALICE=https://$USERNAME_ALICE.localhost:8443/ # npm run jest -- --json --outputFile="$RESULTS_PATH" "$@" export INCLUDE_MAY=1 mkdir -p ../test-suite/NSS -./node_modules/.bin/jest test/surface/ --json --outputFile="$RESULTS_PATH" "$@" +./node_modules/.bin/jest test/surface/ --json --outputFile="$RESULTS_PATH" "$@" --detectOpenHandles diff --git a/test/surface/read-logged_in.test.ts b/test/surface/read-logged_in.test.ts index b15546d..ee58add 100644 --- a/test/surface/read-logged_in.test.ts +++ b/test/surface/read-logged_in.test.ts @@ -151,7 +151,7 @@ describe('Read-LoggedIn', () => { it('Is allowed with accessTo Read access on container resource', async () => { const resourceUrl = `${testFolderUrl}5/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -175,7 +175,7 @@ describe('Read-LoggedIn', () => { it('Is disallowed with accessTo Append+Write+Control access on non-container resource', async () => { const resourceUrl = `${testFolderUrl}6/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -200,7 +200,7 @@ describe('Read-LoggedIn', () => { const containerUrl = `${testFolderUrl}7/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -225,7 +225,7 @@ describe('Read-LoggedIn', () => { const containerUrl = `${testFolderUrl}8/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { diff --git a/test/surface/read-public.test.ts b/test/surface/read-public.test.ts index 644c26f..771a654 100644 --- a/test/surface/read-public.test.ts +++ b/test/surface/read-public.test.ts @@ -153,7 +153,7 @@ describe('Read-Public', () => { it('Is allowed with accessTo Read access on container resource', async () => { const resourceUrl = `${testFolderUrl}5/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -177,7 +177,7 @@ describe('Read-Public', () => { it('Is disallowed with accessTo Append+Write+Control access on non-container resource', async () => { const resourceUrl = `${testFolderUrl}6/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -202,7 +202,7 @@ describe('Read-Public', () => { const containerUrl = `${testFolderUrl}7/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -227,7 +227,7 @@ describe('Read-Public', () => { const containerUrl = `${testFolderUrl}8/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { diff --git a/test/surface/read.test.ts b/test/surface/read.test.ts index abd5a12..9baad79 100644 --- a/test/surface/read.test.ts +++ b/test/surface/read.test.ts @@ -150,10 +150,10 @@ describe('Read', () => { expect(result.status).toEqual(403); }); - it('Is allowed with accessTo Read access on container resource', async () => { + it('Is allowed with accessTo Read access on container resource', async () => { // alain const resourceUrl = `${testFolderUrl}5/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -177,7 +177,7 @@ describe('Read', () => { it('Is disallowed with accessTo Append+Write+Control access on non-container resource', async () => { const resourceUrl = `${testFolderUrl}6/test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -202,7 +202,7 @@ describe('Read', () => { const containerUrl = `${testFolderUrl}7/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { @@ -227,7 +227,7 @@ describe('Read', () => { const containerUrl = `${testFolderUrl}8/`; const resourceUrl = `${containerUrl}test/`; // This will do mkdir-p: - const creationResult = await solidLogicAlice.fetch(`${resourceUrl}.dummy`, { + const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, { method: 'PUT', body: '<#hello> <#linked> <#world> .', headers: { From 9d3723ae8cf54b9c4bee4ff2facd2903782c0d1b Mon Sep 17 00:00:00 2001 From: Rahul Gupta Date: Wed, 28 Aug 2024 23:59:25 +0530 Subject: [PATCH 7/8] Allow server to send 201 on PATCH create When a new resource is created as a result of PATCH, allow 201 as a valid status code. --- test/surface/create.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 1b91542..e85935f 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -386,7 +386,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(200); + expect(responseCodeGroup(result.status)).toEqual('2xx'); }); it(`is disallowed without Write or Append on c/`, async () => { @@ -625,7 +625,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(200); + expect(responseCodeGroup(result.status)).toEqual('2xx'); }); it(`is allowed with Append on c/`, async () => { From 80e26f6c9e26c3d4c2c8b30685c0247186a2a6fd Mon Sep 17 00:00:00 2001 From: bourgeoa Date: Sat, 23 Nov 2024 15:30:14 +0100 Subject: [PATCH 8/8] 200 and 201 are allowed --- test/surface/create.test.ts | 4 ++-- test/surface/read.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/surface/create.test.ts b/test/surface/create.test.ts index 1b91542..d314896 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -386,7 +386,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(200); + expect(responseCodeGroup(result.status)).toEqual("2xx"); }); it(`is disallowed without Write or Append on c/`, async () => { @@ -625,7 +625,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(200); + expect(responseCodeGroup(result.status)).toEqual("2xx"); }); it(`is allowed with Append on c/`, async () => { diff --git a/test/surface/read.test.ts b/test/surface/read.test.ts index 9baad79..9984167 100644 --- a/test/surface/read.test.ts +++ b/test/surface/read.test.ts @@ -150,7 +150,7 @@ describe('Read', () => { expect(result.status).toEqual(403); }); - it('Is allowed with accessTo Read access on container resource', async () => { // alain + it('Is allowed with accessTo Read access on container resource', async () => { const resourceUrl = `${testFolderUrl}5/test/`; // This will do mkdir-p: const creationResult = await solidLogicAlice.fetch(`${resourceUrl}`, {