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

N3 patch #44

Merged
merged 12 commits into from
Feb 7, 2022
7 changes: 5 additions & 2 deletions patch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ async function run(url) {
const result = await fetcher.fetch(url, {
method: 'PATCH',
headers: {
'Content-Type': 'application/sparql-update'
"Content-Type": "text/n3",
},
body: 'INSERT DATA { <#patch> <#to> <#create> . }'
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#patch> <#to> <#create> .}.",
});
console.log(result.status, await result.text());
}
Expand Down
72 changes: 48 additions & 24 deletions test/surface/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(responseCodeGroup(result.status)).toEqual('2xx');
});
Expand All @@ -318,10 +321,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(responseCodeGroup(result.status)).toEqual('2xx');
});
Expand Down Expand Up @@ -350,10 +356,13 @@ describe('Create', () => {

const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(result.status).toEqual(403);
});
Expand All @@ -380,10 +389,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(result.status).toEqual(403);
});
Expand Down Expand Up @@ -539,10 +551,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}nested/new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(responseCodeGroup(result.status)).toEqual('2xx');
});
Expand All @@ -568,10 +583,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}nested/new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(responseCodeGroup(result.status)).toEqual('2xx');
});
Expand All @@ -598,10 +616,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}nested/new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(result.status).toEqual(403);
});
Expand All @@ -628,10 +649,13 @@ describe('Create', () => {
});
const result = await solidLogicBob.fetch(`${containerUrl}nested/new.txt`, {
method: 'PATCH',
body: 'INSERT DATA { <#hello> <#linked> <#world> . }',
headers: {
'Content-Type': 'application/sparql-update'
}
"Content-Type": "text/n3",
},
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#hello> <#linked> <#world> .}.",
});
expect(result.status).toEqual(403);
});
Expand Down
73 changes: 49 additions & 24 deletions test/surface/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,17 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'text/n3',
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body:
"@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -402,14 +405,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -437,14 +442,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down Expand Up @@ -473,14 +480,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -509,14 +518,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -545,14 +556,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'INSERT DATA { <#how> <#are> <#you> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:inserts { <#how> <#are> <#you> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down Expand Up @@ -585,9 +598,11 @@ describe('Update', () => {
});
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers: {
'Content-Type': 'application/sparql-update'
'Content-Type': 'application/text/n3'
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
}
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -615,14 +630,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down Expand Up @@ -651,14 +668,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down Expand Up @@ -687,14 +706,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers
});
expect(responseCodeGroup(result.status)).toEqual("2xx");
Expand Down Expand Up @@ -723,14 +744,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down Expand Up @@ -761,14 +784,16 @@ describe('Update', () => {
}
});
const headers = {
'Content-Type': 'application/sparql-update',
'Content-Type': 'application/text/n3',
bourgeoa marked this conversation as resolved.
Show resolved Hide resolved
};
if (etagInQuotes) {
headers['If-Match'] = etagInQuotes
}
const result = await solidLogicBob.fetch(resourceUrl, {
method: 'PATCH',
body: 'DELETE DATA { <#hello> <#linked> <#world> . }',
body: "@prefix solid: <http://www.w3.org/ns/solid/terms#>." +
"#patch a solid:InsertDeletePatch;" +
" solid:deletes { <#hello> <#linked> <#world> . }",
headers
});
expect(result.status).toEqual(403);
Expand Down