ruby-thumbor 1.1.1 → 1.1.2
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.
- data/lib/ruby-thumbor.rb +2 -0
- data/lib/thumbor/crypto_url.rb +5 -2
- data/lib/thumbor/version.rb +1 -1
- data/spec/thumbor/cascade_spec.rb +24 -5
- metadata +2 -2
data/lib/ruby-thumbor.rb
CHANGED
data/lib/thumbor/crypto_url.rb
CHANGED
@@ -9,7 +9,10 @@ module Thumbor
|
|
9
9
|
|
10
10
|
def initialize(key)
|
11
11
|
Thumbor.key = key
|
12
|
-
|
12
|
+
end
|
13
|
+
|
14
|
+
def computed_key
|
15
|
+
(Thumbor.key * 16)[0..15]
|
13
16
|
end
|
14
17
|
|
15
18
|
def pad(s)
|
@@ -121,7 +124,7 @@ module Thumbor
|
|
121
124
|
def generate_old(options)
|
122
125
|
url = pad(url_for(options))
|
123
126
|
cipher = OpenSSL::Cipher::Cipher.new('aes-128-ecb').encrypt
|
124
|
-
cipher.key =
|
127
|
+
cipher.key = computed_key
|
125
128
|
encrypted = cipher.update(url)
|
126
129
|
based = url_safe_base64(encrypted)
|
127
130
|
|
data/lib/thumbor/version.rb
CHANGED
@@ -8,13 +8,17 @@ describe Thumbor::Cascade do
|
|
8
8
|
let(:image_md5) { 'f33af67e41168e80fcc5b00f8bd8061a' }
|
9
9
|
let(:key) { 'my-security-key' }
|
10
10
|
|
11
|
-
before do
|
12
|
-
Thumbor.key = key
|
13
|
-
end
|
14
|
-
|
15
11
|
subject { Thumbor::Cascade.new image_url }
|
16
12
|
|
13
|
+
after(:each) do
|
14
|
+
Thumbor.key = nil
|
15
|
+
end
|
16
|
+
|
17
17
|
describe '#new' do
|
18
|
+
before do
|
19
|
+
Thumbor.key = key
|
20
|
+
end
|
21
|
+
|
18
22
|
it "should create a new instance passing key and keep it" do
|
19
23
|
subject.computed_key.should == 'my-security-keym'
|
20
24
|
end
|
@@ -36,7 +40,7 @@ describe Thumbor::Cascade do
|
|
36
40
|
end
|
37
41
|
|
38
42
|
it "should return proper url for width-only" do
|
39
|
-
url = subject.width(300).url_for
|
43
|
+
url = subject.width(300).url_for
|
40
44
|
url.should == '300x0/' << image_md5
|
41
45
|
end
|
42
46
|
|
@@ -172,12 +176,23 @@ describe Thumbor::Cascade do
|
|
172
176
|
end
|
173
177
|
|
174
178
|
describe '#generate' do
|
179
|
+
before do
|
180
|
+
Thumbor.key = key
|
181
|
+
end
|
175
182
|
|
176
183
|
it "should create a new instance passing key and keep it" do
|
177
184
|
url = subject.width(300).height(200).generate
|
178
185
|
url.should == '/TQfyd3H36Z3srcNcLOYiM05YNO8=/300x200/my.domain.com/some/image/url.jpg'
|
179
186
|
end
|
180
187
|
|
188
|
+
it "should be able to change the Thumbor key" do
|
189
|
+
thumbor = subject.width(300).height(200)
|
190
|
+
url1 = thumbor.generate
|
191
|
+
Thumbor.key = 'another-thumbor-key'
|
192
|
+
url2 = thumbor.generate
|
193
|
+
url1.should_not == url2
|
194
|
+
end
|
195
|
+
|
181
196
|
it "should create a new instance passing key and keep it" do
|
182
197
|
url = subject.width(300).height(200).meta(true).generate
|
183
198
|
url.should == '/YBQEWd3g_WRMnVEG73zfzcr8Zj0=/meta/300x200/my.domain.com/some/image/url.jpg'
|
@@ -210,6 +225,10 @@ describe Thumbor::Cascade do
|
|
210
225
|
end
|
211
226
|
|
212
227
|
describe "#generate :old => true" do
|
228
|
+
before do
|
229
|
+
Thumbor.key = key
|
230
|
+
end
|
231
|
+
|
213
232
|
subject { Thumbor::Cascade.new(image_url).old(true) }
|
214
233
|
|
215
234
|
it "should create a new instance passing key and keep it" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-thumbor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
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:
|
12
|
+
date: 2013-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|