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/create.test.ts b/test/surface/create.test.ts index 25a92e3..d314896 100644 --- a/test/surface/create.test.ts +++ b/test/surface/create.test.ts @@ -196,8 +196,8 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { - const testing = `test-disallowed-default`; + it(`is allowed with Append on c/r (create new resource)`, async () => { + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -229,6 +229,42 @@ describe('Create', () => { '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: + 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}test.txt`, { + method: 'PUT', + body: 'hello', + headers: { + 'Content-Type': 'text/plain', + // 'If-None-Match': '*' // precondition may be tested before and return 412 + } + }); expect(result.status).toEqual(403); }); @@ -313,8 +349,8 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { - const testing = `test-disallowed-default`; + it(`is allowed with Append on c/r`, async () => { + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -350,7 +386,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(responseCodeGroup(result.status)).toEqual("2xx"); }); it(`is disallowed without Write or Append on c/`, async () => { @@ -435,8 +471,8 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { - const testing = `disallowed-default`; + it(`is allowed with Append on c/r (create new resource)`, async () => { + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -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 () => { @@ -554,8 +590,8 @@ describe('Create', () => { testAllowed('Write', 'Write'); testAllowed('Append', 'Write'); - it(`is disallowed without Write on c/r`, async () => { - const testing = `disallowed-default`; + it(`is allowed with Append on c/r`, async () => { + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -589,11 +625,11 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(responseCodeGroup(result.status)).toEqual("2xx"); }); - it(`is disallowed without Write or Append on c/`, async () => { - const testing = `disallowed-default`; + it(`is allowed with Append on c/`, async () => { + const testing = `allowed-default`; const containerUrl = makeContainerUrl(testFolderUrl, using, testing); // This will do mkdir-p: await solidLogicAlice.fetch(`${containerUrl}test.txt`, { @@ -627,7 +663,7 @@ describe('Create', () => { "<#patch> a solid:InsertDeletePatch;\n" + " solid:inserts { <#hello> <#linked> <#world> .}.\n", }); - expect(result.status).toEqual(403); + expect(result.status).toEqual(200); }); }); }); 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..9984167 100644 --- a/test/surface/read.test.ts +++ b/test/surface/read.test.ts @@ -153,7 +153,7 @@ describe('Read', () => { 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', () => { 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: { 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: