fog-brightbox 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rubocop.yml +20 -0
- data/.rubocop_todo.yml +81 -0
- data/CHANGELOG.md +17 -0
- data/README.md +6 -0
- data/fog-brightbox.gemspec +10 -9
- data/gemfiles/Gemfile.1.8.7 +1 -0
- data/lib/fog/brightbox.rb +2 -2
- data/lib/fog/brightbox/compute.rb +47 -48
- data/lib/fog/brightbox/compute/resource_locking.rb +26 -20
- data/lib/fog/brightbox/compute/shared.rb +2 -7
- data/lib/fog/brightbox/config.rb +12 -15
- data/lib/fog/brightbox/core.rb +5 -5
- data/lib/fog/brightbox/link_helper.rb +33 -0
- data/lib/fog/brightbox/models/compute/account.rb +0 -1
- data/lib/fog/brightbox/models/compute/accounts.rb +2 -6
- data/lib/fog/brightbox/models/compute/api_client.rb +2 -2
- data/lib/fog/brightbox/models/compute/application.rb +2 -2
- data/lib/fog/brightbox/models/compute/applications.rb +2 -6
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +0 -4
- data/lib/fog/brightbox/models/compute/cloud_ips.rb +2 -6
- data/lib/fog/brightbox/models/compute/collaboration.rb +4 -4
- data/lib/fog/brightbox/models/compute/database_server.rb +11 -4
- data/lib/fog/brightbox/models/compute/database_servers.rb +2 -6
- data/lib/fog/brightbox/models/compute/database_snapshot.rb +1 -1
- data/lib/fog/brightbox/models/compute/database_snapshots.rb +2 -2
- data/lib/fog/brightbox/models/compute/database_types.rb +2 -4
- data/lib/fog/brightbox/models/compute/event.rb +0 -2
- data/lib/fog/brightbox/models/compute/events.rb +2 -4
- data/lib/fog/brightbox/models/compute/firewall_policies.rb +2 -6
- data/lib/fog/brightbox/models/compute/firewall_policy.rb +2 -3
- data/lib/fog/brightbox/models/compute/firewall_rule.rb +2 -3
- data/lib/fog/brightbox/models/compute/firewall_rules.rb +2 -6
- data/lib/fog/brightbox/models/compute/flavor.rb +0 -1
- data/lib/fog/brightbox/models/compute/flavors.rb +2 -6
- data/lib/fog/brightbox/models/compute/image.rb +3 -3
- data/lib/fog/brightbox/models/compute/images.rb +2 -6
- data/lib/fog/brightbox/models/compute/load_balancer.rb +5 -5
- data/lib/fog/brightbox/models/compute/load_balancers.rb +2 -6
- data/lib/fog/brightbox/models/compute/server.rb +15 -9
- data/lib/fog/brightbox/models/compute/server_group.rb +1 -1
- data/lib/fog/brightbox/models/compute/server_groups.rb +2 -6
- data/lib/fog/brightbox/models/compute/servers.rb +2 -6
- data/lib/fog/brightbox/models/compute/user.rb +0 -1
- data/lib/fog/brightbox/models/compute/user_collaboration.rb +2 -3
- data/lib/fog/brightbox/models/compute/users.rb +2 -5
- data/lib/fog/brightbox/models/compute/zones.rb +2 -6
- data/lib/fog/brightbox/models/storage/directories.rb +6 -13
- data/lib/fog/brightbox/models/storage/directory.rb +5 -7
- data/lib/fog/brightbox/models/storage/file.rb +37 -45
- data/lib/fog/brightbox/models/storage/files.rb +21 -25
- data/lib/fog/brightbox/oauth2.rb +136 -137
- data/lib/fog/brightbox/requests/compute/accept_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/activate_console_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_listeners_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_nodes_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/add_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/apply_to_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/create_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_authenticated_user.rb +0 -2
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_database_type.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_interface.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_user.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/get_zone.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_applications.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_collaborations.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_servers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_snapshots.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_database_types.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_events.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_firewall_policies.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_images.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_load_balancers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_server_groups.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_servers.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_user_collaborations.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_users.rb +0 -1
- data/lib/fog/brightbox/requests/compute/list_zones.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/lock_resource_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/move_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reboot_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reject_user_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_listeners_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_nodes_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/remove_servers_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/resend_collaboration.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +0 -2
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_password_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_secret_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_secret_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/reset_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +19 -3
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +19 -3
- data/lib/fog/brightbox/requests/compute/start_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/stop_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unlock_resource_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_application.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_cloud_ip.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_database_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_database_snapshot.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_firewall_policy.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_firewall_rule.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_image.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_load_balancer.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_scoped_account.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_server.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_server_group.rb +0 -1
- data/lib/fog/brightbox/requests/compute/update_user.rb +0 -1
- data/lib/fog/brightbox/requests/storage/copy_object.rb +8 -10
- data/lib/fog/brightbox/requests/storage/delete_container.rb +1 -3
- data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -9
- data/lib/fog/brightbox/requests/storage/delete_object.rb +1 -3
- data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +7 -9
- data/lib/fog/brightbox/requests/storage/get_container.rb +3 -5
- data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -6
- data/lib/fog/brightbox/requests/storage/get_object.rb +1 -3
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +5 -10
- data/lib/fog/brightbox/requests/storage/head_container.rb +2 -4
- data/lib/fog/brightbox/requests/storage/head_containers.rb +3 -5
- data/lib/fog/brightbox/requests/storage/head_object.rb +4 -6
- data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +2 -6
- data/lib/fog/brightbox/requests/storage/put_container.rb +3 -5
- data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +2 -4
- data/lib/fog/brightbox/requests/storage/put_object.rb +1 -2
- data/lib/fog/brightbox/requests/storage/put_object_manifest.rb +0 -2
- data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +2 -4
- data/lib/fog/brightbox/storage.rb +26 -29
- data/lib/fog/brightbox/storage/connection.rb +10 -10
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/link_helper_spec.rb +18 -0
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +16 -16
- data/spec/fog/brightbox/storage/connection_spec.rb +12 -12
- data/spec/fog/compute/brightbox/database_server_spec.rb +31 -0
- data/spec/fog/compute/brightbox/server_spec.rb +31 -0
- data/spec/fog/storage/brightbox_spec.rb +3 -3
- data/spec/spec_helper.rb +1 -1
- metadata +28 -10
- data/spec/model_helper.rb +0 -22
@@ -2,7 +2,6 @@ module Fog
|
|
2
2
|
module Storage
|
3
3
|
class Brightbox
|
4
4
|
class Real
|
5
|
-
|
6
5
|
# Create a new dynamic large object manifest
|
7
6
|
#
|
8
7
|
# Creates an object with a +X-Object-Manifest+ header that specifies the common prefix ("<container>/<prefix>")
|
@@ -28,15 +27,14 @@ module Fog
|
|
28
27
|
# @see http://docs.brightbox.org/api/brightbox-object-storage/1.0/content/dynamic-large-object-creation.html
|
29
28
|
def put_dynamic_obj_manifest(container, object, options = {})
|
30
29
|
path = "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}"
|
31
|
-
headers = {
|
30
|
+
headers = { "X-Object-Manifest" => path }.merge(options)
|
32
31
|
request(
|
33
32
|
:expects => 201,
|
34
33
|
:headers => headers,
|
35
|
-
:method =>
|
34
|
+
:method => "PUT",
|
36
35
|
:path => path
|
37
36
|
)
|
38
37
|
end
|
39
|
-
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
@@ -2,7 +2,6 @@ module Fog
|
|
2
2
|
module Storage
|
3
3
|
class Brightbox
|
4
4
|
class Real
|
5
|
-
|
6
5
|
# Create a new object
|
7
6
|
#
|
8
7
|
# When passed a block, it will make a chunked request, calling
|
@@ -30,7 +29,7 @@ module Fog
|
|
30
29
|
:expects => 201,
|
31
30
|
:idempotent => !params[:request_block],
|
32
31
|
:headers => headers,
|
33
|
-
:method =>
|
32
|
+
:method => "PUT",
|
34
33
|
:path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}"
|
35
34
|
)
|
36
35
|
|
@@ -2,14 +2,12 @@ module Fog
|
|
2
2
|
module Storage
|
3
3
|
class Brightbox
|
4
4
|
class Real
|
5
|
-
|
6
5
|
# Create a new dynamic large object manifest
|
7
6
|
#
|
8
7
|
# This is an alias for {#put_dynamic_obj_manifest} for backward compatibility.
|
9
8
|
def put_object_manifest(container, object, options = {})
|
10
9
|
put_dynamic_obj_manifest(container, object, options)
|
11
10
|
end
|
12
|
-
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
@@ -2,7 +2,6 @@ module Fog
|
|
2
2
|
module Storage
|
3
3
|
class Brightbox
|
4
4
|
class Real
|
5
|
-
|
6
5
|
# Create a new static large object manifest.
|
7
6
|
#
|
8
7
|
# A static large object is similar to a dynamic large object. Whereas a GET for a dynamic large object manifest
|
@@ -43,14 +42,13 @@ module Fog
|
|
43
42
|
def put_static_obj_manifest(container, object, segments, options = {})
|
44
43
|
request(
|
45
44
|
:expects => 201,
|
46
|
-
:method =>
|
45
|
+
:method => "PUT",
|
47
46
|
:headers => options,
|
48
47
|
:body => Fog::JSON.encode(segments),
|
49
48
|
:path => "#{Fog::Storage::Brightbox.escape(container)}/#{Fog::Storage::Brightbox.escape(object)}",
|
50
|
-
:query => {
|
49
|
+
:query => { "multipart-manifest" => "put" }
|
51
50
|
)
|
52
51
|
end
|
53
|
-
|
54
52
|
end
|
55
53
|
end
|
56
54
|
end
|
@@ -7,19 +7,18 @@ require "fog/brightbox/storage/connection"
|
|
7
7
|
module Fog
|
8
8
|
module Storage
|
9
9
|
class Brightbox < Fog::Service
|
10
|
-
|
11
|
-
|
12
|
-
:brightbox_secret
|
10
|
+
requires :brightbox_client_id,
|
11
|
+
:brightbox_secret
|
13
12
|
recognizes :persistent, :brightbox_service_name,
|
14
13
|
:brightbox_storage_url,
|
15
14
|
:brightbox_service_type, :brightbox_tenant,
|
16
15
|
:brightbox_region, :brightbox_temp_url_key
|
17
16
|
|
18
17
|
model_path "fog/brightbox/models/storage"
|
19
|
-
model
|
20
|
-
collection
|
21
|
-
model
|
22
|
-
collection
|
18
|
+
model :directory
|
19
|
+
collection :directories
|
20
|
+
model :file
|
21
|
+
collection :files
|
23
22
|
|
24
23
|
request_path "fog/brightbox/requests/storage"
|
25
24
|
request :copy_object
|
@@ -43,7 +42,7 @@ module Fog
|
|
43
42
|
request :put_static_obj_manifest
|
44
43
|
|
45
44
|
class Mock
|
46
|
-
def initialize(
|
45
|
+
def initialize(_options = {})
|
47
46
|
end
|
48
47
|
end
|
49
48
|
|
@@ -92,25 +91,23 @@ module Fog
|
|
92
91
|
end
|
93
92
|
|
94
93
|
def request(params, parse_json = true)
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
raise error
|
105
|
-
end
|
106
|
-
rescue Excon::Errors::HTTPStatusError => error
|
107
|
-
raise case error
|
108
|
-
when Excon::Errors::NotFound
|
109
|
-
Fog::Storage::Brightbox::NotFound.slurp(error)
|
110
|
-
else
|
111
|
-
error
|
112
|
-
end
|
94
|
+
authenticate if @config.must_authenticate?
|
95
|
+
connection.request(params, parse_json)
|
96
|
+
rescue Fog::Brightbox::Storage::AuthenticationRequired => error
|
97
|
+
if @config.managed_tokens?
|
98
|
+
@config.expire_tokens!
|
99
|
+
authenticate
|
100
|
+
retry
|
101
|
+
else # bad credentials
|
102
|
+
raise error
|
113
103
|
end
|
104
|
+
rescue Excon::Errors::HTTPStatusError => error
|
105
|
+
raise case error
|
106
|
+
when Excon::Errors::NotFound
|
107
|
+
Fog::Storage::Brightbox::NotFound.slurp(error)
|
108
|
+
else
|
109
|
+
error
|
110
|
+
end
|
114
111
|
end
|
115
112
|
|
116
113
|
def authenticate
|
@@ -126,7 +123,7 @@ module Fog
|
|
126
123
|
end
|
127
124
|
end
|
128
125
|
|
129
|
-
# @param [URI]
|
126
|
+
# @param [URI] url A URI object to extract the account from
|
130
127
|
# @return [String] The account
|
131
128
|
def extract_account_from_url(url)
|
132
129
|
url.path.split("/")[2]
|
@@ -156,9 +153,9 @@ module Fog
|
|
156
153
|
end
|
157
154
|
|
158
155
|
# CGI.escape, but without special treatment on spaces
|
159
|
-
def self.escape(str,extra_exclude_chars = "")
|
156
|
+
def self.escape(str, extra_exclude_chars = "")
|
160
157
|
str.gsub(/([^a-zA-Z0-9_.-#{extra_exclude_chars}]+)/) do
|
161
|
-
"%" +
|
158
|
+
"%" + Regexp.last_match[1].unpack("H2" * Regexp.last_match[1].bytesize).join("%").upcase
|
162
159
|
end
|
163
160
|
end
|
164
161
|
end
|
@@ -8,20 +8,20 @@ module Fog
|
|
8
8
|
def initialize(config)
|
9
9
|
@config = config
|
10
10
|
|
11
|
-
|
12
|
-
raise ManagementUrlUnknown
|
13
|
-
else
|
11
|
+
if management_url
|
14
12
|
@connection = super(management_url.to_s, persistent?, connection_options)
|
13
|
+
else
|
14
|
+
raise ManagementUrlUnknown
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
def request(params, parse_json = true)
|
19
19
|
begin
|
20
20
|
raise ArgumentError if params.nil?
|
21
|
-
request_params = params.merge(
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
request_params = params.merge(
|
22
|
+
:headers => request_headers(params),
|
23
|
+
:path => path_in_params(params)
|
24
|
+
)
|
25
25
|
response = @connection.request(request_params)
|
26
26
|
rescue Excon::Errors::Unauthorized => error
|
27
27
|
raise AuthenticationRequired.slurp(error)
|
@@ -58,9 +58,9 @@ module Fog
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def authenticated_headers
|
61
|
-
default_headers.merge(
|
62
|
-
|
63
|
-
|
61
|
+
default_headers.merge(
|
62
|
+
"X-Auth-Token" => @config.latest_access_token
|
63
|
+
)
|
64
64
|
end
|
65
65
|
|
66
66
|
def default_headers
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fog::Brightbox::LinkHelper do
|
4
|
+
describe "when initialized with an RFC5988 value" do
|
5
|
+
before do
|
6
|
+
@header = "<https://www.example.com/1.0/images/img-12345>; rel=snapshot"
|
7
|
+
@helper = Fog::Brightbox::LinkHelper.new(@header)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "can return identifier" do
|
11
|
+
assert_equal "img-12345", @helper.identifier
|
12
|
+
end
|
13
|
+
|
14
|
+
it "can return URI" do
|
15
|
+
assert_kind_of URI, @helper.uri
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -9,10 +9,10 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
9
9
|
before do
|
10
10
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
11
11
|
with(:headers => {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
"Host" => "orbit.brightbox.com:443",
|
13
|
+
"X-Auth-User" => "",
|
14
|
+
"X-Auth-Key" => ""
|
15
|
+
}).to_return(bad_url_response)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "raises error" do
|
@@ -27,10 +27,10 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
27
27
|
before do
|
28
28
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
29
29
|
with(:headers => {
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
"Host" => "orbit.brightbox.com:443",
|
31
|
+
"X-Auth-User" => "cli-12345",
|
32
|
+
"X-Auth-Key" => "12345"
|
33
|
+
}).to_return(authorized_response)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "authenticates correctly" do
|
@@ -48,10 +48,10 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
48
48
|
before do
|
49
49
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
50
50
|
with(:headers => {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
51
|
+
"Host" => "orbit.brightbox.com:443",
|
52
|
+
"X-Auth-User" => "user@example.com",
|
53
|
+
"X-Auth-Key" => "abcde"
|
54
|
+
}).to_return(authorized_response)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "authenticates correctly" do
|
@@ -71,10 +71,10 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
71
71
|
before do
|
72
72
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
73
73
|
with(:headers => {
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
"Host" => "orbit.brightbox.com:443",
|
75
|
+
"X-Auth-User" => "user@example.com",
|
76
|
+
"X-Auth-Key" => "abcde"
|
77
|
+
}).to_return(unauthorized_response)
|
78
78
|
end
|
79
79
|
|
80
80
|
it "raises error" do
|
@@ -44,12 +44,12 @@ describe Fog::Brightbox::Storage::Connection do
|
|
44
44
|
before do
|
45
45
|
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345").
|
46
46
|
with(:headers => {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
"Accept" => "application/json",
|
48
|
+
"Content-Type" => "application/json",
|
49
|
+
"X-Auth-Token" => valid_auth_token
|
50
|
+
}).to_return(:status => 200, :body => "{}", :headers => {
|
51
|
+
"Content-Type" => "application/json"
|
52
|
+
})
|
53
53
|
end
|
54
54
|
|
55
55
|
it "completes successfully" do
|
@@ -64,12 +64,12 @@ describe Fog::Brightbox::Storage::Connection do
|
|
64
64
|
before do
|
65
65
|
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord").
|
66
66
|
with(:headers => {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
67
|
+
"Accept" => "application/json",
|
68
|
+
"Content-Type" => "application/json",
|
69
|
+
"X-Auth-Token" => valid_auth_token
|
70
|
+
}).to_return(:status => 200, :body => "{}", :headers => {
|
71
|
+
"Content-Type" => "application/json"
|
72
|
+
})
|
73
73
|
end
|
74
74
|
|
75
75
|
it "completes successfully" do
|
@@ -18,4 +18,35 @@ describe Fog::Compute::Brightbox::DatabaseServer do
|
|
18
18
|
assert_equal "database_server", subject.resource_name
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
describe "when snapshotting withi no options" do
|
23
|
+
it "returns the database server" do
|
24
|
+
skip if RUBY_VERSION < "1.9"
|
25
|
+
|
26
|
+
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot?account_id=").
|
27
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
28
|
+
to_return(:status => 202, :body => %q({"id": "dbs-12345"}), :headers => {})
|
29
|
+
|
30
|
+
@database_server = Fog::Compute::Brightbox::DatabaseServer.new(:service => service, :id => "dbs-12345")
|
31
|
+
assert @database_server.snapshot
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "when snapshotting with link option" do
|
36
|
+
it "returns the new image" do
|
37
|
+
skip if RUBY_VERSION < "1.9"
|
38
|
+
|
39
|
+
link = "<https://api.gb1.brightbox.com/1.0/database_snapshots/dbi-12345>; rel=snapshot"
|
40
|
+
|
41
|
+
stub_request(:post, "http://localhost/1.0/database_servers/dbs-12345/snapshot").
|
42
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
43
|
+
to_return(:status => 202, :body => "{}", :headers => { "Link" => link })
|
44
|
+
|
45
|
+
stub_request(:get, "http://localhost/1.0/database_snapshots/dbi-12345?account_id=").
|
46
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
47
|
+
to_return(:status => 200, :body => %q({"id": "dbs-12345"}))
|
48
|
+
@database_server = Fog::Compute::Brightbox::DatabaseServer.new(:service => service, :id => "dbs-12345")
|
49
|
+
assert_kind_of Fog::Compute::Brightbox::DatabaseSnapshot, @database_server.snapshot(true)
|
50
|
+
end
|
51
|
+
end
|
21
52
|
end
|
@@ -18,4 +18,35 @@ describe Fog::Compute::Brightbox::Server do
|
|
18
18
|
assert_equal "server", subject.resource_name
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
describe "when snapshotting withi no options" do
|
23
|
+
it "returns the server" do
|
24
|
+
skip if RUBY_VERSION < "1.9"
|
25
|
+
|
26
|
+
stub_request(:post, "http://localhost/1.0/servers/srv-12345/snapshot?account_id=").
|
27
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
28
|
+
to_return(:status => 202, :body => %q({"id": "srv-12345"}), :headers => {})
|
29
|
+
|
30
|
+
@server = Fog::Compute::Brightbox::Server.new(:service => service, :id => "srv-12345")
|
31
|
+
assert_kind_of Hash, @server.snapshot
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "when snapshotting with link option" do
|
36
|
+
it "returns the new image" do
|
37
|
+
skip if RUBY_VERSION < "1.9"
|
38
|
+
|
39
|
+
link = "<https://api.gb1.brightbox.com/1.0/images/img-12345>; rel=snapshot"
|
40
|
+
|
41
|
+
stub_request(:post, "http://localhost/1.0/servers/srv-12345/snapshot").
|
42
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
43
|
+
to_return(:status => 202, :body => "{}", :headers => { "Link" => link })
|
44
|
+
|
45
|
+
stub_request(:get, "http://localhost/1.0/images/img-12345?account_id=").
|
46
|
+
with(:headers => { "Authorization" => "OAuth FAKECACHEDTOKEN" }).
|
47
|
+
to_return(:status => 200, :body => %q({"id": "img-12345"}))
|
48
|
+
@server = Fog::Compute::Brightbox::Server.new(:service => service, :id => "srv-12345")
|
49
|
+
assert_kind_of Fog::Compute::Brightbox::Image, @server.snapshot(true)
|
50
|
+
end
|
51
|
+
end
|
21
52
|
end
|
@@ -150,7 +150,7 @@ describe Fog::Storage::Brightbox do
|
|
150
150
|
|
151
151
|
describe "when configured with tokens and management_url" do
|
152
152
|
let(:settings) do
|
153
|
-
|
153
|
+
{
|
154
154
|
:brightbox_client_id => "app-12345",
|
155
155
|
:brightbox_secret => "12345",
|
156
156
|
:brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz",
|
@@ -178,7 +178,7 @@ describe Fog::Storage::Brightbox do
|
|
178
178
|
|
179
179
|
describe "when configured with expired tokens" do
|
180
180
|
let(:settings) do
|
181
|
-
|
181
|
+
{
|
182
182
|
:brightbox_client_id => "app-12345",
|
183
183
|
:brightbox_secret => "12345",
|
184
184
|
:brightbox_access_token => "1234567890abcdefghijklmnopqrstuvwxyz",
|
@@ -203,7 +203,7 @@ describe Fog::Storage::Brightbox do
|
|
203
203
|
|
204
204
|
describe "when configured with user details and expired tokens" do
|
205
205
|
let(:settings) do
|
206
|
-
|
206
|
+
{
|
207
207
|
:brightbox_client_id => "app-12345",
|
208
208
|
:brightbox_secret => "12345",
|
209
209
|
:brightbox_username => "user@example.com",
|