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.
Files changed (64) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +7 -7
  3. data/Gemfile.lock +20 -20
  4. data/README.md +165 -37
  5. data/Rakefile +7 -2
  6. data/VERSION +1 -1
  7. data/bin/httpimagestore +74 -41
  8. data/lib/httpimagestore/configuration/file.rb +20 -11
  9. data/lib/httpimagestore/configuration/handler.rb +96 -257
  10. data/lib/httpimagestore/configuration/handler/source_store_base.rb +37 -0
  11. data/lib/httpimagestore/configuration/handler/statement.rb +114 -0
  12. data/lib/httpimagestore/configuration/identify.rb +17 -9
  13. data/lib/httpimagestore/configuration/output.rb +33 -61
  14. data/lib/httpimagestore/configuration/path.rb +2 -2
  15. data/lib/httpimagestore/configuration/request_state.rb +131 -0
  16. data/lib/httpimagestore/configuration/s3.rb +41 -29
  17. data/lib/httpimagestore/configuration/thumbnailer.rb +189 -96
  18. data/lib/httpimagestore/configuration/validate_hmac.rb +170 -0
  19. data/lib/httpimagestore/error_reporter.rb +6 -1
  20. data/lib/httpimagestore/ruby_string_template.rb +10 -19
  21. metadata +40 -102
  22. data/.rspec +0 -1
  23. data/features/cache-control.feature +0 -41
  24. data/features/compatibility.feature +0 -165
  25. data/features/data-uri.feature +0 -55
  26. data/features/encoding.feature +0 -103
  27. data/features/error-reporting.feature +0 -281
  28. data/features/flexi.feature +0 -259
  29. data/features/health-check.feature +0 -29
  30. data/features/request-matching.feature +0 -211
  31. data/features/rewrite.feature +0 -122
  32. data/features/s3-store-and-thumbnail.feature +0 -82
  33. data/features/source-failover.feature +0 -71
  34. data/features/step_definitions/httpimagestore_steps.rb +0 -203
  35. data/features/storage.feature +0 -198
  36. data/features/support/env.rb +0 -116
  37. data/features/support/test-large.jpg +0 -0
  38. data/features/support/test.empty +0 -0
  39. data/features/support/test.jpg +0 -0
  40. data/features/support/test.png +0 -0
  41. data/features/support/test.txt +0 -1
  42. data/features/support/tiny.png +0 -0
  43. data/features/xid-forwarding.feature +0 -49
  44. data/httpimagestore.gemspec +0 -145
  45. data/load_test/load_test.1k.23a022f6e.m1.small-comp.csv +0 -3
  46. data/load_test/load_test.1k.ec9bde794.m1.small.csv +0 -4
  47. data/load_test/load_test.jmx +0 -317
  48. data/load_test/thumbnail_specs.csv +0 -11
  49. data/load_test/thumbnail_specs_v2.csv +0 -10
  50. data/spec/configuration_file_spec.rb +0 -333
  51. data/spec/configuration_handler_spec.rb +0 -255
  52. data/spec/configuration_identify_spec.rb +0 -67
  53. data/spec/configuration_output_spec.rb +0 -821
  54. data/spec/configuration_path_spec.rb +0 -138
  55. data/spec/configuration_s3_spec.rb +0 -911
  56. data/spec/configuration_source_failover_spec.rb +0 -101
  57. data/spec/configuration_spec.rb +0 -90
  58. data/spec/configuration_thumbnailer_spec.rb +0 -483
  59. data/spec/ruby_string_template_spec.rb +0 -61
  60. data/spec/spec_helper.rb +0 -89
  61. data/spec/support/compute.jpg +0 -0
  62. data/spec/support/cuba_response_env.rb +0 -40
  63. data/spec/support/full.cfg +0 -183
  64. data/spec/support/utf_string.txt +0 -1
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
@@ -1,41 +0,0 @@
1
- Feature: S3 object Cache-Control header settings
2
- S3 objects can have Cache-Control header set during storage.
3
-
4
- Background:
5
- Given S3 settings in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_TEST_BUCKET environment variables
6
- Given httpthumbnailer server is running at http://localhost:3100/health_check
7
- Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
8
- """
9
- s3 key="@AWS_ACCESS_KEY_ID@" secret="@AWS_SECRET_ACCESS_KEY@" ssl=false
10
-
11
- path "hash" "#{input_digest}.#{image_mime_extension}"
12
- path "hash-name" "#{input_digest}-#{image_name}.#{image_mime_extension}"
13
-
14
- put "thumbnail" {
15
- thumbnail "input" {
16
- "no-cache" operation="crop" width=128 height=128 format="jpeg"
17
- "cache" operation="crop" width=256 height=256 format="jpeg"
18
- }
19
-
20
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" public=true path="hash"
21
- store_s3 "no-cache" bucket="@AWS_S3_TEST_BUCKET@" public=true path="hash-name"
22
- store_s3 "cache" bucket="@AWS_S3_TEST_BUCKET@" public=true path="hash-name" cache-control="public, max-age=31557600, s-maxage=0"
23
- }
24
- """
25
-
26
- @cache-control
27
- Scenario: Image files get don't get Cache-Control header by default
28
- Given there is no 4006450256177f4a.jpg file in S3 bucket
29
- And there is no 4006450256177f4a-no-cache.jpg file in S3 bucket
30
- And there is no 4006450256177f4a-cache.jpg file in S3 bucket
31
- Given test.jpg file content as request body
32
- When I do PUT request http://localhost:3000/thumbnail
33
- Then response status will be 200
34
- And response content type will be text/plain
35
- And response body will be CRLF ended lines
36
- """
37
- OK
38
- """
39
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a.jpg Cache-Control header will not be set
40
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a-no-cache.jpg Cache-Control header will not be set
41
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a-cache.jpg Cache-Control header will be public, max-age=31557600, s-maxage=0
@@ -1,165 +0,0 @@
1
- Feature: Image list based thumbnailing and S3 storage
2
- Storage based on URL specified image names to be generated and stored using two different path formats.
3
- This configuration should be mostly compatible with pre v1.0 release.
4
-
5
- Background:
6
- Given S3 settings in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_TEST_BUCKET environment variables
7
- Given httpthumbnailer server is running at http://localhost:3100/health_check
8
- Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
9
- """
10
- s3 key="@AWS_ACCESS_KEY_ID@" secret="@AWS_SECRET_ACCESS_KEY@" ssl=false
11
-
12
- path "hash" "#{input_digest}.#{image_mime_extension}"
13
- path "hash-name" "#{input_digest}/#{image_name}.#{image_mime_extension}"
14
- path "structured" "#{dirname}/#{input_digest}/#{basename}.#{image_mime_extension}"
15
- path "structured-name" "#{dirname}/#{input_digest}/#{basename}-#{image_name}.#{image_mime_extension}"
16
- path "flexi-original" "#{hash}.jpg"
17
-
18
- put "thumbnail" ":name_list" ":path/.+/" {
19
- thumbnail "input" {
20
- "small" operation="crop" width=128 height=128 format="jpeg" if-image-name-on="#{name_list}"
21
- "tiny_png" operation="crop" width=32 height=32 format="png" if-image-name-on="#{name_list}"
22
- "bad" operation="crop" width=0 height=0 if-image-name-on="#{name_list}"
23
- }
24
-
25
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="structured" public=true
26
- store_s3 "small" bucket="@AWS_S3_TEST_BUCKET@" path="structured-name" public=true if-image-name-on="#{name_list}"
27
- store_s3 "tiny_png" bucket="@AWS_S3_TEST_BUCKET@" path="structured-name" public=true if-image-name-on="#{name_list}"
28
-
29
- output_store_url {
30
- "input"
31
- "small" if-image-name-on="#{name_list}"
32
- "tiny_png" if-image-name-on="#{name_list}"
33
- }
34
- }
35
-
36
- put "thumbnail" ":name_list" {
37
- thumbnail "input" {
38
- "small" operation="crop" width=128 height=128 format="jpeg" if-image-name-on="#{name_list}"
39
- "tiny_png" operation="crop" width=32 height=32 format="png" if-image-name-on="#{name_list}"
40
- }
41
-
42
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="hash" public=true
43
- store_s3 "small" bucket="@AWS_S3_TEST_BUCKET@" path="hash-name" public=true if-image-name-on="#{name_list}"
44
- store_s3 "tiny_png" bucket="@AWS_S3_TEST_BUCKET@" path="hash-name" public=true if-image-name-on="#{name_list}"
45
-
46
- output_store_url {
47
- "input"
48
- "small" if-image-name-on="#{name_list}"
49
- "tiny_png" if-image-name-on="#{name_list}"
50
- "bad" if-image-name-on="#{name_list}"
51
- }
52
- }
53
-
54
- # Forward compatible getting of thumbnails
55
- get "thumbnail" ":hash/[0-f]{16}/" ":type/.*-square.jpg/" {
56
- source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="flexi-original"
57
- thumbnail "original" "thumbnail" operation="crop" width="50" height="50"
58
- output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
59
- }
60
-
61
- get "thumbnail" ":hash/[0-f]{16}/" ":type/.*-normal.jpg/" {
62
- source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="flexi-original"
63
- thumbnail "original" "thumbnail" operation="fit" width="100" height="2000"
64
- output_image "thumbnail" cache-control="public, max-age=31557600, s-maxage=0"
65
- }
66
- """
67
-
68
- @compatibility
69
- Scenario: Putting original and its thumbnails to S3 bucket
70
- Given there is no 4006450256177f4a.jpg file in S3 bucket
71
- And there is no 4006450256177f4a/small.jpg file in S3 bucket
72
- And there is no 4006450256177f4a/tiny_png.png file in S3 bucket
73
- Given test.jpg file content as request body
74
- When I do PUT request http://localhost:3000/thumbnail/small,tiny_png
75
- Then response status will be 200
76
- And response content type will be text/uri-list
77
- And response body will be CRLF ended lines
78
- """
79
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a.jpg
80
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/small.jpg
81
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/tiny_png.png
82
- """
83
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a.jpg will contain JPEG image of size 509x719
84
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a.jpg content type will be image/jpeg
85
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/small.jpg will contain JPEG image of size 128x128
86
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/small.jpg content type will be image/jpeg
87
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/tiny_png.png will contain PNG image of size 32x32
88
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/4006450256177f4a/tiny_png.png content type will be image/png
89
-
90
- @compatibility
91
- Scenario: Putting original and its thumbnails to S3 bucket under custom path
92
- Given there is no test/image/4006450256177f4a/test.jpg file in S3 bucket
93
- And there is no test/image/4006450256177f4a/test-small.jpg file in S3 bucket
94
- And there is no test/image/4006450256177f4a/test-tiny_png.png file in S3 bucket
95
- Given test.jpg file content as request body
96
- When I do PUT request http://localhost:3000/thumbnail/small,tiny_png/test/image/test
97
- Then response status will be 200
98
- And response content type will be text/uri-list
99
- And response body will be CRLF ended lines
100
- """
101
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test.jpg
102
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-small.jpg
103
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-tiny_png.png
104
- """
105
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test.jpg will contain JPEG image of size 509x719
106
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test.jpg content type will be image/jpeg
107
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-small.jpg will contain JPEG image of size 128x128
108
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-small.jpg content type will be image/jpeg
109
- Then http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-tiny_png.png will contain PNG image of size 32x32
110
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-tiny_png.png content type will be image/png
111
-
112
- @compatibility
113
- Scenario: Input file extension should be based on content detected mime type and not on provided path
114
- Given there is no test/image/4006450256177f4a/test.jpg file in S3 bucket
115
- And there is no test/image/4006450256177f4a/test-tiny_png.jpg file in S3 bucket
116
- Given test.jpg file content as request body
117
- When I do PUT request http://localhost:3000/thumbnail/tiny_png/test/image/test.gif
118
- Then response status will be 200
119
- And response content type will be text/uri-list
120
- And response body will be CRLF ended lines
121
- """
122
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test.jpg
123
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-tiny_png.png
124
- """
125
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test.jpg content type will be image/jpeg
126
- And http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/image/4006450256177f4a/test-tiny_png.png content type will be image/png
127
-
128
- @compatibility
129
- Scenario: Custom path name encoding when UTF-8 characters can be used
130
- Given there is no test/图像/4006450256177f4a/测试.jpg file in S3 bucket
131
- And there is no test/图像/4006450256177f4a/测试-small.jpg file in S3 bucket
132
- Given test.jpg file content as request body
133
- When I do PUT request with encoded URL http://localhost:3000/thumbnail/small/test/图像/测试
134
- Then response status will be 200
135
- And response content type will be text/uri-list
136
- And response body will be CRLF ended lines
137
- """
138
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/%E5%9B%BE%E5%83%8F/4006450256177f4a/%E6%B5%8B%E8%AF%95.jpg
139
- http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/%E5%9B%BE%E5%83%8F/4006450256177f4a/%E6%B5%8B%E8%AF%95-small.jpg
140
- """
141
- And Encoded URL http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/图像/4006450256177f4a/测试.jpg will contain JPEG image of size 509x719
142
- And Encoded URL http://@AWS_S3_TEST_BUCKET@.s3.amazonaws.com/test/图像/4006450256177f4a/测试-small.jpg will contain JPEG image of size 128x128
143
-
144
- @compatibility @forward @test
145
- Scenario: Getting thumbanils requested with compatibility API from flexi bucket
146
- Given test.jpg file content is stored in S3 under 1234567890123456.jpg
147
- When I do GET request http://localhost:3000/thumbnail/1234567890123456/foobar-blah-square.jpg
148
- Then response status will be 200
149
- And response content type will be image/jpeg
150
- Then response body will contain JPEG image of size 50x50
151
- When I do GET request http://localhost:3000/thumbnail/1234567890123456/foobar-blah-normal.jpg
152
- Then response status will be 200
153
- And response content type will be image/jpeg
154
- Then response body will contain JPEG image of size 100x141
155
-
156
- @compatibility
157
- Scenario: Input file extension should be based on content detected mime type and not on provided path
158
- Given test.jpg file content as request body
159
- When I do PUT request http://localhost:3000/thumbnail/blah/test/image/test.gif
160
- Then response status will be 400
161
- And response content type will be text/plain
162
- And response body will be CRLF ended lines
163
- """
164
- no thumbnailing specs were selected, please use at least one of: small, tiny_png, bad
165
- """
@@ -1,55 +0,0 @@
1
- Feature: Data URI style image output
2
- HTTP Image Store can provide images base64 encoded in data URI format so they can be included directly in HTML pages.
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/ with the following configuration
7
- """
8
- post "data-uri" "no-identify" {
9
- output_data_uri_image "input"
10
- }
11
-
12
- post "data-uri" "cache-control" {
13
- identify "input"
14
- output_data_uri_image "input" cache-control="public, max-age=31557600, s-maxage=0"
15
- }
16
-
17
- post "data-uri" {
18
- identify "input"
19
- output_data_uri_image "input"
20
- }
21
- """
22
-
23
- @data-uri
24
- Scenario: Getting image encoded in data URI scheme with base64 encoding
25
- Given tiny.png file content as request body
26
- When I do POST request http://localhost:3000/data-uri
27
- Then response status will be 200
28
- And response content type will be text/uri-list
29
- And response body will be
30
- """
31
- data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAgUlEQVQI10XNsQ2CUBhF4XOTfwJeog0U2kLJNlZOxQ4swBLGwkhhY6MNRkic4Fq8ENqTLznqhuvlOY2v5f6egaYs6iq1x30YAENdJskgEBAYUFMlYSMw2CYk2sMOkTFgI6Fp/mEpt7Ua69Sf2TRgLESMt8dW5bwE4vtZvOK8xkj8Ac8BL8dFQipPAAAAAElFTkSuQmCC
32
- """
33
-
34
- @data-uri
35
- Scenario: Getting image encoded in data URI scheme with base64 encoding - cache-control should be supported
36
- Given tiny.png file content as request body
37
- When I do POST request http://localhost:3000/data-uri/cache-control
38
- Then response status will be 200
39
- And response content type will be text/uri-list
40
- And response Cache-Control will be public, max-age=31557600, s-maxage=0
41
- And response body will be
42
- """
43
- data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAIAAABLbSncAAAAgUlEQVQI10XNsQ2CUBhF4XOTfwJeog0U2kLJNlZOxQ4swBLGwkhhY6MNRkic4Fq8ENqTLznqhuvlOY2v5f6egaYs6iq1x30YAENdJskgEBAYUFMlYSMw2CYk2sMOkTFgI6Fp/mEpt7Ua69Sf2TRgLESMt8dW5bwE4vtZvOK8xkj8Ac8BL8dFQipPAAAAAElFTkSuQmCC
44
- """
45
-
46
- @data-uri
47
- Scenario: Error 500 served when data URI output is used on unidentified image
48
- Given tiny.png file content as request body
49
- When I do POST request http://localhost:3000/data-uri/no-identify
50
- Then response status will be 500
51
- And response content type will be text/plain
52
- And response body will be CRLF ended lines
53
- """
54
- image 'input' needs to be identified first to be used in data URI output
55
- """
@@ -1,103 +0,0 @@
1
- Feature: Encoded UTF-8 URI support
2
- HTTP Image Store should be able to decode UTF-8 characters form URI using URI decode and also support JavaScript encode() format.
3
-
4
- Background:
5
- Given S3 settings in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_TEST_BUCKET environment variables
6
- Given httpthumbnailer server is running at http://localhost:3100/health_check
7
- Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
8
- """
9
- s3 key="@AWS_ACCESS_KEY_ID@" secret="@AWS_SECRET_ACCESS_KEY@" ssl=false
10
- path "path" "#{path}"
11
-
12
- post "file" "encoding" "encoded" {
13
- store_file "input" root="/tmp" path="path"
14
- output_store_uri "input" path="path"
15
- }
16
-
17
- post "file" "encoding" "decoded" {
18
- store_file "input" root="/tmp" path="path"
19
- output_store_path "input" path="path"
20
- }
21
-
22
- post "s3" "encoding" "encoded" {
23
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="path"
24
- output_store_uri "input" path="path"
25
- }
26
-
27
- post "s3" "encoding" "decoded" {
28
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="path"
29
- output_store_path "input" path="path"
30
- }
31
- """
32
-
33
- Scenario: JavaScript encode() + URL encoded variable decoding and URL encoding for file based storage
34
- Given test.png file content as request body
35
- When I do POST request http://localhost:3000/file/encoding/encoded/triple%20kro%25u0301l.png
36
- And response content type will be text/uri-list
37
- And response body will be CRLF ended lines
38
- """
39
- /triple%20kr%C3%B3l.png
40
- """
41
-
42
- Scenario: JavaScript encode() + URL encoded variable decoding and URL encoding for S3 based storage
43
- Given test.png file content as request body
44
- When I do POST request http://localhost:3000/s3/encoding/encoded/triple%20kro%25u0301l.png
45
- And response content type will be text/uri-list
46
- And response body will be CRLF ended lines
47
- """
48
- /triple%20kr%C3%B3l.png
49
- """
50
-
51
- Scenario: URL encoded variable decoding and URL encoding with ? for file based storage
52
- Given test.png file content as request body
53
- When I do POST request http://localhost:3000/file/encoding/encoded/hello%3Fworld.png
54
- And response content type will be text/uri-list
55
- And response body will be CRLF ended lines
56
- """
57
- /hello%3Fworld.png
58
- """
59
-
60
- Scenario: URL encoded variable decoding and URL encoding with ? for S3 based storage
61
- Given test.png file content as request body
62
- When I do POST request http://localhost:3000/s3/encoding/encoded/hello%3Fworld.png
63
- And response content type will be text/uri-list
64
- And response body will be CRLF ended lines
65
- """
66
- /hello%3Fworld.png
67
- """
68
-
69
- Scenario: URL encoded variable decoding for file based storage
70
- Given test.png file content as request body
71
- When I do POST request http://localhost:3000/file/encoding/decoded/triple%20kr%C3%B3l.png
72
- And response content type will be text/plain
73
- And response body will be CRLF ended lines
74
- """
75
- triple król.png
76
- """
77
-
78
- Scenario: URL encoded variable decoding for S3 based storage
79
- Given test.png file content as request body
80
- When I do POST request http://localhost:3000/s3/encoding/decoded/triple%20kr%C3%B3l.png
81
- And response content type will be text/plain
82
- And response body will be CRLF ended lines
83
- """
84
- triple król.png
85
- """
86
-
87
- Scenario: URL path normalization with ? for file based storage
88
- Given test.png file content as request body
89
- When I do POST request http://localhost:3000/file/encoding/decoded/hello%3Fworld.png
90
- And response content type will be text/plain
91
- And response body will be CRLF ended lines
92
- """
93
- hello?world.png
94
- """
95
-
96
- Scenario: URL path normalization with ? S3 file based storage
97
- Given test.png file content as request body
98
- When I do POST request http://localhost:3000/s3/encoding/decoded/hello%3Fworld.png
99
- And response content type will be text/plain
100
- And response body will be CRLF ended lines
101
- """
102
- hello?world.png
103
- """
@@ -1,281 +0,0 @@
1
- Feature: Error handling
2
- API should provide different status codes with text/plain description body for different error modes.
3
-
4
- Background:
5
- Given S3 settings in AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_S3_TEST_BUCKET environment variables
6
- Given httpthumbnailer server is running at http://localhost:3100/health_check
7
- Given httpimagestore server is running at http://localhost:3000/health_check with the following configuration
8
- """
9
- s3 key="@AWS_ACCESS_KEY_ID@" secret="@AWS_SECRET_ACCESS_KEY@" ssl=false
10
-
11
- path "uri_part" "/thumbnails/#{input_digest}/#{name}.#{image_mime_extension}"
12
- path "structured-name" "#{dirname}/#{input_digest}/#{basename}-#{image_name}.#{image_mime_extension}"
13
- path "missing" "blah"
14
- path "zero" "zero"
15
- path "hash" "#{input_digest}"
16
-
17
- put "multipart" ":name_list" {
18
- thumbnail "input" {
19
- "small" operation="crop" width=128 height=128 if-image-name-on="#{name_list}"
20
- "bad" operation="crop" width=0 height=0 if-image-name-on="#{name_list}"
21
- "bad_dim" operation="crop" width="128x" height=128 if-image-name-on="#{name_list}"
22
- "superlarge" operation="crop" width=16000 height=16000 if-image-name-on="#{name_list}"
23
- "large_png" operation="crop" width=7000 height=7000 format="png" if-image-name-on="#{name_list}"
24
- "bad_opts" operation="crop" width=128 height=128 options="foo=bar" if-image-name-on="#{name_list}"
25
- }
26
- }
27
-
28
- put "singlepart" ":name_list" {
29
- thumbnail "input" "small" operation="crop" width=128 height=128 if-image-name-on="#{name_list}"
30
- thumbnail "input" "bad" operation="crop" width=0 height=0 if-image-name-on="#{name_list}"
31
- thumbnail "input" "bad_dim" operation="crop" width="128x" height=128 if-image-name-on="#{name_list}"
32
- thumbnail "input" "superlarge" operation="crop" width=16000 height=16000 if-image-name-on="#{name_list}"
33
- thumbnail "input" "large_png" operation="crop" width=7000 height=7000 format="png" if-image-name-on="#{name_list}"
34
- thumbnail "input" "bad_opts" operation="crop" width=128 height=128 options="foo=bar" if-image-name-on="#{name_list}"
35
- }
36
-
37
- post "filename" "/(?<name>.+?)(\\.[^\\.]+)?$/" {
38
- identify "input"
39
- store_s3 "input" bucket="@AWS_S3_TEST_BUCKET@" path="hash" cache-root="/tmp"
40
- output_store_path "input" path="uri_part"
41
- }
42
-
43
- get "s3" {
44
- source_s3 "original" bucket="@AWS_S3_TEST_BUCKET@" path="missing"
45
- }
46
-
47
- get "file" {
48
- source_file "original" root="/tmp" path="missing"
49
- }
50
-
51
- get "zero" {
52
- source_file "original" root="/dev" path="zero"
53
- }
54
-
55
- path "not_defined" "#{bogous}"
56
- get "not_defined" {
57
- source_file "original" root="/tmp" path="not_defined"
58
- }
59
-
60
- path "body" "#{input_digest}"
61
- get "body" {
62
- source_file "original" root="/tmp" path="body"
63
- }
64
-
65
- path "no_image_meta" "#{image_mime_extension}"
66
- put "no_image_meta" {
67
- store_file "input" root="/tmp" path="no_image_meta"
68
- }
69
- """
70
-
71
- @error-reporting
72
- Scenario: Reporting of missing resource
73
- When I do GET request http://localhost:3000/blah
74
- Then response status will be 404
75
- And response content type will be text/plain
76
- And response body will be CRLF ended lines
77
- """
78
- request for URI '/blah' was not handled by the server
79
- """
80
-
81
- @error-reporting
82
- Scenario: Reporting of missing S3 resource
83
- When I do GET request http://localhost:3000/s3
84
- Then response status will be 404
85
- And response content type will be text/plain
86
- And response body will be CRLF ended lines
87
- """
88
- S3 bucket 'httpimagestoretest' does not contain key 'blah'
89
- """
90
-
91
- @error-reporting
92
- Scenario: Reporting of missing file resource
93
- When I do GET request http://localhost:3000/file
94
- Then response status will be 404
95
- And response content type will be text/plain
96
- And response body will be CRLF ended lines
97
- """
98
- error while processing image 'original': file 'blah' not found
99
- """
100
-
101
- @error-reporting
102
- Scenario: Reporting of unsupported media type
103
- Given test.txt file content as request body
104
- When I do PUT request http://localhost:3000/multipart/small,tiny
105
- Then response status will be 415
106
- And response content type will be text/plain
107
- And response body will be CRLF ended lines like
108
- """
109
- thumbnailing of 'input' failed: unsupported media type: no decode delegate for this image format
110
- """
111
- When I do PUT request http://localhost:3000/singlepart/small,tiny
112
- Then response status will be 415
113
- And response content type will be text/plain
114
- And response body will be CRLF ended lines like
115
- """
116
- thumbnailing of 'input' into 'small' failed: unsupported media type: no decode delegate for this image format
117
- """
118
-
119
- @error-reporting
120
- Scenario: Reporting and handling of thumbnailing errors
121
- Given test.jpg file content as request body
122
- When I do PUT request http://localhost:3000/multipart/small,bad
123
- Then response status will be 400
124
- And response content type will be text/plain
125
- And response body will be CRLF ended lines like
126
- """
127
- thumbnailing of 'input' into 'bad' failed: at least one image dimension is zero: 0x0
128
- """
129
- When I do PUT request http://localhost:3000/singlepart/small,bad
130
- Then response status will be 400
131
- And response content type will be text/plain
132
- And response body will be CRLF ended lines like
133
- """
134
- thumbnailing of 'input' into 'bad' failed: at least one image dimension is zero: 0x0
135
- """
136
-
137
- @error-reporting
138
- Scenario: Reporting and handling of thumbnailing errors - bad options format
139
- Given test.jpg file content as request body
140
- When I do PUT request http://localhost:3000/multipart/small,bad_opts
141
- Then response status will be 400
142
- And response content type will be text/plain
143
- And response body will be CRLF ended lines
144
- """
145
- thumbnailing of 'input' into 'bad_opts' failed: missing option value for key 'foo=bar'
146
- """
147
- When I do PUT request http://localhost:3000/singlepart/small,bad_opts
148
- Then response status will be 400
149
- And response content type will be text/plain
150
- And response body will be CRLF ended lines
151
- """
152
- thumbnailing of 'input' into 'bad_opts' failed: missing option value for key 'foo=bar'
153
- """
154
-
155
- @error-reporting @test
156
- Scenario: Bad dimension
157
- Given test.jpg file content as request body
158
- When I do PUT request http://localhost:3000/multipart/bad_dim
159
- Then response status will be 400
160
- And response content type will be text/plain
161
- And response body will be CRLF ended lines like
162
- """
163
- thumbnailing of 'input' into 'bad_dim' failed: bad dimension value: 128x
164
- """
165
- When I do PUT request http://localhost:3000/singlepart/bad_dim
166
- Then response status will be 400
167
- And response content type will be text/plain
168
- And response body will be CRLF ended lines like
169
- """
170
- thumbnailing of 'input' into 'bad_dim' failed: bad dimension value: 128x
171
- """
172
-
173
- @error-reporting @413 @load
174
- Scenario: Too large image - uploaded image too big to fit in memory limit
175
- Given test-large.jpg file content as request body
176
- When I do PUT request http://localhost:3000/multipart/large_png
177
- Then response status will be 413
178
- And response content type will be text/plain
179
- And response body will be CRLF ended lines like
180
- """
181
- thumbnailing of 'input' failed: image too large: cache resources exhausted
182
- """
183
- When I do PUT request http://localhost:3000/singlepart/large_png
184
- Then response status will be 413
185
- And response content type will be text/plain
186
- And response body will be CRLF ended lines like
187
- """
188
- thumbnailing of 'input' into 'large_png' failed: image too large: cache resources exhausted
189
- """
190
-
191
- @error-reporting @413 @thumbnail
192
- Scenario: Too large image - memory exhausted when thmbnailing
193
- Given test.jpg file content as request body
194
- When I do PUT request http://localhost:3000/multipart/superlarge
195
- Then response status will be 413
196
- And response content type will be text/plain
197
- And response body will be CRLF ended lines like
198
- """
199
- thumbnailing of 'input' into 'superlarge' failed: image too large: cache resources exhausted
200
- """
201
- When I do PUT request http://localhost:3000/singlepart/superlarge
202
- Then response status will be 413
203
- And response content type will be text/plain
204
- And response body will be CRLF ended lines like
205
- """
206
- thumbnailing of 'input' into 'superlarge' failed: image too large: cache resources exhausted
207
- """
208
-
209
- @error-reporting
210
- Scenario: Bad URI encoding
211
- Given test.jpg file content as request body
212
- When I do POST request http://localhost:3000/filename/hello%e9world.jpg
213
- Then response status will be 400
214
- And response content type will be text/plain
215
- And response body will be CRLF ended lines like
216
- """
217
- invalid UTF-8 encoding in URI: "hello\\xE9world"
218
- """
219
-
220
- @error-reporting
221
- Scenario: Bad URI encoding + JavaScript encode
222
- Given test.jpg file content as request body
223
- When I do POST request http://localhost:3000/filename/triple%20kro%25udfcfl.png
224
- Then response status will be 400
225
- And response content type will be text/plain
226
- And response body will be CRLF ended lines like
227
- """
228
- invalid UTF-8 encoding in URI: "triple kro\\xED\\xBF\\x8Fl"
229
- """
230
-
231
- @error-reporting
232
- Scenario: Zero body length
233
- Given test.empty file content as request body
234
- When I do PUT request http://localhost:3000/multipart/small
235
- Then response status will be 400
236
- And response content type will be text/plain
237
- And response body will be CRLF ended lines like
238
- """
239
- empty body - expected image data
240
- """
241
-
242
- @error-reporting
243
- Scenario: Memory limit exceeded
244
- When I do GET request http://localhost:3000/zero
245
- Then response status will be 413
246
- And response content type will be text/plain
247
- And response body will be CRLF ended lines like
248
- """
249
- memory limit exceeded
250
- """
251
-
252
- @error-reporting @variables
253
- Scenario: Bad variable use - not defined
254
- When I do GET request http://localhost:3000/not_defined
255
- Then response status will be 500
256
- And response content type will be text/plain
257
- And response body will be CRLF ended lines like
258
- """
259
- cannot generate path 'not_defined' from template '\#{bogous}': variable 'bogous' not defined
260
- """
261
-
262
- @error-reporting @variables
263
- Scenario: Bad variable use - no body
264
- When I do GET request http://localhost:3000/body
265
- Then response status will be 500
266
- And response content type will be text/plain
267
- And response body will be CRLF ended lines like
268
- """
269
- cannot generate path 'body' from template '#{input_digest}': need not empty request body to generate value for 'input_digest'
270
- """
271
-
272
- @error-reporting @variables
273
- Scenario: Bad variable use - no image meta
274
- Given test.jpg file content as request body
275
- When I do PUT request http://localhost:3000/no_image_meta
276
- Then response status will be 500
277
- And response content type will be text/plain
278
- And response body will be CRLF ended lines like
279
- """
280
- cannot generate path 'no_image_meta' from template '#{image_mime_extension}': image 'input' does not have data for variable 'image_mime_extension'
281
- """