httpimagestore 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,10 @@
1
1
  require_relative 'spec_helper'
2
2
  require 'aws-sdk'
3
3
  require 'httpimagestore/configuration'
4
- require 'httpimagestore/configuration/output'
5
- Configuration::Scope.logger = Logger.new('/dev/null')
4
+ MemoryLimit.logger = Configuration::Scope.logger = RootLogger.new('/dev/null')
6
5
 
6
+ require 'httpimagestore/configuration/output'
7
7
  require 'httpimagestore/configuration/s3'
8
- MemoryLimit.logger = Logger.new('/dev/null')
9
8
 
10
9
  unless ENV['AWS_ACCESS_KEY_ID'] and ENV['AWS_SECRET_ACCESS_KEY'] and ENV['AWS_S3_TEST_BUCKET']
11
10
  puts "AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY or AWS_S3_TEST_BUCKET environment variables not set - Skipping S3 specs"
@@ -131,10 +130,10 @@ else
131
130
  subject.handlers[0].sources[0].realize(state)
132
131
 
133
132
  state.images['original'].source_path.should == "test.jpg"
134
- state.images['original'].source_url.should start_with "https://"
135
- state.images['original'].source_url.should include ENV['AWS_S3_TEST_BUCKET']
136
- state.images['original'].source_url.should include "/test.jpg"
137
- state.images['original'].source_url.should include ENV['AWS_ACCESS_KEY_ID']
133
+ state.images['original'].source_url.to_s.should start_with "https://"
134
+ state.images['original'].source_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
135
+ state.images['original'].source_url.to_s.should include "/test.jpg"
136
+ state.images['original'].source_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
138
137
  status(state.images['original'].source_url).should == 200
139
138
  end
140
139
 
@@ -152,10 +151,10 @@ else
152
151
  it 'should still provide valid HTTPS URL incliding prefix' do
153
152
  subject.handlers[0].sources[0].realize(state)
154
153
 
155
- state.images['original'].source_url.should start_with "https://"
156
- state.images['original'].source_url.should include ENV['AWS_S3_TEST_BUCKET']
157
- state.images['original'].source_url.should include "/test_prefix/test.jpg"
158
- state.images['original'].source_url.should include ENV['AWS_ACCESS_KEY_ID']
154
+ state.images['original'].source_url.to_s.should start_with "https://"
155
+ state.images['original'].source_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
156
+ state.images['original'].source_url.to_s.should include "/test_prefix/test.jpg"
157
+ state.images['original'].source_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
159
158
  status(state.images['original'].source_url).should == 200
160
159
  end
161
160
 
@@ -219,7 +218,8 @@ else
219
218
  it 'should keep private source URL' do
220
219
  subject.handlers[0].sources[0].realize(state)
221
220
 
222
- state.images['original'].source_url.should == 'https://s3-eu-west-1.amazonaws.com/test/ghost.jpg?' + ENV['AWS_ACCESS_KEY_ID']
221
+ state.images['original'].source_url.should be_a URI::HTTPS
222
+ state.images['original'].source_url.to_s.should == 'https://s3-eu-west-1.amazonaws.com/test/ghost.jpg?' + ENV['AWS_ACCESS_KEY_ID']
223
223
  end
224
224
 
225
225
  it 'should keep public source URL' do
@@ -232,7 +232,8 @@ else
232
232
  EOF
233
233
  subject.handlers[0].sources[0].realize(state)
234
234
 
235
- state.images['original'].source_url.should == 'https://s3-eu-west-1.amazonaws.com/test/ghost.jpg'
235
+ state.images['original'].source_url.should be_a URI::HTTPS
236
+ state.images['original'].source_url.to_s.should == 'https://s3-eu-west-1.amazonaws.com/test/ghost.jpg'
236
237
  end
237
238
 
238
239
  describe 'read-through' do
@@ -417,10 +418,10 @@ else
417
418
 
418
419
  it 'should provide source HTTP url' do
419
420
  subject.handlers[0].sources[0].realize(state)
420
- state.images['original'].source_url.should start_with "http://"
421
- state.images['original'].source_url.should include ENV['AWS_S3_TEST_BUCKET']
422
- state.images['original'].source_url.should include "/test.jpg"
423
- state.images['original'].source_url.should include ENV['AWS_ACCESS_KEY_ID']
421
+ state.images['original'].source_url.to_s.should start_with "http://"
422
+ state.images['original'].source_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
423
+ state.images['original'].source_url.to_s.should include "/test.jpg"
424
+ state.images['original'].source_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
424
425
  status(state.images['original'].source_url).should == 200
425
426
  end
426
427
  end
@@ -627,10 +628,10 @@ else
627
628
  subject.handlers[0].stores[0].realize(state)
628
629
 
629
630
  state.images['input'].store_path.should == "test_out.jpg"
