nifty-cloud-sdk 1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +112 -0
- data/Gemfile +4 -0
- data/INSTALL +30 -0
- data/LICENSE.txt +58 -0
- data/README.rdoc +375 -0
- data/Rakefile +61 -0
- data/lib/NIFTY.rb +405 -0
- data/lib/NIFTY/Cloud.rb +24 -0
- data/lib/NIFTY/Cloud/availability_zones.rb +23 -0
- data/lib/NIFTY/Cloud/certificates.rb +283 -0
- data/lib/NIFTY/Cloud/images.rb +134 -0
- data/lib/NIFTY/Cloud/instances.rb +372 -0
- data/lib/NIFTY/Cloud/keypairs.rb +76 -0
- data/lib/NIFTY/Cloud/load_balancers.rb +433 -0
- data/lib/NIFTY/Cloud/security_groups.rb +357 -0
- data/lib/NIFTY/Cloud/volumes.rb +140 -0
- data/lib/NIFTY/config.rb +41 -0
- data/lib/NIFTY/exceptions.rb +32 -0
- data/lib/NIFTY/responses.rb +19 -0
- data/lib/NIFTY/version.rb +3 -0
- data/nifty-cloud-sdk.gemspec +28 -0
- data/sample/availability_zones/describe-availability-zones.rb +37 -0
- data/sample/certificate/create-ssl-certificate.rb +41 -0
- data/sample/certificate/delete-ssl-certificate.rb +28 -0
- data/sample/certificate/describe-ssl-certificate-attribute.rb +58 -0
- data/sample/certificate/describe-ssl-certificates.rb +49 -0
- data/sample/certificate/download-ssl-certificate.rb +31 -0
- data/sample/certificate/modify-ssl-certificate-attribute.rb +29 -0
- data/sample/certificate/register-corporate-info-for-certificate.rb +57 -0
- data/sample/certificate/upload-ssl-certificate.rb +32 -0
- data/sample/images/create-image.rb +33 -0
- data/sample/images/delete-image.rb +26 -0
- data/sample/images/describe-images.rb +70 -0
- data/sample/images/modify-image-attribute.rb +33 -0
- data/sample/instances/cancel_copy_instances.rb +26 -0
- data/sample/instances/copy-instances.rb +41 -0
- data/sample/instances/describe-instance-attribute.rb +78 -0
- data/sample/instances/describe-instances.rb +100 -0
- data/sample/instances/modify-instance-attribute.rb +30 -0
- data/sample/instances/reboot-instances.rb +29 -0
- data/sample/instances/run-instances.rb +104 -0
- data/sample/instances/start-instances.rb +36 -0
- data/sample/instances/stop-instances.rb +35 -0
- data/sample/instances/terminate-instances.rb +34 -0
- data/sample/keypairs/create-key-pair.rb +31 -0
- data/sample/keypairs/delete-key-pair.rb +28 -0
- data/sample/keypairs/describe-key-pairs.rb +31 -0
- data/sample/load_balancers/configure-health-check.rb +41 -0
- data/sample/load_balancers/create-load-balancer.rb +35 -0
- data/sample/load_balancers/delete-load-balancer.rb +28 -0
- data/sample/load_balancers/deregister-instances-from-load-balancer.rb +35 -0
- data/sample/load_balancers/describe-instance-health.rb +36 -0
- data/sample/load_balancers/describe-load-balancers.rb +89 -0
- data/sample/load_balancers/register-instances-with-load-balancer.rb +33 -0
- data/sample/load_balancers/register-port-with-load-balancer.rb +37 -0
- data/sample/load_balancers/set-filter-for-load-balancer.rb +38 -0
- data/sample/load_balancers/update-load-balancer.rb +33 -0
- data/sample/security_groups/authorize-security-group-ingress.rb +36 -0
- data/sample/security_groups/create-security-group.rb +29 -0
- data/sample/security_groups/delete-security-group.rb +28 -0
- data/sample/security_groups/deregister-instances-from-security-group.rb +31 -0
- data/sample/security_groups/describe-security-activities.rb +33 -0
- data/sample/security_groups/describe-security-groups.rb +59 -0
- data/sample/security_groups/register-instances-with-security-group.rb +31 -0
- data/sample/security_groups/revoke-security-group-ingress.rb +36 -0
- data/sample/security_groups/update-security-group.rb +30 -0
- data/sample/volumes/attach-volumes.rb +34 -0
- data/sample/volumes/create-volume.rb +38 -0
- data/sample/volumes/delete-volume.rb +28 -0
- data/sample/volumes/describe-volumes.rb +44 -0
- data/sample/volumes/detach-volume.rb +35 -0
- data/test/test_Cloud.rb +186 -0
- data/test/test_Cloud_availability_zones.rb +50 -0
- data/test/test_Cloud_certificates.rb +627 -0
- data/test/test_Cloud_images.rb +284 -0
- data/test/test_Cloud_instances.rb +941 -0
- data/test/test_Cloud_keypairs.rb +177 -0
- data/test/test_Cloud_load_balancers.rb +1183 -0
- data/test/test_Cloud_responses.rb +43 -0
- data/test/test_Cloud_security_groups.rb +699 -0
- data/test/test_Cloud_volumes.rb +325 -0
- data/test/test_helper.rb +23 -0
- metadata +275 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
#--
|
2
|
+
# ニフティクラウドSDK for Ruby
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: nifty-cloud-sdk
|
5
|
+
# Author:: NIFTY Corporation
|
6
|
+
# Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://cloud.nifty.com/api/
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "key_pairs" do
|
14
|
+
|
15
|
+
before do
|
16
|
+
@api = NIFTY::Cloud::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret",
|
17
|
+
:server => 'cp.cloud.nifty.com', :path => '/api/1.7/', :user_agent => 'NIFTY Cloud API Ruby SDK',
|
18
|
+
:signature_version => '2', :signature_method => 'HmacSHA256')
|
19
|
+
|
20
|
+
@create_key_pair_response_body = <<-RESPONSE
|
21
|
+
<Createkey_pairResponse xmlns="http://cp.cloud.nifty.com/api/1.7/">
|
22
|
+
<keyName>gsg-key_pair</keyName>
|
23
|
+
<keyFingerprint>1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f</keyFingerprint>
|
24
|
+
<keyMaterial>-----BEGIN RSA PRIVATE KEY-----
|
25
|
+
MIIEoQIBAAKCAQBuLFg5ujHrtm1jnutSuoO8Xe56LlT+HM8v/xkaa39EstM3/aFxTHgElQiJLChp
|
26
|
+
HungXQ29VTc8rc1bW0lkdi23OH5eqkMHGhvEwqa0HWASUMll4o3o/IX+0f2UcPoKCOVUR+jx71Sg
|
27
|
+
5AU52EQfanIn3ZQ8lFW7Edp5a3q4DhjGlUKToHVbicL5E+g45zfB95wIyywWZfeW/UUF3LpGZyq/
|
28
|
+
ebIUlq1qTbHkLbCC2r7RTn8vpQWp47BGVYGtGSBMpTRP5hnbzzuqj3itkiLHjU39S2sJCJ0TrJx5
|
29
|
+
i8BygR4s3mHKBj8l+ePQxG1kGbF6R4yg6sECmXn17MRQVXODNHZbAgMBAAECggEAY1tsiUsIwDl5
|
30
|
+
91CXirkYGuVfLyLflXenxfI50mDFms/mumTqloHO7tr0oriHDR5K7wMcY/YY5YkcXNo7mvUVD1pM
|
31
|
+
ZNUJs7rw9gZRTrf7LylaJ58kOcyajw8TsC4e4LPbFaHwS1d6K8rXh64o6WgW4SrsB6ICmr1kGQI7
|
32
|
+
3wcfgt5ecIu4TZf0OE9IHjn+2eRlsrjBdeORi7KiUNC/pAG23I6MdDOFEQRcCSigCj+4/mciFUSA
|
33
|
+
SWS4dMbrpb9FNSIcf9dcLxVM7/6KxgJNfZc9XWzUw77Jg8x92Zd0fVhHOux5IZC+UvSKWB4dyfcI
|
34
|
+
tE8C3p9bbU9VGyY5vLCAiIb4qQKBgQDLiO24GXrIkswF32YtBBMuVgLGCwU9h9HlO9mKAc2m8Cm1
|
35
|
+
jUE5IpzRjTedc9I2qiIMUTwtgnw42auSCzbUeYMURPtDqyQ7p6AjMujp9EPemcSVOK9vXYL0Ptco
|
36
|
+
xW9MC0dtV6iPkCN7gOqiZXPRKaFbWADp16p8UAIvS/a5XXk5jwKBgQCKkpHi2EISh1uRkhxljyWC
|
37
|
+
iDCiK6JBRsMvpLbc0v5dKwP5alo1fmdR5PJaV2qvZSj5CYNpMAy1/EDNTY5OSIJU+0KFmQbyhsbm
|
38
|
+
rdLNLDL4+TcnT7c62/aH01ohYaf/VCbRhtLlBfqGoQc7+sAc8vmKkesnF7CqCEKDyF/dhrxYdQKB
|
39
|
+
gC0iZzzNAapayz1+JcVTwwEid6j9JqNXbBc+Z2YwMi+T0Fv/P/hwkX/ypeOXnIUcw0Ih/YtGBVAC
|
40
|
+
DQbsz7LcY1HqXiHKYNWNvXgwwO+oiChjxvEkSdsTTIfnK4VSCvU9BxDbQHjdiNDJbL6oar92UN7V
|
41
|
+
rBYvChJZF7LvUH4YmVpHAoGAbZ2X7XvoeEO+uZ58/BGKOIGHByHBDiXtzMhdJr15HTYjxK7OgTZm
|
42
|
+
gK+8zp4L9IbvLGDMJO8vft32XPEWuvI8twCzFH+CsWLQADZMZKSsBasOZ/h1FwhdMgCMcY+Qlzd4
|
43
|
+
JZKjTSu3i7vhvx6RzdSedXEMNTZWN4qlIx3kR5aHcukCgYA9T+Zrvm1F0seQPbLknn7EqhXIjBaT
|
44
|
+
P8TTvW/6bdPi23ExzxZn7KOdrfclYRph1LHMpAONv/x2xALIf91UB+v5ohy1oDoasL0gij1houRe
|
45
|
+
2ERKKdwz0ZL9SWq6VTdhr/5G994CK72fy5WhyERbDjUIdHaK3M849JJuf8cSrvSb4g==
|
46
|
+
-----END RSA PRIVATE KEY-----</keyMaterial>
|
47
|
+
</Createkey_pairResponse>
|
48
|
+
RESPONSE
|
49
|
+
|
50
|
+
@describe_key_pairs_response_body = <<-RESPONSE
|
51
|
+
<Describekey_pairsResponse xmlns="http://xxxx.nifty.com/xxx/xxx/">
|
52
|
+
<keySet>
|
53
|
+
<item>
|
54
|
+
<keyName>gsg-key_pair</keyName>
|
55
|
+
<keyFingerprint>1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f</keyFingerprint>
|
56
|
+
</item>
|
57
|
+
</keySet>
|
58
|
+
</Describekey_pairsResponse>
|
59
|
+
RESPONSE
|
60
|
+
|
61
|
+
@delete_key_pair_response_body = <<-RESPONSE
|
62
|
+
<Deletekey_pairResponse xmlns="http://xxxx.nifty.com/xxx/xxx/">
|
63
|
+
<return>true</return>
|
64
|
+
</Deletekey_pairResponse>
|
65
|
+
RESPONSE
|
66
|
+
end
|
67
|
+
|
68
|
+
|
69
|
+
# create_key_pair
|
70
|
+
specify "create_key_pair - レスポンスを正しく解析できるか" do
|
71
|
+
@api.stubs(:exec_request).returns stub(:body => @create_key_pair_response_body, :is_a? => true)
|
72
|
+
response = @api.create_key_pair(:key_name => 'name', :password => 'pass')
|
73
|
+
response.keyName.should.equal 'gsg-key_pair'
|
74
|
+
response.keyFingerprint.should.equal '1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f'
|
75
|
+
response.keyMaterial.should.equal '-----BEGIN RSA PRIVATE KEY-----
|
76
|
+
MIIEoQIBAAKCAQBuLFg5ujHrtm1jnutSuoO8Xe56LlT+HM8v/xkaa39EstM3/aFxTHgElQiJLChp
|
77
|
+
HungXQ29VTc8rc1bW0lkdi23OH5eqkMHGhvEwqa0HWASUMll4o3o/IX+0f2UcPoKCOVUR+jx71Sg
|
78
|
+
5AU52EQfanIn3ZQ8lFW7Edp5a3q4DhjGlUKToHVbicL5E+g45zfB95wIyywWZfeW/UUF3LpGZyq/
|
79
|
+
ebIUlq1qTbHkLbCC2r7RTn8vpQWp47BGVYGtGSBMpTRP5hnbzzuqj3itkiLHjU39S2sJCJ0TrJx5
|
80
|
+
i8BygR4s3mHKBj8l+ePQxG1kGbF6R4yg6sECmXn17MRQVXODNHZbAgMBAAECggEAY1tsiUsIwDl5
|
81
|
+
91CXirkYGuVfLyLflXenxfI50mDFms/mumTqloHO7tr0oriHDR5K7wMcY/YY5YkcXNo7mvUVD1pM
|
82
|
+
ZNUJs7rw9gZRTrf7LylaJ58kOcyajw8TsC4e4LPbFaHwS1d6K8rXh64o6WgW4SrsB6ICmr1kGQI7
|
83
|
+
3wcfgt5ecIu4TZf0OE9IHjn+2eRlsrjBdeORi7KiUNC/pAG23I6MdDOFEQRcCSigCj+4/mciFUSA
|
84
|
+
SWS4dMbrpb9FNSIcf9dcLxVM7/6KxgJNfZc9XWzUw77Jg8x92Zd0fVhHOux5IZC+UvSKWB4dyfcI
|
85
|
+
tE8C3p9bbU9VGyY5vLCAiIb4qQKBgQDLiO24GXrIkswF32YtBBMuVgLGCwU9h9HlO9mKAc2m8Cm1
|
86
|
+
jUE5IpzRjTedc9I2qiIMUTwtgnw42auSCzbUeYMURPtDqyQ7p6AjMujp9EPemcSVOK9vXYL0Ptco
|
87
|
+
xW9MC0dtV6iPkCN7gOqiZXPRKaFbWADp16p8UAIvS/a5XXk5jwKBgQCKkpHi2EISh1uRkhxljyWC
|
88
|
+
iDCiK6JBRsMvpLbc0v5dKwP5alo1fmdR5PJaV2qvZSj5CYNpMAy1/EDNTY5OSIJU+0KFmQbyhsbm
|
89
|
+
rdLNLDL4+TcnT7c62/aH01ohYaf/VCbRhtLlBfqGoQc7+sAc8vmKkesnF7CqCEKDyF/dhrxYdQKB
|
90
|
+
gC0iZzzNAapayz1+JcVTwwEid6j9JqNXbBc+Z2YwMi+T0Fv/P/hwkX/ypeOXnIUcw0Ih/YtGBVAC
|
91
|
+
DQbsz7LcY1HqXiHKYNWNvXgwwO+oiChjxvEkSdsTTIfnK4VSCvU9BxDbQHjdiNDJbL6oar92UN7V
|
92
|
+
rBYvChJZF7LvUH4YmVpHAoGAbZ2X7XvoeEO+uZ58/BGKOIGHByHBDiXtzMhdJr15HTYjxK7OgTZm
|
93
|
+
gK+8zp4L9IbvLGDMJO8vft32XPEWuvI8twCzFH+CsWLQADZMZKSsBasOZ/h1FwhdMgCMcY+Qlzd4
|
94
|
+
JZKjTSu3i7vhvx6RzdSedXEMNTZWN4qlIx3kR5aHcukCgYA9T+Zrvm1F0seQPbLknn7EqhXIjBaT
|
95
|
+
P8TTvW/6bdPi23ExzxZn7KOdrfclYRph1LHMpAONv/x2xALIf91UB+v5ohy1oDoasL0gij1houRe
|
96
|
+
2ERKKdwz0ZL9SWq6VTdhr/5G994CK72fy5WhyERbDjUIdHaK3M849JJuf8cSrvSb4g==
|
97
|
+
-----END RSA PRIVATE KEY-----'
|
98
|
+
end
|
99
|
+
|
100
|
+
specify "create_key_pair - パラメータが正しく作られるか" do
|
101
|
+
@api.stubs(:make_request).with("Action" => "CreateKeyPair",
|
102
|
+
"KeyName" => "a",
|
103
|
+
"Password" => "a"
|
104
|
+
).returns stub(:body => @create_key_pair_response_body, :is_a? => true)
|
105
|
+
@api.stubs(:exec_request).returns stub(:body => @create_key_pair_response_body, :is_a? => true)
|
106
|
+
response = @api.create_key_pair(:key_name => "a", :password => "a")
|
107
|
+
end
|
108
|
+
|
109
|
+
specify "create_key_pair - :key_name, :password正常" do
|
110
|
+
@api.stubs(:exec_request).returns stub(:body => @create_key_pair_response_body, :is_a? => true)
|
111
|
+
lambda { @api.create_key_pair(:key_name => 'foo', :password => 'bar') }.should.not.raise(NIFTY::ArgumentError)
|
112
|
+
end
|
113
|
+
|
114
|
+
specify "create_key_pair - :key_name未指定" do
|
115
|
+
lambda { @api.create_key_pair }.should.raise(NIFTY::ArgumentError)
|
116
|
+
lambda { @api.create_key_pair(:key_name => nil) }.should.raise(NIFTY::ArgumentError)
|
117
|
+
lambda { @api.create_key_pair(:key_name => '') }.should.raise(NIFTY::ArgumentError)
|
118
|
+
end
|
119
|
+
|
120
|
+
specify "create_key_pair - :password未指定" do
|
121
|
+
lambda { @api.create_key_pair(:key_name => 'foo') }.should.raise(NIFTY::ArgumentError)
|
122
|
+
lambda { @api.create_key_pair(:key_name => 'foo', :password => nil) }.should.raise(NIFTY::ArgumentError)
|
123
|
+
lambda { @api.create_key_pair(:key_name => 'foo', :password => '') }.should.raise(NIFTY::ArgumentError)
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# describe_key_pairs
|
128
|
+
specify "describe_key_pairs - レスポンスを正しく解析できるか" do
|
129
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_key_pairs_response_body, :is_a? => true)
|
130
|
+
response = @api.describe_key_pairs
|
131
|
+
response.keySet.item[0].keyName.should.equal 'gsg-key_pair'
|
132
|
+
response.keySet.item[0].keyFingerprint.should.equal '1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f'
|
133
|
+
end
|
134
|
+
|
135
|
+
specify "describe_key_pairs - パラメータが正しく作られるか" do
|
136
|
+
@api.stubs(:make_request).with("Action" => "DescribeKeyPairs",
|
137
|
+
"KeyName.1" => "a",
|
138
|
+
"KeyName.2" => "a"
|
139
|
+
).returns stub(:body => @describe_key_pairs_response_body, :is_a? => true)
|
140
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_key_pairs_response_body, :is_a? => true)
|
141
|
+
response = @api.describe_key_pairs(:key_name => %w(a a))
|
142
|
+
end
|
143
|
+
|
144
|
+
specify "describe_key_pairs - :key_name正常" do
|
145
|
+
@api.stubs(:exec_request).returns stub(:body => @create_key_pair_response_body, :is_a? => true)
|
146
|
+
lambda { @api.describe_key_pairs(:key_name => 'foo') }.should.not.raise(NIFTY::ArgumentError)
|
147
|
+
lambda { @api.describe_key_pairs(:key_name => ['foo', 'bar']) }.should.not.raise(NIFTY::ArgumentError)
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
# delete_key_pairs
|
152
|
+
specify "delete_key_pair - レスポンスを正しく解析できるか" do
|
153
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_key_pair_response_body, :is_a? => true)
|
154
|
+
response = @api.delete_key_pair(:key_name => 'name')
|
155
|
+
response.return.should.equal 'true'
|
156
|
+
end
|
157
|
+
|
158
|
+
specify "delete_key_pair - パラメータが正しく作られるか" do
|
159
|
+
@api.stubs(:make_request).with("Action" => "DeleteKeyPair",
|
160
|
+
"KeyName" => "a"
|
161
|
+
).returns stub(:body => @delete_key_pair_response_body, :is_a? => true)
|
162
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_key_pair_response_body, :is_a? => true)
|
163
|
+
response = @api.delete_key_pair(:key_name => "a")
|
164
|
+
end
|
165
|
+
|
166
|
+
specify "delete_key_pair - :key_name正常" do
|
167
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_key_pair_response_body, :is_a? => true)
|
168
|
+
lambda { @api.delete_key_pair(:key_name => 'foo') }.should.not.raise(NIFTY::ArgumentError)
|
169
|
+
end
|
170
|
+
|
171
|
+
specify "delete_key_pair - :key_name未指定" do
|
172
|
+
lambda { @api.delete_key_pair }.should.raise(NIFTY::ArgumentError)
|
173
|
+
lambda { @api.delete_key_pair(:key_name => nil) }.should.raise(NIFTY::ArgumentError)
|
174
|
+
lambda { @api.delete_key_pair(:key_name => '') }.should.raise(NIFTY::ArgumentError)
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
@@ -0,0 +1,1183 @@
|
|
1
|
+
#--
|
2
|
+
# ニフティクラウドSDK for Ruby
|
3
|
+
#
|
4
|
+
# Ruby Gem Name:: nifty-cloud-sdk
|
5
|
+
# Author:: NIFTY Corporation
|
6
|
+
# Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
|
7
|
+
# License:: Distributes under the same terms as Ruby
|
8
|
+
# Home:: http://cloud.nifty.com/api/
|
9
|
+
#++
|
10
|
+
|
11
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
12
|
+
|
13
|
+
context "load_balancers" do
|
14
|
+
before do
|
15
|
+
@api = NIFTY::Cloud::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret",
|
16
|
+
:server => 'cp.cloud.nifty.com', :path => '/api/1.7/', :user_agent => 'NIFTY Cloud API Ruby SDK',
|
17
|
+
:signature_version => '2', :signature_method => 'HmacSHA256')
|
18
|
+
|
19
|
+
@valid_protocol = %w(HTTP HTTPS FTP)
|
20
|
+
@valid_port = [443, 80, 21, '443', '80', '21']
|
21
|
+
@valid_balancing_type = [1, 2, '1', '2']
|
22
|
+
@valid_network_volume = [10, 20, 30, 40, 100, 200, '10', '20', '30', '40', '100', '200']
|
23
|
+
@valid_ip_version = %w(v4 v6)
|
24
|
+
|
25
|
+
@basic_create_lb_params = {
|
26
|
+
:load_balancer_name => 'lb01',
|
27
|
+
:listeners => [{:protocol => 'HTTP', :instance_port => '80'}]
|
28
|
+
}
|
29
|
+
@basic_reg_instance_params = {
|
30
|
+
:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80,
|
31
|
+
:instances => 'server01'
|
32
|
+
}
|
33
|
+
@basic_dereg_instance_params = @basic_reg_instance_params
|
34
|
+
@basic_desc_instance_health_params = {:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80}
|
35
|
+
@basic_conf_health_params = {
|
36
|
+
:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :target => 'TCP:80', :interval => 30,
|
37
|
+
:unhealthy_threshold => 1
|
38
|
+
}
|
39
|
+
@basic_set_filter_params = {:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80}
|
40
|
+
|
41
|
+
@valid_delete_load_balancer_params = {
|
42
|
+
:load_balancer_name => 'Test Name'
|
43
|
+
}
|
44
|
+
|
45
|
+
@valid_describe_load_balancer_params = {
|
46
|
+
}
|
47
|
+
|
48
|
+
@valid_register_instances_with_load_balancer_params = {
|
49
|
+
:load_balancer_name => 'Test Name',
|
50
|
+
:instances => ['i-6055fa09']
|
51
|
+
}
|
52
|
+
|
53
|
+
@valid_deregister_instances_from_load_balancer_params = @valid_register_instances_with_load_balancer_params
|
54
|
+
|
55
|
+
@valid_configure_health_check_params = {
|
56
|
+
:load_balancer_name => 'Test Name',
|
57
|
+
:health_check => {
|
58
|
+
:target => 'HTTP:80/servlets-examples/servlet/',
|
59
|
+
:timeout => '2',
|
60
|
+
:interval => '5',
|
61
|
+
:unhealthy_threshold => '2',
|
62
|
+
:healthy_threshold => '2'}
|
63
|
+
}
|
64
|
+
|
65
|
+
@create_load_balancer_response_body = <<-RESPONSE
|
66
|
+
<CreateLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
67
|
+
<CreateLoadBalancerResult>
|
68
|
+
<DNSName>10.0.5.222</DNSName>
|
69
|
+
</CreateLoadBalancerResult>
|
70
|
+
<ResponseMetadata>
|
71
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
72
|
+
</ResponseMetadata>
|
73
|
+
</CreateLoadBalancerResponse>
|
74
|
+
RESPONSE
|
75
|
+
|
76
|
+
@update_load_balancer_response_body = <<-RESPONSE
|
77
|
+
<UpdateLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
78
|
+
<ResponseMetadata>
|
79
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
80
|
+
</ResponseMetadata>
|
81
|
+
</UpdateLoadBalancerResponse>
|
82
|
+
RESPONSE
|
83
|
+
|
84
|
+
@delete_load_balancer_response_body = <<-RESPONSE
|
85
|
+
<DeleteLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
86
|
+
<DeleteLoadBalancerResult />
|
87
|
+
<ResponseMetadata>
|
88
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
89
|
+
</ResponseMetadata>
|
90
|
+
</DeleteLoadBalancerResponse>
|
91
|
+
RESPONSE
|
92
|
+
|
93
|
+
@describe_load_balancers_response_body = <<-RESPONSE
|
94
|
+
<DescribeLoadBalancersResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
95
|
+
<DescribeLoadBalancersResult>
|
96
|
+
<LoadBalancerDescriptions>
|
97
|
+
<member>
|
98
|
+
<LoadBalancerName>lb0001</LoadBalancerName>
|
99
|
+
<DNSName>10.0.5.222</DNSName>
|
100
|
+
<NetworkVolume>10</NetworkVolume>
|
101
|
+
<ListenerDescriptions>
|
102
|
+
<member>
|
103
|
+
<Listener>
|
104
|
+
<Protocol>http</Protocol>
|
105
|
+
<LoadBalancerPort>80</LoadBalancerPort>
|
106
|
+
<InstancePort>80</InstancePort>
|
107
|
+
<balancingType>1</balancingType>
|
108
|
+
</Listener>
|
109
|
+
</member>
|
110
|
+
</ListenerDescriptions>
|
111
|
+
<Instances>
|
112
|
+
<member>
|
113
|
+
<InstanceId>server02</InstanceId>
|
114
|
+
<InstanceId>server03</InstanceId>
|
115
|
+
</member>
|
116
|
+
</Instances>
|
117
|
+
<HealthCheck>
|
118
|
+
<Target>TCP:80</Target>
|
119
|
+
<Interval>300</Interval>
|
120
|
+
<Timeout>30</Timeout>
|
121
|
+
<UnhealthyThreshold>1</UnhealthyThreshold>
|
122
|
+
<HealthyThreshold>1</HealthyThreshold>
|
123
|
+
</HealthCheck>
|
124
|
+
<Filter>
|
125
|
+
<FilterType>1</FilterType>
|
126
|
+
<IPAddresses>
|
127
|
+
<member>111.111.111.111</member>
|
128
|
+
<member>111.111.111.112</member>
|
129
|
+
</IPAddresses>
|
130
|
+
</Filter>
|
131
|
+
<AvailabilityZones>
|
132
|
+
<member>ap-japan-1a</member>
|
133
|
+
</AvailabilityZones>
|
134
|
+
<CreatedTime>2010-05-17T11:22:33.456Z</CreatedTime>
|
135
|
+
</member>
|
136
|
+
</LoadBalancerDescriptions>
|
137
|
+
<LoadBalancerDescriptions>
|
138
|
+
<member>
|
139
|
+
<LoadBalancerName>lb0001</LoadBalancerName>
|
140
|
+
<DNSName>10.0.5.222</DNSName>
|
141
|
+
<NetworkVolume>10</NetworkVolume>
|
142
|
+
<ListenerDescriptions>
|
143
|
+
<member>
|
144
|
+
<Protocol>http</Protocol>
|
145
|
+
<LoadBalancerPort>443</LoadBalancerPort>
|
146
|
+
<InstancePort>443</InstancePort>
|
147
|
+
<balancingType>2</balancingType>
|
148
|
+
</member>
|
149
|
+
</ListenerDescriptions>
|
150
|
+
<Instances>
|
151
|
+
<member>
|
152
|
+
<InstanceId>server02</InstanceId>
|
153
|
+
<InstanceId>server03</InstanceId>
|
154
|
+
</member>
|
155
|
+
</Instances>
|
156
|
+
<HealthCheck>
|
157
|
+
<Target>TCP:443</Target>
|
158
|
+
<Interval>300</Interval>
|
159
|
+
<Timeout>30</Timeout>
|
160
|
+
<UnhealthyThreshold>1</UnhealthyThreshold>
|
161
|
+
<HealthyThreshold>1</HealthyThreshold>
|
162
|
+
</HealthCheck>
|
163
|
+
<Filter>
|
164
|
+
<FilterType>1</FilterType>
|
165
|
+
<IPAddresses>
|
166
|
+
<member>*.*.*.*</member>
|
167
|
+
</IPAddresses>
|
168
|
+
</Filter>
|
169
|
+
<AvailabilityZones>
|
170
|
+
<member>ap-japan-1a</member>
|
171
|
+
</AvailabilityZones>
|
172
|
+
<CreatedTime>2010-05-17T11:22:43.789Z</CreatedTime>
|
173
|
+
</member>
|
174
|
+
</LoadBalancerDescriptions>
|
175
|
+
</DescribeLoadBalancersResult>
|
176
|
+
<ResponseMetadata>
|
177
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
178
|
+
</ResponseMetadata>
|
179
|
+
</DescribeLoadBalancersResponse>
|
180
|
+
RESPONSE
|
181
|
+
|
182
|
+
@register_port_with_load_balancer_response_body = <<-RESPONSE
|
183
|
+
<RegisterPortWithLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
184
|
+
<RegisterPortWithLoadBalancerResult>
|
185
|
+
<ListenerDescriptions>
|
186
|
+
<member>
|
187
|
+
<Listener>
|
188
|
+
<Protocol>http</Protocol>
|
189
|
+
<LoadBalancerPort>80</LoadBalancerPort>
|
190
|
+
<InstancePort>80</InstancePort>
|
191
|
+
<balancingType>1</balancingType>
|
192
|
+
</Listener>
|
193
|
+
</member>
|
194
|
+
<member>
|
195
|
+
<Listener>
|
196
|
+
<Protocol>https</Protocol>
|
197
|
+
<LoadBalancerPort>443</LoadBalancerPort>
|
198
|
+
<InstancePort>443</InstancePort>
|
199
|
+
<balancingType>1</balancingType>
|
200
|
+
</Listener>
|
201
|
+
</member>
|
202
|
+
</ListenerDescriptions>
|
203
|
+
</RegisterPortWithLoadBalancerResult>
|
204
|
+
<ResponseMetadata>
|
205
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
206
|
+
</ResponseMetadata>
|
207
|
+
</RegisterPortWithLoadBalancerResponse>
|
208
|
+
RESPONSE
|
209
|
+
|
210
|
+
@register_instances_with_load_balancer_response_body = <<-RESPONSE
|
211
|
+
<RegisterInstancesWithLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
212
|
+
<RegisterInstancesWithLoadBalancerResult>
|
213
|
+
<Instances>
|
214
|
+
<member>
|
215
|
+
<InstanceId>server02</InstanceId>
|
216
|
+
</member>
|
217
|
+
</Instances>
|
218
|
+
</RegisterInstancesWithLoadBalancerResult>
|
219
|
+
<ResponseMetadata>
|
220
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
221
|
+
</ResponseMetadata>
|
222
|
+
</RegisterInstancesWithLoadBalancerResponse>
|
223
|
+
RESPONSE
|
224
|
+
|
225
|
+
@deregister_instances_from_load_balancer_response_body = <<-RESPONSE
|
226
|
+
<DeregisterInstancesFromLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
227
|
+
<DeregisterInstancesFromLoadBalancerResult>
|
228
|
+
<Instances>
|
229
|
+
<member>
|
230
|
+
<InstanceId>server03</InstanceId>
|
231
|
+
</member>
|
232
|
+
</Instances>
|
233
|
+
</DeregisterInstancesFromLoadBalancerResult>
|
234
|
+
<ResponseMetadata>
|
235
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
236
|
+
</ResponseMetadata>
|
237
|
+
</DeregisterInstancesFromLoadBalancerResponse>
|
238
|
+
RESPONSE
|
239
|
+
|
240
|
+
@describe_instance_health_response_body = <<-RESPONSE
|
241
|
+
<DescribeInstanceHealthResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
242
|
+
<DescribeInstanceHealthResult>
|
243
|
+
<InstanceStates>
|
244
|
+
<member>
|
245
|
+
<InstanceId>server02</InstanceId>
|
246
|
+
<State>InService</State>
|
247
|
+
<ReasonCode>N/A</ReasonCode>
|
248
|
+
<Description>N/A</Description>
|
249
|
+
</member>
|
250
|
+
<member>
|
251
|
+
<InstanceId>server06</InstanceId>
|
252
|
+
<State>OutOfService</State>
|
253
|
+
<ReasonCode>ELB</ReasonCode>
|
254
|
+
<Description>Instance registration is still in progress</Description>
|
255
|
+
</member>
|
256
|
+
</InstanceStates>
|
257
|
+
</DescribeInstanceHealthResult>
|
258
|
+
<ResponseMetadata>
|
259
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
260
|
+
</ResponseMetadata>
|
261
|
+
</DescribeInstanceHealthResponse>
|
262
|
+
RESPONSE
|
263
|
+
|
264
|
+
@configure_health_check_response_body = <<-RESPONSE
|
265
|
+
<ConfigureHealthCheckResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
266
|
+
<ConfigureHealthCheckResult>
|
267
|
+
<HealthCheck>
|
268
|
+
<Target>TCP:80</Target>
|
269
|
+
<Interval>300</Interval>
|
270
|
+
<Timeout>30</Timeout>
|
271
|
+
<UnhealthyThreshold>3</UnhealthyThreshold>
|
272
|
+
<HealthyThreshold>1</HealthyThreshold>
|
273
|
+
</HealthCheck>
|
274
|
+
</ConfigureHealthCheckResult>
|
275
|
+
<ResponseMetadata>
|
276
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
277
|
+
</ResponseMetadata>
|
278
|
+
</ConfigureHealthCheckResponse>
|
279
|
+
RESPONSE
|
280
|
+
|
281
|
+
@set_filter_for_load_balancer_response_body = <<-RESPONSE
|
282
|
+
<SetFilterForLoadBalancerResponse xmlns="https://cp.cloud.nifty.com/api/1.5/">
|
283
|
+
<SetFilterForLoadBalancerResult>
|
284
|
+
<Filter>
|
285
|
+
<FilterType>1</FilterType>
|
286
|
+
<IPAddresses>
|
287
|
+
<member>111.111.111.111</member>
|
288
|
+
<member>111.111.111.112</member>
|
289
|
+
</IPAddresses>
|
290
|
+
</Filter>
|
291
|
+
</SetFilterForLoadBalancerResult>
|
292
|
+
<ResponseMetadata>
|
293
|
+
<RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
|
294
|
+
</ResponseMetadata>
|
295
|
+
</SetFilterForLoadBalancerResponse>
|
296
|
+
RESPONSE
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
# create_load_balancer
|
301
|
+
specify "create_load_balancer - レスポンスを正しく解析できるか" do
|
302
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
303
|
+
response = @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:protocol => 'HTTPS', :instance_port => 443})
|
304
|
+
response.CreateLoadBalancerResult.DNSName.should.equal '10.0.5.222'
|
305
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
306
|
+
end
|
307
|
+
|
308
|
+
specify "create_load_balancer - パラメータが正しく作られるか" do
|
309
|
+
@api.stubs(:make_request).with("Action" => "CreateLoadBalancer",
|
310
|
+
"LoadBalancerName" => "a",
|
311
|
+
"Listeners.member.1.Protocol" => "HTTP",
|
312
|
+
"Listeners.member.2.Protocol" => "HTTP",
|
313
|
+
"Listeners.member.1.LoadBalancerPort" => "80",
|
314
|
+
"Listeners.member.2.LoadBalancerPort" => "80",
|
315
|
+
"Listeners.member.1.InstancePort" => "80",
|
316
|
+
"Listeners.member.2.InstancePort" => "80",
|
317
|
+
"Listeners.member.1.BalancingType" => "1",
|
318
|
+
"Listeners.member.2.BalancingType" => "1",
|
319
|
+
"AvailabilityZones.member.1" => "a",
|
320
|
+
"AvailabilityZones.member.2" => "a",
|
321
|
+
"NetworkVolume" => "10",
|
322
|
+
"IpVersion" => "v4"
|
323
|
+
).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
324
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
325
|
+
response = @api.create_load_balancer(:load_balancer_name => "a", :listeners => [{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1},{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1}], :availability_zones => %w(a a), :network_volume => 10, :ip_version => "v4")
|
326
|
+
end
|
327
|
+
|
328
|
+
specify "create_load_balancer - :listeners - :protocol正常" do
|
329
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
330
|
+
@valid_protocol.each do |protocol|
|
331
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:protocol => protocol, :instance_port => 80}) }.should.not.raise(NIFTY::ArgumentError)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
specify "create_load_balancer - :listeners - :load_balancer_port正常" do
|
336
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
337
|
+
@valid_port.each do |port|
|
338
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:load_balancer_port => port, :instance_port => 80}) }.should.not.raise(NIFTY::ArgumentError)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
specify "create_load_balancer - :listeners - :instance_port正常" do
|
343
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
344
|
+
@valid_port.each do |port|
|
345
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:protocol => 'HTTP', :instance_port => port}) }.should.not.raise(NIFTY::ArgumentError)
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
specify "create_load_balancer - :listeners - :balancing_type正常" do
|
350
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
351
|
+
@valid_balancing_type.each do |type|
|
352
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:balancing_type => type, :protocol => 'HTTP', :instance_port => 80}) }.should.not.raise(NIFTY::ArgumentError)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
specify "create_load_balancer - :network_volume正常" do
|
357
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
358
|
+
@valid_network_volume.each do |vol|
|
359
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:network_volume => vol)) }.should.not.raise(NIFTY::ArgumentError)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
|
363
|
+
specify "create_load_balancer - :ip_version正常" do
|
364
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
365
|
+
@valid_ip_version.each do |ver|
|
366
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:ip_version => ver)) }.should.not.raise(NIFTY::ArgumentError)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
specify "create_load_balancer - :load_balancer_name未指定" do
|
371
|
+
lambda { @api.create_load_balancer }.should.raise(NIFTY::ArgumentError)
|
372
|
+
lambda { @api.create_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
373
|
+
lambda { @api.create_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
374
|
+
end
|
375
|
+
|
376
|
+
specify "create_load_balancer - :listeners未指定" do
|
377
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
|
378
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => nil) }.should.raise(NIFTY::ArgumentError)
|
379
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => '') }.should.raise(NIFTY::ArgumentError)
|
380
|
+
end
|
381
|
+
|
382
|
+
specify "create_load_balancer - :listeners - :protocol, :load_balancer_port未指定/不正" do
|
383
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80}) }.should.raise(NIFTY::ArgumentError)
|
384
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => nil}) }.should.raise(NIFTY::ArgumentError)
|
385
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => ''}) }.should.raise(NIFTY::ArgumentError)
|
386
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => 'foo'}) }.should.raise(NIFTY::ArgumentError)
|
387
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => 'SSH'}) }.should.raise(NIFTY::ArgumentError)
|
388
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :load_balancer_port => 'foo'}) }.should.raise(NIFTY::ArgumentError)
|
389
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :load_balancer_port => 65536}) }.should.raise(NIFTY::ArgumentError)
|
390
|
+
end
|
391
|
+
|
392
|
+
specify "create_load_balancer - :listeners - :balancing_type不正" do
|
393
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => 'HTTP', :balancing_type => 'foo'}) }.should.raise(NIFTY::ArgumentError)
|
394
|
+
lambda { @api.create_load_balancer(:load_balancer_name => 'lb1', :listeners => {:instance_port => 80, :protocol => 'HTTP', :balancing_type => 3}) }.should.raise(NIFTY::ArgumentError)
|
395
|
+
end
|
396
|
+
|
397
|
+
specify "create_load_balancer - :network_volume未指定" do
|
398
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:network_volume => 'foo')) }.should.raise(NIFTY::ArgumentError)
|
399
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:network_volume => 500)) }.should.raise(NIFTY::ArgumentError)
|
400
|
+
end
|
401
|
+
|
402
|
+
specify "create_load_balancer - :ip_version未指定" do
|
403
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:ip_version => 'foo')) }.should.raise(NIFTY::ArgumentError)
|
404
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:ip_version => 'v5')) }.should.raise(NIFTY::ArgumentError)
|
405
|
+
end
|
406
|
+
|
407
|
+
|
408
|
+
# update_load_balancer
|
409
|
+
specify "update_load_balancer - レスポンスを正しく解析できるか" do
|
410
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
411
|
+
response = @api.update_load_balancer(:load_balancer_name => 'lb1')
|
412
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
413
|
+
end
|
414
|
+
|
415
|
+
specify "update_load_balancer - パラメータが正しく作られるか" do
|
416
|
+
@api.stubs(:make_request).with("Action" => "UpdateLoadBalancer",
|
417
|
+
"LoadBalancerName" => "a",
|
418
|
+
"ListenerUpdate.LoadBalancerPort" => "80",
|
419
|
+
"ListenerUpdate.InstancePort" => "80",
|
420
|
+
"ListenerUpdate.Listener.Protocol" => "HTTP",
|
421
|
+
"ListenerUpdate.Listener.LoadBalancerPort" => "80",
|
422
|
+
"ListenerUpdate.Listener.InstancePort" => "80",
|
423
|
+
"ListenerUpdate.Listener.BalancingType" => "1",
|
424
|
+
"NetworkVolumeUpdate" => "10"
|
425
|
+
).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
426
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
427
|
+
response = @api.update_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :listener_protocol => "HTTP", :listener_load_balancer_port => 80, :listener_instance_port => 80, :listener_balancing_type => 1, :network_volume_update => 10)
|
428
|
+
end
|
429
|
+
|
430
|
+
specify "update_load_balancer - :load_balancer_port正常" do
|
431
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
432
|
+
@valid_port.each do |port|
|
433
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80) }.should.not.raise(NIFTY::ArgumentError)
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
specify "update_load_balancer - :instance_port正常" do
|
438
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
439
|
+
@valid_port.each do |port|
|
440
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
specify "update_load_balancer - :protocol正常" do
|
445
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
446
|
+
@valid_protocol.each do |protocol|
|
447
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :listener_protocol => protocol) }.should.not.raise(NIFTY::ArgumentError)
|
448
|
+
end
|
449
|
+
end
|
450
|
+
|
451
|
+
specify "update_load_balancer - :listener_load_balancer_port正常" do
|
452
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
453
|
+
@valid_port.each do |port|
|
454
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :listener_load_balancer_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
specify "update_load_balancer - :listener_instance_port正常" do
|
459
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
460
|
+
@valid_port.each do |port|
|
461
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :listener_instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
specify "update_load_balancer - :listener_balancing_type正常" do
|
466
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
467
|
+
@valid_balancing_type.each do |type|
|
468
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :listener_balancing_type => type) }.should.not.raise(NIFTY::ArgumentError)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
specify "update_load_balancer - :network_volume_update正常" do
|
473
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
474
|
+
@valid_network_volume.each do |vol|
|
475
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :network_volume_update => vol) }.should.not.raise(NIFTY::ArgumentError)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
specify "update_load_balancer - :load_balancer_name未指定" do
|
480
|
+
lambda { @api.update_load_balancer }.should.raise(NIFTY::ArgumentError)
|
481
|
+
lambda { @api.update_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
482
|
+
lambda { @api.update_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
483
|
+
end
|
484
|
+
|
485
|
+
specify "update_load_balancer - :load_balancer_port未指定/不正" do
|
486
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
487
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => nil, :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
488
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => '', :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
489
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
490
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
491
|
+
end
|
492
|
+
|
493
|
+
specify "update_load_balancer - :instance_port不正" do
|
494
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
495
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => nil, :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
496
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => '', :listener_protocol => 'HTTP') }.should.raise(NIFTY::ArgumentError)
|
497
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
498
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
499
|
+
end
|
500
|
+
|
501
|
+
specify "update_load_balancer - :listener_protocol不正" do
|
502
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_protocol => 'ABC') }.should.raise(NIFTY::ArgumentError)
|
503
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_protocol => 80) }.should.raise(NIFTY::ArgumentError)
|
504
|
+
end
|
505
|
+
|
506
|
+
specify "update_load_balancer - :listener_load_balancer_port不正" do
|
507
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
508
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
509
|
+
end
|
510
|
+
|
511
|
+
specify "update_load_balancer - :listener_instance_port不正" do
|
512
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
513
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
514
|
+
end
|
515
|
+
|
516
|
+
specify "update_load_balancer - :listener_balancing_type不正" do
|
517
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_balancing_type => 3) }.should.raise(NIFTY::ArgumentError)
|
518
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :listener_balancing_type => 'foo') }.should.raise(NIFTY::ArgumentError)
|
519
|
+
end
|
520
|
+
|
521
|
+
specify "update_load_balancer - :network_volume_update不正" do
|
522
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :network_volume_update => 300) }.should.raise(NIFTY::ArgumentError)
|
523
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :network_volume_update => 'foo') }.should.raise(NIFTY::ArgumentError)
|
524
|
+
end
|
525
|
+
|
526
|
+
|
527
|
+
# delete_load_balancer
|
528
|
+
specify "delete_load_balancer - レスポンスを正しく解析できるか" do
|
529
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
530
|
+
response = @api.delete_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 443, :instance_port => 443)
|
531
|
+
response.DeleteLoadBalancerResult.should.equal nil
|
532
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
533
|
+
end
|
534
|
+
|
535
|
+
specify "delete_load_balancer - パラメータが正しく作られるか" do
|
536
|
+
@api.stubs(:make_request).with("Action" => "DeleteLoadBalancer",
|
537
|
+
"LoadBalancerName" => "a",
|
538
|
+
"LoadBalancerPort" => "80",
|
539
|
+
"InstancePort" => "80"
|
540
|
+
).returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
541
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
542
|
+
response = @api.delete_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80)
|
543
|
+
end
|
544
|
+
|
545
|
+
specify "delete_load_balancer - :load_balancer_port正常" do
|
546
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
547
|
+
@valid_port.each do |port|
|
548
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80) }.should.not.raise(NIFTY::ArgumentError)
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
specify "delete_load_balancer - :instance_port正常" do
|
553
|
+
@api.stubs(:exec_request).returns stub(:body => @delete_load_balancer_response_body, :is_a? => true)
|
554
|
+
@valid_port.each do |port|
|
555
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
556
|
+
end
|
557
|
+
end
|
558
|
+
|
559
|
+
specify "delete_load_balancer - :load_balancer_name未指定" do
|
560
|
+
lambda { @api.delete_load_balancer }.should.raise(NIFTY::ArgumentError)
|
561
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
562
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
563
|
+
end
|
564
|
+
|
565
|
+
specify "delete_load_balancer - :load_balancer_port未指定/不正" do
|
566
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
|
567
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
568
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
569
|
+
end
|
570
|
+
|
571
|
+
specify "delete_load_balancer - :instance_port未指定/不正" do
|
572
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
|
573
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :instance_port => -1) }.should.raise(NIFTY::ArgumentError)
|
574
|
+
lambda { @api.delete_load_balancer(:load_balancer_name => 'lb1', :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
|
575
|
+
end
|
576
|
+
|
577
|
+
|
578
|
+
# describe_load_balancers
|
579
|
+
specify "describe_load_balancers - レスポンスを正しく解析できるか" do
|
580
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
581
|
+
response = @api.describe_load_balancers
|
582
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].LoadBalancerName.should.equal 'lb0001'
|
583
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].DNSName.should.equal '10.0.5.222'
|
584
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].NetworkVolume.should.equal '10'
|
585
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].ListenerDescriptions.member[0].Listener.Protocol.should.equal 'http'
|
586
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].ListenerDescriptions.member[0].Listener.LoadBalancerPort.should.equal '80'
|
587
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].ListenerDescriptions.member[0].Listener.InstancePort.should.equal '80'
|
588
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].ListenerDescriptions.member[0].Listener.balancingType.should.equal '1'
|
589
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Instances.member[0].InstanceId[0].should.equal 'server02'
|
590
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Instances.member[0].InstanceId[1].should.equal 'server03'
|
591
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].HealthCheck.Target.should.equal 'TCP:80'
|
592
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].HealthCheck.Interval.should.equal '300'
|
593
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].HealthCheck.Timeout.should.equal '30'
|
594
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].HealthCheck.UnhealthyThreshold.should.equal '1'
|
595
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].HealthCheck.HealthyThreshold.should.equal '1'
|
596
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Filter.FilterType.should.equal '1'
|
597
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Filter.IPAddresses.member[0].should.equal '111.111.111.111'
|
598
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Filter.IPAddresses.member[1].should.equal '111.111.111.112'
|
599
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].AvailabilityZones.member[0].should.equal 'ap-japan-1a'
|
600
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].CreatedTime.should.equal '2010-05-17T11:22:33.456Z'
|
601
|
+
|
602
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].LoadBalancerName.should.equal 'lb0001'
|
603
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].DNSName.should.equal '10.0.5.222'
|
604
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].NetworkVolume.should.equal '10'
|
605
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].ListenerDescriptions.member[0].Protocol.should.equal 'http'
|
606
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].ListenerDescriptions.member[0].LoadBalancerPort.should.equal '443'
|
607
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].ListenerDescriptions.member[0].InstancePort.should.equal '443'
|
608
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].ListenerDescriptions.member[0].balancingType.should.equal '2'
|
609
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].Instances.member[0].InstanceId[0].should.equal 'server02'
|
610
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].Instances.member[0].InstanceId[1].should.equal 'server03'
|
611
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].HealthCheck.Target.should.equal 'TCP:443'
|
612
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].HealthCheck.Interval.should.equal '300'
|
613
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].HealthCheck.Timeout.should.equal '30'
|
614
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].HealthCheck.UnhealthyThreshold.should.equal '1'
|
615
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].HealthCheck.HealthyThreshold.should.equal '1'
|
616
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].Filter.FilterType.should.equal '1'
|
617
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].Filter.IPAddresses.member[0].should.equal '*.*.*.*'
|
618
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].AvailabilityZones.member[0].should.equal 'ap-japan-1a'
|
619
|
+
response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].CreatedTime.should.equal '2010-05-17T11:22:43.789Z'
|
620
|
+
|
621
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
622
|
+
end
|
623
|
+
|
624
|
+
specify "describe_load_balancers - パラメータが正しく作られるか" do
|
625
|
+
@api.stubs(:make_request).with("Action" => "DescribeLoadBalancers",
|
626
|
+
"LoadBalancerNames.member.1" => "a",
|
627
|
+
"LoadBalancerNames.member.2" => "a",
|
628
|
+
"LoadBalancerNames.LoadBalancerPort.1" => "80",
|
629
|
+
"LoadBalancerNames.LoadBalancerPort.2" => "80",
|
630
|
+
"LoadBalancerNames.InstancePort.1" => "80",
|
631
|
+
"LoadBalancerNames.InstancePort.2" => "80"
|
632
|
+
).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
633
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
634
|
+
response = @api.describe_load_balancers(:load_balancer_name => %w(a a), :load_balancer_port => %w(80 80), :instance_port => %w(80 80))
|
635
|
+
end
|
636
|
+
|
637
|
+
specify "describe_load_balancers - :member正常" do
|
638
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
639
|
+
lambda { @api.describe_load_balancers(:member => 'foo') }.should.not.raise(NIFTY::ArgumentError)
|
640
|
+
lambda { @api.describe_load_balancers(:member => %w(foo bar hoge)) }.should.not.raise(NIFTY::ArgumentError)
|
641
|
+
end
|
642
|
+
|
643
|
+
specify "describe_load_balancers - :load_balancer_port正常" do
|
644
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
645
|
+
@valid_port.each do |port|
|
646
|
+
lambda { @api.describe_load_balancers(:load_balancer_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
647
|
+
lambda { @api.describe_load_balancers(:load_balancer_port => [port, port]) }.should.not.raise(NIFTY::ArgumentError)
|
648
|
+
end
|
649
|
+
end
|
650
|
+
|
651
|
+
specify "describe_load_balancers - :instance_port正常" do
|
652
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_load_balancers_response_body, :is_a? => true)
|
653
|
+
@valid_port.each do |port|
|
654
|
+
lambda { @api.describe_load_balancers(:instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
|
655
|
+
lambda { @api.describe_load_balancers(:instance_port => [port, port]) }.should.not.raise(NIFTY::ArgumentError)
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
|
660
|
+
# register_port_with_load_balancer
|
661
|
+
specify "register_port_with_load_balancer - レスポンスを正しく解析できるか" do
|
662
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
663
|
+
response = @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => {:protocol => 'HTTPS'})
|
664
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[0].Listener.Protocol.should.equal 'http'
|
665
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[0].Listener.LoadBalancerPort.should.equal '80'
|
666
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[0].Listener.InstancePort.should.equal '80'
|
667
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[0].Listener.balancingType.should.equal '1'
|
668
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[1].Listener.Protocol.should.equal 'https'
|
669
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[1].Listener.LoadBalancerPort.should.equal '443'
|
670
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[1].Listener.InstancePort.should.equal '443'
|
671
|
+
response.RegisterPortWithLoadBalancerResult.ListenerDescriptions.member[1].Listener.balancingType.should.equal '1'
|
672
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
673
|
+
end
|
674
|
+
|
675
|
+
specify "register_port_with_load_balancer - パラメータが正しく作られるか" do
|
676
|
+
@api.stubs(:make_request).with("Action" => "RegisterPortWithLoadBalancer",
|
677
|
+
"LoadBalancerName" => "a",
|
678
|
+
"Listeners.member.1.Protocol" => "HTTP",
|
679
|
+
"Listeners.member.2.Protocol" => "HTTP",
|
680
|
+
"Listeners.member.1.LoadBalancerPort" => "80",
|
681
|
+
"Listeners.member.2.LoadBalancerPort" => "80",
|
682
|
+
"Listeners.member.1.InstancePort" => "80",
|
683
|
+
"Listeners.member.2.InstancePort" => "80",
|
684
|
+
"Listeners.member.1.BalancingType" => "1",
|
685
|
+
"Listeners.member.2.BalancingType" => "1"
|
686
|
+
).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
687
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
688
|
+
response = @api.register_port_with_load_balancer(:load_balancer_name => "a", :listeners => [{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1},{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1}])
|
689
|
+
end
|
690
|
+
|
691
|
+
specify "register_port_with_load_balancer - :listeners - :protocol正常" do
|
692
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
693
|
+
@valid_protocol.each do |protocol|
|
694
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => {:protocol => protocol}) }.should.not.raise(NIFTY::ArgumentError)
|
695
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => protocol}, {:protocol => protocol}]) }.should.not.raise(NIFTY::ArgumentError)
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
specify "register_port_with_load_balancer - :listeners - :load_balancer_port正常" do
|
700
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
701
|
+
@valid_port.each do |port|
|
702
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => {:load_balancer_port => port}) }.should.not.raise(NIFTY::ArgumentError)
|
703
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:load_balancer_port => port}, {:load_balancer_port => port}]) }.should.not.raise(NIFTY::ArgumentError)
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
specify "register_port_with_load_balancer - :instance_port正常" do
|
708
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
709
|
+
@valid_port.each do |port|
|
710
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => {:load_balancer_port => 80, :instance_port => port}) }.should.not.raise(NIFTY::ArgumentError)
|
711
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:load_balancer_port => 80, :instance_port => port}, {:load_balancer_port => 80, :instance_port => port}]) }.should.not.raise(NIFTY::ArgumentError)
|
712
|
+
end
|
713
|
+
end
|
714
|
+
|
715
|
+
specify "register_port_with_load_balancer - :balancing_type正常" do
|
716
|
+
@api.stubs(:exec_request).returns stub(:body => @register_port_with_load_balancer_response_body, :is_a? => true)
|
717
|
+
@valid_balancing_type.each do |type|
|
718
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => {:load_balancer_port => 80, :balancing_type => type}) }.should.not.raise(NIFTY::ArgumentError)
|
719
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:load_balancer_port => 80, :balancing_type => type}, {:load_balancer_port => 80, :balancing_type => type}]) }.should.not.raise(NIFTY::ArgumentError)
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
723
|
+
specify "register_port_with_load_balancer - :load_balancer_name未指定" do
|
724
|
+
lambda { @api.register_port_with_load_balancer }.should.raise(NIFTY::ArgumentError)
|
725
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
726
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
727
|
+
end
|
728
|
+
|
729
|
+
specify "register_port_with_load_balancer - :listeners未指定" do
|
730
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
|
731
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => nil) }.should.raise(NIFTY::ArgumentError)
|
732
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => '') }.should.raise(NIFTY::ArgumentError)
|
733
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => []) }.should.raise(NIFTY::ArgumentError)
|
734
|
+
end
|
735
|
+
|
736
|
+
specify "register_port_with_load_balancer - :protocol, :load_balancer_port未指定/不正" do
|
737
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:protocol => nil]) }.should.raise(NIFTY::ArgumentError)
|
738
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:protocol => '']) }.should.raise(NIFTY::ArgumentError)
|
739
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:protocol => 'foo']) }.should.raise(NIFTY::ArgumentError)
|
740
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => 'foo'}, {:protocol => 'bar'}]) }.should.raise(NIFTY::ArgumentError)
|
741
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:load_balancer_port => nil]) }.should.raise(NIFTY::ArgumentError)
|
742
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:load_balancer_port => '']) }.should.raise(NIFTY::ArgumentError)
|
743
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [:load_balancer_port => 65536]) }.should.raise(NIFTY::ArgumentError)
|
744
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:load_balancer_port => 80}, {:load_balancer_port => 65536}]) }.should.raise(NIFTY::ArgumentError)
|
745
|
+
end
|
746
|
+
|
747
|
+
specify "register_port_with_load_balancer - :instance_port不正" do
|
748
|
+
lambda { @api.register_port_with_load_balancer }.should.raise(NIFTY::ArgumentError)
|
749
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => 'HTTP', :instance_port => 65536}]) }.should.raise(NIFTY::ArgumentError)
|
750
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => 'HTTP', :instance_port => 8080}, {:protocol => 'HTTP', :instance_port => -1}]) }.should.raise(NIFTY::ArgumentError)
|
751
|
+
end
|
752
|
+
|
753
|
+
specify "register_port_with_load_balancer - :balancing_type不正" do
|
754
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => 'HTTP', :balancing_type => 3}]) }.should.raise(NIFTY::ArgumentError)
|
755
|
+
lambda { @api.register_port_with_load_balancer(:load_balancer_name => 'lb1', :listeners => [{:protocol => 'HTTP', :balancing_type => 4}, {:protocol => 'HTTP', :balancing_type => 5}]) }.should.raise(NIFTY::ArgumentError)
|
756
|
+
end
|
757
|
+
|
758
|
+
|
759
|
+
# register_instances_with_load_balancer
|
760
|
+
specify "register_instances_with_load_balancer - レスポンスを正しく解析できるか" do
|
761
|
+
@api.stubs(:exec_request).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
762
|
+
response = @api.register_instances_with_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :instances => 'serv01')
|
763
|
+
response.RegisterInstancesWithLoadBalancerResult.Instances.member[0].InstanceId.should.equal 'server02'
|
764
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
765
|
+
end
|
766
|
+
|
767
|
+
specify "register_instances_with_load_balancer - パラメータが正しく作られるか" do
|
768
|
+
@api.stubs(:make_request).with("Action" => "RegisterInstancesWithLoadBalancer",
|
769
|
+
"LoadBalancerName" => "a",
|
770
|
+
"LoadBalancerPort" => "80",
|
771
|
+
"InstancePort" => "80",
|
772
|
+
"Instances.member.1.InstanceId" => "a",
|
773
|
+
"Instances.member.2.InstanceId" => "a"
|
774
|
+
).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
775
|
+
@api.stubs(:exec_request).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
776
|
+
response = @api.register_instances_with_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :instances => %w(a a))
|
777
|
+
end
|
778
|
+
|
779
|
+
specify "register_instances_with_load_balancer - :load_balancer_port正常" do
|
780
|
+
@api.stubs(:exec_request).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
781
|
+
@valid_port.each do |port|
|
782
|
+
lambda { @api.register_instances_with_load_balancer(@basic_reg_instance_params.merge(:load_balancer_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
783
|
+
end
|
784
|
+
end
|
785
|
+
|
786
|
+
specify "register_instances_with_load_balancer - :instance_port正常" do
|
787
|
+
@api.stubs(:exec_request).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
788
|
+
@valid_port.each do |port|
|
789
|
+
lambda { @api.register_instances_with_load_balancer(@basic_reg_instance_params.merge(:instance_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
793
|
+
specify "register_instances_with_load_balancer - :instances正常" do
|
794
|
+
@api.stubs(:exec_request).returns stub(:body => @register_instances_with_load_balancer_response_body, :is_a? => true)
|
795
|
+
lambda { @api.register_instances_with_load_balancer(@basic_reg_instance_params.merge(:instances => 'foo')) }.should.not.raise(NIFTY::ArgumentError)
|
796
|
+
lambda { @api.register_instances_with_load_balancer(@basic_reg_instance_params.merge(:instances => %w(foo bar hoge))) }.should.not.raise(NIFTY::ArgumentError)
|
797
|
+
end
|
798
|
+
|
799
|
+
specify "register_instances_with_load_balancer - :load_balancer_name未指定" do
|
800
|
+
lambda { @api.register_instances_with_load_balancer }.should.raise(NIFTY::ArgumentError)
|
801
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
802
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
803
|
+
end
|
804
|
+
|
805
|
+
specify "register_instances_with_load_balancer - :load_balancer_port未指定/不正" do
|
806
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo') }.should.raise(NIFTY::ArgumentError)
|
807
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
|
808
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
|
809
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => -1) }.should.raise(NIFTY::ArgumentError)
|
810
|
+
end
|
811
|
+
|
812
|
+
specify "register_instances_with_load_balancer - :instance_port未指定/不正" do
|
813
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
|
814
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
|
815
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
|
816
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => -1) }.should.raise(NIFTY::ArgumentError)
|
817
|
+
end
|
818
|
+
|
819
|
+
specify "register_instances_with_load_balancer - :instances未指定" do
|
820
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80) }.should.raise(NIFTY::ArgumentError)
|
821
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80, :instances => nil) }.should.raise(NIFTY::ArgumentError)
|
822
|
+
lambda { @api.register_instances_with_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80, :instances => '') }.should.raise(NIFTY::ArgumentError)
|
823
|
+
end
|
824
|
+
|
825
|
+
|
826
|
+
# deregister_instances_from_load_balancer
|
827
|
+
specify "deregister_instances_from_load_balancer - レスポンスを正しく解析できるか" do
|
828
|
+
@api.stubs(:exec_request).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
829
|
+
response = @api.deregister_instances_from_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :instances => 'serv01')
|
830
|
+
response.DeregisterInstancesFromLoadBalancerResult.Instances.member[0].InstanceId.should.equal 'server03'
|
831
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
832
|
+
end
|
833
|
+
|
834
|
+
specify "deregister_instances_from_load_balancer - パラメータが正しく作られるか" do
|
835
|
+
@api.stubs(:make_request).with("Action" => "DeregisterInstancesFromLoadBalancer",
|
836
|
+
"LoadBalancerName" => "a",
|
837
|
+
"LoadBalancerPort" => "80",
|
838
|
+
"InstancePort" => "80",
|
839
|
+
"Instances.member.1.InstanceId" => "a",
|
840
|
+
"Instances.member.2.InstanceId" => "a"
|
841
|
+
).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
842
|
+
@api.stubs(:exec_request).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
843
|
+
response = @api.deregister_instances_from_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :instances => %w(a a))
|
844
|
+
end
|
845
|
+
|
846
|
+
specify "deregister_instances_from_load_balancer - :load_balancer_port正常" do
|
847
|
+
@api.stubs(:exec_request).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
848
|
+
@valid_port.each do |port|
|
849
|
+
lambda { @api.deregister_instances_from_load_balancer(@basic_reg_instance_params.merge(:load_balancer_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
850
|
+
end
|
851
|
+
end
|
852
|
+
|
853
|
+
specify "deregister_instances_from_load_balancer - :instance_port正常" do
|
854
|
+
@api.stubs(:exec_request).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
855
|
+
@valid_port.each do |port|
|
856
|
+
lambda { @api.deregister_instances_from_load_balancer(@basic_reg_instance_params.merge(:instance_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
specify "deregister_instances_from_load_balancer - :instances正常" do
|
861
|
+
@api.stubs(:exec_request).returns stub(:body => @deregister_instances_from_load_balancer_response_body, :is_a? => true)
|
862
|
+
lambda { @api.deregister_instances_from_load_balancer(@basic_reg_instance_params.merge(:instances => 'foo')) }.should.not.raise(NIFTY::ArgumentError)
|
863
|
+
lambda { @api.deregister_instances_from_load_balancer(@basic_reg_instance_params.merge(:instances => %w(foo bar hoge))) }.should.not.raise(NIFTY::ArgumentError)
|
864
|
+
end
|
865
|
+
|
866
|
+
specify "deregister_instances_from_load_balancer - :load_balancer_name未指定" do
|
867
|
+
lambda { @api.deregister_instances_from_load_balancer }.should.raise(NIFTY::ArgumentError)
|
868
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
869
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
870
|
+
end
|
871
|
+
|
872
|
+
specify "deregister_instances_from_load_balancer - :load_balancer_port未指定/不正" do
|
873
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo') }.should.raise(NIFTY::ArgumentError)
|
874
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
|
875
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
|
876
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
877
|
+
end
|
878
|
+
|
879
|
+
specify "deregister_instances_from_load_balancer - :instance_port未指定/不正" do
|
880
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
|
881
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
|
882
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
|
883
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => -1) }.should.raise(NIFTY::ArgumentError)
|
884
|
+
end
|
885
|
+
|
886
|
+
specify "deregister_instances_from_load_balancer - :instances未指定" do
|
887
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80) }.should.raise(NIFTY::ArgumentError)
|
888
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80, :instances => nil) }.should.raise(NIFTY::ArgumentError)
|
889
|
+
lambda { @api.deregister_instances_from_load_balancer(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => 80, :instances => '') }.should.raise(NIFTY::ArgumentError)
|
890
|
+
end
|
891
|
+
|
892
|
+
|
893
|
+
|
894
|
+
# describe_instance_health
|
895
|
+
specify "describe_instance_health - レスポンスを正しく解析できるか" do
|
896
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
897
|
+
response = @api.describe_instance_health(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :instances => 'serv01')
|
898
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[0].InstanceId.should.equal 'server02'
|
899
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[0].State.should.equal 'InService'
|
900
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[0].ReasonCode.should.equal 'N/A'
|
901
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[0].Description.should.equal 'N/A'
|
902
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[1].InstanceId.should.equal 'server06'
|
903
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[1].State.should.equal 'OutOfService'
|
904
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[1].ReasonCode.should.equal 'ELB'
|
905
|
+
response.DescribeInstanceHealthResult.InstanceStates.member[1].Description.should.equal 'Instance registration is still in progress'
|
906
|
+
|
907
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
908
|
+
end
|
909
|
+
|
910
|
+
specify "describe_instance_health - パラメータが正しく作られるか" do
|
911
|
+
@api.stubs(:make_request).with("Action" => "DescribeInstanceHealth",
|
912
|
+
"LoadBalancerName" => "a",
|
913
|
+
"LoadBalancerPort" => "80",
|
914
|
+
"InstancePort" => "80",
|
915
|
+
"Instances.member.1.InstanceId" => "a",
|
916
|
+
"Instances.member.2.InstanceId" => "a"
|
917
|
+
).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
918
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
919
|
+
response = @api.describe_instance_health(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :instances => %w(a a))
|
920
|
+
end
|
921
|
+
|
922
|
+
specify "describe_instance_health - :load_balancer_port正常" do
|
923
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
924
|
+
@valid_port.each do |port|
|
925
|
+
lambda { @api.describe_instance_health(@basic_desc_instance_health_params.merge(:load_balancer_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
926
|
+
end
|
927
|
+
end
|
928
|
+
|
929
|
+
specify "describe_instance_health - :instance_port正常" do
|
930
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
931
|
+
@valid_port.each do |port|
|
932
|
+
lambda { @api.describe_instance_health(@basic_desc_instance_health_params.merge(:instance_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
936
|
+
specify "describe_instance_health - :instances正常" do
|
937
|
+
@api.stubs(:exec_request).returns stub(:body => @describe_instance_health_response_body, :is_a? => true)
|
938
|
+
lambda { @api.describe_instance_health(@basic_desc_instance_health_params.merge(:instances => 'foo')) }.should.not.raise(NIFTY::ArgumentError)
|
939
|
+
lambda { @api.describe_instance_health(@basic_desc_instance_health_params.merge(:instances => %w(foo bar hoge))) }.should.not.raise(NIFTY::ArgumentError)
|
940
|
+
end
|
941
|
+
|
942
|
+
specify "describe_instance_health - :load_balancer_name未指定" do
|
943
|
+
lambda { @api.describe_instance_health }.should.raise(NIFTY::ArgumentError)
|
944
|
+
lambda { @api.describe_instance_health(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
945
|
+
lambda { @api.describe_instance_health(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
|
946
|
+
end
|
947
|
+
|
948
|
+
specify "describe_instance_health - :load_balancer_port未指定/不正" do
|
949
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo') }.should.raise(NIFTY::ArgumentError)
|
950
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
|
951
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
|
952
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
|
953
|
+
end
|
954
|
+
|
955
|
+
specify "describe_instance_health - :instance_port未指定/不正" do
|
956
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
|
957
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
|
958
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
|
959
|
+
lambda { @api.describe_instance_health(:load_balancer_name => 'foo', :load_balancer_port => 80, :instance_port => -1) }.should.raise(NIFTY::ArgumentError)
|
960
|
+
end
|
961
|
+
|
962
|
+
|
963
|
+
# configure_health_check
|
964
|
+
specify "configure_health_check - レスポンスを正しく解析できるか" do
|
965
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
966
|
+
response = @api.configure_health_check(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :target => 'TCP:80', :interval => 30, :unhealthy_threshold => 1)
|
967
|
+
response.ConfigureHealthCheckResult.HealthCheck.Target.should.equal 'TCP:80'
|
968
|
+
response.ConfigureHealthCheckResult.HealthCheck.Interval.should.equal '300'
|
969
|
+
response.ConfigureHealthCheckResult.HealthCheck.Timeout.should.equal '30'
|
970
|
+
response.ConfigureHealthCheckResult.HealthCheck.UnhealthyThreshold.should.equal '3'
|
971
|
+
response.ConfigureHealthCheckResult.HealthCheck.HealthyThreshold.should.equal '1'
|
972
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
973
|
+
end
|
974
|
+
|
975
|
+
specify "configure_health_check - パラメータが正しく作られるか" do
|
976
|
+
@api.stubs(:make_request).with("Action" => "ConfigureHealthCheck",
|
977
|
+
"LoadBalancerName" => "a",
|
978
|
+
"LoadBalancerPort" => "80",
|
979
|
+
"InstancePort" => "80",
|
980
|
+
"HealthCheck.Target" => "TCP:80",
|
981
|
+
"HealthCheck.Interval" => "300",
|
982
|
+
"HealthCheck.Timeout" => "a",
|
983
|
+
"HealthCheck.UnhealthyThreshold" => "1",
|
984
|
+
"HealthCheck.HealthyThreshold" => "1"
|
985
|
+
).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
986
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
987
|
+
response = @api.configure_health_check(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :target => "TCP:80", :interval => 300, :timeout => "a", :unhealthy_threshold => 1, :healthy_threshold => 1)
|
988
|
+
end
|
989
|
+
|
990
|
+
specify "configure_health_check - :load_balancer_name, :load_balancer_port正常" do
|
991
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
992
|
+
@valid_port.each do |port|
|
993
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
994
|
+
end
|
995
|
+
end
|
996
|
+
|
997
|
+
specify "configure_health_check - :instance_port正常" do
|
998
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
999
|
+
@valid_port.each do |port|
|
1000
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:instance_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
1001
|
+
end
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
specify "configure_health_check - :target正常" do
|
1005
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
1006
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'TCP:22')) }.should.not.raise(NIFTY::ArgumentError)
|
1007
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'TCP:8080')) }.should.not.raise(NIFTY::ArgumentError)
|
1008
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'ICMP')) }.should.not.raise(NIFTY::ArgumentError)
|
1009
|
+
end
|
1010
|
+
|
1011
|
+
specify "configure_health_check - :interval正常" do
|
1012
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
1013
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => 10)) }.should.not.raise(NIFTY::ArgumentError)
|
1014
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => 150)) }.should.not.raise(NIFTY::ArgumentError)
|
1015
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => 300)) }.should.not.raise(NIFTY::ArgumentError)
|
1016
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => '200')) }.should.not.raise(NIFTY::ArgumentError)
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
specify "configure_health_check - :timeout正常" do
|
1020
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
1021
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:timeout => 30)) }.should.not.raise(NIFTY::ArgumentError)
|
1022
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:timeout => 60)) }.should.not.raise(NIFTY::ArgumentError)
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
specify "configure_health_check - :unhealthy_threshold正常" do
|
1026
|
+
@api.stubs(:exec_request).returns stub(:body => @configure_health_check_response_body, :is_a? => true)
|
1027
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => 1)) }.should.not.raise(NIFTY::ArgumentError)
|
1028
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => 5)) }.should.not.raise(NIFTY::ArgumentError)
|
1029
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => 10)) }.should.not.raise(NIFTY::ArgumentError)
|
1030
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => '3')) }.should.not.raise(NIFTY::ArgumentError)
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
specify "configure_health_check - :load_balancer_name未指定" do
|
1034
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :load_balancer_name}) }.should.raise(NIFTY::ArgumentError)
|
1035
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_name => nil)) }.should.raise(NIFTY::ArgumentError)
|
1036
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_name => '')) }.should.raise(NIFTY::ArgumentError)
|
1037
|
+
end
|
1038
|
+
|
1039
|
+
specify "configure_health_check - :load_balancer_port未指定/不正" do
|
1040
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :load_balancer_port}) }.should.raise(NIFTY::ArgumentError)
|
1041
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_port => nil)) }.should.raise(NIFTY::ArgumentError)
|
1042
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1043
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_port => -1)) }.should.raise(NIFTY::ArgumentError)
|
1044
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:load_balancer_port => 65536)) }.should.raise(NIFTY::ArgumentError)
|
1045
|
+
end
|
1046
|
+
|
1047
|
+
specify "configure_health_check - :instance_port未指定/不正" do
|
1048
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :instance_port}) }.should.raise(NIFTY::ArgumentError)
|
1049
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:instance_port => nil)) }.should.raise(NIFTY::ArgumentError)
|
1050
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:instance_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1051
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:instance_port => 65536)) }.should.raise(NIFTY::ArgumentError)
|
1052
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:instance_port => -1)) }.should.raise(NIFTY::ArgumentError)
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
specify "configure_health_check - :target未指定/不正" do
|
1056
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :target}) }.should.raise(NIFTY::ArgumentError)
|
1057
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => nil)) }.should.raise(NIFTY::ArgumentError)
|
1058
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => '')) }.should.raise(NIFTY::ArgumentError)
|
1059
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'TCP')) }.should.raise(NIFTY::ArgumentError)
|
1060
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'TCP:-1')) }.should.raise(NIFTY::ArgumentError)
|
1061
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:target => 'ICMP:80')) }.should.raise(NIFTY::ArgumentError)
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
specify "configure_health_check - :interval未指定/不正" do
|
1065
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :interval}) }.should.raise(NIFTY::ArgumentError)
|
1066
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => nil)) }.should.raise(NIFTY::ArgumentError)
|
1067
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => '')) }.should.raise(NIFTY::ArgumentError)
|
1068
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => 5)) }.should.raise(NIFTY::ArgumentError)
|
1069
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:interval => 301)) }.should.raise(NIFTY::ArgumentError)
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
specify "configure_health_check - :unhealthy_threshold未指定/不正" do
|
1073
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.reject{|k, v| k == :unhealthy_threshold}) }.should.raise(NIFTY::ArgumentError)
|
1074
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => nil)) }.should.raise(NIFTY::ArgumentError)
|
1075
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => '')) }.should.raise(NIFTY::ArgumentError)
|
1076
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => 0)) }.should.raise(NIFTY::ArgumentError)
|
1077
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:unhealthy_threshold => 20)) }.should.raise(NIFTY::ArgumentError)
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
specify "configure_health_check - :healthy_threshold不正" do
|
1081
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:healthy_threshold => 0)) }.should.raise(NIFTY::ArgumentError)
|
1082
|
+
lambda { @api.configure_health_check(@basic_conf_health_params.merge(:healthy_threshold => 2)) }.should.raise(NIFTY::ArgumentError)
|
1083
|
+
end
|
1084
|
+
|
1085
|
+
|
1086
|
+
# set_filter_for_load_balancer
|
1087
|
+
specify "set_filter_for_load_balancer - レスポンスを正しく解析できるか" do
|
1088
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1089
|
+
response = @api.set_filter_for_load_balancer(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80)
|
1090
|
+
response.SetFilterForLoadBalancerResult.Filter.FilterType.should.equal '1'
|
1091
|
+
response.SetFilterForLoadBalancerResult.Filter.IPAddresses.member[0].should.equal '111.111.111.111'
|
1092
|
+
response.SetFilterForLoadBalancerResult.Filter.IPAddresses.member[1].should.equal '111.111.111.112'
|
1093
|
+
response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
|
1094
|
+
end
|
1095
|
+
|
1096
|
+
specify "set_filter_for_load_balancer - パラメータが正しく作られるか" do
|
1097
|
+
@api.stubs(:make_request).with("Action" => "SetFilterForLoadBalancer",
|
1098
|
+
"LoadBalancerName" => "a",
|
1099
|
+
"LoadBalancerPort" => "80",
|
1100
|
+
"InstancePort" => "80",
|
1101
|
+
"IPAddresses.member.1.IPAddress" => "1.1.1.1",
|
1102
|
+
"IPAddresses.member.2.IPAddress" => "1.1.1.1",
|
1103
|
+
"IPAddresses.member.1.AddOnFilter" => "true",
|
1104
|
+
"IPAddresses.member.2.AddOnFilter" => "true",
|
1105
|
+
"FilterType" => "1"
|
1106
|
+
).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1107
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1108
|
+
response = @api.set_filter_for_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :ip_addresses => [{:ip_address => "1.1.1.1", :add_on_filter => true},{:ip_address => "1.1.1.1", :add_on_filter => true}], :filter_type => 1)
|
1109
|
+
end
|
1110
|
+
|
1111
|
+
specify "set_filter_for_load_balancer - :load_balancer_name正常" do
|
1112
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1113
|
+
@valid_port.each do |port|
|
1114
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
1115
|
+
end
|
1116
|
+
end
|
1117
|
+
|
1118
|
+
specify "set_filter_for_load_balancer - :instance_port正常" do
|
1119
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1120
|
+
@valid_port.each do |port|
|
1121
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:instance_port => port)) }.should.not.raise(NIFTY::ArgumentError)
|
1122
|
+
end
|
1123
|
+
end
|
1124
|
+
|
1125
|
+
specify "set_filter_for_load_balancer - :ip_addresses - :ip_address正常" do
|
1126
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1127
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => {:ip_address => '111.111.111.111'})) }.should.not.raise(NIFTY::ArgumentError)
|
1128
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => [{:ip_address => '111.111.111.111'}, {:ip_address => '::ffff:6f6f:6f6f'}])) }.should.not.raise(NIFTY::ArgumentError)
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
specify "set_filter_for_load_balancer - ip_addresses - :add_on_filter正常" do
|
1132
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1133
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => {:add_on_filter => true})) }.should.not.raise(NIFTY::ArgumentError)
|
1134
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => [{:add_on_filter => true}, {:add_on_filter => false}])) }.should.not.raise(NIFTY::ArgumentError)
|
1135
|
+
end
|
1136
|
+
|
1137
|
+
specify "set_filter_for_load_balancer - :filter_type正常" do
|
1138
|
+
@api.stubs(:exec_request).returns stub(:body => @set_filter_for_load_balancer_response_body, :is_a? => true)
|
1139
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => 1)) }.should.not.raise(NIFTY::ArgumentError)
|
1140
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => 2)) }.should.not.raise(NIFTY::ArgumentError)
|
1141
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => '1')) }.should.not.raise(NIFTY::ArgumentError)
|
1142
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => '2')) }.should.not.raise(NIFTY::ArgumentError)
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
specify "set_filter_for_load_balancer - :load_balancer_name未指定" do
|
1146
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.reject{|k, v| k == :load_balancer_name}) }.should.raise(NIFTY::ArgumentError)
|
1147
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_name => nil)) }.should.raise(NIFTY::ArgumentError)
|
1148
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_name => '')) }.should.raise(NIFTY::ArgumentError)
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
specify "set_filter_for_load_balancer - :load_balancer_port未指定/不正" do
|
1152
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.reject{|k, v| k == :load_balancer_port}) }.should.raise(NIFTY::ArgumentError)
|
1153
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_port => nil)) }.should.raise(NIFTY::ArgumentError)
|
1154
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1155
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1156
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:load_balancer_port => -1)) }.should.raise(NIFTY::ArgumentError)
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
specify "set_filter_for_load_balancer - :instance_port未指定/不正" do
|
1160
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.reject{|k, v| k == :instance_port}) }.should.raise(NIFTY::ArgumentError)
|
1161
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:instance_port => nil)) }.should.raise(NIFTY::ArgumentError)
|
1162
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:instance_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1163
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:instance_port => '')) }.should.raise(NIFTY::ArgumentError)
|
1164
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:instance_port => -1)) }.should.raise(NIFTY::ArgumentError)
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
specify "set_filter_for_load_balancer - ip_addresses - :ip_address不正" do
|
1168
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => {:ip_address => '123.456.789.123'})) }.should.raise(NIFTY::ArgumentError)
|
1169
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => [{:ip_address => '111.111.111.111'}, {:ip_address => '123.456.789.123'}])) }.should.raise(NIFTY::ArgumentError)
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
specify "set_filter_for_load_balancer - ip_addresses - :add_on_filter不正" do
|
1173
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => {:add_on_filter => 'foo'})) }.should.raise(NIFTY::ArgumentError)
|
1174
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:ip_addresses => [{:add_on_filter => true}, {:add_on_filter => 'hoge'}])) }.should.raise(NIFTY::ArgumentError)
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
specify "set_filter_for_load_balancer - :filter_type未指定" do
|
1178
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => 3)) }.should.raise(NIFTY::ArgumentError)
|
1179
|
+
lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => 0)) }.should.raise(NIFTY::ArgumentError)
|
1180
|
+
end
|
1181
|
+
|
1182
|
+
end
|
1183
|
+
|