fog-brightbox 1.10.0 → 1.11.0
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/.rubocop.yml +15 -10
- data/CHANGELOG.md +17 -0
- data/Rakefile +1 -1
- data/fog-brightbox.gemspec +5 -3
- data/lib/fog/brightbox/compute/shared.rb +11 -10
- data/lib/fog/brightbox/compute.rb +20 -21
- data/lib/fog/brightbox/config.rb +6 -9
- data/lib/fog/brightbox/models/compute/api_client.rb +4 -4
- data/lib/fog/brightbox/models/compute/application.rb +2 -2
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +11 -11
- data/lib/fog/brightbox/models/compute/collaboration.rb +3 -3
- data/lib/fog/brightbox/models/compute/collaborations.rb +1 -1
- data/lib/fog/brightbox/models/compute/config_map.rb +2 -3
- data/lib/fog/brightbox/models/compute/database_server.rb +17 -5
- data/lib/fog/brightbox/models/compute/database_snapshot.rb +2 -2
- data/lib/fog/brightbox/models/compute/firewall_policy.rb +6 -6
- data/lib/fog/brightbox/models/compute/firewall_rule.rb +9 -9
- data/lib/fog/brightbox/models/compute/image.rb +9 -9
- data/lib/fog/brightbox/models/compute/load_balancer.rb +12 -12
- data/lib/fog/brightbox/models/compute/server.rb +21 -23
- data/lib/fog/brightbox/models/compute/server_group.rb +6 -6
- data/lib/fog/brightbox/models/compute/user.rb +3 -3
- data/lib/fog/brightbox/models/compute/volume.rb +16 -16
- data/lib/fog/brightbox/models/storage/directories.rb +2 -2
- data/lib/fog/brightbox/models/storage/directory.rb +7 -7
- data/lib/fog/brightbox/models/storage/file.rb +13 -13
- data/lib/fog/brightbox/models/storage/files.rb +9 -13
- data/lib/fog/brightbox/oauth2.rb +11 -11
- data/lib/fog/brightbox/requests/compute/list_accounts.rb +1 -1
- data/lib/fog/brightbox/requests/compute/reset_database_server.rb +21 -0
- data/lib/fog/brightbox/requests/compute/resize_database_server.rb +25 -0
- data/lib/fog/brightbox/requests/compute/snapshot_database_server.rb +1 -1
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +1 -1
- data/lib/fog/brightbox/requests/storage/copy_object.rb +5 -5
- data/lib/fog/brightbox/requests/storage/delete_container.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_multiple_objects.rb +7 -7
- data/lib/fog/brightbox/requests/storage/delete_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/delete_static_large_object.rb +6 -6
- data/lib/fog/brightbox/requests/storage/get_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/get_object.rb +4 -6
- data/lib/fog/brightbox/requests/storage/get_object_http_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/get_object_https_url.rb +1 -1
- data/lib/fog/brightbox/requests/storage/head_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_containers.rb +4 -4
- data/lib/fog/brightbox/requests/storage/head_object.rb +3 -3
- data/lib/fog/brightbox/requests/storage/post_set_meta_temp_url_key.rb +3 -3
- data/lib/fog/brightbox/requests/storage/put_container.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_dynamic_obj_manifest.rb +4 -4
- data/lib/fog/brightbox/requests/storage/put_object.rb +7 -7
- data/lib/fog/brightbox/requests/storage/put_static_obj_manifest.rb +6 -6
- data/lib/fog/brightbox/storage/authentication_request.rb +4 -4
- data/lib/fog/brightbox/storage/connection.rb +2 -2
- data/lib/fog/brightbox/storage.rb +13 -14
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/compute/config_spec.rb +4 -4
- data/spec/fog/brightbox/compute/get_access_token_spec.rb +28 -28
- data/spec/fog/brightbox/compute/wrapped_request_spec.rb +23 -23
- data/spec/fog/brightbox/config_spec.rb +23 -23
- data/spec/fog/brightbox/oauth2/client_credentials_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/credential_set_spec.rb +5 -5
- data/spec/fog/brightbox/oauth2/grant_type_strategy_spec.rb +2 -2
- data/spec/fog/brightbox/oauth2/refresh_token_strategy_spec.rb +3 -3
- data/spec/fog/brightbox/oauth2/user_credentials_strategy_spec.rb +4 -4
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +34 -34
- data/spec/fog/brightbox/storage/config_spec.rb +4 -4
- data/spec/fog/brightbox/storage/connection_errors_spec.rb +6 -6
- data/spec/fog/brightbox/storage/connection_spec.rb +37 -37
- data/spec/fog/brightbox/storage/directory_spec.rb +6 -6
- data/spec/fog/brightbox/storage/files_spec.rb +5 -5
- data/spec/fog/brightbox/storage_spec.rb +5 -5
- data/spec/fog/compute/brightbox/database_server_spec.rb +19 -19
- data/spec/fog/compute/brightbox/image_selector_spec.rb +18 -18
- data/spec/fog/compute/brightbox/load_balancer_spec.rb +5 -5
- data/spec/fog/compute/brightbox/server_spec.rb +44 -44
- data/spec/fog/compute/brightbox/volume_spec.rb +68 -69
- data/spec/fog/compute/brightbox_spec.rb +10 -10
- data/spec/fog/storage/brightbox_spec.rb +83 -83
- data/spec/model_setup.rb +9 -9
- data/spec/stock_storage_responses.rb +9 -9
- data/spec/supports_resource_locking.rb +6 -6
- data/tests/brightbox/compute/schema.rb +74 -74
- data/tests/brightbox/compute_tests.rb +14 -14
- data/tests/brightbox/models/compute/server_tests.rb +0 -1
- data/tests/brightbox/requests/compute/account_tests.rb +9 -9
- data/tests/brightbox/requests/compute/api_client_tests.rb +9 -9
- data/tests/brightbox/requests/compute/application_test.rb +8 -8
- data/tests/brightbox/requests/compute/cloud_ip_tests.rb +11 -13
- data/tests/brightbox/requests/compute/collaboration_tests.rb +1 -1
- data/tests/brightbox/requests/compute/database_server_tests.rb +7 -7
- data/tests/brightbox/requests/compute/database_snapsnot_tests.rb +5 -5
- data/tests/brightbox/requests/compute/database_type_tests.rb +1 -1
- data/tests/brightbox/requests/compute/firewall_policy_tests.rb +7 -7
- data/tests/brightbox/requests/compute/firewall_rule_tests.rb +8 -10
- data/tests/brightbox/requests/compute/helper.rb +1 -1
- data/tests/brightbox/requests/compute/image_tests.rb +2 -2
- data/tests/brightbox/requests/compute/interface_tests.rb +1 -1
- data/tests/brightbox/requests/compute/load_balancer_tests.rb +23 -23
- data/tests/brightbox/requests/compute/server_group_tests.rb +16 -18
- data/tests/brightbox/requests/compute/server_tests.rb +12 -12
- data/tests/brightbox/requests/compute/server_type_tests.rb +2 -2
- data/tests/brightbox/requests/compute/user_tests.rb +4 -4
- data/tests/brightbox/requests/compute/volume_tests.rb +5 -5
- data/tests/brightbox/requests/compute/zone_tests.rb +2 -2
- data/tests/helper.rb +1 -1
- data/tests/helpers/collection_helper.rb +16 -23
- data/tests/helpers/compute/server_helper.rb +4 -6
- data/tests/helpers/formats_helper.rb +5 -5
- data/tests/helpers/formats_helper_tests.rb +16 -16
- data/tests/helpers/mock_helper.rb +84 -86
- data/tests/helpers/model_helper.rb +1 -3
- data/tests/helpers/schema_validator_tests.rb +14 -14
- metadata +17 -2
- data/.rubocop_todo.yml +0 -81
@@ -19,8 +19,8 @@ describe Fog::Brightbox::Storage do
|
|
19
19
|
describe "when created with a Config object" do
|
20
20
|
let(:settings) do
|
21
21
|
{
|
22
|
-
:
|
23
|
-
:
|
22
|
+
brightbox_client_id: "cli-12345",
|
23
|
+
brightbox_secret: "1234567890"
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
@@ -43,14 +43,14 @@ describe Fog::Brightbox::Storage do
|
|
43
43
|
describe "when created with a viable config" do
|
44
44
|
let(:settings) do
|
45
45
|
{
|
46
|
-
:
|
47
|
-
:
|
46
|
+
brightbox_client_id: "cli-12345",
|
47
|
+
brightbox_secret: "fdkls"
|
48
48
|
}
|
49
49
|
end
|
50
50
|
|
51
51
|
before do
|
52
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
53
|
-
to_return(authorized_response)
|
52
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
53
|
+
.to_return(authorized_response)
|
54
54
|
end
|
55
55
|
|
56
56
|
it "requires a call to authenticate" do
|
@@ -70,14 +70,14 @@ describe Fog::Brightbox::Storage do
|
|
70
70
|
describe "when created with bad credentials" do
|
71
71
|
let(:settings) do
|
72
72
|
{
|
73
|
-
:
|
74
|
-
:
|
73
|
+
brightbox_client_id: "cli-12345",
|
74
|
+
brightbox_secret: "wrong"
|
75
75
|
}
|
76
76
|
end
|
77
77
|
|
78
78
|
it "fails to authenticate" do
|
79
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
80
|
-
to_return(unauthorized_response)
|
79
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
80
|
+
.to_return(unauthorized_response)
|
81
81
|
|
82
82
|
assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { service.authenticate }
|
83
83
|
assert_nil service.management_url
|
@@ -87,17 +87,17 @@ describe Fog::Brightbox::Storage do
|
|
87
87
|
describe "when configured scoped to a specific account" do
|
88
88
|
let(:settings) do
|
89
89
|
{
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
90
|
+
brightbox_client_id: "app-12345",
|
91
|
+
brightbox_secret: "12345",
|
92
|
+
brightbox_username: "user@example.test",
|
93
|
+
brightbox_password: "abcde",
|
94
|
+
brightbox_account: "acc-abcde"
|
95
95
|
}
|
96
96
|
end
|
97
97
|
|
98
98
|
before do
|
99
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
100
|
-
to_return(authorized_response)
|
99
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
100
|
+
.to_return(authorized_response)
|
101
101
|
end
|
102
102
|
|
103
103
|
it "uses the configured account" do
|
@@ -109,16 +109,16 @@ describe Fog::Brightbox::Storage do
|
|
109
109
|
describe "when account is not configured" do
|
110
110
|
let(:settings) do
|
111
111
|
{
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
112
|
+
brightbox_client_id: "app-12345",
|
113
|
+
brightbox_secret: "12345",
|
114
|
+
brightbox_username: "user@example.test",
|
115
|
+
brightbox_password: "abcde"
|
116
116
|
}
|
117
117
|
end
|
118
118
|
|
119
119
|
before do
|
120
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
121
|
-
to_return(authorized_response)
|
120
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
121
|
+
.to_return(authorized_response)
|
122
122
|
end
|
123
123
|
|
124
124
|
it "extracts the account from the management URL" do
|
@@ -130,10 +130,10 @@ describe Fog::Brightbox::Storage do
|
|
130
130
|
describe "when configured with existing token" do
|
131
131
|
let(:settings) do
|
132
132
|
{
|
133
|
-
:
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
133
|
+
brightbox_client_id: "app-12345",
|
134
|
+
brightbox_secret: "12345",
|
135
|
+
brightbox_access_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
136
|
+
brightbox_refresh_token: "1234567890abcdefghijklmnopqrstuvwxyz"
|
137
137
|
}
|
138
138
|
end
|
139
139
|
|
@@ -149,11 +149,11 @@ describe Fog::Brightbox::Storage do
|
|
149
149
|
describe "when configured with tokens and management_url" do
|
150
150
|
let(:settings) do
|
151
151
|
{
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
155
|
-
:
|
156
|
-
:
|
152
|
+
brightbox_client_id: "app-12345",
|
153
|
+
brightbox_secret: "12345",
|
154
|
+
brightbox_access_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
155
|
+
brightbox_refresh_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
156
|
+
brightbox_storage_management_url: "https://files.gb2.brightbox.com/v1/acc-12345"
|
157
157
|
}
|
158
158
|
end
|
159
159
|
|
@@ -166,8 +166,8 @@ describe Fog::Brightbox::Storage do
|
|
166
166
|
end
|
167
167
|
|
168
168
|
it "keeps setting after authentication" do
|
169
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
170
|
-
to_return(authorized_response)
|
169
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
170
|
+
.to_return(authorized_response)
|
171
171
|
config.expire_tokens!
|
172
172
|
service.authenticate
|
173
173
|
assert_equal "https://files.gb2.brightbox.com/v1/acc-12345", service.management_url.to_s
|
@@ -177,22 +177,22 @@ describe Fog::Brightbox::Storage do
|
|
177
177
|
describe "when configured with expired tokens" do
|
178
178
|
let(:settings) do
|
179
179
|
{
|
180
|
-
:
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
180
|
+
brightbox_client_id: "app-12345",
|
181
|
+
brightbox_secret: "12345",
|
182
|
+
brightbox_access_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
183
|
+
brightbox_refresh_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
184
|
+
brightbox_storage_management_url: "https://files.gb2.brightbox.com/v1/acc-12345",
|
185
|
+
brightbox_token_management: false
|
186
186
|
}
|
187
187
|
end
|
188
188
|
|
189
189
|
before do
|
190
190
|
# Ongoing request but tokens are expired
|
191
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
192
|
-
to_return(unauthorized_response)
|
191
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
192
|
+
.to_return(unauthorized_response)
|
193
193
|
end
|
194
194
|
|
195
|
-
let(:params) { { :
|
195
|
+
let(:params) { { expects: [200], path: "fnord" } }
|
196
196
|
|
197
197
|
it "raises Fog::Brightbox::Storage::AuthenticationRequired" do
|
198
198
|
assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { service.request(params) }
|
@@ -202,35 +202,35 @@ describe Fog::Brightbox::Storage do
|
|
202
202
|
describe "when configured with user details and expired tokens" do
|
203
203
|
let(:settings) do
|
204
204
|
{
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
208
|
-
:
|
209
|
-
:
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
205
|
+
brightbox_client_id: "app-12345",
|
206
|
+
brightbox_secret: "12345",
|
207
|
+
brightbox_username: "user@example.test",
|
208
|
+
brightbox_password: "12345",
|
209
|
+
brightbox_access_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
210
|
+
brightbox_refresh_token: "1234567890abcdefghijklmnopqrstuvwxyz",
|
211
|
+
brightbox_storage_url: "https://files.gb2.brightbox.com",
|
212
|
+
brightbox_storage_management_url: "https://files.gb2.brightbox.com/v1/acc-12345"
|
213
213
|
}
|
214
214
|
end
|
215
215
|
|
216
216
|
before do
|
217
217
|
# Ongoing request but tokens are expired
|
218
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
219
|
-
with(:
|
220
|
-
to_return(unauthorized_response)
|
218
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
219
|
+
.with(headers: { "X-Auth-Token" => "1234567890abcdefghijklmnopqrstuvwxyz" })
|
220
|
+
.to_return(unauthorized_response)
|
221
221
|
|
222
222
|
# The reauthentication
|
223
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1")
|
224
|
-
with(:
|
225
|
-
to_return(authorized_response)
|
223
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1")
|
224
|
+
.with(headers: { "X-Auth-User" => "user@example.test", "X-Auth-Key" => "12345" })
|
225
|
+
.to_return(authorized_response)
|
226
226
|
|
227
227
|
# Repeated request
|
228
|
-
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
229
|
-
with(:
|
230
|
-
to_return(:
|
228
|
+
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord")
|
229
|
+
.with(headers: { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" })
|
230
|
+
.to_return(status: 200)
|
231
231
|
end
|
232
232
|
|
233
|
-
let(:params) { { :
|
233
|
+
let(:params) { { expects: [200], path: "fnord" } }
|
234
234
|
|
235
235
|
it "authenticates again and retries" do
|
236
236
|
service.request(params)
|
@@ -241,23 +241,23 @@ describe Fog::Brightbox::Storage do
|
|
241
241
|
describe "when configured with client credentials" do
|
242
242
|
let(:settings) do
|
243
243
|
{
|
244
|
-
:
|
245
|
-
:
|
244
|
+
brightbox_client_id: "cli-12345",
|
245
|
+
brightbox_secret: "12345"
|
246
246
|
}
|
247
247
|
end
|
248
248
|
|
249
249
|
before do
|
250
250
|
# Initial authentication
|
251
|
-
stub_request(:get, "https://orbit.brightbox.com/v1")
|
252
|
-
with(:
|
253
|
-
to_return(authorized_response)
|
251
|
+
stub_request(:get, "https://orbit.brightbox.com/v1")
|
252
|
+
.with(headers: { "X-Auth-Key" => "12345", "X-Auth-User" => "cli-12345" })
|
253
|
+
.to_return(authorized_response)
|
254
254
|
|
255
|
-
stub_request(:get, "https://orbit.brightbox.com/v1/acc-12345/fnord")
|
256
|
-
with(:
|
257
|
-
to_return(:
|
255
|
+
stub_request(:get, "https://orbit.brightbox.com/v1/acc-12345/fnord")
|
256
|
+
.with(headers: { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" })
|
257
|
+
.to_return(status: 200)
|
258
258
|
end
|
259
259
|
|
260
|
-
let(:params) { { :
|
260
|
+
let(:params) { { expects: [200], path: "fnord" } }
|
261
261
|
|
262
262
|
it "authenticates again and retries" do
|
263
263
|
service.request(params)
|
@@ -268,8 +268,8 @@ describe Fog::Brightbox::Storage do
|
|
268
268
|
describe "when not initialised with temporary URL key" do
|
269
269
|
let(:settings) do
|
270
270
|
{
|
271
|
-
:
|
272
|
-
:
|
271
|
+
brightbox_client_id: "cli-12345",
|
272
|
+
brightbox_secret: "12345"
|
273
273
|
}
|
274
274
|
end
|
275
275
|
|
@@ -286,10 +286,10 @@ describe Fog::Brightbox::Storage do
|
|
286
286
|
let(:temp_url_key) { "1234567890" }
|
287
287
|
let(:settings) do
|
288
288
|
{
|
289
|
-
:
|
290
|
-
:
|
291
|
-
:
|
292
|
-
:
|
289
|
+
brightbox_client_id: "cli-12345",
|
290
|
+
brightbox_secret: "12345",
|
291
|
+
brightbox_storage_management_url: "https://example.brightbox.com",
|
292
|
+
brightbox_temp_url_key: temp_url_key
|
293
293
|
}
|
294
294
|
end
|
295
295
|
let(:container) { "container" }
|
@@ -303,17 +303,17 @@ describe Fog::Brightbox::Storage do
|
|
303
303
|
|
304
304
|
it "can generate temporary HTTPS URLs" do
|
305
305
|
assert_equal "https://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
306
|
-
|
306
|
+
service.create_temp_url(container, object, expiry_time, request_method, scheme: "https")
|
307
307
|
end
|
308
308
|
|
309
309
|
it "can generate temporary HTTP URLs" do
|
310
310
|
assert_equal "http://example.brightbox.com/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
311
|
-
|
311
|
+
service.create_temp_url(container, object, expiry_time, request_method, scheme: "http")
|
312
312
|
end
|
313
313
|
|
314
314
|
it "can generate temporary HTTP URLs on non standard ports" do
|
315
315
|
assert_equal "http://example.brightbox.com:401/container/file.ext?temp_url_sig=86dcfd2cf9d501936abab2badc152e90d6b3b133&temp_url_expires=1325376000",
|
316
|
-
|
316
|
+
service.create_temp_url(container, object, expiry_time, request_method, scheme: "http", port: 401)
|
317
317
|
end
|
318
318
|
end
|
319
319
|
|
@@ -321,9 +321,9 @@ describe Fog::Brightbox::Storage do
|
|
321
321
|
let(:temp_url_key) { "1234567890" }
|
322
322
|
let(:settings) do
|
323
323
|
{
|
324
|
-
:
|
325
|
-
:
|
326
|
-
:
|
324
|
+
brightbox_client_id: "cli-12345",
|
325
|
+
brightbox_secret: "12345",
|
326
|
+
brightbox_temp_url_key: temp_url_key
|
327
327
|
}
|
328
328
|
end
|
329
329
|
let(:container) { "container" }
|
@@ -333,7 +333,7 @@ describe Fog::Brightbox::Storage do
|
|
333
333
|
|
334
334
|
it "raises an error" do
|
335
335
|
assert_raises Fog::Brightbox::Storage::ManagementUrlUnknown do
|
336
|
-
service.create_temp_url(container, object, expiry_time, request_method, :
|
336
|
+
service.create_temp_url(container, object, expiry_time, request_method, scheme: "https")
|
337
337
|
end
|
338
338
|
end
|
339
339
|
end
|
data/spec/model_setup.rb
CHANGED
@@ -3,15 +3,15 @@ module ModelSetup
|
|
3
3
|
base.class_eval do
|
4
4
|
let(:configuration) do
|
5
5
|
{
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
6
|
+
brightbox_auth_url: "http://localhost",
|
7
|
+
brightbox_api_url: "http://localhost",
|
8
|
+
brightbox_client_id: "",
|
9
|
+
brightbox_secret: "",
|
10
|
+
brightbox_username: "",
|
11
|
+
brightbox_password: "",
|
12
|
+
brightbox_account: "",
|
13
|
+
brightbox_default_image: "img-test",
|
14
|
+
brightbox_access_token: "FAKECACHEDTOKEN"
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module StockStorageResponses
|
2
2
|
def authorized_response
|
3
3
|
{
|
4
|
-
:
|
5
|
-
:
|
6
|
-
:
|
4
|
+
status: 200,
|
5
|
+
body: "Authenticated",
|
6
|
+
headers: {
|
7
7
|
"X-Storage-Url" => "https://orbit.brightbox.com/v1/acc-12345",
|
8
8
|
"X-Storage-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
9
9
|
"X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
@@ -14,9 +14,9 @@ module StockStorageResponses
|
|
14
14
|
|
15
15
|
def unauthorized_response
|
16
16
|
{
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
17
|
+
status: 401,
|
18
|
+
body: "<html><h1>Unauthorized</h1><p>This server could not verify that you are authorized to access the document you requested.</p></html>",
|
19
|
+
headers: {
|
20
20
|
"Content-Length" => 131,
|
21
21
|
"Content-Type" => "text/html; charset=UTF-8"
|
22
22
|
}
|
@@ -25,9 +25,9 @@ module StockStorageResponses
|
|
25
25
|
|
26
26
|
def bad_url_response
|
27
27
|
{
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
28
|
+
status: 412,
|
29
|
+
body: "Bad URL",
|
30
|
+
headers: {
|
31
31
|
"Content-Length" => 7,
|
32
32
|
"Content-Type" => "text/html; charset=UTF-8"
|
33
33
|
}
|
@@ -16,9 +16,9 @@ module SupportsResourceLocking
|
|
16
16
|
def test_lock_makes_request
|
17
17
|
subject.id = "tst-12345"
|
18
18
|
|
19
|
-
stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/lock_resource")
|
20
|
-
with(:
|
21
|
-
to_return(:
|
19
|
+
stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/lock_resource")
|
20
|
+
.with(query: hash_including(:account_id))
|
21
|
+
.to_return(status: 200, body: "{}", headers: {})
|
22
22
|
|
23
23
|
subject.lock!
|
24
24
|
end
|
@@ -30,9 +30,9 @@ module SupportsResourceLocking
|
|
30
30
|
def test_unlock_makes_request
|
31
31
|
subject.id = "tst-12345"
|
32
32
|
|
33
|
-
stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/unlock_resource")
|
34
|
-
with(:
|
35
|
-
to_return(:
|
33
|
+
stub_request(:put, "http://localhost/1.0/#{collection_name}/tst-12345/unlock_resource")
|
34
|
+
.with(query: hash_including(:account_id))
|
35
|
+
.to_return(status: 200, body: "{}", headers: {})
|
36
36
|
|
37
37
|
subject.unlock!
|
38
38
|
end
|