630
- state.images['input'].store_url.should start_with "https://"
631
- state.images['input'].store_url.should include ENV['AWS_S3_TEST_BUCKET']
632
- state.images['input'].store_url.should include "/test_out.jpg"
633
- state.images['input'].store_url.should include ENV['AWS_ACCESS_KEY_ID']
631
+ state.images['input'].store_url.to_s.should start_with "https://"
632
+ state.images['input'].store_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
633
+ state.images['input'].store_url.to_s.should include "/test_out.jpg"
634
+ state.images['input'].store_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
634
635
  status(state.images['input'].store_url).should == 200
635
636
  end
636
637
 
@@ -648,10 +649,10 @@ else
648
649
  it 'should still provide valid HTTPS URL incliding prefix' do
649
650
  subject.handlers[0].stores[0].realize(state)
650
651
 
651
- state.images['input'].store_url.should start_with "https://"
652
- state.images['input'].store_url.should include ENV['AWS_S3_TEST_BUCKET']
653
- state.images['input'].store_url.should include "test_prefix/test_out.jpg"
654
- state.images['input'].store_url.should include ENV['AWS_ACCESS_KEY_ID']
652
+ state.images['input'].store_url.to_s.should start_with "https://"
653
+ state.images['input'].store_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
654
+ state.images['input'].store_url.to_s.should include "test_prefix/test_out.jpg"
655
+ state.images['input'].store_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
655
656
  status(state.images['input'].store_url).should == 200
656
657
  end
657
658
 
@@ -683,10 +684,10 @@ else
683
684
  it 'should provide source HTTP url' do
684
685
  subject.handlers[0].stores[0].realize(state)
685
686
 
686
- state.images['input'].store_url.should start_with "http://"
687
- state.images['input'].store_url.should include ENV['AWS_S3_TEST_BUCKET']
688
- state.images['input'].store_url.should include "/test_out.jpg"
689
- state.images['input'].store_url.should include ENV['AWS_ACCESS_KEY_ID']
687
+ state.images['input'].store_url.to_s.should start_with "http://"
688
+ state.images['input'].store_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
689
+ state.images['input'].store_url.to_s.should include "/test_out.jpg"
690
+ state.images['input'].store_url.to_s.should include ENV['AWS_ACCESS_KEY_ID']
690
691
  status(state.images['input'].store_url).should == 200
691
692
  end
692
693
  end
@@ -694,7 +695,7 @@ else
694
695
  describe 'permission control' do
695
696
  it 'should store images that are not accessible by public by default' do
696
697
  subject.handlers[0].stores[0].realize(state)
697
- status(state.images['input'].store_url[/^[^\?]*/]).should == 403
698
+ status(state.images['input'].store_url.to_s[/^[^\?]*/]).should == 403
698
699
  end
699
700
 
700
701
  describe 'public' do
@@ -717,10 +718,10 @@ else
717
718
  it 'should provide public source HTTPS url' do
718
719
  subject.handlers[0].stores[0].realize(state)
719
720
 
720
- state.images['input'].store_url.should start_with "https://"
721
- state.images['input'].store_url.should include ENV['AWS_S3_TEST_BUCKET']
722
- state.images['input'].store_url.should include "/test_out.jpg"
723
- state.images['input'].store_url.should_not include ENV['AWS_ACCESS_KEY_ID']
721
+ state.images['input'].store_url.to_s.should start_with "https://"
722
+ state.images['input'].store_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
723
+ state.images['input'].store_url.to_s.should include "/test_out.jpg"
724
+ state.images['input'].store_url.to_s.should_not include ENV['AWS_ACCESS_KEY_ID']
724
725
  status(state.images['input'].store_url).should == 200
725
726
  end
726
727
 
@@ -738,10 +739,10 @@ else
738
739
  it 'should provide public source HTTP url' do
739
740
  subject.handlers[0].stores[0].realize(state)
740
741
 
741
- state.images['input'].store_url.should start_with "http://"
742
- state.images['input'].store_url.should include ENV['AWS_S3_TEST_BUCKET']
743
- state.images['input'].store_url.should include "/test_out.jpg"
744
- state.images['input'].store_url.should_not include ENV['AWS_ACCESS_KEY_ID']
742
+ state.images['input'].store_url.to_s.should start_with "http://"
743
+ state.images['input'].store_url.to_s.should include ENV['AWS_S3_TEST_BUCKET']
744
+ state.images['input'].store_url.to_s.should include "/test_out.jpg"
745
+ state.images['input'].store_url.to_s.should_not include ENV['AWS_ACCESS_KEY_ID']
745
746
  status(state.images['input'].store_url).should == 200
746
747
  end
747
748
  end
@@ -1,6 +1,6 @@
1
1
  require_relative 'spec_helper'
2
2
  require 'httpimagestore/configuration'
3
- Configuration::Scope.logger = Logger.new('/dev/null')
3
+ MemoryLimit.logger = Configuration::Scope.logger = RootLogger.new('/dev/null')
4
4
 
5
5
  require 'httpimagestore/configuration/source_failover'
6
6
  require 'httpimagestore/configuration/file'
