diff --git a/.gitignore b/.gitignore index 24b6183..df13a54 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ *.env config reports -target \ No newline at end of file +target +/certs/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c843ca..7e22312 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Solid Specification Conformance Tests +## Release 0.0.12 +* Use harness API to test sending requests without a content type header. +* Ensure container created correctly on slash semantic tests. + ## Release 0.0.11 * Moved repository to `solid-contrib` organization. diff --git a/protocol/writing-resource/content-type-reject.feature b/protocol/writing-resource/content-type-reject.feature index 0e740e8..307a77f 100644 --- a/protocol/writing-resource/content-type-reject.feature +++ b/protocol/writing-resource/content-type-reject.feature @@ -1,32 +1,19 @@ Feature: Server MUST reject write requests without Content-Type Background: Set up clients and paths - * def testContainer = rootTestContainer.reserveContainer() - * def resource = testContainer.reserveResource('.ttl') + * def testContainer = rootTestContainer.createContainer() Scenario: Server rejects PUT requests without Content-Type - Given url resource.url - And headers clients.alice.getAuthHeaders('PUT', resource.url) - And header Content-Type = '' - And request "<> a <#Something> ." - When method PUT - Then status 400 + * def resource = testContainer.reserveResource('.ttl') + * def response = clients.alice.sendAuthorized('PUT', resource.url, '<> a <#Something> .', null, null) + Then assert response.status == 400 Scenario: Server rejects POST requests without Content-Type - * def containerUrl = testContainer.url - Given url containerUrl - And headers clients.alice.getAuthHeaders('POST', containerUrl) - And header Content-Type = '' - And request "<> a <#Something> ." - When method POST - Then status 400 + * def response = clients.alice.sendAuthorized('POST', testContainer.url, '<> a <#Something> .', null, null) + Then assert response.status == 400 Scenario: Server rejects PATCH requests without Content-Type - Given url resource.url - And headers clients.alice.getAuthHeaders('PATCH', resource.url) - And header Content-Type = '' - And request "INSERT DATA { <> a <#Something> . }" - When method PATCH - Then status 400 - - + * def resource = testContainer.createResource('.ttl', karate.readAsString('../fixtures/example.ttl'), 'text/turtle') + * def patch = '@prefix solid: . _:insert a solid:InsertDeletePatch; solid:inserts { <> a . }.' + * def response = clients.alice.sendAuthorized('PATCH', resource.url, patch, null, null) + Then assert response.status == 400 diff --git a/protocol/writing-resource/slash-semantics-exclude.feature b/protocol/writing-resource/slash-semantics-exclude.feature index 8f6a468..a66fee9 100644 --- a/protocol/writing-resource/slash-semantics-exclude.feature +++ b/protocol/writing-resource/slash-semantics-exclude.feature @@ -2,7 +2,7 @@ Feature: With and without trailing slash cannot co-exist Background: Set up clients and paths - * def testContainer = rootTestContainer.reserveContainer() + * def testContainer = rootTestContainer.createContainer() * configure followRedirects = false Scenario: PUT container, then try resource with same name @@ -13,37 +13,39 @@ Feature: With and without trailing slash cannot co-exist When method PUT Then assert responseStatus >= 200 && responseStatus < 300 + # confirm there is no non-container resource with the same URI * def resourceUrl = testContainer.url + 'foo' Given url resourceUrl And headers clients.alice.getAuthHeaders('GET', resourceUrl) When method GET Then match [301, 404, 410] contains responseStatus + # attempt to overwrite the container with a resource of the same name Given url resourceUrl And headers clients.alice.getAuthHeaders('PUT', resourceUrl) And header Content-Type = 'text/plain' - And request "Hello" + And request 'Hello' When method PUT # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415 Then match [409, 415] contains responseStatus - Scenario: PUT resource, then try container with same name * def resourceUrl = testContainer.url + 'foo' Given url resourceUrl And headers clients.alice.getAuthHeaders('PUT', resourceUrl) And header Content-Type = 'text/plain' - And request "Hello" + And request 'Hello' When method PUT Then assert responseStatus >= 200 && responseStatus < 300 + # confirm there is no container with the same URI * def childContainerUrl = testContainer.url + 'foo/' Given url childContainerUrl And headers clients.alice.getAuthHeaders('GET', childContainerUrl) When method GET Then match [301, 404, 410] contains responseStatus - * def childContainerUrl = testContainer.url + 'foo/' + # attempt to overwrite the resource with a container of the same name Given url childContainerUrl And headers clients.alice.getAuthHeaders('PUT', childContainerUrl) And header Content-Type = 'text/turtle' @@ -51,9 +53,75 @@ Feature: With and without trailing slash cannot co-exist # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415 Then match [409, 415] contains responseStatus -# TODO: Evil test to check various suffices. + Scenario: POST container, then try resource with same name + Given url testContainer.url + And headers clients.alice.getAuthHeaders('POST', testContainer.url) + And header Content-Type = 'text/turtle' + And header Link = '; rel="type"' + When method POST + Then assert responseStatus >= 200 && responseStatus < 300 + And def childContainerUrl = responseHeaders['Location'][0] + And assert childContainerUrl.endsWith('/') + # confirm there is no non-container resource with the same URI + * def resourceUrl = childContainerUrl.slice(0, -1) + Given url resourceUrl + And headers clients.alice.getAuthHeaders('GET', resourceUrl) + When method GET + Then match [301, 404, 410] contains responseStatus + # attempt to overwrite the container with a resource of the same name by PUT + Given url resourceUrl + And headers clients.alice.getAuthHeaders('PUT', resourceUrl) + And header Content-Type = 'text/plain' + And request 'Hello' + When method PUT + # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415 + Then match [409, 415] contains responseStatus + # attempt to overwrite the container with a resource of the same name by POST with a slug + Given url testContainer.url + And headers clients.alice.getAuthHeaders('POST', testContainer.url) + And header Slug = resourceUrl.substring(resourceUrl.lastIndexOf('/') + 1) + And header Content-Type = 'text/plain' + And request 'Hello' + When method POST + # this should either succeed (without using the slug) or fail as a conflict + Then assert (responseStatus >= 200 && responseStatus < 300 && responseHeaders['Location'][0] != resourceUrl) || [409, 415].includes(responseStatus) + Scenario: POST resource, then try container with same name + Given url testContainer.url + And headers clients.alice.getAuthHeaders('POST', testContainer.url) + And header Content-Type = 'text/plain' + And request 'Hello' + When method POST + Then assert responseStatus >= 200 && responseStatus < 300 + And def resourceUrl = responseHeaders['Location'][0] + And assert !resourceUrl.endsWith('/') + + # confirm there is no container with the same URI + * def childContainerUrl = resourceUrl + '/' + Given url childContainerUrl + And headers clients.alice.getAuthHeaders('GET', childContainerUrl) + When method GET + Then match [301, 404, 410] contains responseStatus + + # attempt to overwrite the resource with a container of the same name by PUT + Given url childContainerUrl + And headers clients.alice.getAuthHeaders('PUT', childContainerUrl) + And header Content-Type = 'text/turtle' + When method PUT + # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415 + Then match [409, 415] contains responseStatus + + # attempt to overwrite the resource with a container of the same name by POST with a slug + Given url testContainer.url + And headers clients.alice.getAuthHeaders('POST', testContainer.url) + And header Slug = resourceUrl.substring(resourceUrl.lastIndexOf('/') + 1) + And header Content-Type = 'text/turtle' + And header Link = '; rel="type"' + When method POST + # this should either succeed (without using the slug) or fail as a conflict + Then assert (responseStatus >= 200 && responseStatus < 300 && responseHeaders['Location'][0] != resourceUrl + '/') || [409, 415].includes(responseStatus) +# TODO: Evil test to check various suffices. diff --git a/run.sh b/run.sh index f0a0859..ea0b971 100755 --- a/run.sh +++ b/run.sh @@ -28,7 +28,7 @@ setup_css() { mkdir -p config cat > ./config/css-config.json <