nifty-cloud-sdk 1.8.beta1 → 1.9.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,6 +24,7 @@ context "instances" do
24
24
  @windows_image_id = [12, 16, '12', '16']
25
25
 
26
26
  @basic_run_instances_options = {:security_group => "gr01", :image_id => 2, :key_name => 'foo', :password => 'password'}
27
+ @basic_import_instance_options = {:ovf => "dummy"}
27
28
 
28
29
  @run_instances_response_body = <<-RESPONSE
29
30
  <RunInstancesResponse xmlns="https://cp.cloud.nifty.com/api/1.3/">
@@ -218,6 +219,32 @@ context "instances" do
218
219
  <requestId>f6dd8353-eb6b-6b4fd32e4f05</requestId>
219
220
  </CancelCopyInstancesResponse>
220
221
  RESPONSE
222
+
223
+ @import_instance_response_body = <<-RESPONSE
224
+ <ImportInstanceResponse xmlns="https://cp.cloud.nifty.com/api/">
225
+ <conversionTask>
226
+ <conversionTaskId>import-n-sd-093rar3gl4</conversionTaskId>
227
+ <expirationTime>2012-10-13T19:17:28.799+09:00</expirationTime>
228
+ <importInstance>
229
+ <volumes>
230
+ <item>
231
+ <bytesConverted>0</bytesConverted>
232
+ <availabilityZone>east-11</availabilityZone>
233
+ <image>
234
+ <format>VMDK</format>
235
+ <size>266189212314</size>
236
+ </image>
237
+ <description/>
238
+ <status>active</status>
239
+ <statusMessage/>
240
+ </item>
241
+ </volumes>
242
+ <instanceId>server01</instanceId>
243
+ <description>memo</description>
244
+ </importInstance>
245
+ </conversionTask>
246
+ </ImportInstanceResponse>
247
+ RESPONSE
221
248
  end
222
249
 
223
250
 
@@ -357,7 +384,8 @@ context "instances" do
357
384
  { 'instanceType' => @valid_instance_type,
358
385
  'disableApiTermination' => [true, false, 'true', 'false'],
359
386
  'instanceName' => ['hoge'],
360
- 'description' => ['hoge']
387
+ 'description' => ['hoge'],
388
+ 'accountingType' => @accounting_type
361
389
  }.each do |attr, arr|
362
390
  arr.each do |val|
363
391
  lambda { @api.modify_instance_attribute(:instance_id => "i-10a64379", :attribute => attr, :value => val) }.should.not.raise(NIFTY::ArgumentError)
@@ -964,4 +992,107 @@ context "instances" do
964
992
  lambda { @api.cancel_copy_instances(:instance_id => nil) }.should.raise(NIFTY::ArgumentError)
965
993
  lambda { @api.cancel_copy_instances(:instance_id => '') }.should.raise(NIFTY::ArgumentError)
966
994
  end
