httpimagestore 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/Gemfile +7 -7
- data/Gemfile.lock +20 -20
- data/README.md +165 -37
- data/Rakefile +7 -2
- data/VERSION +1 -1
- data/bin/httpimagestore +74 -41
- data/lib/httpimagestore/configuration/file.rb +20 -11
- data/lib/httpimagestore/configuration/handler.rb +96 -257
- data/lib/httpimagestore/configuration/handler/source_store_base.rb +37 -0
- data/lib/httpimagestore/configuration/handler/statement.rb +114 -0
- data/lib/httpimagestore/configuration/identify.rb +17 -9
- data/lib/httpimagestore/configuration/output.rb +33 -61
- data/lib/httpimagestore/configuration/path.rb +2 -2
- data/lib/httpimagestore/configuration/request_state.rb +131 -0
- data/lib/httpimagestore/configuration/s3.rb +41 -29
- data/lib/httpimagestore/configuration/thumbnailer.rb +189 -96
- data/lib/httpimagestore/configuration/validate_hmac.rb +170 -0
- data/lib/httpimagestore/error_reporter.rb +6 -1
- data/lib/httpimagestore/ruby_string_template.rb +10 -19
- metadata +40 -102
- data/.rspec +0 -1
- data/features/cache-control.feature +0 -41
- data/features/compatibility.feature +0 -165
- data/features/data-uri.feature +0 -55
- data/features/encoding.feature +0 -103
- data/features/error-reporting.feature +0 -281
- data/features/flexi.feature +0 -259
- data/features/health-check.feature +0 -29
- data/features/request-matching.feature +0 -211
- data/features/rewrite.feature +0 -122
- data/features/s3-store-and-thumbnail.feature +0 -82
- data/features/source-failover.feature +0 -71
- data/features/step_definitions/httpimagestore_steps.rb +0 -203
- data/features/storage.feature +0 -198
- data/features/support/env.rb +0 -116
- data/features/support/test-large.jpg +0 -0
- data/features/support/test.empty +0 -0
- data/features/support/test.jpg +0 -0
- data/features/support/test.png +0 -0
- data/features/support/test.txt +0 -1
- data/features/support/tiny.png +0 -0
- data/features/xid-forwarding.feature +0 -49
- data/httpimagestore.gemspec +0 -145
- data/load_test/load_test.1k.23a022f6e.m1.small-comp.csv +0 -3
- data/load_test/load_test.1k.ec9bde794.m1.small.csv +0 -4
- data/load_test/load_test.jmx +0 -317
- data/load_test/thumbnail_specs.csv +0 -11
- data/load_test/thumbnail_specs_v2.csv +0 -10
- data/spec/configuration_file_spec.rb +0 -333
- data/spec/configuration_handler_spec.rb +0 -255
- data/spec/configuration_identify_spec.rb +0 -67
- data/spec/configuration_output_spec.rb +0 -821
- data/spec/configuration_path_spec.rb +0 -138
- data/spec/configuration_s3_spec.rb +0 -911
- data/spec/configuration_source_failover_spec.rb +0 -101
- data/spec/configuration_spec.rb +0 -90
- data/spec/configuration_thumbnailer_spec.rb +0 -483
- data/spec/ruby_string_template_spec.rb +0 -61
- data/spec/spec_helper.rb +0 -89
- data/spec/support/compute.jpg +0 -0
- data/spec/support/cuba_response_env.rb +0 -40
- data/spec/support/full.cfg +0 -183
- data/spec/support/utf_string.txt +0 -1
data/features/flexi.feature
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
Feature: Flexible API with two storage options and Facebook like thumbnailing URL format
|
|
2
|
-
Features two storage approaches: with JPEG conversion and limiting in size - for user provided content - and storing as is.
|
|
3
|
-
POST requests will end up with server side generated storage key based on input data digest.
|
|
4
|
-
PUT requests can be used to store image under provided storage key.
|
|
5
|
-
Thumbnail GET API is similar to described in https://developers.facebook.com/docs/reference/api/using-pictures/#sizes.
|
|
6
|
-
Stored object extension and content type is determined from image data.
|
|
7
|
-
|
|
8
|
-
Background:
|
|
9
|
-
Given S3 settings in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_TEST_BUCKET environment variables
|
|
10
|
-
Given httpthumbnailer server is running at http://localhost:3100/health_check
|
|
11
|
-
Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
|
|
12
|
-
"""
|
|
13
|
-
s3 key="@AWS_ACCESS_KEY_ID@" secret="@AWS_SECRET_ACCESS_KEY@" ssl=false
|
|
14
|
-
|
|
15
|
-
path "hash" "#{input_digest}.#{image_mime_extension}"
|
|
16
|
-
path "path" "#{path}"
|
|
17
|
-
|
|
18
|
-
## User uploaded content - always JPEG converted, not bigger than 2160x2160 and in hight quality compression
|
|
19
|
-
post "pictures" {
|
|
20
|
-
thumbnail "input" "original" operation="limit" width=2160 height=2160 format="jpeg" quality=95
|
|
21
|
-
store_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="hash"
|
|
22
|
-
output_store_path "original"
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
put "pictures" {
|
|
26
|
-
thumbnail "input" "original" operation="limit" width=2160 height=2160 format="jpeg" quality=95
|
|
27
|
-
store_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
28
|
-
output_store_path "original"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
## Uploaded by us for use on the website - whatever we send
|
|
32
|
-
post "images" {
|
|
33
|
-
identify "input"
|
|
34
|
-
store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="hash"
|
|
35
|
-
output_store_path "input"
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
put "images" {
|
|
39
|
-
identify "input"
|
|
40
|
-
store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
41
|
-
output_store_path "input"
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
## Thumbailing - keep input format; default JPEG quality is 85
|
|
45
|
-
get "pictures" "&:width" "&:height" "&:operation?crop" "&:background-color?white" {
|
|
46
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
47
|
-
thumbnail "original" "thumbnail" operation="#{operation}" width="#{width}" height="#{height}" options="background-color:#{background-color}"
|
|
48
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
get "pictures" "&:width" "&:height?1080" "&:operation?fit" "&:background-color?white" {
|
|
52
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
53
|
-
thumbnail "original" "thumbnail" operation="#{operation}" width="#{width}" height="#{height}" options="background-color:#{background-color}"
|
|
54
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
get "pictures" "&:height" "&:width?1080" "&:operation?fit" "&:background-color?white" {
|
|
58
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
59
|
-
thumbnail "original" "thumbnail" operation="#{operation}" width="#{width}" height="#{height}" options="background-color:#{background-color}"
|
|
60
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get "pictures" "&type=square" {
|
|
64
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
65
|
-
thumbnail "original" "thumbnail" operation="crop" width="50" height="50"
|
|
66
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get "pictures" "&type=small" {
|
|
70
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
71
|
-
thumbnail "original" "thumbnail" operation="fit" width="50" height="2000"
|
|
72
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
get "pictures" "&type=normall" {
|
|
76
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
77
|
-
thumbnail "original" "thumbnail" operation="fit" width="100" height="2000"
|
|
78
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
get "pictures" "&type=large" {
|
|
82
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
83
|
-
thumbnail "original" "thumbnail" operation="fit" width="200" height="2000"
|
|
84
|
-
output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
## By default serve original image
|
|
88
|
-
get "pictures" {
|
|
89
|
-
source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="path"
|
|
90
|
-
output_image "original" cache-control="public, max-age=31557600, s-maxage=0"
|
|
91
|
-
}
|
|
92
|
-
"""
|
|
93
|
-
|
|
94
|
-
@flexi @pictures @post
|
|
95
|
-
Scenario: Posting picture to S3 bucket will store it under input data digest, limit to 2160x1260 and converted to JPEG
|
|
96
|
-
Given there is no 625d51a1820b607f.jpg file in S3 bucket
|
|
97
|
-
Given test-large.jpg file content as request body
|
|
98
|
-
When I do POST request http://localhost:3000/pictures
|
|
99
|
-
Then response status will be 200
|
|
100
|
-
And response content type will be text/plain
|
|
101
|
-
And response body will be CRLF ended lines
|
|
102
|
-
"""
|
|
103
|
-
625d51a1820b607f.jpg
|
|
104
|
-
"""
|
|
105
|
-
Then S3 object 625d51a1820b607f.jpg will contain JPEG image of size 1529x2160
|
|
106
|
-
Then S3 object 625d51a1820b607f.jpg content type will be image/jpeg
|
|
107
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/625d51a1820b607f.jpg
|
|
108
|
-
Then response status will be 403
|
|
109
|
-
Given there is no b0fe25319ba5909a.jpg file in S3 bucket
|
|
110
|
-
Given test.png file content as request body
|
|
111
|
-
When I do POST request http://localhost:3000/pictures
|
|
112
|
-
Then response status will be 200
|
|
113
|
-
And response content type will be text/plain
|
|
114
|
-
And response body will be CRLF ended lines
|
|
115
|
-
"""
|
|
116
|
-
b0fe25319ba5909a.jpg
|
|
117
|
-
"""
|
|
118
|
-
Then S3 object b0fe25319ba5909a.jpg will contain JPEG image of size 509x719
|
|
119
|
-
Then S3 object b0fe25319ba5909a.jpg content type will be image/jpeg
|
|
120
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/b0fe25319ba5909a.jpg
|
|
121
|
-
Then response status will be 403
|
|
122
|
-
|
|
123
|
-
@flexi @pictures @put
|
|
124
|
-
Scenario: Putting picture to S3 bucket will store it under provided path, limit it to 2160x1260 and converted to JPEG
|
|
125
|
-
Given there is no hello/world file in S3 bucket
|
|
126
|
-
Given test-large.jpg file content as request body
|
|
127
|
-
When I do PUT request http://localhost:3000/pictures/hello/world
|
|
128
|
-
Then response status will be 200
|
|
129
|
-
And response content type will be text/plain
|
|
130
|
-
And response body will be CRLF ended lines
|
|
131
|
-
"""
|
|
132
|
-
hello/world
|
|
133
|
-
"""
|
|
134
|
-
Then S3 object hello/world will contain JPEG image of size 1529x2160
|
|
135
|
-
Then S3 object hello/world content type will be image/jpeg
|
|
136
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/hello/world
|
|
137
|
-
Then response status will be 403
|
|
138
|
-
Given test.png file content as request body
|
|
139
|
-
When I do PUT request http://localhost:3000/pictures/hello/world
|
|
140
|
-
Then response status will be 200
|
|
141
|
-
And response content type will be text/plain
|
|
142
|
-
And response body will be CRLF ended lines
|
|
143
|
-
"""
|
|
144
|
-
hello/world
|
|
145
|
-
"""
|
|
146
|
-
Then S3 object hello/world will contain JPEG image of size 509x719
|
|
147
|
-
Then S3 object hello/world content type will be image/jpeg
|
|
148
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/hello/world
|
|
149
|
-
Then response status will be 403
|
|
150
|
-
|
|
151
|
-
@flexi @images @post
|
|
152
|
-
Scenario: Posting picture to S3 bucket will store it under first input data digest
|
|
153
|
-
Given there is no b0fe25319ba5909a.png file in S3 bucket
|
|
154
|
-
Given test.png file content as request body
|
|
155
|
-
When I do POST request http://localhost:3000/images
|
|
156
|
-
Then response status will be 200
|
|
157
|
-
And response content type will be text/plain
|
|
158
|
-
And response body will be CRLF ended lines
|
|
159
|
-
"""
|
|
160
|
-
b0fe25319ba5909a.png
|
|
161
|
-
"""
|
|
162
|
-
Then S3 object b0fe25319ba5909a.png will contain PNG image of size 509x719
|
|
163
|
-
Then S3 object b0fe25319ba5909a.png content type will be image/png
|
|
164
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/b0fe25319ba5909a.png
|
|
165
|
-
Then response status will be 403
|
|
166
|
-
|
|
167
|
-
@flexi @images @put
|
|
168
|
-
Scenario: Putting picture to S3 bucket will store it under provided path
|
|
169
|
-
Given there is no hello/world file in S3 bucket
|
|
170
|
-
Given test.png file content as request body
|
|
171
|
-
When I do PUT request http://localhost:3000/images/hello/world
|
|
172
|
-
Then response status will be 200
|
|
173
|
-
And response content type will be text/plain
|
|
174
|
-
And response body will be CRLF ended lines
|
|
175
|
-
"""
|
|
176
|
-
hello/world
|
|
177
|
-
"""
|
|
178
|
-
Then S3 object hello/world will contain PNG image of size 509x719
|
|
179
|
-
Then S3 object hello/world content type will be image/png
|
|
180
|
-
When I do GET request http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/hello/world
|
|
181
|
-
Then response status will be 403
|
|
182
|
-
|
|
183
|
-
@flexi @default
|
|
184
|
-
Scenario: Getting stored image when no query string param is present
|
|
185
|
-
Given test.png file content as request body
|
|
186
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
187
|
-
And I do GET request http://localhost:3000/pictures/test.png
|
|
188
|
-
Then response status will be 200
|
|
189
|
-
And response content type will be image/png
|
|
190
|
-
Then response body will contain PNG image of size 509x719
|
|
191
|
-
Given test.jpg file content as request body
|
|
192
|
-
When I do PUT request http://localhost:3000/images/test.jpg
|
|
193
|
-
And I do GET request http://localhost:3000/pictures/test.jpg
|
|
194
|
-
Then response status will be 200
|
|
195
|
-
And response content type will be image/jpeg
|
|
196
|
-
Then response body will contain JPEG image of size 509x719
|
|
197
|
-
|
|
198
|
-
@flexi @type
|
|
199
|
-
Scenario: Getting square type tumbnail
|
|
200
|
-
Given test.png file content as request body
|
|
201
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
202
|
-
And I do GET request http://localhost:3000/pictures/test.png?type=square
|
|
203
|
-
Then response status will be 200
|
|
204
|
-
And response content type will be image/png
|
|
205
|
-
Then response body will contain PNG image of size 50x50
|
|
206
|
-
|
|
207
|
-
@flexi @type
|
|
208
|
-
Scenario: Getting small type tumbnail
|
|
209
|
-
Given test.png file content as request body
|
|
210
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
211
|
-
And I do GET request http://localhost:3000/pictures/test.png?type=small
|
|
212
|
-
Then response status will be 200
|
|
213
|
-
And response content type will be image/png
|
|
214
|
-
Then response body will contain PNG image of size 50x71
|
|
215
|
-
|
|
216
|
-
@flexi @type
|
|
217
|
-
Scenario: Getting normall type tumbnail
|
|
218
|
-
Given test.png file content as request body
|
|
219
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
220
|
-
And I do GET request http://localhost:3000/pictures/test.png?type=normall
|
|
221
|
-
Then response status will be 200
|
|
222
|
-
And response content type will be image/png
|
|
223
|
-
Then response body will contain PNG image of size 100x141
|
|
224
|
-
|
|
225
|
-
@flexi @type
|
|
226
|
-
Scenario: Getting large type tumbnail
|
|
227
|
-
Given test.png file content as request body
|
|
228
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
229
|
-
And I do GET request http://localhost:3000/pictures/test.png?type=large
|
|
230
|
-
Then response status will be 200
|
|
231
|
-
And response content type will be image/png
|
|
232
|
-
Then response body will contain PNG image of size 200x283
|
|
233
|
-
|
|
234
|
-
@flexi @size
|
|
235
|
-
Scenario: Getting custom size tumbnail
|
|
236
|
-
Given test.png file content as request body
|
|
237
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
238
|
-
And I do GET request http://localhost:3000/pictures/test.png?width=123&height=321
|
|
239
|
-
Then response status will be 200
|
|
240
|
-
And response content type will be image/png
|
|
241
|
-
Then response body will contain PNG image of size 123x321
|
|
242
|
-
|
|
243
|
-
@flexi @size
|
|
244
|
-
Scenario: Getting custom size tumbnail without height
|
|
245
|
-
Given test.png file content as request body
|
|
246
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
247
|
-
And I do GET request http://localhost:3000/pictures/test.png?width=123
|
|
248
|
-
Then response status will be 200
|
|
249
|
-
And response content type will be image/png
|
|
250
|
-
Then response body will contain PNG image of size 123x174
|
|
251
|
-
|
|
252
|
-
@flexi @size
|
|
253
|
-
Scenario: Getting custom size tumbnail without width
|
|
254
|
-
Given test.png file content as request body
|
|
255
|
-
When I do PUT request http://localhost:3000/images/test.png
|
|
256
|
-
And I do GET request http://localhost:3000/pictures/test.png?height=321
|
|
257
|
-
Then response status will be 200
|
|
258
|
-
And response content type will be image/png
|
|
259
|
-
Then response body will contain PNG image of size 227x321
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
Feature: Health check URL
|
|
2
|
-
Server can be tested with GET request to '/health_check'.
|
|
3
|
-
|
|
4
|
-
Background:
|
|
5
|
-
Given httpimagestore server is running at http://localhost:3000/ with the following configuration
|
|
6
|
-
"""
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
@health-check
|
|
10
|
-
Scenario: Passing health check when thumbnailer is running
|
|
11
|
-
Given httpthumbnailer server is running at http://localhost:3100/
|
|
12
|
-
When I do GET request http://localhost:3000/health_check
|
|
13
|
-
Then response status will be 200
|
|
14
|
-
And response content type will be text/plain
|
|
15
|
-
And response body will be CRLF ended lines
|
|
16
|
-
"""
|
|
17
|
-
HTTP Image Store OK
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
@health-check
|
|
21
|
-
Scenario: Failing health check when thumbnailer is not running
|
|
22
|
-
Given httpthumbnailer server is not running
|
|
23
|
-
When I do GET request http://localhost:3000/health_check
|
|
24
|
-
Then response status will be 502
|
|
25
|
-
And response content type will be text/plain
|
|
26
|
-
And response body will be CRLF ended lines
|
|
27
|
-
"""
|
|
28
|
-
Connection refused - connect(2) (http://localhost:3100)
|
|
29
|
-
"""
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
Feature: Request matching
|
|
2
|
-
Incoming requests needs to be matched in flexible way and appropriate data needs to be available in form of variables used to parametrize processing.
|
|
3
|
-
|
|
4
|
-
Background:
|
|
5
|
-
Given httpthumbnailer server is running at http://localhost:3100/health_check
|
|
6
|
-
Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
|
|
7
|
-
"""
|
|
8
|
-
# URI segment matchers
|
|
9
|
-
get "string" {
|
|
10
|
-
output_text "path: '#{path}'"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
get "any" "default" ":test1" ":test2?foo" ":test3?bar" ":test4?baz" {
|
|
14
|
-
output_text "test1: '#{test1}' test2: '#{test2}' test3: '#{test3}' test4: '#{test4}' path: '#{path}'"
|
|
15
|
-
}
|
|
16
|
-
get "any" ":test1" ":test2" {
|
|
17
|
-
output_text "test1: '#{test1}' test2: '#{test2}' path: '#{path}'"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
get "regexp1" ":test1/a.c/" ":test2/.*/" {
|
|
21
|
-
output_text "test1: '#{test1}' test2: '#{test2}' path: '#{path}'"
|
|
22
|
-
}
|
|
23
|
-
get "regexp-404" ":test1/a.c.*/" ":test2/\\./" {
|
|
24
|
-
output_text "test1: '#{test1}' test2: '#{test2}' path: '#{path}'"
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
get "regexp" "named" "/(?<test1>..)-(?<test2>..)/" ":test3/.*/" {
|
|
28
|
-
output_text "test1: '#{test1}' test2: '#{test2}' test3: '#{test3}' path: '#{path}'"
|
|
29
|
-
}
|
|
30
|
-
get "regexp" "named" "nocapture" "/..-../" {
|
|
31
|
-
output_text "path: '#{path}'"
|
|
32
|
-
}
|
|
33
|
-
get "regexp" "named" "bad1" "/(?<test1>..)-(?<test1>..)/" ":test3/.*/" {
|
|
34
|
-
output_text "test1: '#{test1}' test2: '#{test2}' test3: '#{test3}' path: '#{path}'"
|
|
35
|
-
}
|
|
36
|
-
get "regexp" "named" "bad2" "/(?<test1>..)-(?<test1>..)/" ":test3/.*/" {
|
|
37
|
-
output_text "test1: '#{test1}' test3: '#{test3}' path: '#{path}'"
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
# Query string matchers
|
|
41
|
-
get "query" "key-value" "&hello=world" {
|
|
42
|
-
output_text "query key-value matched path: '#{path}'"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get "query" "key" "default" "&:hello?abc" {
|
|
46
|
-
output_text "key: '#{hello}' path: '#{path}'"
|
|
47
|
-
}
|
|
48
|
-
get "query" "key" "&:hello" {
|
|
49
|
-
output_text "key: '#{hello}' path: '#{path}'"
|
|
50
|
-
}
|
|
51
|
-
get "query" "options" {
|
|
52
|
-
output_text "query_string_options: '#{query_string_options}' path: '#{path}'"
|
|
53
|
-
}
|
|
54
|
-
"""
|
|
55
|
-
|
|
56
|
-
@request-matching @string
|
|
57
|
-
Scenario: Matching URI segment with strings
|
|
58
|
-
When I do GET request http://localhost:3000/string/hello/world
|
|
59
|
-
Then response status will be 200
|
|
60
|
-
And response content type will be text/plain
|
|
61
|
-
And response body will be CRLF ended lines
|
|
62
|
-
"""
|
|
63
|
-
path: 'hello/world'
|
|
64
|
-
"""
|
|
65
|
-
|
|
66
|
-
@request-matching @capture-any
|
|
67
|
-
Scenario: Capturing any URI segment
|
|
68
|
-
When I do GET request http://localhost:3000/any/foo/bar/hello/world
|
|
69
|
-
Then response status will be 200
|
|
70
|
-
And response content type will be text/plain
|
|
71
|
-
And response body will be CRLF ended lines
|
|
72
|
-
"""
|
|
73
|
-
test1: 'foo' test2: 'bar' path: 'hello/world'
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
@request-matching @capture-any-default
|
|
77
|
-
Scenario: Capturing any URI segment with default value
|
|
78
|
-
When I do GET request http://localhost:3000/any/default/foo/bar
|
|
79
|
-
Then response status will be 200
|
|
80
|
-
And response content type will be text/plain
|
|
81
|
-
And response body will be CRLF ended lines
|
|
82
|
-
"""
|
|
83
|
-
test1: 'foo' test2: 'bar' test3: 'bar' test4: 'baz' path: ''
|
|
84
|
-
"""
|
|
85
|
-
|
|
86
|
-
@request-matching @capture-regexp
|
|
87
|
-
Scenario: Capturing URI segment with regexp match
|
|
88
|
-
When I do GET request http://localhost:3000/regexp1/abc/foobar/hello/world
|
|
89
|
-
Then response status will be 200
|
|
90
|
-
And response content type will be text/plain
|
|
91
|
-
And response body will be CRLF ended lines
|
|
92
|
-
"""
|
|
93
|
-
test1: 'abc' test2: 'foobar/hello/world' path: ''
|
|
94
|
-
"""
|
|
95
|
-
When I do GET request http://localhost:3000/regexp2/abc/foobar/hello/world
|
|
96
|
-
Then response status will be 404
|
|
97
|
-
|
|
98
|
-
@request-matching @capture-named-regexp
|
|
99
|
-
Scenario: Capturing URI segment with named regexp match
|
|
100
|
-
When I do GET request http://localhost:3000/regexp/named/ab-12/hello/world
|
|
101
|
-
Then response status will be 200
|
|
102
|
-
And response content type will be text/plain
|
|
103
|
-
And response body will be CRLF ended lines
|
|
104
|
-
"""
|
|
105
|
-
test1: 'ab' test2: '12' test3: 'hello/world' path: ''
|
|
106
|
-
"""
|
|
107
|
-
When I do GET request http://localhost:3000/regexp/named/nocapture/ab-12/hello/world
|
|
108
|
-
Then response status will be 200
|
|
109
|
-
And response content type will be text/plain
|
|
110
|
-
And response body will be CRLF ended lines
|
|
111
|
-
"""
|
|
112
|
-
path: 'hello/world'
|
|
113
|
-
"""
|
|
114
|
-
When I do GET request http://localhost:3000/regexp/named/ab-12
|
|
115
|
-
Then response status will be 404
|
|
116
|
-
When I do GET request http://localhost:3000/regexp/named/ab-123/hello/world
|
|
117
|
-
Then response status will be 404
|
|
118
|
-
When I do GET request http://localhost:3000/regexp/named/bad1/ab-12/hello/world
|
|
119
|
-
Then response status will be 500
|
|
120
|
-
When I do GET request http://localhost:3000/regexp/named/bad2/ab-12/hello/world
|
|
121
|
-
Then response status will be 500
|
|
122
|
-
And response body will be CRLF ended lines
|
|
123
|
-
"""
|
|
124
|
-
matched more arguments than named (3 for 2)
|
|
125
|
-
"""
|
|
126
|
-
|
|
127
|
-
@request-matching @query-key-value
|
|
128
|
-
Scenario: Capturing URI by presence of given key-value query string pair
|
|
129
|
-
When I do GET request http://localhost:3000/query/key-value/hello/world?hello=world
|
|
130
|
-
Then response status will be 200
|
|
131
|
-
And response content type will be text/plain
|
|
132
|
-
And response body will be CRLF ended lines
|
|
133
|
-
"""
|
|
134
|
-
query key-value matched path: 'hello/world'
|
|
135
|
-
"""
|
|
136
|
-
When I do GET request http://localhost:3000/query/key-value/hello/world?foo=bar&hello=world&bar=baz
|
|
137
|
-
Then response status will be 200
|
|
138
|
-
And response content type will be text/plain
|
|
139
|
-
And response body will be CRLF ended lines
|
|
140
|
-
"""
|
|
141
|
-
query key-value matched path: 'hello/world'
|
|
142
|
-
"""
|
|
143
|
-
When I do GET request http://localhost:3000/query/key-value/hello/world
|
|
144
|
-
Then response status will be 404
|
|
145
|
-
When I do GET request http://localhost:3000/query/key-value/hello/world?hello=Xorld
|
|
146
|
-
Then response status will be 404
|
|
147
|
-
When I do GET request http://localhost:3000/query/key-value/hello/world?heXlo=world
|
|
148
|
-
Then response status will be 404
|
|
149
|
-
|
|
150
|
-
@request-matching @query-key
|
|
151
|
-
Scenario: Capturing URI by query string key presence
|
|
152
|
-
When I do GET request http://localhost:3000/query/key/hello/world?hello=world
|
|
153
|
-
Then response status will be 200
|
|
154
|
-
And response content type will be text/plain
|
|
155
|
-
And response body will be CRLF ended lines
|
|
156
|
-
"""
|
|
157
|
-
key: 'world' path: 'hello/world'
|
|
158
|
-
"""
|
|
159
|
-
When I do GET request http://localhost:3000/query/key/hello/world?foo=bar&hello=foobar&bar=baz
|
|
160
|
-
Then response status will be 200
|
|
161
|
-
And response content type will be text/plain
|
|
162
|
-
And response body will be CRLF ended lines
|
|
163
|
-
"""
|
|
164
|
-
key: 'foobar' path: 'hello/world'
|
|
165
|
-
"""
|
|
166
|
-
When I do GET request http://localhost:3000/query/key/hello/world
|
|
167
|
-
Then response status will be 404
|
|
168
|
-
When I do GET request http://localhost:3000/query/key/hello/world?heXlo=world
|
|
169
|
-
Then response status will be 404
|
|
170
|
-
|
|
171
|
-
@request-matching @query-key-default
|
|
172
|
-
Scenario: Capturing URI by query string key presence
|
|
173
|
-
When I do GET request http://localhost:3000/query/key/default/hello/world?hello=world
|
|
174
|
-
Then response status will be 200
|
|
175
|
-
And response content type will be text/plain
|
|
176
|
-
And response body will be CRLF ended lines
|
|
177
|
-
"""
|
|
178
|
-
key: 'world' path: 'hello/world'
|
|
179
|
-
"""
|
|
180
|
-
When I do GET request http://localhost:3000/query/key/default/hello/world?foo=bar&hello=foobar&bar=baz
|
|
181
|
-
Then response status will be 200
|
|
182
|
-
And response content type will be text/plain
|
|
183
|
-
And response body will be CRLF ended lines
|
|
184
|
-
"""
|
|
185
|
-
key: 'foobar' path: 'hello/world'
|
|
186
|
-
"""
|
|
187
|
-
When I do GET request http://localhost:3000/query/key/default/hello/world
|
|
188
|
-
Then response status will be 200
|
|
189
|
-
And response content type will be text/plain
|
|
190
|
-
And response body will be CRLF ended lines
|
|
191
|
-
"""
|
|
192
|
-
key: 'abc' path: 'hello/world'
|
|
193
|
-
"""
|
|
194
|
-
When I do GET request http://localhost:3000/query/key/default/hello/world?heXlo=world
|
|
195
|
-
Then response status will be 200
|
|
196
|
-
And response content type will be text/plain
|
|
197
|
-
And response body will be CRLF ended lines
|
|
198
|
-
"""
|
|
199
|
-
key: 'abc' path: 'hello/world'
|
|
200
|
-
"""
|
|
201
|
-
|
|
202
|
-
@request-matching @query-string-options
|
|
203
|
-
Scenario: URI query string key-value pairs should always be available as query_string_options variable
|
|
204
|
-
When I do GET request http://localhost:3000/query/options/hello/world?foo=hello&bar=world
|
|
205
|
-
Then response status will be 200
|
|
206
|
-
And response content type will be text/plain
|
|
207
|
-
And response body will be CRLF ended lines
|
|
208
|
-
"""
|
|
209
|
-
query_string_options: 'bar:world,foo:hello' path: 'hello/world'
|
|
210
|
-
"""
|
|
211
|
-
|