stacker_bee 2.1.0.pre184 → 2.1.0.pre185
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 +8 -8
- data/lib/stacker_bee/http_middleware/detokenizer.rb +1 -1
- data/lib/stacker_bee/http_middleware/signed_query.rb +3 -3
- data/lib/stacker_bee/rash.rb +2 -2
- data/lib/stacker_bee/request_error.rb +1 -1
- data/spec/integration/console_spec.rb +4 -6
- data/spec/integration/request_spec.rb +10 -16
- data/spec/spec_helper.rb +1 -1
- data/spec/units/stacker_bee/api_spec.rb +1 -1
- data/spec/units/stacker_bee/client_spec.rb +10 -10
- data/spec/units/stacker_bee/configuration_spec.rb +3 -3
- data/spec/units/stacker_bee/connection_spec.rb +7 -11
- data/spec/units/stacker_bee/middleware/base_spec.rb +1 -1
- data/spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb +3 -5
- data/spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb +1 -3
- data/spec/units/stacker_bee/rash_spec.rb +6 -6
- data/spec/units/stacker_bee/request_error_spec.rb +4 -4
- data/spec/units/stacker_bee/utilities_spec.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmVlYmQ2ZjAzM2Y3NDRmYzMxYzFkMzYxZDQwMTFmMDU0NjU1OWI5Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzIwMjlkNWE4NWE5NDg4MzM3YmRhNjQ5OTFlYjc4MjJiZjc1OGFjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDE4OWMyYTQ1NWY1M2RiOThlZjZlMDNhM2EwYjM4MzY2N2UxYjM1NDU0M2Ey
|
10
|
+
YWQyNDIxNjcxNGViNDRmZjEzYTg4OWNiYjA1ZjI4MzIyYjM1ZWQyOTM0ZDll
|
11
|
+
ZjEzNmE1ODVmYjMzYWJiNzlkOWExNGZmMzAyM2ZmODQ1MDg5YzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmVlODRhMTA5OTRlNTQ1YTBkYjg2ZmNkYzIyYmQ5ODAzZWY5OTQ4NmFlYWZl
|
14
|
+
MWRhMzkwMTRkNDM1ZjZkM2VhNzA2ZTliZWYxMzFmYWMzMzdhODI4Njg5Y2U2
|
15
|
+
MzIwZGJlODU0YzJhYjk4N2VhZDQzZGQwMmI1NjgyMTQ4MTFkYTU=
|
@@ -7,18 +7,18 @@ module StackerBee
|
|
7
7
|
def initialize(app, key)
|
8
8
|
@key = key
|
9
9
|
fail "Key cannot be nil" unless @key
|
10
|
-
super
|
10
|
+
super app
|
11
11
|
end
|
12
12
|
|
13
13
|
def call(env)
|
14
|
-
sign_uri
|
14
|
+
sign_uri env[:url]
|
15
15
|
@app.call(env)
|
16
16
|
end
|
17
17
|
|
18
18
|
def sign_uri(uri)
|
19
19
|
downcased = uri.query.downcase
|
20
20
|
nonplussed = downcased.gsub('+', '%20')
|
21
|
-
signed = OpenSSL::HMAC.digest
|
21
|
+
signed = OpenSSL::HMAC.digest('sha1', @key, nonplussed)
|
22
22
|
encoded = Base64.encode64(signed).chomp
|
23
23
|
escaped = CGI.escape(encoded)
|
24
24
|
|
data/lib/stacker_bee/rash.rb
CHANGED
@@ -32,11 +32,11 @@ module StackerBee
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def select(*args, &block)
|
35
|
-
Rash.new
|
35
|
+
Rash.new(@hash.select(*args, &block))
|
36
36
|
end
|
37
37
|
|
38
38
|
def reject(*args, &block)
|
39
|
-
Rash.new
|
39
|
+
Rash.new(@hash.reject(*args, &block))
|
40
40
|
end
|
41
41
|
|
42
42
|
def values_at(*keys)
|
@@ -1,6 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "A request sent to CloudStack for console access", :vcr do
|
4
|
+
subject(:console_access) { client.console_access(vm: vm) }
|
5
|
+
|
6
|
+
let(:vm) { "36f9c08b-f17a-4d0e-ac9b-d45ce2d34fcd" }
|
7
|
+
let(:client) { StackerBee::Client.new(config_hash) }
|
4
8
|
let(:config_hash) do
|
5
9
|
{
|
6
10
|
url: CONFIG['url'],
|
@@ -9,12 +13,6 @@ describe "A request sent to CloudStack for console access", :vcr do
|
|
9
13
|
}
|
10
14
|
end
|
11
15
|
|
12
|
-
let(:client) { StackerBee::Client.new(config_hash) }
|
13
|
-
|
14
|
-
let(:vm) { "36f9c08b-f17a-4d0e-ac9b-d45ce2d34fcd" }
|
15
|
-
|
16
|
-
subject(:console_access) { client.console_access(vm: vm) }
|
17
|
-
|
18
16
|
it "returns html for console access" do
|
19
17
|
expect(console_access).to match(/<html>.*<frame src=.*<\/html>/)
|
20
18
|
end
|
@@ -2,6 +2,8 @@ require "spec_helper"
|
|
2
2
|
require "logger"
|
3
3
|
|
4
4
|
describe "A response to a request sent to the CloudStack API", :vcr do
|
5
|
+
subject { client.list_accounts }
|
6
|
+
|
5
7
|
let(:url) { CONFIG["url"] }
|
6
8
|
let(:config_hash) do
|
7
9
|
{
|
@@ -18,8 +20,6 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
18
20
|
StackerBee::Client.new(config_hash)
|
19
21
|
end
|
20
22
|
|
21
|
-
subject { client.list_accounts }
|
22
|
-
|
23
23
|
it { should_not be_empty }
|
24
24
|
|
25
25
|
context "first item" do
|
@@ -47,10 +47,8 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
context "space character in a request parameter", :regression do
|
50
|
+
subject { client.list_accounts(params) }
|
50
51
|
let(:params) { { name: "stacker bee" } }
|
51
|
-
subject do
|
52
|
-
client.list_accounts(params)
|
53
|
-
end
|
54
52
|
|
55
53
|
it "properly signs the request" do
|
56
54
|
expect { subject }.not_to raise_error
|
@@ -58,10 +56,8 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
58
56
|
end
|
59
57
|
|
60
58
|
context "a nil request parameter" do
|
59
|
+
subject { client.list_accounts(params) }
|
61
60
|
let(:params) { { name: nil } }
|
62
|
-
subject do
|
63
|
-
client.list_accounts(params)
|
64
|
-
end
|
65
61
|
|
66
62
|
it "properly executes the request" do
|
67
63
|
expect { subject }.not_to raise_error
|
@@ -69,10 +65,8 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
69
65
|
end
|
70
66
|
|
71
67
|
context "a request parameter with and empty string", :regression do
|
68
|
+
subject { client.list_accounts(params) }
|
72
69
|
let(:params) { { name: '' } }
|
73
|
-
subject do
|
74
|
-
client.list_accounts(params)
|
75
|
-
end
|
76
70
|
|
77
71
|
it "properly executes the request" do
|
78
72
|
expect { subject }.not_to raise_error
|
@@ -89,10 +83,8 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
89
83
|
end
|
90
84
|
|
91
85
|
context "a request parameter with an Array", :regression do
|
86
|
+
subject { client.list_hosts(params).first.keys }
|
92
87
|
let(:params) { { page: 1, pagesize: 1, details: [:events, :stats] } }
|
93
|
-
subject do
|
94
|
-
client.list_hosts(params).first.keys
|
95
|
-
end
|
96
88
|
it { should include "cpuused" }
|
97
89
|
it { should include "events" }
|
98
90
|
it { should_not include "cpuallocated" }
|
@@ -100,11 +92,13 @@ describe "A response to a request sent to the CloudStack API", :vcr do
|
|
100
92
|
|
101
93
|
context "a request parameter with a map" do
|
102
94
|
let(:zone_id) { client.list_zones.first["id"] }
|
95
|
+
let(:service_offering_id) { service_offerings.first["id"] }
|
103
96
|
|
104
|
-
let(:
|
97
|
+
let(:service_offerings) do
|
105
98
|
client.list_network_offerings(
|
106
99
|
supported_services: 'sourcenat',
|
107
|
-
type: 'isolated'
|
100
|
+
type: 'isolated'
|
101
|
+
)
|
108
102
|
end
|
109
103
|
|
110
104
|
let(:network) do
|
data/spec/spec_helper.rb
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
describe StackerBee::API do
|
4
4
|
subject { api }
|
5
5
|
|
6
|
-
let(:api) {
|
6
|
+
let(:api) { described_class.new(api_path: api_path) }
|
7
7
|
let(:api_path) do
|
8
8
|
File.join(File.dirname(__FILE__), '../../fixtures/simple.json')
|
9
9
|
end
|
@@ -2,19 +2,19 @@ require "spec_helper"
|
|
2
2
|
require "ostruct"
|
3
3
|
|
4
4
|
describe StackerBee::Client, ".api" do
|
5
|
+
subject { described_class }
|
5
6
|
let(:api) { double }
|
6
7
|
before do
|
7
|
-
StackerBee::API.stub
|
8
|
-
|
8
|
+
StackerBee::API.stub new: api
|
9
|
+
described_class.api_path = nil
|
9
10
|
end
|
10
|
-
subject { StackerBee::Client }
|
11
11
|
its(:api_path) { should_not be_nil }
|
12
12
|
its(:api) { should eq api }
|
13
13
|
end
|
14
14
|
|
15
15
|
describe StackerBee::Client, "calling endpoint" do
|
16
16
|
let(:client) do
|
17
|
-
|
17
|
+
described_class.new(
|
18
18
|
url: "http://example.com",
|
19
19
|
middlewares: lambda do |builder|
|
20
20
|
builder.before middleware_class,
|
@@ -92,20 +92,20 @@ describe StackerBee::Client, "configuration" do
|
|
92
92
|
StackerBee::Configuration.new(instance_config_hash)
|
93
93
|
end
|
94
94
|
before do
|
95
|
-
StackerBee::Configuration.stub(:new) do
|
95
|
+
StackerBee::Configuration.stub(:new) do
|
96
96
|
fail "Unexpected Configuration instantiation: \n#{args.inspect}"
|
97
97
|
end
|
98
|
-
StackerBee::Configuration.stub(:new).with(default_config_hash)
|
98
|
+
StackerBee::Configuration.stub(:new).with(default_config_hash) do
|
99
99
|
default_configuration
|
100
100
|
end
|
101
101
|
StackerBee::Configuration.stub(:new).with(instance_config_hash) do
|
102
102
|
instance_configuration
|
103
103
|
end
|
104
|
-
|
104
|
+
described_class.configuration = default_config_hash
|
105
105
|
end
|
106
106
|
|
107
107
|
describe ".new" do
|
108
|
-
subject {
|
108
|
+
subject { described_class.new }
|
109
109
|
|
110
110
|
context "with default, class configuration" do
|
111
111
|
its(:url) { should eq default_url }
|
@@ -114,7 +114,7 @@ describe StackerBee::Client, "configuration" do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
context "with instance-specific configuration" do
|
117
|
-
subject {
|
117
|
+
subject { described_class.new(instance_config_hash) }
|
118
118
|
its(:configuration) { should eq instance_configuration }
|
119
119
|
its(:url) { should eq instance_url }
|
120
120
|
its(:api_key) { should eq instance_api_key }
|
@@ -122,7 +122,7 @@ describe StackerBee::Client, "configuration" do
|
|
122
122
|
end
|
123
123
|
|
124
124
|
context "with instance-specific configuration that's not a hash" do
|
125
|
-
subject {
|
125
|
+
subject { described_class.new(config) }
|
126
126
|
let(:config) { double(to_hash: instance_config_hash) }
|
127
127
|
its(:configuration) { should eq instance_configuration }
|
128
128
|
its(:url) { should eq instance_url }
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe StackerBee::Configuration do
|
4
|
-
its(:url)
|
5
|
-
its(:api_key)
|
6
|
-
its(:secret_key)
|
4
|
+
its(:url) { should be_nil }
|
5
|
+
its(:api_key) { should be_nil }
|
6
|
+
its(:secret_key) { should be_nil }
|
7
7
|
end
|
@@ -1,21 +1,19 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe StackerBee::Connection do
|
4
|
+
subject(:get) { connection.get(path, query_params) }
|
5
|
+
before { Faraday.stub new: faraday }
|
6
|
+
|
4
7
|
let(:url) { "http://test.com:1234/foo/bar/" }
|
5
8
|
let(:path) { "/foo/bar" }
|
6
9
|
let(:secret_key) { "shhh" }
|
7
10
|
let(:query_params) { [[:foo, :bar]] }
|
8
11
|
let(:response) { double(:response) }
|
9
12
|
let(:faraday) { double(:faraday, get: response) }
|
10
|
-
let(:connection) {
|
13
|
+
let(:connection) { described_class.new(configuration) }
|
11
14
|
let(:configuration) do
|
12
15
|
double(url: url, secret_key: secret_key, ssl_verify: nil)
|
13
16
|
end
|
14
|
-
subject(:get) { connection.get(path, query_params) }
|
15
|
-
|
16
|
-
before do
|
17
|
-
Faraday.stub(:new) { faraday }
|
18
|
-
end
|
19
17
|
|
20
18
|
context "successfully connecting" do
|
21
19
|
before do
|
@@ -34,16 +32,14 @@ describe StackerBee::Connection do
|
|
34
32
|
faraday.stub(:get) { fail Faraday::Error::ConnectionFailed, "boom" }
|
35
33
|
end
|
36
34
|
it "raises a helpful exception" do
|
37
|
-
|
38
|
-
expect { get }.to raise_error klass, /#{url}/
|
35
|
+
expect { get }.to raise_error StackerBee::ConnectionError, /#{url}/
|
39
36
|
end
|
40
37
|
end
|
41
38
|
|
42
39
|
context "no protocol specified in URL" do
|
43
40
|
let(:url) { "wrong.com" }
|
44
41
|
it "raises a helpful exception" do
|
45
|
-
|
46
|
-
expect { get }.to raise_error klass, /no protocol/
|
42
|
+
expect { get }.to raise_error StackerBee::ConnectionError, /no protocol/
|
47
43
|
end
|
48
44
|
end
|
49
45
|
|
@@ -57,7 +53,7 @@ describe StackerBee::Connection do
|
|
57
53
|
|
58
54
|
context "when verifying an ssl connection" do
|
59
55
|
let(:configuration) do
|
60
|
-
double
|
56
|
+
double(url: url, secret_key: secret_key, ssl_verify: false)
|
61
57
|
end
|
62
58
|
it "specifies the ssl verify option when creating a connection" do
|
63
59
|
get
|
@@ -10,7 +10,7 @@ describe StackerBee::Middleware::Base do
|
|
10
10
|
|
11
11
|
let(:middleware) { subclass.new(app: app) }
|
12
12
|
|
13
|
-
let(:subclass) { Class.new(
|
13
|
+
let(:subclass) { Class.new(described_class, &subclass_body) }
|
14
14
|
let(:subclass_body) { proc {} }
|
15
15
|
|
16
16
|
describe "#call" do
|
@@ -17,6 +17,8 @@ describe StackerBee::Middleware::DictionaryFlattener do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
describe ".new" do
|
20
|
+
subject { described_class.new.params(params) }
|
21
|
+
|
20
22
|
def prefix(number)
|
21
23
|
described_class.tokenize "rebels[#{number}]"
|
22
24
|
end
|
@@ -26,17 +28,13 @@ describe StackerBee::Middleware::DictionaryFlattener do
|
|
26
28
|
"rebels" => { "r2" => "d2", "r1" => "", "father" => false } }
|
27
29
|
end
|
28
30
|
|
29
|
-
subject do
|
30
|
-
described_class.new.params(params)
|
31
|
-
end
|
32
|
-
|
33
31
|
it "flattens objects in the manner that cloudstack expects" do
|
34
32
|
subject["#{prefix(0)}.name"].should eq "r2"
|
35
33
|
subject["#{prefix(0)}.key"].should eq "r2"
|
36
34
|
subject["#{prefix(0)}.value"].should eq "d2"
|
37
35
|
end
|
38
36
|
|
39
|
-
it "
|
37
|
+
it "does not flatten empty hashes" do
|
40
38
|
subject.should_not have_key "#{prefix(2)}.name"
|
41
39
|
end
|
42
40
|
|
@@ -5,9 +5,7 @@ describe StackerBee::Middleware::EndpointNormalizer do
|
|
5
5
|
let(:app) { double(:app) }
|
6
6
|
|
7
7
|
let(:env) do
|
8
|
-
StackerBee::Middleware::Environment.new(
|
9
|
-
endpoint_name: endpoint_name
|
10
|
-
)
|
8
|
+
StackerBee::Middleware::Environment.new(endpoint_name: endpoint_name)
|
11
9
|
end
|
12
10
|
|
13
11
|
context "when it doesn't match" do
|
@@ -5,6 +5,8 @@ shared_examples_for "a Rash" do |mapping|
|
|
5
5
|
end
|
6
6
|
|
7
7
|
describe StackerBee::Rash do
|
8
|
+
subject { rash }
|
9
|
+
|
8
10
|
let(:wiz) { [{ "aB_C" => "abc" }, { "X_yZ" => "xyz" }] }
|
9
11
|
let(:ziz) do
|
10
12
|
{
|
@@ -28,15 +30,14 @@ describe StackerBee::Rash do
|
|
28
30
|
end
|
29
31
|
end
|
30
32
|
let(:dissimilar_hash) { hash.dup.tap { |loud| loud.delete "foo" } }
|
31
|
-
let(:rash) {
|
32
|
-
subject { rash }
|
33
|
+
let(:rash) { described_class.new(hash) }
|
33
34
|
|
34
35
|
it { should include "FOO" }
|
35
36
|
|
36
37
|
it { should == subject }
|
37
38
|
it { should == subject.dup }
|
38
39
|
it { should == hash }
|
39
|
-
it { should ==
|
40
|
+
it { should == described_class.new(hash) }
|
40
41
|
it { should == similar_hash }
|
41
42
|
it { should_not == dissimilar_hash }
|
42
43
|
|
@@ -67,14 +68,14 @@ describe StackerBee::Rash do
|
|
67
68
|
|
68
69
|
describe "#select" do
|
69
70
|
subject { rash.select { |key, value| value.is_a? String } }
|
70
|
-
it { should be_a
|
71
|
+
it { should be_a described_class }
|
71
72
|
it { should include "FOO" }
|
72
73
|
it { should_not include "WIZ" }
|
73
74
|
end
|
74
75
|
|
75
76
|
describe "#reject" do
|
76
77
|
subject { rash.reject { |key, value| value.is_a? String } }
|
77
|
-
it { should be_a
|
78
|
+
it { should be_a described_class }
|
78
79
|
it { should include "WIZ" }
|
79
80
|
it { should_not include "FOO" }
|
80
81
|
end
|
@@ -83,5 +84,4 @@ describe StackerBee::Rash do
|
|
83
84
|
subject { rash.values_at "FOO", "WIZ", "WRONG" }
|
84
85
|
it { should == ["foo", wiz, nil] }
|
85
86
|
end
|
86
|
-
|
87
87
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "An error occuring" do
|
4
|
-
let(:env) { double
|
5
|
-
let(:response) { double
|
4
|
+
let(:env) { double(response: response) }
|
5
|
+
let(:response) { double(status: status, error: error_text) }
|
6
6
|
let(:error_text) { "There was an error!" }
|
7
7
|
let(:status) { 431 }
|
8
8
|
|
9
9
|
describe StackerBee::RequestError, ".for" do
|
10
|
-
subject {
|
10
|
+
subject { described_class.for(env) }
|
11
11
|
|
12
12
|
context "HTTP status in the 400s" do
|
13
13
|
let(:status) { 431 }
|
@@ -24,7 +24,7 @@ describe "An error occuring" do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe StackerBee::RequestError do
|
27
|
-
subject {
|
27
|
+
subject { described_class.new(env) }
|
28
28
|
|
29
29
|
its(:status) { should eq status }
|
30
30
|
its(:to_s) { should eq error_text }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stacker_bee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.0.
|
4
|
+
version: 2.1.0.pre185
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Sterndale
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-04-
|
12
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|