From 7e9592ae28132984f6345b51ecb9aad80a416112 Mon Sep 17 00:00:00 2001 From: Kjetil Kjernsmo Date: Wed, 29 Dec 2021 11:28:12 +0100 Subject: [PATCH 1/5] Initial attempt at testing containment triples --- protocol/solid-protocol-test-manifest.ttl | 7 +++++++ .../protect-containment.feature | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 protocol/writing-resource/protect-containment.feature diff --git a/protocol/solid-protocol-test-manifest.ttl b/protocol/solid-protocol-test-manifest.ttl index 8eb41fa..bc44abf 100644 --- a/protocol/solid-protocol-test-manifest.ttl +++ b/protocol/solid-protocol-test-manifest.ttl @@ -96,3 +96,10 @@ manifest:slug-uri-assignment spec:testScript . +manifest:protect-containment + a td:TestCase ; + spec:requirementReference sopr:server-protect-containment ; + td:reviewStatus td:unreviewed ; + spec:testScript + . + diff --git a/protocol/writing-resource/protect-containment.feature b/protocol/writing-resource/protect-containment.feature new file mode 100644 index 0000000..d521513 --- /dev/null +++ b/protocol/writing-resource/protect-containment.feature @@ -0,0 +1,19 @@ +Feature: Server protects containment triples + + Background: Set up container and a few child resources + * def testContainer = rootTestContainer.createContainer() + * def exampleTurtle = karate.readAsString('../fixtures/example.ttl') + * def resource1 = testContainer.createResource('.ttl', exampleTurtle, 'text/turtle'); + * def resource2 = testContainer.createResource('.txt', 'DAHUT', 'text/plain'); + * def resource3 = testContainer.createResource('.txt', 'FOOBAR', 'text/plain'); + * def container1 = testContainer.createContainer() + * def children = [ resource1.url, resource2.url, resource3.url, container1.url ] + + Scenario: Check that members are correct + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained From 118759545a296d47d38539affbdb07011a576777 Mon Sep 17 00:00:00 2001 From: Kjetil Kjernsmo Date: Wed, 19 Jan 2022 01:34:17 +0100 Subject: [PATCH 2/5] Add parantheses for Karate --- protocol/writing-resource/protect-containment.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/writing-resource/protect-containment.feature b/protocol/writing-resource/protect-containment.feature index d521513..ed2e6e6 100644 --- a/protocol/writing-resource/protect-containment.feature +++ b/protocol/writing-resource/protect-containment.feature @@ -7,7 +7,7 @@ Feature: Server protects containment triples * def resource2 = testContainer.createResource('.txt', 'DAHUT', 'text/plain'); * def resource3 = testContainer.createResource('.txt', 'FOOBAR', 'text/plain'); * def container1 = testContainer.createContainer() - * def children = [ resource1.url, resource2.url, resource3.url, container1.url ] + * def children = ([ resource1.url, resource2.url, resource3.url, container1.url ]) Scenario: Check that members are correct Given url testContainer.url From 47535818ec957b7b8240b3bd1d5fcf3d25e415e2 Mon Sep 17 00:00:00 2001 From: Kjetil Kjernsmo Date: Wed, 19 Jan 2022 02:10:09 +0100 Subject: [PATCH 3/5] Add simple PUT test --- .../writing-resource/protect-containment.feature | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/protocol/writing-resource/protect-containment.feature b/protocol/writing-resource/protect-containment.feature index ed2e6e6..23d8bf3 100644 --- a/protocol/writing-resource/protect-containment.feature +++ b/protocol/writing-resource/protect-containment.feature @@ -17,3 +17,18 @@ Feature: Server protects containment triples * def contained = parse(response, 'text/turtle', testContainer.url).members And match contained contains only children And match children contains only contained + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('PUT', testContainer.url) + And header Content-Type = 'text/turtle' + And request '<> .' + When method PUT + Then status 409 + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained From 7d0d9ad94618bfdaefd9b32296d3f050751fe834 Mon Sep 17 00:00:00 2001 From: Kjetil Kjernsmo Date: Wed, 19 Jan 2022 02:12:55 +0100 Subject: [PATCH 4/5] Improve scenario description --- protocol/writing-resource/protect-containment.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/writing-resource/protect-containment.feature b/protocol/writing-resource/protect-containment.feature index 23d8bf3..f2fc6b2 100644 --- a/protocol/writing-resource/protect-containment.feature +++ b/protocol/writing-resource/protect-containment.feature @@ -9,7 +9,7 @@ Feature: Server protects containment triples * def container1 = testContainer.createContainer() * def children = ([ resource1.url, resource2.url, resource3.url, container1.url ]) - Scenario: Check that members are correct + Scenario: PUT invalid object to container Given url testContainer.url And headers clients.alice.getAuthHeaders('GET', testContainer.url) When method GET From 7943ddcfca62cf8a4c57cf5ebb558a336c1e8edc Mon Sep 17 00:00:00 2001 From: Kjetil Kjernsmo Date: Wed, 19 Jan 2022 02:29:26 +0100 Subject: [PATCH 5/5] Add more PUT tests --- .../protect-containment.feature | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/protocol/writing-resource/protect-containment.feature b/protocol/writing-resource/protect-containment.feature index f2fc6b2..a4b22a3 100644 --- a/protocol/writing-resource/protect-containment.feature +++ b/protocol/writing-resource/protect-containment.feature @@ -32,3 +32,51 @@ Feature: Server protects containment triples * def contained = parse(response, 'text/turtle', testContainer.url).members And match contained contains only children And match children contains only contained + + Scenario: PUT invalid subject and object to container + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('PUT', testContainer.url) + And header Content-Type = 'text/turtle' + And request ' .' + When method PUT + Then status 409 + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained + + Scenario: PUT invalid subject to container + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('PUT', testContainer.url) + And header Content-Type = 'text/turtle' + And request ' <' + resource1.url + '> .' + When method PUT + Then status 409 + + Given url testContainer.url + And headers clients.alice.getAuthHeaders('GET', testContainer.url) + When method GET + Then status 200 + * def contained = parse(response, 'text/turtle', testContainer.url).members + And match contained contains only children + And match children contains only contained