fog-brightbox 0.5.0 → 0.5.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 +8 -0
- data/lib/fog/brightbox/storage/authentication_request.rb +2 -2
- data/lib/fog/brightbox/version.rb +1 -1
- data/spec/fog/brightbox/storage/authentication_request_spec.rb +30 -15
- data/spec/fog/storage/brightbox_spec.rb +20 -41
- data/spec/spec_helper.rb +1 -0
- data/spec/stock_storage_responses.rb +36 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e284d72c08bde3b84dde44cd5eddf1cf54da198
|
4
|
+
data.tar.gz: 668a97efaef6e604174b3178eb3857fdd8e3d240
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86b3f5e1f72d0f621e594b0eea69184b263cefde28891ccb12de854a2c634c9bbbd6e35b94438750f89ac3d174ad1af5c8fede4807699e4532abf346d4d7e8f
|
7
|
+
data.tar.gz: 0c4d0996fb3d7eb4670e8cdd01800dea3d81ee7472bb7f9992a98e0cda7a0f0ac2aba3e8a6071d806f6c218be3d4f0a70856ca4c74eba9ba77753b3c8ed0fac5
|
data/CHANGELOG.md
CHANGED
@@ -15,8 +15,8 @@ module Fog
|
|
15
15
|
self.access_token = response.headers["X-Auth-Token"]
|
16
16
|
self.management_url = response.headers["X-Server-Management-Url"] || response.headers["X-Storage-Url"]
|
17
17
|
self
|
18
|
-
rescue Excon::Errors::
|
19
|
-
|
18
|
+
rescue Excon::Errors::Unauthorized => error
|
19
|
+
raise Fog::Brightbox::Storage::AuthenticationRequired.slurp(error)
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -3,6 +3,8 @@ require "webmock/minitest"
|
|
3
3
|
require "fog/brightbox"
|
4
4
|
|
5
5
|
describe Fog::Brightbox::Storage::AuthenticationRequest do
|
6
|
+
include StockStorageResponses
|
7
|
+
|
6
8
|
describe "when initialised with blank config" do
|
7
9
|
before do
|
8
10
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
@@ -10,14 +12,14 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
10
12
|
"Host" => "orbit.brightbox.com:443",
|
11
13
|
"X-Auth-User" => "",
|
12
14
|
"X-Auth-Key" => ""
|
13
|
-
}).to_return(
|
15
|
+
}).to_return(bad_url_response)
|
14
16
|
end
|
15
17
|
|
16
|
-
it "
|
18
|
+
it "raises error" do
|
17
19
|
settings = {}
|
18
20
|
@config = Fog::Brightbox::Config.new(settings)
|
19
21
|
@request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config)
|
20
|
-
|
22
|
+
assert_raises(Excon::Errors::PreconditionFailed) { @request.authenticate }
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -28,12 +30,7 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
28
30
|
"Host" => "orbit.brightbox.com:443",
|
29
31
|
"X-Auth-User" => "cli-12345",
|
30
32
|
"X-Auth-Key" => "12345"
|
31
|
-
}).to_return(
|
32
|
-
"X-Storage-Url" => "https://orbit.brightbox.com/v1/acc-12345",
|
33
|
-
"X-Storage-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
34
|
-
"X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
35
|
-
"Content-Type" => "text/plain"
|
36
|
-
})
|
33
|
+
}).to_return(authorized_response)
|
37
34
|
end
|
38
35
|
|
39
36
|
it "authenticates correctly" do
|
@@ -54,12 +51,7 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
54
51
|
"Host" => "orbit.brightbox.com:443",
|
55
52
|
"X-Auth-User" => "user@example.com",
|
56
53
|
"X-Auth-Key" => "abcde"
|
57
|
-
}).to_return(
|
58
|
-
"X-Storage-Url" => "https://orbit.brightbox.com/v1/acc-12345",
|
59
|
-
"X-Storage-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
60
|
-
"X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
61
|
-
"Content-Type" => "text/plain"
|
62
|
-
})
|
54
|
+
}).to_return(authorized_response)
|
63
55
|
end
|
64
56
|
|
65
57
|
it "authenticates correctly" do
|
@@ -74,4 +66,27 @@ describe Fog::Brightbox::Storage::AuthenticationRequest do
|
|
74
66
|
assert @request.authenticate
|
75
67
|
end
|
76
68
|
end
|
69
|
+
|
70
|
+
describe "when initialised with bad user details" do
|
71
|
+
before do
|
72
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
73
|
+
with(:headers => {
|
74
|
+
"Host" => "orbit.brightbox.com:443",
|
75
|
+
"X-Auth-User" => "user@example.com",
|
76
|
+
"X-Auth-Key" => "abcde"
|
77
|
+
}).to_return(unauthorized_response)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "raises error" do
|
81
|
+
settings = {
|
82
|
+
:brightbox_client_id => "app-12345",
|
83
|
+
:brightbox_secret => "12345",
|
84
|
+
:brightbox_username => "user@example.com",
|
85
|
+
:brightbox_password => "abcde"
|
86
|
+
}
|
87
|
+
@config = Fog::Brightbox::Config.new(settings)
|
88
|
+
@request = Fog::Brightbox::Storage::AuthenticationRequest.new(@config)
|
89
|
+
assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { @request.authenticate }
|
90
|
+
end
|
91
|
+
end
|
77
92
|
end
|
@@ -3,21 +3,8 @@ require "webmock/minitest"
|
|
3
3
|
require "fog/brightbox"
|
4
4
|
|
5
5
|
describe Fog::Storage::Brightbox do
|
6
|
-
|
7
|
-
|
8
|
-
:status => 200,
|
9
|
-
:body => "Authenticated",
|
10
|
-
:headers => {
|
11
|
-
"X-Storage-Url"=>"https://orbit.brightbox.com:443/v1/acc-12345",
|
12
|
-
"Content-Length"=>"13",
|
13
|
-
"X-Storage-Token"=>"c1236c8c34d668df497c06075d8a76a79c6fdd0d",
|
14
|
-
"Content-Type"=>"text/plain",
|
15
|
-
"X-Auth-Token"=>"c1236c8c34d668df497c06075d8a76a79c6fdd0d",
|
16
|
-
"X-Trans-Id"=>"txcb228b8b9bfe4d5184828-0053568313",
|
17
|
-
"Date"=>"Tue, 22 Apr 2014 14:56:20 GMT"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
end
|
6
|
+
include StockStorageResponses
|
7
|
+
|
21
8
|
let(:config) { Fog::Brightbox::Config.new(settings) }
|
22
9
|
let(:service) { Fog::Storage::Brightbox.new(config) }
|
23
10
|
|
@@ -64,7 +51,8 @@ describe Fog::Storage::Brightbox do
|
|
64
51
|
end
|
65
52
|
|
66
53
|
before do
|
67
|
-
stub_request(:get, "https://orbit.brightbox.com/v1").
|
54
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
55
|
+
to_return(authorized_response)
|
68
56
|
end
|
69
57
|
|
70
58
|
it "requires a call to authenticate" do
|
@@ -90,18 +78,10 @@ describe Fog::Storage::Brightbox do
|
|
90
78
|
end
|
91
79
|
|
92
80
|
it "fails to authenticate" do
|
93
|
-
|
94
|
-
|
95
|
-
:headers=>
|
96
|
-
{"Content-Length"=>"7",
|
97
|
-
"Content-Type"=>"text/html; charset=UTF-8",
|
98
|
-
"X-Trans-Id"=>"txab03ff4864ff42989f4a1-0053568282",
|
99
|
-
"Date"=>"Tue, 22 Apr 2014 14:53:54 GMT"},
|
100
|
-
:status=>412
|
101
|
-
}
|
102
|
-
stub_request(:get, "https://orbit.brightbox.com/v1").to_return(response)
|
81
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
82
|
+
to_return(unauthorized_response)
|
103
83
|
|
104
|
-
service.authenticate
|
84
|
+
assert_raises(Fog::Brightbox::Storage::AuthenticationRequired) { service.authenticate }
|
105
85
|
assert_nil service.management_url
|
106
86
|
end
|
107
87
|
end
|
@@ -118,7 +98,8 @@ describe Fog::Storage::Brightbox do
|
|
118
98
|
end
|
119
99
|
|
120
100
|
before do
|
121
|
-
stub_request(:get, "https://orbit.brightbox.com/v1").
|
101
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
102
|
+
to_return(authorized_response)
|
122
103
|
end
|
123
104
|
|
124
105
|
it "uses the configured account" do
|
@@ -138,7 +119,8 @@ describe Fog::Storage::Brightbox do
|
|
138
119
|
end
|
139
120
|
|
140
121
|
before do
|
141
|
-
stub_request(:get, "https://orbit.brightbox.com/v1").
|
122
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
123
|
+
to_return(authorized_response)
|
142
124
|
end
|
143
125
|
|
144
126
|
it "extracts the account from the management URL" do
|
@@ -186,7 +168,8 @@ describe Fog::Storage::Brightbox do
|
|
186
168
|
end
|
187
169
|
|
188
170
|
it "keeps setting after authentication" do
|
189
|
-
stub_request(:get, "https://orbit.brightbox.com/v1").
|
171
|
+
stub_request(:get, "https://orbit.brightbox.com/v1").
|
172
|
+
to_return(authorized_response)
|
190
173
|
config.expire_tokens!
|
191
174
|
service.authenticate
|
192
175
|
assert_equal "https://files.gb2.brightbox.com/v1/acc-12345", service.management_url.to_s
|
@@ -208,9 +191,7 @@ describe Fog::Storage::Brightbox do
|
|
208
191
|
before do
|
209
192
|
# Ongoing request but tokens are expired
|
210
193
|
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord").
|
211
|
-
to_return(
|
212
|
-
:body => "Authentication required",
|
213
|
-
:headers => { "Content-Type" => "text/plain" })
|
194
|
+
to_return(unauthorized_response)
|
214
195
|
end
|
215
196
|
|
216
197
|
let(:params) { { :expects => [200], :path => "fnord" } }
|
@@ -238,18 +219,16 @@ describe Fog::Storage::Brightbox do
|
|
238
219
|
# Ongoing request but tokens are expired
|
239
220
|
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord").
|
240
221
|
with(:headers => { "X-Auth-Token" => "1234567890abcdefghijklmnopqrstuvwxyz" }).
|
241
|
-
to_return(
|
242
|
-
:body => "Authentication required",
|
243
|
-
:headers => { "Content-Type" => "text/plain" })
|
222
|
+
to_return(unauthorized_response)
|
244
223
|
|
245
224
|
# The reauthentication
|
246
225
|
stub_request(:get, "https://files.gb2.brightbox.com/v1").
|
247
226
|
with(:headers => { "X-Auth-User" => "user@example.com", "X-Auth-Key" => "12345" }).
|
248
|
-
to_return(
|
227
|
+
to_return(authorized_response)
|
249
228
|
|
250
229
|
# Repeated request
|
251
230
|
stub_request(:get, "https://files.gb2.brightbox.com/v1/acc-12345/fnord").
|
252
|
-
with(:headers => { "X-Auth-Token" => "
|
231
|
+
with(:headers => { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" }).
|
253
232
|
to_return(:status => 200)
|
254
233
|
end
|
255
234
|
|
@@ -272,11 +251,11 @@ describe Fog::Storage::Brightbox do
|
|
272
251
|
before do
|
273
252
|
# Initial authentication
|
274
253
|
stub_request(:get, "https://orbit.brightbox.com/v1").
|
275
|
-
with(:headers => {"X-Auth-Key" => "12345", "X-Auth-User" => "cli-12345"}).
|
276
|
-
to_return(
|
254
|
+
with(:headers => { "X-Auth-Key" => "12345", "X-Auth-User" => "cli-12345" }).
|
255
|
+
to_return(authorized_response)
|
277
256
|
|
278
257
|
stub_request(:get, "https://orbit.brightbox.com/v1/acc-12345/fnord").
|
279
|
-
with(:headers => { "X-Auth-Token" => "
|
258
|
+
with(:headers => { "X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890" }).
|
280
259
|
to_return(:status => 200)
|
281
260
|
end
|
282
261
|
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module StockStorageResponses
|
2
|
+
def authorized_response
|
3
|
+
{
|
4
|
+
:status => 200,
|
5
|
+
:body => "Authenticated",
|
6
|
+
:headers => {
|
7
|
+
"X-Storage-Url" => "https://orbit.brightbox.com/v1/acc-12345",
|
8
|
+
"X-Storage-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
9
|
+
"X-Auth-Token" => "abcdefghijklmnopqrstuvwxyz1234567890",
|
10
|
+
"Content-Type" => "text/plain"
|
11
|
+
}
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def unauthorized_response
|
16
|
+
{
|
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
|
+
"Content-Length" => 131,
|
21
|
+
"Content-Type" => "text/html; charset=UTF-8"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def bad_url_response
|
27
|
+
{
|
28
|
+
:status => 412,
|
29
|
+
:body => "Bad URL",
|
30
|
+
:headers => {
|
31
|
+
"Content-Length" => 7,
|
32
|
+
"Content-Type" => "text/html; charset=UTF-8"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
end
|
36
|
+
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.5.
|
4
|
+
version: 0.5.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-09-
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -359,6 +359,7 @@ files:
|
|
359
359
|
- spec/model_helper.rb
|
360
360
|
- spec/model_setup.rb
|
361
361
|
- spec/spec_helper.rb
|
362
|
+
- spec/stock_storage_responses.rb
|
362
363
|
- spec/supports_resource_locking.rb
|
363
364
|
homepage: ''
|
364
365
|
licenses:
|
@@ -415,4 +416,5 @@ test_files:
|
|
415
416
|
- spec/model_helper.rb
|
416
417
|
- spec/model_setup.rb
|
417
418
|
- spec/spec_helper.rb
|
419
|
+
- spec/stock_storage_responses.rb
|
418
420
|
- spec/supports_resource_locking.rb
|