/
slash-semantics-exclude.feature
128 lines (112 loc) · 5.9 KB
/
slash-semantics-exclude.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@parallel=false
Feature: With and without trailing slash cannot co-exist
Background: Set up clients and paths
* def testContainer = rootTestContainer.createContainer()
* configure followRedirects = false
Scenario: PUT container, then try resource with same name
* def childContainerUrl = testContainer.url + 'foo/'
Given url childContainerUrl
And headers clients.alice.getAuthHeaders('PUT', childContainerUrl)
And header Content-Type = 'text/turtle'
And header Link = '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'
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'
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'
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
# 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'
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: 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 = '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'
When method POST
Then assert responseStatus >= 200 && responseStatus < 300
And def childContainerUrl = resolveUri(testContainer.url, karate.response.headerValues('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 && resolveUri(testContainer.url, karate.response.headerValues('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 = resolveUri(testContainer.url, karate.response.headerValues('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 = '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"'
When method POST
# this should either succeed (without using the slug) or fail as a conflict
Then assert (responseStatus >= 200 && responseStatus < 300 && resolveUri(testContainer.url, karate.response.headerValues('location')[0]) != resourceUrl + '/') || [409, 415].includes(responseStatus)
# TODO: Evil test to check various suffices.