fog-brightbox 1.7.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/fog/brightbox/models/storage/directory.rb +2 -1
- data/lib/fog/brightbox/models/storage/files.rb +3 -3
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/storage/escape_spec.rb +62 -0
- data/spec/fog/brightbox/storage/files_spec.rb +88 -0
- data/spec/fog/brightbox/storage_spec.rb +34 -0
- metadata +7 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92ebad94e1526398b760b8a104898cdb2600d3a624e6f77af9b9a2bf24011279
|
4
|
+
data.tar.gz: 913cf9025ebd5dda7b47b4c2511da1b3f03eea54de7db58a30b1ca15423d592e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d7d77edd59fb85d9d5ae125896a6d9f2f572ea7161a1da1eb4f183567f6fbf9682d18b55e648560cfa1ea179006aaa764b15a0fe11502d727038f2d97571cf2
|
7
|
+
data.tar.gz: 24359f5541ce79e0f658bdd86c039e1b90358e5b1a3defa2b52bc7fd391fbf87f783cdd33f96d4caaffccaa48fefb2b5438f90ff979462cd1b1a8f3c0536150b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
### 1.7.3 / 2022-08-17
|
2
|
+
|
3
|
+
Bug fixes:
|
4
|
+
|
5
|
+
* Fix to deduplicate forward slashes in `Storage::File#public_url` when object keys are prefixed with "/"
|
6
|
+
|
1
7
|
### 1.7.2 / 2022-08-17
|
2
8
|
|
9
|
+
Bug fixes:
|
10
|
+
|
3
11
|
* Fix in `Storage.escape` regexp which failed to handle dashes correctly and broke generated URLs.
|
4
12
|
|
5
13
|
### 1.7.1 / 2022-08-17
|
@@ -32,7 +32,8 @@ module Fog
|
|
32
32
|
|
33
33
|
def public_url
|
34
34
|
requires :key
|
35
|
-
@public_url ||=
|
35
|
+
@public_url ||= ::File.join(service.management_url.to_s,
|
36
|
+
Fog::Brightbox::Storage.escape(key, "/"))
|
36
37
|
end
|
37
38
|
|
38
39
|
def save
|
@@ -63,9 +63,9 @@ module Fog
|
|
63
63
|
|
64
64
|
def get_url(key)
|
65
65
|
requires :directory
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
return unless directory.public_url
|
67
|
+
|
68
|
+
::File.join(directory.public_url, Fog::Brightbox::Storage.escape(key, "/"))
|
69
69
|
end
|
70
70
|
|
71
71
|
def get_http_url(key, expires, options = {})
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "fog/brightbox"
|
3
|
+
|
4
|
+
describe Fog::Brightbox::Storage, ".escape" do
|
5
|
+
describe "when only excluded characters are used" do
|
6
|
+
it "escapes no letters" do
|
7
|
+
str = ("A".."Z").to_a.join
|
8
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
9
|
+
assert_equal str, escaped
|
10
|
+
|
11
|
+
str = ("a".."z").to_a.join
|
12
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
13
|
+
assert_equal str, escaped
|
14
|
+
end
|
15
|
+
|
16
|
+
it "escapes no numbers" do
|
17
|
+
str = ("0".."9").to_a.join
|
18
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
19
|
+
assert_equal str, escaped
|
20
|
+
end
|
21
|
+
|
22
|
+
it "does not escape dashes" do
|
23
|
+
str = "test-pattern123"
|
24
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
25
|
+
assert_equal str, escaped
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does not escape dots" do
|
29
|
+
str = "sample.demo"
|
30
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
31
|
+
assert_equal str, escaped
|
32
|
+
end
|
33
|
+
|
34
|
+
it "does not escape underscores" do
|
35
|
+
str = "file_name"
|
36
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
37
|
+
assert_equal str, escaped
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when escaped characters are included" do
|
42
|
+
it "escapes those forward slashes" do
|
43
|
+
str = "test/pattern/123.txt"
|
44
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
45
|
+
assert_equal "test%2Fpattern%2F123.txt", escaped
|
46
|
+
end
|
47
|
+
|
48
|
+
it "escapes those backslashes" do
|
49
|
+
str = "test\\pattern\\123.txt"
|
50
|
+
escaped = Fog::Brightbox::Storage.escape(str)
|
51
|
+
assert_equal "test%5Cpattern%5C123.txt", escaped
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "when additional characters are excluded" do
|
56
|
+
it "escapes those characters" do
|
57
|
+
str = "test/pattern/123.txt"
|
58
|
+
escaped = Fog::Brightbox::Storage.escape(str, "/")
|
59
|
+
assert_equal "test/pattern/123.txt", escaped
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "fog/brightbox"
|
3
|
+
require "fog/brightbox/models/storage/directory"
|
4
|
+
require "fog/brightbox/models/storage/files"
|
5
|
+
|
6
|
+
describe Fog::Brightbox::Storage::Files do
|
7
|
+
describe "#get_url" do
|
8
|
+
before do
|
9
|
+
@options = {
|
10
|
+
:brightbox_client_id => "cli-12345",
|
11
|
+
:brightbox_secret => "1234567890",
|
12
|
+
:brightbox_storage_management_url => "https://management.url/v1/acc-12345"
|
13
|
+
}
|
14
|
+
@service = Fog::Brightbox::Storage.new(@options)
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "when directory can generate URL" do
|
18
|
+
describe "with object prefixed by forward slash" do
|
19
|
+
it do
|
20
|
+
assert_equal "https://management.url/v1/acc-12345", @service.management_url.to_s
|
21
|
+
|
22
|
+
directory = Fog::Brightbox::Storage::Directory.new(
|
23
|
+
service: @service,
|
24
|
+
key: "container-name"
|
25
|
+
)
|
26
|
+
assert_equal "https://management.url/v1/acc-12345/container-name", directory.public_url
|
27
|
+
|
28
|
+
files = Fog::Brightbox::Storage::Files.new(
|
29
|
+
service: @service,
|
30
|
+
directory: directory
|
31
|
+
)
|
32
|
+
|
33
|
+
expected = "https://management.url/v1/acc-12345/container-name/object"
|
34
|
+
|
35
|
+
assert_equal expected, files.get_url("/object")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "when object is correctly named" do
|
40
|
+
it do
|
41
|
+
assert_equal "https://management.url/v1/acc-12345", @service.management_url.to_s
|
42
|
+
|
43
|
+
directory = Fog::Brightbox::Storage::Directory.new(
|
44
|
+
service: @service,
|
45
|
+
key: "container-name"
|
46
|
+
)
|
47
|
+
assert_equal "https://management.url/v1/acc-12345/container-name", directory.public_url
|
48
|
+
|
49
|
+
files = Fog::Brightbox::Storage::Files.new(
|
50
|
+
service: @service,
|
51
|
+
directory: directory
|
52
|
+
)
|
53
|
+
|
54
|
+
expected = "https://management.url/v1/acc-12345/container-name/object"
|
55
|
+
|
56
|
+
assert_equal expected, files.get_url("object")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "when no management URL" do
|
62
|
+
before do
|
63
|
+
@options = {
|
64
|
+
:brightbox_client_id => "cli-12345",
|
65
|
+
:brightbox_secret => "1234567890"
|
66
|
+
}
|
67
|
+
@service = Fog::Brightbox::Storage.new(@options)
|
68
|
+
end
|
69
|
+
|
70
|
+
it do
|
71
|
+
assert_equal "", @service.management_url.to_s
|
72
|
+
|
73
|
+
directory = Fog::Brightbox::Storage::Directory.new(
|
74
|
+
service: @service,
|
75
|
+
key: "container-name"
|
76
|
+
)
|
77
|
+
assert_equal "/container-name", directory.public_url
|
78
|
+
|
79
|
+
files = Fog::Brightbox::Storage::Files.new(
|
80
|
+
service: @service,
|
81
|
+
directory: directory
|
82
|
+
)
|
83
|
+
|
84
|
+
assert_equal "/container-name/object", files.get_url("/object")
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "fog/brightbox"
|
3
|
+
|
4
|
+
describe Fog::Brightbox::Storage do
|
5
|
+
describe "when passed in configuration" do
|
6
|
+
before do
|
7
|
+
@options = {
|
8
|
+
:brightbox_client_id => "cli-12345",
|
9
|
+
:brightbox_secret => "1234567890",
|
10
|
+
:brightbox_storage_management_url => "https://management.url/v1/acc-12345"
|
11
|
+
}
|
12
|
+
@service = Fog::Brightbox::Storage.new(@options)
|
13
|
+
end
|
14
|
+
|
15
|
+
it "returns a URI matching config option" do
|
16
|
+
assert_kind_of URI, @service.management_url
|
17
|
+
assert_equal "https://management.url/v1/acc-12345", @service.management_url.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "when unavailable" do
|
22
|
+
before do
|
23
|
+
@options = {
|
24
|
+
:brightbox_client_id => "cli-12345",
|
25
|
+
:brightbox_secret => "1234567890"
|
26
|
+
}
|
27
|
+
@service = Fog::Brightbox::Storage.new(@options)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "returns nil" do
|
31
|
+
assert_nil @service.management_url
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-brightbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Thornthwaite
|
@@ -403,6 +403,9 @@ files:
|
|
403
403
|
- spec/fog/brightbox/storage/config_spec.rb
|
404
404
|
- spec/fog/brightbox/storage/connection_errors_spec.rb
|
405
405
|
- spec/fog/brightbox/storage/connection_spec.rb
|
406
|
+
- spec/fog/brightbox/storage/escape_spec.rb
|
407
|
+
- spec/fog/brightbox/storage/files_spec.rb
|
408
|
+
- spec/fog/brightbox/storage_spec.rb
|
406
409
|
- spec/fog/compute/brightbox/account_spec.rb
|
407
410
|
- spec/fog/compute/brightbox/api_client_spec.rb
|
408
411
|
- spec/fog/compute/brightbox/application_spec.rb
|
@@ -513,6 +516,9 @@ test_files:
|
|
513
516
|
- spec/fog/brightbox/storage/config_spec.rb
|
514
517
|
- spec/fog/brightbox/storage/connection_errors_spec.rb
|
515
518
|
- spec/fog/brightbox/storage/connection_spec.rb
|
519
|
+
- spec/fog/brightbox/storage/escape_spec.rb
|
520
|
+
- spec/fog/brightbox/storage/files_spec.rb
|
521
|
+
- spec/fog/brightbox/storage_spec.rb
|
516
522
|
- spec/fog/compute/brightbox/account_spec.rb
|
517
523
|
- spec/fog/compute/brightbox/api_client_spec.rb
|
518
524
|
- spec/fog/compute/brightbox/application_spec.rb
|