22Feature : With and without trailing slash cannot co-exist
33
44 Background : Set up clients and paths
5- * def testContainer = rootTestContainer.reserveContainer ()
5+ * def testContainer = rootTestContainer.createContainer ()
66 * configure followRedirects = false
77
88 Scenario : PUT container, then try resource with same name
@@ -13,47 +13,115 @@ Feature: With and without trailing slash cannot co-exist
1313 When method PUT
1414 Then assert responseStatus >= 200 && responseStatus < 300
1515
16+ # confirm there is no non-container resource with the same URI
1617 * def resourceUrl = testContainer.url + 'foo'
1718 Given url resourceUrl
1819 And headers clients.alice.getAuthHeaders('GET', resourceUrl)
1920 When method GET
2021 Then match [301, 404, 410] contains responseStatus
2122
23+ # attempt to overwrite the container with a resource of the same name
2224 Given url resourceUrl
2325 And headers clients.alice.getAuthHeaders('PUT', resourceUrl)
2426 And header Content-Type = 'text/plain'
25- And request " Hello"
27+ And request ' Hello'
2628 When method PUT
2729 # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415
2830 Then match [409, 415] contains responseStatus
2931
30-
3132 Scenario: PUT resource, then try container with same name
3233 * def resourceUrl = testContainer.url + 'foo'
3334 Given url resourceUrl
3435 And headers clients.alice.getAuthHeaders('PUT', resourceUrl)
3536 And header Content-Type = 'text/plain'
36- And request " Hello"
37+ And request ' Hello'
3738 When method PUT
3839 Then assert responseStatus > = 200 && responseStatus < 300
3940
41+ # confirm there is no container with the same URI
4042 * def childContainerUrl = testContainer.url + 'foo/'
4143 Given url childContainerUrl
4244 And headers clients.alice.getAuthHeaders('GET', childContainerUrl)
4345 When method GET
4446 Then match [301, 404, 410] contains responseStatus
4547
46- * def childContainerUrl = testContainer.url + 'foo/'
48+ # attempt to overwrite the resource with a container of the same name
4749 Given url childContainerUrl
4850 And headers clients.alice.getAuthHeaders('PUT', childContainerUrl)
4951 And header Content-Type = 'text/turtle'
5052 When method PUT
5153 # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415
5254 Then match [409, 415] contains responseStatus
5355
54- # TODO: Evil test to check various suffices.
56+ Scenario: POST container, then try resource with same name
57+ Given url testContainer.url
58+ And headers clients.alice.getAuthHeaders('POST', testContainer.url)
59+ And header Content-Type = 'text/turtle'
60+ And header Link = '<http://www.w3.org/ns/ldp#BasicContainer> ; rel="type" '
61+ When method POST
62+ Then assert responseStatus >= 200 && responseStatus < 300
63+ And def childContainerUrl = responseHeaders['Location'][0]
64+ And assert childContainerUrl.endsWith('/')
5565
66+ # confirm there is no non-container resource with the same URI
67+ * def resourceUrl = childContainerUrl.slice(0, -1)
68+ Given url resourceUrl
69+ And headers clients.alice.getAuthHeaders('GET', resourceUrl)
70+ When method GET
71+ Then match [301, 404, 410] contains responseStatus
5672
73+ # attempt to overwrite the container with a resource of the same name by PUT
74+ Given url resourceUrl
75+ And headers clients.alice.getAuthHeaders('PUT', resourceUrl)
76+ And header Content-Type = 'text/plain'
77+ And request 'Hello'
78+ When method PUT
79+ # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415
80+ Then match [409, 415] contains responseStatus
5781
82+ # attempt to overwrite the container with a resource of the same name by POST with a slug
83+ Given url testContainer.url
84+ And headers clients.alice.getAuthHeaders('POST', testContainer.url)
85+ And header Slug = resourceUrl.substring(resourceUrl.lastIndexOf('/') + 1)
86+ And header Content-Type = 'text/plain'
87+ And request 'Hello'
88+ When method POST
89+ # this should either succeed (without using the slug) or fail as a conflict
90+ Then assert (responseStatus > = 200 && responseStatus < 300 && responseHeaders['Location'][0] != resourceUrl) || [409, 415].includes(responseStatus)
5891
92+ Scenario: POST resource, then try container with same name
93+ Given url testContainer.url
94+ And headers clients.alice.getAuthHeaders('POST', testContainer.url)
95+ And header Content-Type = 'text/plain'
96+ And request 'Hello'
97+ When method POST
98+ Then assert responseStatus > = 200 && responseStatus < 300
99+ And def resourceUrl = responseHeaders['Location'][0]
100+ And assert !resourceUrl.endsWith('/')
101+
102+ # confirm there is no container with the same URI
103+ * def childContainerUrl = resourceUrl + '/'
104+ Given url childContainerUrl
105+ And headers clients.alice.getAuthHeaders('GET', childContainerUrl)
106+ When method GET
107+ Then match [301, 404, 410] contains responseStatus
108+
109+ # attempt to overwrite the resource with a container of the same name by PUT
110+ Given url childContainerUrl
111+ And headers clients.alice.getAuthHeaders('PUT', childContainerUrl)
112+ And header Content-Type = 'text/turtle'
113+ When method PUT
114+ # See https://www.rfc-editor.org/rfc/rfc7231.html#page-27 for why 409 or 415
115+ Then match [409, 415] contains responseStatus
116+
117+ # attempt to overwrite the resource with a container of the same name by POST with a slug
118+ Given url testContainer.url
119+ And headers clients.alice.getAuthHeaders('POST', testContainer.url)
120+ And header Slug = resourceUrl.substring(resourceUrl.lastIndexOf('/') + 1)
121+ And header Content-Type = 'text/turtle'
122+ And header Link = '<http://www.w3.org/ns/ldp#BasicContainer> ; rel="type" '
123+ When method POST
124+ # this should either succeed (without using the slug) or fail as a conflict
125+ Then assert (responseStatus >= 200 && responseStatus < 300 && responseHeaders['Location'][0] != resourceUrl + '/') || [409, 415].includes(responseStatus)
59126
127+ # TODO: Evil test to check various suffices.
0 commit comments