@@ -1,7 +1,6 @@
1
1
  require_relative 'spec_helper'
2
2
  require 'httpimagestore/configuration'
3
-
4
- Configuration::Scope.logger = Logger.new('/dev/null')
3
+ MemoryLimit.logger = Configuration::Scope.logger = RootLogger.new('/dev/null')
5
4
 
6
5
  require 'pathname'
7
6
  Pathname.glob('lib/httpimagestore/configuration/*.rb').each do |conf|
@@ -1,10 +1,9 @@
1
1
  require_relative 'spec_helper'
2
2
  require 'httpimagestore/configuration'
3
3
  require 'httpimagestore/configuration/output'
4
- Configuration::Scope.logger = Logger.new('/dev/null')
4
+ MemoryLimit.logger = Configuration::Scope.logger = RootLogger.new('/dev/null')
5
5
 
6
6
  require 'httpimagestore/configuration/thumbnailer'
7
- MemoryLimit.logger = Logger.new('/dev/null')
8
7
 
9
8
  describe Configuration do
10
9
  describe 'thumbnailer' do
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
- require 'httpclient'
4
+ require 'faraday'
5
5
  require 'daemon'
6
6
 
7
7
  # Requires supporting files with custom matchers and macros, etc,
@@ -9,30 +9,38 @@ require 'daemon'
9
9
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
10
 
11
11
  RSpec.configure do |config|
12
-
12
+
13
13
  end
14
14
 
15
15
  def support_dir
16
16
  Pathname.new('spec/support')
17
17
  end
18
18
 
19
+ def http_client
20
+ @faraday ||= Faraday.new
21
+ end
22
+
23
+ def request(method, uri, body, headers)
24
+ http_client.run_request(method.downcase.to_sym, uri.replace_s3_variables, body, headers || {})
25
+ end
26
+
19
27
  def get(url)
20
- HTTPClient.new.get_content(url)
28
+ http_client.get(url).body
21
29
  end
22
30
 
23
31
  def status(url)
24
- HTTPClient.new.get(url).status
32
+ http_client.get(url).status
25
33
  end
26
34
 
27
35
  def headers(url)
28
- HTTPClient.new.get(url).headers
36
+ http_client.get(url).headers
29
37
  end
30
38
 
31
39
  @@running_cmd = {}
32
40
  def start_server(cmd, pid_file, log_file, test_url)
33
41
  if @@running_cmd[pid_file]
34
42
  return if @@running_cmd[pid_file] == cmd
35
- stop_server(pid_file)
43
+ stop_server(pid_file)
36
44
  end
37
45
 
38
46
  fork do
@@ -52,7 +60,7 @@ def start_server(cmd, pid_file, log_file, test_url)
52
60
  Timeout.timeout(10) do
53
61
  begin
54
62
  get test_url
55
- rescue Errno::ECONNREFUSED
63
+ rescue Faraday::Error::ConnectionFailed
56
64
  sleep 0.1
57
65
  retry
58
66
  end
@@ -0,0 +1 @@
1
+ zażółć gęślą jaźń
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpimagestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-28 00:00:00.000000000 Z
12
+ date: 2014-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: unicorn-cuba-base
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 1.2.0
21
+ version: 1.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: 1.2.0
29
+ version: 1.2.2
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: httpthumbnailer-client
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -108,13 +108,13 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0.5'
110
110
  - !ruby/object:Gem::Dependency
111
- name: httpclient
111
+ name: faraday
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ! '>='
116
116
  - !ruby/object:Gem::Version
117
- version: '2.3'
117
+ version: '0.8'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -122,7 +122,7 @@ dependencies:
122
122
  requirements:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
- version: '2.3'
125
+ version: '0.8'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: rspec
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -257,10 +257,12 @@ files:
257
257
  - features/cache-control.feature
258
258
  - features/compatibility.feature
259
259
  - features/data-uri.feature
260
+ - features/encoding.feature
260
261
  - features/error-reporting.feature
261
262
  - features/flexi.feature
262
263
  - features/health-check.feature
263
264
  - features/request-matching.feature
265
+ - features/rewrite.feature
264
266
  - features/s3-store-and-thumbnail.feature
265
267
  - features/source-failover.feature
266
268
  - features/step_definitions/httpimagestore_steps.rb
@@ -305,6 +307,7 @@ files:
305
307
  - spec/support/compute.jpg
306
308
  - spec/support/cuba_response_env.rb
307
309
  - spec/support/full.cfg
310
+ - spec/support/utf_string.txt
308
311
  homepage: http://github.com/jpastuszek/httpimagestore
309
312
  licenses:
310
313
  - MIT
@@ -320,7 +323,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
320
323
  version: '0'
321
324
  segments:
322
325
  - 0
323
- hash: 3070670501834592299
326
+ hash: -4420249284992726613
324
327
  required_rubygems_version: !ruby/object:Gem::Requirement
325
328
  none: false
326
329
  requirements: