fog-brightbox 0.7.0 → 0.7.1
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +32 -34
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/storage/brightbox_spec.rb +53 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ceab58130b1687c75932bd53be5455950a3f7f8
|
4
|
+
data.tar.gz: 851bb3bed538588fbbdc0ee9827afcf8ac02e2eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 374a94033bb49c034ba1db1f8f62ed899243e3e28d6b79975806b403e573d4b9757278e96d2354e11ae476dcd43ed51f7f38d26feabc5e367af10296ac11a544
|
7
|
+
data.tar.gz: 4a80fc6844ce04cd65d4f5e3d9274d4f0f7b6d4add941560ce3451f01ddcfa9ccd5c7d7f4436b07328ea73b5a0b0fcd5397345b9fb2f288f490b9d770e3b2d13
|
data/CHANGELOG.md
CHANGED
@@ -18,25 +18,23 @@ module Fog
|
|
18
18
|
|
19
19
|
# creates a temporary url
|
20
20
|
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
21
|
+
# @param container [String] Name of container containing object
|
22
|
+
# @param object [String] Name of object to get expiring url for
|
23
|
+
# @param expires_at [Time] An expiry time for this url
|
24
|
+
# @param method [String] The method to use for accessing the object (GET, PUT, HEAD)
|
25
|
+
# @param options [Hash] An optional options hash
|
26
|
+
# @option options [String] :scheme The scheme to use (http, https)
|
27
|
+
# @option options [String] :port A non standard port to use
|
28
28
|
#
|
29
|
-
#
|
30
|
-
# * response<~Excon::Response>:
|
31
|
-
# * body<~String> - url for object
|
29
|
+
# @return [String] url for object
|
32
30
|
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
31
|
+
# @raise [ArgumentError] if +storage_temp_key+ is not set in configuration
|
32
|
+
# @raise [ArgumentError] if +method+ is not valid
|
33
|
+
#
|
34
|
+
# @see http://docs.rackspace.com/files/api/v1/cf-devguide/content/Create_TempURL-d1a444.html
|
35
|
+
#
|
36
|
+
def create_temp_url(container, object, expires_at, method, options = {})
|
37
|
+
raise ArgumentError, "Storage must be instantiated with the :brightbox_temp_url_key option" if @config.storage_temp_key.nil?
|
40
38
|
|
41
39
|
# POST not allowed
|
42
40
|
allowed_methods = %w(GET PUT HEAD)
|
@@ -44,25 +42,25 @@ module Fog
|
|
44
42
|
raise ArgumentError.new("Invalid method '#{method}' specified. Valid methods are: #{allowed_methods.join(", ")}")
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
# This assumes we have access to the management URL at this point
|
46
|
+
destination_url = management_url.dup
|
47
|
+
object_path = destination_url.path
|
48
|
+
|
49
|
+
destination_url.scheme = options[:scheme] if options[:scheme]
|
50
|
+
destination_url.port = options[:port] if options[:port]
|
51
|
+
|
52
|
+
object_path_escaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object, "/")}"
|
53
|
+
object_path_unescaped = "#{object_path}/#{Fog::Storage::Brightbox.escape(container)}/#{object}"
|
54
|
+
|
55
|
+
expiry_timestamp = expires_at.to_i
|
56
|
+
string_to_sign = [method, expiry_timestamp, object_path_unescaped].join("\n")
|
51
57
|
|
52
|
-
hmac = Fog::HMAC.new("sha1", @
|
53
|
-
sig
|
58
|
+
hmac = Fog::HMAC.new("sha1", @config.storage_temp_key)
|
59
|
+
sig = sig_to_hex(hmac.sign(string_to_sign))
|
54
60
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
:port => @port,
|
59
|
-
:path => object_path_escaped,
|
60
|
-
:query => URI.encode_www_form(
|
61
|
-
:temp_url_sig => sig,
|
62
|
-
:temp_url_expires => expires
|
63
|
-
)
|
64
|
-
}
|
65
|
-
URI::Generic.build(temp_url_options).to_s
|
61
|
+
destination_url.path = object_path_escaped
|
62
|
+
destination_url.query = URI.encode_www_form(:temp_url_sig => sig, :temp_url_expires => expiry_timestamp)
|
63
|
+
destination_url.to_s
|
66
64
|
end
|
67
65
|
|
68
66
|
private
|
@@ -266,4 +266,57 @@ describe Fog::Storage::Brightbox do
|
|
266
266
|
pass
|
267
267
|
end
|
268
268
|
end
|
269
|
+
|
270
|
+
describe "when not initialised with temporary URL key" do
|
271
|
+
let(:settings) do
|
272
|
+
{
|
273
|
+
:brightbox_client_id => "cli-12345",
|
274
|
+
:brightbox_secret => "12345"
|
275
|
+
}
|
276
|
+
end
|
277
|
+
|
278
|
+
it "returns nil" do
|
279
|
+
assert_nil config.storage_temp_key
|
280
|
+
end
|
281
|
+
|
282
|
+
it "fails to generate temporary URLs" do
|
283
|
+
assert_raises(ArgumentError) { service.create_temp_url("container", "object", Time.now, "GET") }
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "when initialised with temporary URL key" do
|
288
|
+
before { skip unless RUBY_VERSION > "1.9.3" }
|
289
|
+
let(:temp_url_key) { "1234567890" }
|
290
|
+
let(:settings) do
|
291
|
+
{
|
292
|
+
:brightbox_client_id => "cli-12345",
|
293
|
+
:brightbox_secret => "12345",
|
294
|
+
:brightbox_storage_management_url => "https://example.brightbox.com",
|
295
|
+
:brightbox_temp_url_key => temp_url_key
|
296
|
+
}
|
297
|
+
end
|
298
|
+
let(:container) { "container" }
|
299
|
+
let(:object) { "file.ext" }
|
300
|
+
let(:expiry_time) { Time.utc(2012) }
|
301
|
+
let(:request_method) { "GET" }
|
302
|
+
|
303
|
+
it "returns the key" do
|
304
|
+
assert_equal temp_url_key, config.storage_temp_key
|
305
|
+
end
|
306
|
+
|
307
|
+
it "can generate temporary HTTPS URLs" do
|
308
|
+
assert_equal "https://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
309
|
+
service.create_temp_url(container, object, expiry_time, request_method, :scheme => "https")
|
310
|
+
end
|
311
|
+
|
312
|
+
it "can generate temporary HTTP URLs" do
|
313
|
+
assert_equal "http://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
314
|
+
service.create_temp_url(container, object, expiry_time, request_method, :scheme => "http")
|
315
|
+
end
|
316
|
+
|
317
|
+
it "can generate temporary HTTP URLs on non standard ports" do
|
318
|
+
assert_equal "http://example.brightbox.com:401/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
319
|
+
service.create_temp_url(container, object, expiry_time, request_method, :scheme => "http", :port => 401)
|
320
|
+
end
|
321
|
+
end
|
269
322
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-brightbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Thornthwaite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|