995
+
996
+ # import_instance
997
+ specify "import_instance - レスポンスを正しく解析できるか" do
998
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
999
+ response = @api.import_instance(:ovf => "dummy")
1000
+ response.conversionTask.conversionTaskId.should.equal "import-n-sd-093rar3gl4"
1001
+ response.conversionTask.expirationTime.should.equal "2012-10-13T19:17:28.799+09:00"
1002
+ response.conversionTask.importInstance.volumes.item[0].bytesConverted.should.equal "0"
1003
+ response.conversionTask.importInstance.volumes.item[0].availabilityZone.should.equal "east-11"
1004
+ response.conversionTask.importInstance.volumes.item[0].image.format.should.equal "VMDK"
1005
+ response.conversionTask.importInstance.volumes.item[0].image["size"].should.equal "266189212314"
1006
+ #response.conversionTask.importInstance.volumes.item[0].description.should.equal ""
1007
+ response.conversionTask.importInstance.volumes.item[0].status.should.equal "active"
1008
+ #response.conversionTask.importInstance.volumes.item[0].statusMessage.should.equal ""
1009
+ response.conversionTask.importInstance.instanceId.should.equal "server01"
1010
+ response.conversionTask.importInstance.description.should.equal "memo"
1011
+ end
1012
+
1013
+ specify "import_instance - パラメータが正しく作られるか" do
1014
+ @api.stubs(:make_request).with("Action" => "ImportInstance",
1015
+ "SecurityGroup.1" => "gr1",
1016
+ "SecurityGroup.2" => "gr2",
1017
+ "InstanceType" => "mini",
1018
+ "Placement.AvailabilityZone" => "east-12",
1019
+ "DisableApiTermination" => "false",
1020
+ "InstanceId" => "server01",
1021
+ "Ovf" => "dummy",
1022
+ "AccountingType" => "1",
1023
+ "IpType" => "static"
1024
+ ).returns stub(:body => @import_instance_response_body, :is_a? => true)
1025
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1026
+ response = @api.import_instance(:security_group => %w(gr1 gr2), :instance_type => "mini", :availability_zone => "east-12", :disable_api_termination => "false", :instance_id => "server01", :ovf => "dummy", :accounting_type => "1", :ip_type => "static")
1027
+ end
1028
+
1029
+ specify "import_instance - :security_group正常" do
1030
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1031
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:security_group => 'Group1')) }.should.not.raise(NIFTY::ArgumentError)
1032
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:security_group => 'default(Linux)')) }.should.not.raise(NIFTY::ArgumentError)
1033
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:security_group => 'default(Windows)')) }.should.not.raise(NIFTY::ArgumentError)
1034
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:security_group => %w(Group1 Group2 Group3))) }.should.not.raise(NIFTY::ArgumentError)
1035
+ end
1036
+
1037
+ specify "import_instance - :instance_type正常" do
1038
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1039
+ @valid_instance_type.each do |type|
1040
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:instance_type => type)) }.should.not.raise(NIFTY::ArgumentError)
1041
+ end
1042
+ end
1043
+
1044
+ specify "import_instance - :availability_zone正常" do
1045
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1046
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:availability_zone => 'ap-japan-1a')) }.should.not.raise(NIFTY::ArgumentError)
1047
+ end
1048
+
1049
+ specify "import_instance - :disable_api_termination正常" do
1050
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1051
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:disable_api_termination => true)) }.should.not.raise(NIFTY::ArgumentError)
1052
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:disable_api_termination => false)) }.should.not.raise(NIFTY::ArgumentError)
1053
+ end
1054
+
1055
+ specify "import_instance - :instance_id正常" do
1056
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1057
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:instance_id => 'server01')) }.should.not.raise(NIFTY::ArgumentError)
1058
+ end
1059
+
1060
+ specify "import_instance - :accounting_type正常" do
1061
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1062
+ @accounting_type.each do |type|
1063
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:accounting_type => type)) }.should.not.raise(NIFTY::ArgumentError)
1064
+ end
1065
+ end
1066
+
1067
+ specify "import_instance - :ip_type正常" do
1068
+ @api.stubs(:exec_request).returns stub(:body => @import_instance_response_body, :is_a? => true)
1069
+ @valid_ip_type.each do |type|
1070
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:ip_type => type)) }.should.not.raise(NIFTY::ArgumentError)
1071
+ end
1072
+ end
1073
+
1074
+ specify "import_instance - :security_group不正" do
1075
+ lambda { @api.import_instance(:image_id => 10000, :key_name => "Keyname", :security_group => "Group_name") }.should.raise(NIFTY::ArgumentError)
1076
+ lambda { @api.import_instance(:image_id => 10000, :key_name => "Keyname", :security_group => %w(Group1 Group_2)) }.should.raise(NIFTY::ArgumentError)
1077
+ end
1078
+
1079
+ specify "import_instance - :instance_type不正" do
1080
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:instance_type => 'type')) }.should.raise(NIFTY::ArgumentError)
1081
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:instance_type => 5)) }.should.raise(NIFTY::ArgumentError)
1082
+ end
1083
+
1084
+ specify "import_instance - :disable_api_termination不正" do
1085
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:disable_api_termination => 'disable')) }.should.raise(NIFTY::ArgumentError)
1086
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:disable_api_termination => 0)) }.should.raise(NIFTY::ArgumentError)
1087
+ end
1088
+
1089
+ specify "import_instance - :accounting_type不正" do
1090
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:accounting_type => 3)) }.should.raise(NIFTY::ArgumentError)
1091
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:accounting_type => 'type')) }.should.raise(NIFTY::ArgumentError)
1092
+ end
1093
+
1094
+ specify "import_instance - :ip_type不正" do
1095
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:ip_type => 'ip')) }.should.raise(NIFTY::ArgumentError)
1096
+ lambda { @api.import_instance(@basic_import_instance_options.merge(:ip_type => 5)) }.should.raise(NIFTY::ArgumentError)
1097
+ end
967
1098
  end
