-
Notifications
You must be signed in to change notification settings - Fork 5
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
PATCH/PUT Append to create a new resource #56
base: main
Are you sure you want to change the base?
Changes from all commits
a567231
ca44c67
8dcf691
59278f4
e63fc5c
312494c
9d3723a
a18d54f
80e26f6
1d50174
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if I agree. This test is about required permissions on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @michielbdejong I should have added this link as a clarification on WAC |
||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name to the test artifact below should be changed to match the test purpose to avoid future confusion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I commit my changes to testing