stacker_bee 2.0.0.pre178 → 2.0.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 +5 -13
- data/.travis.yml +1 -13
- data/README.md +64 -104
- data/bin/stacker_bee +3 -4
- data/lib/stacker_bee/body_parser.rb +1 -11
- data/lib/stacker_bee/client.rb +1 -30
- data/lib/stacker_bee/connection.rb +10 -12
- data/lib/stacker_bee/dictionary_flattener.rb +12 -12
- data/lib/stacker_bee/graylog_faraday_middleware.rb +2 -3
- data/lib/stacker_bee/middleware/logger.rb +47 -0
- data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/{a_request_parameter_with_a_map → a_request_parameter_with_a_Map}/can_create_an_object.yml +0 -0
- data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/object.yml +153 -0
- data/spec/spec_helper.rb +0 -4
- data/spec/units/faraday_graylog_middleware_spec.rb +1 -1
- data/spec/units/stacker_bee/client_spec.rb +7 -48
- data/spec/units/stacker_bee/connection_spec.rb +7 -32
- data/spec/units/stacker_bee/graylog_faraday_middleware_spec.rb +1 -17
- data/spec/units/stacker_bee/middleware/logger_spec.rb +55 -0
- data/spec/units/stacker_bee/request_error_spec.rb +3 -7
- data/spec/units/stacker_bee/response_spec.rb +4 -18
- data/stacker_bee.gemspec +2 -6
- metadata +23 -30
- data/spec/cassettes/A_request_sent_to_CloudStack_for_console_access/returns_html_for_console_access.yml +0 -34
- data/spec/integration/console_spec.rb +0 -23
- data/spec/units/stacker_bee/console_spec.rb +0 -0
@@ -0,0 +1,153 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=listZones&response=json&signature=/MnHgTBKGc%2BXx0Z8KwMllvw92vg=
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.8.8
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- ! '*/*'
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- text/javascript; charset=UTF-8
|
23
|
+
Content-Length:
|
24
|
+
- '403'
|
25
|
+
Server:
|
26
|
+
- Jetty(6.1.26)
|
27
|
+
body:
|
28
|
+
encoding: US-ASCII
|
29
|
+
string: ! '{ "listzonesresponse" : { "count":1 ,"zone" : [ {"id":"39e9e31e-925c-4b55-8d33-f99912b73dfc","name":"Sandbox-simulator","dns1":"10.147.28.6","internaldns1":"10.147.28.6","guestcidraddress":"10.1.1.0/24","networktype":"Advanced","securitygroupsenabled":false,"allocationstate":"Enabled","zonetoken":"ea3acbc4-cae8-3b82-b42f-7492ddfede00","dhcpprovider":"VirtualRouter","localstorageenabled":false}
|
30
|
+
] } }'
|
31
|
+
http_version:
|
32
|
+
recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
|
33
|
+
- request:
|
34
|
+
method: get
|
35
|
+
uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=listNetworkOfferings&response=json&signature=BAdYatJ5Rjcffi6sU8P%2BZtLhSF8=&supportedServices=sourcenat&type=isolated
|
36
|
+
body:
|
37
|
+
encoding: US-ASCII
|
38
|
+
string: ''
|
39
|
+
headers:
|
40
|
+
User-Agent:
|
41
|
+
- Faraday v0.8.8
|
42
|
+
Accept-Encoding:
|
43
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
44
|
+
Accept:
|
45
|
+
- ! '*/*'
|
46
|
+
response:
|
47
|
+
status:
|
48
|
+
code: 200
|
49
|
+
message: OK
|
50
|
+
headers:
|
51
|
+
Content-Type:
|
52
|
+
- text/javascript; charset=UTF-8
|
53
|
+
Content-Length:
|
54
|
+
- '6006'
|
55
|
+
Server:
|
56
|
+
- Jetty(6.1.26)
|
57
|
+
body:
|
58
|
+
encoding: US-ASCII
|
59
|
+
string: ! '{ "listnetworkofferingsresponse" : { "count":4 ,"networkoffering"
|
60
|
+
: [ {"id":"fa126319-f822-4786-9cd3-30bd0c55ca94","name":"DefaultIsolatedNetworkOfferingWithSourceNatService","displaytext":"Offering
|
61
|
+
for Isolated networks with Source Nat service enabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":true,"specifyipranges":false,"availability":"Required","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VirtualRouter"}]},{"name":"UserData","provider":[{"name":"VirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VirtualRouter"}]},{"name":"Firewall","provider":[{"name":"VirtualRouter"}]},{"name":"Lb","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]}],"forvpc":false,"ispersistent":false,"egressdefaultpolicy":false},
|
62
|
+
{"id":"7e70b3b5-5e2c-42cb-9b49-93a87c13a675","name":"DefaultIsolatedNetworkOfferingForVpcNetworks","displaytext":"Offering
|
63
|
+
for Isolated Vpc networks with Source Nat service enabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Lb","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VpcVirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false},
|
64
|
+
{"id":"a9d78d52-f306-44c5-bb6d-c121a507db05","name":"DefaultIsolatedNetworkOfferingForVpcNetworksNoLB","displaytext":"Offering
|
65
|
+
for Isolated Vpc networks with Source Nat service enabled and LB service Disabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VpcVirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false},
|
66
|
+
{"id":"f9a7b0d0-ce61-4f8d-a360-be1040d67287","name":"DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB","displaytext":"Offering
|
67
|
+
for Isolated Vpc networks with Internal LB support","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Lb","provider":[{"name":"InternalLbVm"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false}
|
68
|
+
] } }'
|
69
|
+
http_version:
|
70
|
+
recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
|
71
|
+
- request:
|
72
|
+
method: get
|
73
|
+
uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=createNetwork&displaytext=John&name=John&networkOfferingId=fa126319-f822-4786-9cd3-30bd0c55ca94&response=json&signature=UDcfFqlzwpHJib/9kLKzR0%2BCbyc=&zoneId=39e9e31e-925c-4b55-8d33-f99912b73dfc
|
74
|
+
body:
|
75
|
+
encoding: US-ASCII
|
76
|
+
string: ''
|
77
|
+
headers:
|
78
|
+
User-Agent:
|
79
|
+
- Faraday v0.8.8
|
80
|
+
Accept-Encoding:
|
81
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
82
|
+
Accept:
|
83
|
+
- ! '*/*'
|
84
|
+
response:
|
85
|
+
status:
|
86
|
+
code: 200
|
87
|
+
message: OK
|
88
|
+
headers:
|
89
|
+
Content-Type:
|
90
|
+
- text/javascript; charset=UTF-8
|
91
|
+
Content-Length:
|
92
|
+
- '4441'
|
93
|
+
Server:
|
94
|
+
- Jetty(6.1.26)
|
95
|
+
body:
|
96
|
+
encoding: US-ASCII
|
97
|
+
string: ! '{ "createnetworkresponse" : { "network" : {"id":"02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f","name":"John","displaytext":"John","broadcastdomaintype":"Vlan","traffictype":"Guest","gateway":"10.1.1.1","netmask":"255.255.255.0","cidr":"10.1.1.0/24","zoneid":"39e9e31e-925c-4b55-8d33-f99912b73dfc","zonename":"Sandbox-simulator","networkofferingid":"fa126319-f822-4786-9cd3-30bd0c55ca94","networkofferingname":"DefaultIsolatedNetworkOfferingWithSourceNatService","networkofferingdisplaytext":"Offering
|
98
|
+
for Isolated networks with Source Nat service enabled","networkofferingconservemode":true,"networkofferingavailability":"Required","issystem":false,"state":"Allocated","related":"02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f","dns1":"10.147.28.6","type":"Isolated","acltype":"Account","account":"admin","domainid":"ce4585b8-41f5-11e3-aaa7-d6558ad1fb9f","domain":"ROOT","service":[{"name":"SourceNat","capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"true","canchooseservicecapability":false}]},{"name":"Dns","capability":[{"name":"AllowDnsSuffixModification","value":"true","canchooseservicecapability":false}]},{"name":"UserData"},{"name":"PortForwarding"},{"name":"Firewall","capability":[{"name":"TrafficStatistics","value":"per
|
99
|
+
public ip","canchooseservicecapability":false},{"name":"SupportedTrafficDirection","value":"ingress,
|
100
|
+
egress","canchooseservicecapability":false},{"name":"SupportedProtocols","value":"tcp,udp,icmp","canchooseservicecapability":false},{"name":"MultipleIps","value":"true","canchooseservicecapability":false},{"name":"SupportedEgressProtocols","value":"tcp,udp,icmp,
|
101
|
+
all","canchooseservicecapability":false}]},{"name":"Lb","capability":[{"name":"SupportedLbAlgorithms","value":"roundrobin,leastconn,source","canchooseservicecapability":false},{"name":"LbSchemes","value":"Public","canchooseservicecapability":false},{"name":"SupportedStickinessMethods","value":"[{\"methodname\":\"LbCookie\",\"paramlist\":[{\"paramname\":\"cookie-name\",\"required\":false,\"isflag\":false,\"description\":\"
|
102
|
+
\"},{\"paramname\":\"mode\",\"required\":false,\"isflag\":false,\"description\":\"
|
103
|
+
\"},{\"paramname\":\"nocache\",\"required\":false,\"isflag\":true,\"description\":\"
|
104
|
+
\"},{\"paramname\":\"indirect\",\"required\":false,\"isflag\":true,\"description\":\"
|
105
|
+
\"},{\"paramname\":\"postonly\",\"required\":false,\"isflag\":true,\"description\":\"
|
106
|
+
\"},{\"paramname\":\"domain\",\"required\":false,\"isflag\":false,\"description\":\"
|
107
|
+
\"}],\"description\":\"This is loadbalancer cookie based stickiness method.\"},{\"methodname\":\"AppCookie\",\"paramlist\":[{\"paramname\":\"cookie-name\",\"required\":false,\"isflag\":false,\"description\":\"
|
108
|
+
\"},{\"paramname\":\"length\",\"required\":false,\"isflag\":false,\"description\":\"
|
109
|
+
\"},{\"paramname\":\"holdtime\",\"required\":false,\"isflag\":false,\"description\":\"
|
110
|
+
\"},{\"paramname\":\"request-learn\",\"required\":false,\"isflag\":true,\"description\":\"
|
111
|
+
\"},{\"paramname\":\"prefix\",\"required\":false,\"isflag\":true,\"description\":\"
|
112
|
+
\"},{\"paramname\":\"mode\",\"required\":false,\"isflag\":false,\"description\":\"
|
113
|
+
\"}],\"description\":\"This is App session based sticky method. Define session
|
114
|
+
stickiness on an existing application cookie. It can be used only for a specific
|
115
|
+
http traffic\"},{\"methodname\":\"SourceBased\",\"paramlist\":[{\"paramname\":\"tablesize\",\"required\":false,\"isflag\":false,\"description\":\"
|
116
|
+
\"},{\"paramname\":\"expire\",\"required\":false,\"isflag\":false,\"description\":\"
|
117
|
+
\"}],\"description\":\"This is source based Stickiness method, it can be used
|
118
|
+
for any type of protocol.\"}]","canchooseservicecapability":false},{"name":"SupportedProtocols","value":"tcp,
|
119
|
+
udp","canchooseservicecapability":false},{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false}]},{"name":"Dhcp","capability":[{"name":"DhcpAccrossMultipleSubnets","value":"true","canchooseservicecapability":false}]},{"name":"Vpn","capability":[{"name":"SupportedVpnTypes","value":"pptp,l2tp,ipsec","canchooseservicecapability":false},{"name":"VpnTypes","value":"removeaccessvpn","canchooseservicecapability":false}]},{"name":"StaticNat"}],"networkdomain":"cs2sandbox.simulator","physicalnetworkid":"46d08659-81e9-4f31-a589-a15aca972af0","restartrequired":false,"specifyipranges":false,"canusefordeploy":true,"ispersistent":false,"tags":[],"displaynetwork":true}
|
120
|
+
} }'
|
121
|
+
http_version:
|
122
|
+
recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
|
123
|
+
- request:
|
124
|
+
method: get
|
125
|
+
uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=createTags&resourceIds=02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f&resourceType=Network&response=json&signature=KnWoymoA3Q34Iz%2BZ9iFEc8R0lEo=&tags%5B0%5D%5B.key%5D=speed&tags%5B0%5D%5B.name%5D=speed&tags%5B0%5D%5B.value%5D=fast
|
126
|
+
body:
|
127
|
+
encoding: US-ASCII
|
128
|
+
string: ''
|
129
|
+
headers:
|
130
|
+
User-Agent:
|
131
|
+
- Faraday v0.8.8
|
132
|
+
Accept-Encoding:
|
133
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
134
|
+
Accept:
|
135
|
+
- ! '*/*'
|
136
|
+
response:
|
137
|
+
status:
|
138
|
+
code: 200
|
139
|
+
message: OK
|
140
|
+
headers:
|
141
|
+
Content-Type:
|
142
|
+
- text/javascript; charset=UTF-8
|
143
|
+
Content-Length:
|
144
|
+
- '75'
|
145
|
+
Server:
|
146
|
+
- Jetty(6.1.26)
|
147
|
+
body:
|
148
|
+
encoding: US-ASCII
|
149
|
+
string: ! '{ "createtagsresponse" : {"jobid":"90bdb3e9-dcd5-4aac-9aa9-1879863082cc"}
|
150
|
+
}'
|
151
|
+
http_version:
|
152
|
+
recorded_at: Wed, 18 Dec 2013 21:25:07 GMT
|
153
|
+
recorded_with: VCR 2.8.0
|
data/spec/spec_helper.rb
CHANGED
@@ -41,10 +41,6 @@ VCR.configure do |c|
|
|
41
41
|
c.filter_sensitive_data('<CLOUD_STACK_URL>') do
|
42
42
|
CONFIG["url"]
|
43
43
|
end
|
44
|
-
c.filter_sensitive_data('<CLOUD_STACK_HOST>') do
|
45
|
-
uri = URI.parse(CONFIG["url"])
|
46
|
-
"#{uri.scheme}://#{uri.host}:#{uri.port}"
|
47
|
-
end
|
48
44
|
c.filter_sensitive_data('<CLOUD_STACK_API_KEY>') do
|
49
45
|
CONFIG["api_key"]
|
50
46
|
end
|
@@ -11,7 +11,7 @@ describe FaradayMiddleware::Graylog do
|
|
11
11
|
let(:log_data) { logger.data }
|
12
12
|
let(:logger) { DummyLogger.new }
|
13
13
|
|
14
|
-
let(:dummy_adapter) { ->(env)
|
14
|
+
let(:dummy_adapter) { ->(env){ Faraday::Response.new(env) } }
|
15
15
|
let(:middleware) do
|
16
16
|
described_class.new(dummy_adapter, logger, facility: facility)
|
17
17
|
end
|
@@ -13,7 +13,7 @@ describe StackerBee::Client, ".api" do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe StackerBee::Client, "calling endpoint" do
|
16
|
-
let(:url) { "
|
16
|
+
let(:url) { "cloud-stack.com" }
|
17
17
|
let(:api_key) { "cloud-stack-api-key" }
|
18
18
|
let(:secret_key) { "cloud-stack-secret-key" }
|
19
19
|
let(:config_hash) do
|
@@ -42,7 +42,7 @@ describe StackerBee::Client, "calling endpoint" do
|
|
42
42
|
) do
|
43
43
|
request
|
44
44
|
end
|
45
|
-
connection.stub(:get).with(request
|
45
|
+
connection.stub(:get).with(request) { raw_response }
|
46
46
|
StackerBee::Response.stub(:new).with(raw_response) { response }
|
47
47
|
end
|
48
48
|
|
@@ -59,7 +59,7 @@ describe StackerBee::Client, "#request" do
|
|
59
59
|
let(:endpoint) { "listVirtualMachines" }
|
60
60
|
let(:params) { { list: :all } }
|
61
61
|
|
62
|
-
let(:url) { "
|
62
|
+
let(:url) { "cloud-stack.com" }
|
63
63
|
let(:api_key) { "cloud-stack-api-key" }
|
64
64
|
let(:secret_key) { "cloud-stack-secret-key" }
|
65
65
|
let(:config_hash) do
|
@@ -80,7 +80,7 @@ describe StackerBee::Client, "#request" do
|
|
80
80
|
StackerBee::Request.should_receive(:new).with(endpoint, api_key, params) do
|
81
81
|
request
|
82
82
|
end
|
83
|
-
connection.should_receive(:get).with(request
|
83
|
+
connection.should_receive(:get).with(request) { raw_response }
|
84
84
|
StackerBee::Response.should_receive(:new).with(raw_response) { response }
|
85
85
|
end
|
86
86
|
|
@@ -93,7 +93,7 @@ describe StackerBee::Client, "#request" do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
describe StackerBee::Client, "configuration" do
|
96
|
-
let(:default_url) { "
|
96
|
+
let(:default_url) { "default_cloud-stack.com" }
|
97
97
|
let(:default_api_key) { "default-cloud-stack-api-key" }
|
98
98
|
let(:default_secret_key) { "default-cloud-stack-secret-key" }
|
99
99
|
let(:default_config_hash) do
|
@@ -108,7 +108,7 @@ describe StackerBee::Client, "configuration" do
|
|
108
108
|
let!(:default_configuration) do
|
109
109
|
StackerBee::Configuration.new(default_config_hash)
|
110
110
|
end
|
111
|
-
let(:instance_url) { "
|
111
|
+
let(:instance_url) { "instance-cloud-stack.com" }
|
112
112
|
let(:instance_api_key) { "instance-cloud-stack-api-key" }
|
113
113
|
let(:instance_secret_key) { "instance-cloud-stack-secret-key" }
|
114
114
|
let(:instance_config_hash) do
|
@@ -163,7 +163,7 @@ describe StackerBee::Client, "configuration" do
|
|
163
163
|
end
|
164
164
|
|
165
165
|
describe "#url" do
|
166
|
-
let(:other_url) { "
|
166
|
+
let(:other_url) { "other-cloud-stack.com" }
|
167
167
|
before { subject.url = other_url }
|
168
168
|
its(:url) { should eq other_url }
|
169
169
|
end
|
@@ -181,44 +181,3 @@ describe StackerBee::Client, "configuration" do
|
|
181
181
|
end
|
182
182
|
end
|
183
183
|
end
|
184
|
-
|
185
|
-
describe StackerBee::Client, "#console_access" do
|
186
|
-
let(:config_hash) do
|
187
|
-
{
|
188
|
-
url: CONFIG["url"],
|
189
|
-
api_key: CONFIG["api_key"],
|
190
|
-
secret_key: CONFIG["secret_key"]
|
191
|
-
}
|
192
|
-
end
|
193
|
-
|
194
|
-
let(:client) do
|
195
|
-
StackerBee::Client.new(config_hash)
|
196
|
-
end
|
197
|
-
|
198
|
-
let(:vm) { "36f9c08b-f17a-4d0e-ac9b-d45ce2d34fcd" }
|
199
|
-
|
200
|
-
let(:body) { "<body></body>" }
|
201
|
-
let(:headers) { { 'content-type' => 'text/html' } }
|
202
|
-
let(:response_stub) do
|
203
|
-
double(StackerBee::Response, success?: true, body: body, headers: headers)
|
204
|
-
end
|
205
|
-
|
206
|
-
subject(:console_access) { client.console_access(vm: vm) }
|
207
|
-
|
208
|
-
it "makes a request with the consoleAccess endpoint" do
|
209
|
-
expect(client).to receive(:request).with(
|
210
|
-
"consoleAccess", cmd: 'access', vm: vm
|
211
|
-
)
|
212
|
-
|
213
|
-
console_access
|
214
|
-
end
|
215
|
-
|
216
|
-
it "makes a get request to the connection" do
|
217
|
-
expect(client.send(:connection)).to receive(:get) do |request, path|
|
218
|
-
expect(request.endpoint).to eq("consoleAccess")
|
219
|
-
expect(path).to eq("/client/console")
|
220
|
-
end.and_return(response_stub)
|
221
|
-
|
222
|
-
expect(console_access).to eq(body)
|
223
|
-
end
|
224
|
-
end
|
@@ -2,32 +2,26 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe StackerBee::Connection do
|
4
4
|
let(:url) { "http://test.com:1234/foo/bar/" }
|
5
|
-
let(:path) { "/foo/bar" }
|
6
5
|
let(:secret_key) { "shhh" }
|
6
|
+
let(:configuration) { double url: url, secret_key: secret_key }
|
7
7
|
let(:query_params) { [[:foo, :bar]] }
|
8
8
|
let(:request) { double query_params: query_params }
|
9
9
|
let(:response) { double }
|
10
10
|
let(:faraday) { double get: response }
|
11
11
|
let(:connection) { StackerBee::Connection.new configuration }
|
12
|
-
|
13
|
-
double url: url, secret_key: secret_key, ssl_verify: nil
|
14
|
-
end
|
15
|
-
|
16
|
-
subject(:get) { connection.get request, path }
|
17
|
-
|
12
|
+
subject { connection.get request }
|
18
13
|
before do
|
19
14
|
Faraday.stub(:new) { faraday }
|
20
15
|
end
|
21
16
|
|
22
17
|
context "successfully connecting" do
|
23
18
|
before do
|
24
|
-
faraday.should_receive(:get).with('/foo/bar', query_params) { response }
|
19
|
+
faraday.should_receive(:get).with('/foo/bar/', query_params) { response }
|
25
20
|
end
|
26
21
|
it { should be response }
|
27
22
|
it "specifies url without path when creating connection" do
|
28
|
-
|
29
|
-
Faraday.should have_received(:new).with(url: "http://test.com:1234"
|
30
|
-
ssl: { verify: true })
|
23
|
+
subject
|
24
|
+
Faraday.should have_received(:new).with(url: "http://test.com:1234")
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
@@ -37,7 +31,7 @@ describe StackerBee::Connection do
|
|
37
31
|
end
|
38
32
|
it "should raise helpful exception" do
|
39
33
|
klass = StackerBee::ConnectionError
|
40
|
-
expect {
|
34
|
+
expect(-> { subject }).to raise_error klass, /#{url}/
|
41
35
|
end
|
42
36
|
end
|
43
37
|
|
@@ -45,26 +39,7 @@ describe StackerBee::Connection do
|
|
45
39
|
let(:url) { "wrong.com" }
|
46
40
|
it "should raise helpful exception" do
|
47
41
|
klass = StackerBee::ConnectionError
|
48
|
-
expect {
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context "when given a path" do
|
53
|
-
let(:path) { '/baz' }
|
54
|
-
it "makes a request to the correct path" do
|
55
|
-
expect(faraday).to receive(:get).with(path, query_params)
|
56
|
-
connection.get request, path
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "when verifying an ssl connection" do
|
61
|
-
let(:configuration) do
|
62
|
-
double url: url, secret_key: secret_key, ssl_verify: false
|
63
|
-
end
|
64
|
-
it "specifies the ssl verify option when creating a connection" do
|
65
|
-
get
|
66
|
-
Faraday.should have_received(:new).with(url: "http://test.com:1234",
|
67
|
-
ssl: { verify: false })
|
42
|
+
expect(-> { subject }).to raise_error klass, /no protocol/
|
68
43
|
end
|
69
44
|
end
|
70
45
|
end
|
@@ -11,7 +11,7 @@ describe StackerBee::GraylogFaradayMiddleware do
|
|
11
11
|
let(:log_data) { logger.data }
|
12
12
|
let(:logger) { DummyLogger.new }
|
13
13
|
|
14
|
-
let(:dummy_adapter) { ->(env)
|
14
|
+
let(:dummy_adapter) { ->(env){ Faraday::Response.new(env) } }
|
15
15
|
let(:middleware) { described_class.new(dummy_adapter, logger) }
|
16
16
|
let(:status) { 200 }
|
17
17
|
|
@@ -32,20 +32,4 @@ describe StackerBee::GraylogFaradayMiddleware do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
its([:facility]) { should == "stacker-bee" }
|
35
|
-
|
36
|
-
context "without a command in the url" do
|
37
|
-
let(:env) do
|
38
|
-
{
|
39
|
-
body: "DATA",
|
40
|
-
response_headers: {},
|
41
|
-
response: {},
|
42
|
-
status: status,
|
43
|
-
url: URI.parse("http://a.b/?key=KEY&&val=val")
|
44
|
-
}
|
45
|
-
end
|
46
|
-
|
47
|
-
it "sets a custom short message" do
|
48
|
-
log_data[:short_message].should eq "StackerBee"
|
49
|
-
end
|
50
|
-
end
|
51
35
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe StackerBee::Middleware::Logger do
|
4
|
+
let(:app) { double }
|
5
|
+
let(:io) { StringIO.new }
|
6
|
+
let(:logger) { Logger.new(io) }
|
7
|
+
let(:log_string) { io.string }
|
8
|
+
let(:middleware) { described_class.new app, logger }
|
9
|
+
subject { middleware }
|
10
|
+
|
11
|
+
context "with a no logger specified" do
|
12
|
+
let(:middleware) { described_class.new app, nil }
|
13
|
+
its(:logger) { should be_a Logger }
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "logging request" do
|
17
|
+
let(:env) do
|
18
|
+
{
|
19
|
+
method: "PATCH",
|
20
|
+
url: "http://localhost",
|
21
|
+
request_headers: { "User-Agent" => "RSpec" }
|
22
|
+
}
|
23
|
+
end
|
24
|
+
before do
|
25
|
+
middleware.log_request(env)
|
26
|
+
end
|
27
|
+
subject { log_string }
|
28
|
+
it { should include "PATCH" }
|
29
|
+
it { should include "localhost" }
|
30
|
+
it { should include "User-Agent" }
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "logging a response" do
|
34
|
+
let(:status) { 200 }
|
35
|
+
let(:env) do
|
36
|
+
{
|
37
|
+
status: status,
|
38
|
+
body: "OK",
|
39
|
+
response_headers: { "Server" => "RSpec" }
|
40
|
+
}
|
41
|
+
end
|
42
|
+
before do
|
43
|
+
middleware.log_response(env)
|
44
|
+
end
|
45
|
+
subject { log_string }
|
46
|
+
it { should =~ /INFO.*#{status}/ }
|
47
|
+
it { should include "OK" }
|
48
|
+
it { should include "Server" }
|
49
|
+
|
50
|
+
context "failing status" do
|
51
|
+
let(:status) { 401 }
|
52
|
+
it { should =~ /ERROR.*#{status}/ }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe StackerBee::RequestError, ".for" do
|
4
|
-
let(:raw_response)
|
5
|
-
double status: status, body: '{"foo": "bar"}', headers: {}
|
6
|
-
end
|
4
|
+
let(:raw_response) { double status: status, body: '{"foo": "bar"}' }
|
7
5
|
subject { StackerBee::RequestError.for raw_response }
|
8
6
|
|
9
7
|
context "HTTP status in the 400s" do
|
@@ -23,7 +21,7 @@ end
|
|
23
21
|
describe StackerBee::RequestError do
|
24
22
|
let(:http_status) { 431 }
|
25
23
|
let(:message) do
|
26
|
-
"Unable to execute API command deployvirtualmachine "
|
24
|
+
"Unable to execute API command deployvirtualmachine " +
|
27
25
|
"due to missing parameter zoneid"
|
28
26
|
end
|
29
27
|
let(:raw_body) do
|
@@ -38,9 +36,7 @@ describe StackerBee::RequestError do
|
|
38
36
|
}
|
39
37
|
EOS
|
40
38
|
end
|
41
|
-
let(:raw_response)
|
42
|
-
double body: raw_body, :success? => false, status: 431, headers: {}
|
43
|
-
end
|
39
|
+
let(:raw_response) { double body: raw_body, :success? => false, status: 431 }
|
44
40
|
let(:client_error) { StackerBee::ClientError.new raw_response }
|
45
41
|
subject { client_error }
|
46
42
|
its(:status) { should eq http_status }
|
@@ -2,12 +2,8 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe StackerBee::Response do
|
4
4
|
let(:raw_body) { '{ "json": "here" }' }
|
5
|
-
let(:raw_response)
|
6
|
-
|
7
|
-
end
|
8
|
-
let(:response) { StackerBee::Response.new raw_response }
|
9
|
-
let(:headers) { { 'content-type' => content_type } }
|
10
|
-
let(:content_type) { "application/json; charset=UTF-8" }
|
5
|
+
let(:raw_response) { double body: raw_body, :success? => true }
|
6
|
+
let(:response) { StackerBee::Response.new raw_response }
|
11
7
|
subject { response }
|
12
8
|
its(:body) { should == 'here' }
|
13
9
|
|
@@ -48,8 +44,7 @@ describe StackerBee::Response do
|
|
48
44
|
double(
|
49
45
|
:body => '{ "foo": "bar" }',
|
50
46
|
:success? => false,
|
51
|
-
:status => 431
|
52
|
-
:headers => {}
|
47
|
+
:status => 431
|
53
48
|
)
|
54
49
|
end
|
55
50
|
it { expect { subject }.to raise_exception StackerBee::ClientError }
|
@@ -67,8 +62,7 @@ describe StackerBee::Response do
|
|
67
62
|
{ "createprojectresponse" :
|
68
63
|
{"uuidList":[],"errorcode":401,"errortext":"#{message}"} } ],
|
69
64
|
success?: false,
|
70
|
-
status: 401
|
71
|
-
headers: {}
|
65
|
+
status: 401
|
72
66
|
)
|
73
67
|
end
|
74
68
|
let(:client_error) { StackerBee::AuthenticationError.new raw_response }
|
@@ -82,12 +76,4 @@ describe StackerBee::Response do
|
|
82
76
|
end
|
83
77
|
end
|
84
78
|
|
85
|
-
context "with an html response" do
|
86
|
-
let(:raw_body) { "<html><body>hi</body><html>" }
|
87
|
-
let(:content_type) { "text/html" }
|
88
|
-
|
89
|
-
it "returns the raw html without parsing" do
|
90
|
-
expect(response.body).to eq(raw_body)
|
91
|
-
end
|
92
|
-
end
|
93
79
|
end
|
data/stacker_bee.gemspec
CHANGED
@@ -19,11 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
spec.add_runtime_dependency "faraday", "~> 0.8"
|
23
|
-
spec.add_runtime_dependency 'multi_json', "~> 1.8"
|
24
|
-
|
22
|
+
spec.add_runtime_dependency "faraday", "~> 0.8"
|
25
23
|
# this is a dependency for FaradayMiddleware::Graylog
|
26
24
|
spec.add_runtime_dependency "faraday_middleware", "~> 0.9"
|
25
|
+
spec.add_runtime_dependency 'multi_json', "~> 1.8"
|
27
26
|
|
28
27
|
spec.add_development_dependency "bundler", "~> 1.3"
|
29
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -32,7 +31,4 @@ Gem::Specification.new do |spec|
|
|
32
31
|
spec.add_development_dependency "vcr", "~> 2.6"
|
33
32
|
spec.add_development_dependency "rubocop"
|
34
33
|
spec.add_development_dependency "pry"
|
35
|
-
|
36
|
-
# Release every merge to master as a prerelease
|
37
|
-
spec.version = "#{spec.version}.pre#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
|
38
34
|
end
|