@@ -23,6 +23,8 @@ context "load_balancers" do
23
23
  @valid_network_volume = [10, 20, 30, 40, 100, 200, '10', '20', '30', '40', '100', '200']
24
24
  @valid_ip_version = %w(v4 v6)
25
25
  @accounting_type = %w(1 2)
26
+ @session_stickiness_expiration_period = %w(3 5 10 15 30)
27
+ @sorry_page_status_code = %w(200 503)
26
28
 
27
29
  @basic_create_lb_params = {
28
30
  :load_balancer_name => 'lb01',
@@ -136,6 +138,19 @@ context "load_balancers" do
136
138
  <CreatedTime>2010-05-17T11:22:33.456Z</CreatedTime>
137
139
  <AccountingType>1</AccountingType>
138
140
  <NextMonthAccountingType>1</NextMonthAccountingType>
141
+ <Option>
142
+ <SessionStickinessPolicy>
143
+ <Enabled>true</Enabled>
144
+ <ExpirationPeriod>10</ExpirationPeriod>
145
+ </SessionStickinessPolicy>
146
+ <SorryPage>
147
+ <Enabled>true</Enabled>
148
+ <StatusCode>200</StatusCode>
149
+ </SorryPage>
150
+ <MobileFilter>
151
+ <Enabled>true</Enabled>
152
+ </MobileFilter>
153
+ </Option>
139
154
  </member>
140
155
  </LoadBalancerDescriptions>
141
156
  <LoadBalancerDescriptions>
@@ -176,6 +191,19 @@ context "load_balancers" do
176
191
  <CreatedTime>2010-05-17T11:22:43.789Z</CreatedTime>
177
192
  <AccountingType>1</AccountingType>
178
193
  <NextMonthAccountingType>1</NextMonthAccountingType>
194
+ <Option>
195
+ <SessionStickinessPolicy>
196
+ <Enabled>true</Enabled>
197
+ <ExpirationPeriod>10</ExpirationPeriod>
198
+ </SessionStickinessPolicy>
199
+ <SorryPage>
200
+ <Enabled>true</Enabled>
201
+ <StatusCode>200</StatusCode>
202
+ </SorryPage>
203
+ <MobileFilter>
204
+ <Enabled>true</Enabled>
205
+ </MobileFilter>
206
+ </Option>
179
207
  </member>
180
208
  </LoadBalancerDescriptions>
181
209
  </DescribeLoadBalancersResult>
@@ -300,6 +328,41 @@ context "load_balancers" do
300
328
  </ResponseMetadata>
301
329
  </SetFilterForLoadBalancerResponse>
302
330
  RESPONSE
331
+
332
+ @update_load_balancer_option_response_body = <<-RESPONSE
333
+ <UpdateLoadBalancerOptionResponse xmlns="https://cp.cloud.nifty.com/api/">
334
+ <ResponseMetadata>
335
+ <RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
336
+ </ResponseMetadata>
337
+ </UpdateLoadBalancerOptionResponse>
338
+ RESPONSE
339
+
340
+ @set_load_balancer_listener_ssl_certificate_response_body = <<-RESPONSE
341
+ <SetLoadBalancerListenerSSLCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
342
+ <SetLoadBalancerListenerSSLCertificateResult />
343
+ <ResponseMetadata>
344
+ <RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
345
+ </ResponseMetadata>
346
+ </SetLoadBalancerListenerSSLCertificateResponse>
347
+ RESPONSE
348
+
349
+ @unset_load_balancer_listener_ssl_certificate_response_body = <<-RESPONSE
350
+ <UnsetLoadBalancerListenerSSLCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
351
+ <UnsetLoadBalancerListenerSSLCertificateResult />
352
+ <ResponseMetadata>
353
+ <RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
354
+ </ResponseMetadata>
355
+ </UnsetLoadBalancerListenerSSLCertificateResponse>
356
+ RESPONSE
357
+
358
+ @clear_load_balancer_session_response_body = <<-RESPONSE
359
+ <ClearLoadBalancerSessionResponse xmlns="https://cp.cloud.nifty.com/api/">
360
+ <ClearLoadBalancerSessionResult />
361
+ <ResponseMetadata>
362
+ <RequestId>f6dd8353-eb6b-6b4fd32e4f05</RequestId>
363
+ </ResponseMetadata>
364
+ </ClearLoadBalancerSessionResponse>
365
+ RESPONSE
303
366
  end
304
367
 
305
368
 
@@ -632,6 +695,11 @@ context "load_balancers" do
632
695
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Filter.IPAddresses.member[1].should.equal '111.111.111.112'
633
696
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].AvailabilityZones.member[0].should.equal 'ap-japan-1a'
634
697
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].CreatedTime.should.equal '2010-05-17T11:22:33.456Z'
698
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SessionStickinessPolicy.Enabled.should.equal 'true'
699
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SessionStickinessPolicy.ExpirationPeriod.should.equal '10'
700
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SorryPage.Enabled.should.equal 'true'
701
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SorryPage.StatusCode.should.equal '200'
702
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.MobileFilter.Enabled.should.equal 'true'
635
703
 
636
704
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].LoadBalancerName.should.equal 'lb0001'
637
705
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].DNSName.should.equal '10.0.5.222'
@@ -651,6 +719,11 @@ context "load_balancers" do
651
719
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].Filter.IPAddresses.member[0].should.equal '*.*.*.*'
652
720
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].AvailabilityZones.member[0].should.equal 'ap-japan-1a'
653
721
  response.DescribeLoadBalancersResult.LoadBalancerDescriptions[1].member[0].CreatedTime.should.equal '2010-05-17T11:22:43.789Z'
722
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SessionStickinessPolicy.Enabled.should.equal 'true'
723
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SessionStickinessPolicy.ExpirationPeriod.should.equal '10'
724
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SorryPage.Enabled.should.equal 'true'
725
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.SorryPage.StatusCode.should.equal '200'
726
+ response.DescribeLoadBalancersResult.LoadBalancerDescriptions[0].member[0].Option.MobileFilter.Enabled.should.equal 'true'
654
727
 
655
728
  response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
656
729
  end
@@ -1213,5 +1286,288 @@ context "load_balancers" do
1213
1286
  lambda { @api.set_filter_for_load_balancer(@basic_set_filter_params.merge(:filter_type => 0)) }.should.raise(NIFTY::ArgumentError)
1214
1287
  end
1215
1288
 
1289
+
1290
+ # update_load_balancer_option
1291
+ specify "update_load_balancer_option - レスポンスを正しく解析できるか" do
1292
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1293
+ response = @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80)
1294
+ response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
1295
+ end
1296
+
1297
+ specify "update_load_balancer_option - パラメータが正しく作られるか" do
1298
+ @api.stubs(:make_request).with("Action" => "UpdateLoadBalancerOption",
1299
+ "LoadBalancerName" => "a",
1300
+ "LoadBalancerPort" => "80",
1301
+ "InstancePort" => "80",
1302
+ "SessionStickinessOptionUpdate.Enable" => "true",
1303
+ "SessionStickinessOptionUpdate.ExpirationPeriod" => "3",
1304
+ "SorryPageOptionUpdate.Enable" => "true",
1305
+ "SorryPageOptionUpdate.StatusCode" => "200",
1306
+ "MobileFilterOptionUpdate.Enable" => "true"
1307
+ ).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1308
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1309
+ response = @api.update_load_balancer_option(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :session_stickiness_enable => true, :session_stickiness_expiration_period => 3, :sorry_page_enable => true, :sorry_page_status_code => 200, :mobile_filter_enable => true)
1310
+ end
1311
+
1312
+ specify "update_load_balancer_option - :load_balancer_port正常" do
1313
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1314
+ @valid_port.each do |port|
1315
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80) }.should.not.raise(NIFTY::ArgumentError)
1316
+ end
1317
+ end
1318
+
1319
+ specify "update_load_balancer_option - :instance_port正常" do
1320
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1321
+ @valid_port.each do |port|
1322
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
1323
+ end
1324
+ end
1325
+
1326
+ specify "update_load_balancer_option - :session_stickiness_enable,:session_stickiness_expiration_period正常" do
1327
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1328
+ @session_stickiness_expiration_period.each do |period|
1329
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:session_stickiness_enable => true, :session_stickiness_expiration_period => period)) }.should.not.raise(NIFTY::ArgumentError)
1330
+ end
1331
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:session_stickiness_enable => false)) }.should.not.raise(NIFTY::ArgumentError)
1332
+ end
1333
+
1334
+ specify "update_load_balancer_option - :sorry_page_enable,:sorry_page_status_code正常" do
1335
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1336
+ @sorry_page_status_code.each do |code|
1337
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:sorry_page_enable => true, :sorry_page_status_code => code)) }.should.not.raise(NIFTY::ArgumentError)
1338
+ end
1339
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:sorry_page_enable => false)) }.should.not.raise(NIFTY::ArgumentError)
1340
+ end
1341
+
1342
+ specify "update_load_balancer_option - :mobile_filter_enable正常" do
1343
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1344
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:mobile_filter_enable => true)) }.should.not.raise(NIFTY::ArgumentError)
1345
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:mobile_filter_enable => false)) }.should.not.raise(NIFTY::ArgumentError)
1346
+ end
1347
+
1348
+ specify "update_load_balancer_option - :load_balancer_name未指定" do
1349
+ lambda { @api.update_load_balancer_option }.should.raise(NIFTY::ArgumentError)
1350
+ lambda { @api.update_load_balancer_option(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
1351
+ lambda { @api.update_load_balancer_option(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
1352
+ end
1353
+
1354
+ specify "update_load_balancer_option - :load_balancer_port未指定/不正" do
1355
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
1356
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
1357
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
1358
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
1359
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1360
+ end
1361
+
1362
+ specify "update_load_balancer_option - :instance_port未指定/不正" do
1363
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
1364
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
1365
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
1366
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
1367
+ lambda { @api.update_load_balancer_option(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1368
+ end
1369
+
1370
+ specify "update_load_balancer_option - :session_stickiness_enable,:session_stickiness_expiration_period不正" do
1371
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1372
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:session_stickiness_enable => true)) }.should.raise(NIFTY::ArgumentError)
1373
+ [1000, 'hoge'].each do |enable|
1374
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:session_stickiness_enable => enable, :session_stickiness_expiration_period => '3')) }.should.raise(NIFTY::ArgumentError)
1375
+ end
1376
+ [1000, 'hoge'].each do |period|
1377
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:session_stickiness_expiration_period => period)) }.should.raise(NIFTY::ArgumentError)
1378
+ end
1379
+ end
1380
+
1381
+ specify "update_load_balancer_option - :sorry_page_enable,:sorry_page_status_code不正" do
1382
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1383
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:sorry_page_enable => true)) }.should.raise(NIFTY::ArgumentError)
1384
+ [1000, 'hoge'].each do |enable|
1385
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:sorry_page_enable => enable, :sorry_page_status_code => '200')) }.should.raise(NIFTY::ArgumentError)
1386
+ end
1387
+ [1000, 'hoge'].each do |code|
1388
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:sorry_page_status_code => code)) }.should.raise(NIFTY::ArgumentError)
1389
+ end
1390
+ end
1391
+
1392
+ specify "update_load_balancer_option - :mobile_filter_enable不正" do
1393
+ @api.stubs(:exec_request).returns stub(:body => @update_load_balancer_option_response_body, :is_a? => true)
1394
+ [1000, 'hoge'].each do |enable|
1395
+ lambda { @api.update_load_balancer_option(@basic_set_filter_params.merge(:mobile_filter_enable => enable)) }.should.raise(NIFTY::ArgumentError)
1396
+ end
1397
+ end
1398
+
1399
+
1400
+ # set_load_balancer_listener_ssl_certificate
1401
+ specify "set_load_balancer_listener_ssl_certificate - レスポンスを正しく解析できるか" do
1402
+ @api.stubs(:exec_request).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1403
+ response = @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :ssl_certificate_id => 111)
1404
+ response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
1405
+ end
1406
+
1407
+ specify "set_load_balancer_listener_ssl_certificate - パラメータが正しく作られるか" do
1408
+ @api.stubs(:make_request).with("Action" => "SetLoadBalancerListenerSSLCertificate",
1409
+ "LoadBalancerName" => "a",
1410
+ "LoadBalancerPort" => "80",
1411
+ "InstancePort" => "80",
1412
+ "SSLCertificateId" => "111"
1413
+ ).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1414
+ @api.stubs(:exec_request).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1415
+ response = @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :ssl_certificate_id => 111)
1416
+ end
1417
+
1418
+ specify "set_load_balancer_listener_ssl_certificate - :load_balancer_port正常" do
1419
+ @api.stubs(:exec_request).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1420
+ @valid_port.each do |port|
1421
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80, :ssl_certificate_id => 111) }.should.not.raise(NIFTY::ArgumentError)
1422
+ end
1423
+ end
1424
+
1425
+ specify "set_load_balancer_listener_ssl_certificate - :instance_port正常" do
1426
+ @api.stubs(:exec_request).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1427
+ @valid_port.each do |port|
1428
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port, :ssl_certificate_id => 111) }.should.not.raise(NIFTY::ArgumentError)
1429
+ end
1430
+ end
1431
+
1432
+ specify "set_load_balancer_listener_ssl_certificate - :ssl_certificate_id正常" do
1433
+ @api.stubs(:exec_request).returns stub(:body => @set_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1434
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80, :ssl_certificate_id => 111) }.should.not.raise(NIFTY::ArgumentError)
1435
+ end
1436
+
1437
+ specify "set_load_balancer_listener_ssl_certificate - :load_balancer_name未指定" do
1438
+ lambda { @api.set_load_balancer_listener_ssl_certificate }.should.raise(NIFTY::ArgumentError)
1439
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
1440
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
1441
+ end
1442
+
1443
+ specify "set_load_balancer_listener_ssl_certificate - :load_balancer_port未指定/不正" do
1444
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
1445
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
1446
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
1447
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
1448
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1449
+ end
1450
+
1451
+ specify "set_load_balancer_listener_ssl_certificate - :instance_port未指定/不正" do
1452
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
1453
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
1454
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
1455
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
1456
+ lambda { @api.set_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1457
+ end
1458
+
1459
+ specify "set_load_balancer_listener_ssl_certificate - :ssl_certificate_id未指定" do
1460
+ lambda { @api.set_load_balancer_listener_ssl_certificate(@basic_set_filter_params) }.should.raise(NIFTY::ArgumentError)
1461
+ lambda { @api.set_load_balancer_listener_ssl_certificate(@basic_set_filter_params.merge(:ssl_certificate_id => nil)) }.should.raise(NIFTY::ArgumentError)
1462
+ lambda { @api.set_load_balancer_listener_ssl_certificate(@basic_set_filter_params.merge(:ssl_certificate_id => '')) }.should.raise(NIFTY::ArgumentError)
1463
+ end
1464
+
1465
+
1466
+ # unset_load_balancer_listener_ssl_certificate
1467
+ specify "unset_load_balancer_listener_ssl_certificate - レスポンスを正しく解析できるか" do
1468
+ @api.stubs(:exec_request).returns stub(:body => @unset_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1469
+ response = @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80)
1470
+ response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
1471
+ end
1472
+
1473
+ specify "unset_load_balancer_listener_ssl_certificate - パラメータが正しく作られるか" do
1474
+ @api.stubs(:make_request).with("Action" => "UnsetLoadBalancerListenerSSLCertificate",
1475
+ "LoadBalancerName" => "a",
1476
+ "LoadBalancerPort" => "80",
1477
+ "InstancePort" => "80"
1478
+ ).returns stub(:body => @unset_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1479
+ @api.stubs(:exec_request).returns stub(:body => @unset_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1480
+ response = @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80)
1481
+ end
1482
+
1483
+ specify "unset_load_balancer_listener_ssl_certificate - :load_balancer_port正常" do
1484
+ @api.stubs(:exec_request).returns stub(:body => @unset_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1485
+ @valid_port.each do |port|
1486
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80) }.should.not.raise(NIFTY::ArgumentError)
1487
+ end
1488
+ end
1489
+
1490
+ specify "unset_load_balancer_listener_ssl_certificate - :instance_port正常" do
1491
+ @api.stubs(:exec_request).returns stub(:body => @unset_load_balancer_listener_ssl_certificate_response_body, :is_a? => true)
1492
+ @valid_port.each do |port|
1493
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
1494
+ end
1495
+ end
1496
+
1497
+ specify "unset_load_balancer_listener_ssl_certificate - :load_balancer_name未指定" do
1498
+ lambda { @api.unset_load_balancer_listener_ssl_certificate }.should.raise(NIFTY::ArgumentError)
1499
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
1500
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
1501
+ end
1502
+
1503
+ specify "unset_load_balancer_listener_ssl_certificate - :load_balancer_port未指定/不正" do
1504
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
1505
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
1506
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
1507
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
1508
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1509
+ end
1510
+
1511
+ specify "unset_load_balancer_listener_ssl_certificate - :instance_port未指定/不正" do
1512
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
1513
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
1514
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
1515
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
1516
+ lambda { @api.unset_load_balancer_listener_ssl_certificate(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1517
+ end
1518
+
1519
+
1520
+ # clear_load_balancer_session
1521
+ specify "clear_load_balancer_session - レスポンスを正しく解析できるか" do
1522
+ @api.stubs(:exec_request).returns stub(:body => @clear_load_balancer_session_response_body, :is_a? => true)
1523
+ response = @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 80)
1524
+ response.ResponseMetadata.RequestId.should.equal 'f6dd8353-eb6b-6b4fd32e4f05'
1525
+ end
1526
+
1527
+ specify "clear_load_balancer_session - パラメータが正しく作られるか" do
1528
+ @api.stubs(:make_request).with("Action" => "ClearLoadBalancerSession",
1529
+ "LoadBalancerName" => "a",
1530
+ "LoadBalancerPort" => "80",
1531
+ "InstancePort" => "80"
1532
+ ).returns stub(:body => @clear_load_balancer_session_response_body, :is_a? => true)
1533
+ @api.stubs(:exec_request).returns stub(:body => @clear_load_balancer_session_response_body, :is_a? => true)
1534
+ response = @api.clear_load_balancer_session(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80)
1535
+ end
1536
+
1537
+ specify "clear_load_balancer_session - :load_balancer_port正常" do
1538
+ @api.stubs(:exec_request).returns stub(:body => @clear_load_balancer_session_response_body, :is_a? => true)
1539
+ @valid_port.each do |port|
1540
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => port, :instance_port => 80) }.should.not.raise(NIFTY::ArgumentError)
1541
+ end
1542
+ end
1543
+
1544
+ specify "clear_load_balancer_session - :instance_port正常" do
1545
+ @api.stubs(:exec_request).returns stub(:body => @clear_load_balancer_session_response_body, :is_a? => true)
1546
+ @valid_port.each do |port|
1547
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => port) }.should.not.raise(NIFTY::ArgumentError)
1548
+ end
1549
+ end
1550
+
1551
+ specify "clear_load_balancer_session - :load_balancer_name未指定" do
1552
+ lambda { @api.clear_load_balancer_session }.should.raise(NIFTY::ArgumentError)
1553
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
1554
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => '') }.should.raise(NIFTY::ArgumentError)
1555
+ end
1556
+
1557
+ specify "clear_load_balancer_session - :load_balancer_port未指定/不正" do
1558
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1') }.should.raise(NIFTY::ArgumentError)
1559
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => nil) }.should.raise(NIFTY::ArgumentError)
1560
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => '') }.should.raise(NIFTY::ArgumentError)
1561
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 65536) }.should.raise(NIFTY::ArgumentError)
1562
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1563
+ end
1564
+
1565
+ specify "clear_load_balancer_session - :instance_port未指定/不正" do
1566
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80) }.should.raise(NIFTY::ArgumentError)
1567
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => nil) }.should.raise(NIFTY::ArgumentError)
1568
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => '') }.should.raise(NIFTY::ArgumentError)
1569
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 65536) }.should.raise(NIFTY::ArgumentError)
1570
+ lambda { @api.clear_load_balancer_session(:load_balancer_name => 'lb1', :load_balancer_port => 80, :instance_port => 'foo') }.should.raise(NIFTY::ArgumentError)
1571
+ end
1216
1572
  end
1217
1573