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.
@@ -0,0 +1,648 @@
1
+ # coding:utf-8
2
+ #--
3
+ # ニフティクラウドSDK for Ruby
4
+ #
5
+ # Ruby Gem Name:: nifty-cloud-sdk
6
+ # Author:: NIFTY Corporation
7
+ # Copyright:: Copyright 2011 NIFTY Corporation All Rights Reserved.
8
+ # License:: Distributes under the same terms as Ruby
9
+ # Home:: http://cloud.nifty.com/api/
10
+ #++
11
+
12
+ require File.dirname(__FILE__) + '/test_helper.rb'
13
+
14
+ context "instances" do
15
+
16
+ before do
17
+ @api = NIFTY::Cloud::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret",
18
+ :server => 'cp.cloud.nifty.com', :path => '/api/1.7/', :user_agent => 'NIFTY Cloud API Ruby SDK',
19
+ :signature_version => '2', :signature_method => 'HmacSHA256')
20
+
21
+ @describe_resources_response_body = <<-RESPONSE
22
+ <DescribeResourcesResponse xmlns="https://cp.cloud.nifty.com/api/">
23
+ <requestId>b1d415ab-5916-49b2-a428-07ca18548c56</requestId>
24
+ <resourceInfo>
25
+ <instanceItemSet>
26
+ <item>
27
+ <type>mini</type>
28
+ <count>5</count>
29
+ </item>
30
+ </instanceItemSet>
31
+ <dynamicIpCount>1</dynamicIpCount>
32
+ <customizeImageCount>0</customizeImageCount>
33
+ <addDiskCount>1</addDiskCount>
34
+ <addDiskTotalSize>100</addDiskTotalSize>
35
+ <networkFlowAmount>1</networkFlowAmount>
36
+ <securityGroupCount>1</securityGroupCount>
37
+ <loadBalancerCount>1</loadBalancerCount>
38
+ <sslCertCount>1</sslCertCount>
39
+ <monitoringRuleCount>1</monitoringRuleCount>
40
+ <autoScaleCount>1</autoScaleCount>
41
+ <privateLanCount>1</privateLanCount>
42
+ <premiumSupportSet>
43
+ <item>
44
+ <supportName>ヘルプデスク</supportName>
45
+ </item>
46
+ </premiumSupportSet>
47
+ </resourceInfo>
48
+ </DescribeResourcesResponse>
49
+ RESPONSE
50
+
51
+ @describe_service_status_response_body = <<-RESPONSE
52
+ <DescribeServiceStatusResponse xmlns="https://cp.cloud.nifty.com/api/">
53
+ <requestId>b1d415ab-5916-49b2-a428-07ca18548c56</requestId>
54
+ <serviceStatusSet>
55
+ <item>
56
+ <date>2012/02/19</date>
57
+ <instanceStatus>normal</instanceStatus>
58
+ <diskStatus>abnormal</diskStatus>
59
+ <networkStatus>stop</networkStatus>
60
+ <controlPanelStatus>stop</controlPanelStatus>
61
+ <storageStatus>normal</storageStatus>
62
+ </item>
63
+ <item>
64
+ <date>2012/02/20</date>
65
+ <instanceStatus>normal</instanceStatus>
66
+ <diskStatus>normal</diskStatus>
67
+ <networkStatus>normal</networkStatus>
68
+ <controlPanelStatus>normal</controlPanelStatus>
69
+ <storageStatus>normal</storageStatus>
70
+ </item>
71
+ </serviceStatusSet>
72
+ </DescribeServiceStatusResponse>
73
+ RESPONSE
74
+
75
+ @describe_usage_response_body = <<-RESPONSE
76
+ <DescribeUsageResponse xmlns="https://cp.cloud.nifty.com/api/">
77
+ <requestId>b1d415ab-5916-49b2-a428-07ca18548c56</requestId>
78
+ <yearMonth>201106</yearMonth>
79
+ <instanceInfo>
80
+ <instanceMonthlyRateSet>
81
+ <item>
82
+ <type>mini</type>
83
+ <unit>machine</unit>
84
+ <value>1</value>
85
+ </item>
86
+ </instanceMonthlyRateSet>
87
+ <runningInstanceMeasuredRateSet>
88
+ <item>
89
+ <type>mini</type>
90
+ <unit>hour</unit>
91
+ <value>1</value>
92
+ </item>
93
+ </runningInstanceMeasuredRateSet>
94
+ <stoppedInstanceMeasuredRateSet>
95
+ <item>
96
+ <type>mini</type>
97
+ <unit>hour</unit>
98
+ <value>1</value>
99
+ </item>
100
+ </stoppedInstanceMeasuredRateSet>
101
+ <dynamicIpMonthlyRate>
102
+ <unit>machine</unit>
103
+ <value>1</value>
104
+ </dynamicIpMonthlyRate>
105
+ <dynamicIpMeasuredRate>
106
+ <unit>hour</unit>
107
+ <value>1</value>
108
+ </dynamicIpMeasuredRate>
109
+ <osMonthlyRate>
110
+ <item>
111
+ <type>windows</type>
112
+ <unit>vCPU</unit>
113
+ <value>1</value>
114
+ </item>
115
+ </osMonthlyRate>
116
+ <osMeasuredRate>
117
+ <item>
118
+ <type>windows</type>
119
+ <unit>hour</unit>
120
+ <value>1</value>
121
+ </item>
122
+ </osMeasuredRate>
123
+ <multiIpMonthlyRate>
124
+ <unit>IP</unit>
125
+ <value>4</value>
126
+ </multiIpMonthlyRate>
127
+ </instanceInfo>
128
+ <copyInfo>
129
+ <instanceCopy>
130
+ <unit>times</unit>
131
+ <value>1</value>
132
+ </instanceCopy>
133
+ </copyInfo>
134
+ <imageInfo>
135
+ <createImage>
136
+ <unit>times</unit>
137
+ <value>1</value>
138
+ </createImage>
139
+ <keepImageSet>
140
+ <item>
141
+ <type>linux</type>
142
+ <unit>image</unit>
143
+ <value>1</value>
144
+ </item>
145
+ <item>
146
+ <type>windows</type>
147
+ <unit>image</unit>
148
+ <value>1</value>
149
+ </item>
150
+ </keepImageSet>
151
+ </imageInfo>
152
+ <volumeInfo>
153
+ <volumeSet>
154
+ <item>
155
+ <type>Disk100</type>
156
+ <unit>100GB</unit>
157
+ <value>1</value>
158
+ </item>
159
+ </volumeSet>
160
+ <volumeMeasuredRateSet>
161
+ <item>
162
+ <type>Disk100</type>
163
+ <unit>hour</unit>
164
+ <value>223</value>
165
+ </item>
166
+ </volumeMeasuredRateSet>
167
+ <importInstanceDiskMonthlyRate>
168
+ <unit>100GB</unit>
169
+ <value>1</value>
170
+ </importInstanceDiskMonthlyRate>
171
+ <importInstanceDiskMeasuredRate>
172
+ <unit>hour</unit>
173
+ <value>1</value>
174
+ </importInstanceDiskMeasuredRate>
175
+ </volumeInfo>
176
+ <networkInfo>
177
+ <networkFlowSet>
178
+ <item>
179
+ <type>free</type>
180
+ <unit>GB</unit>
181
+ <value>1</value>
182
+ </item>
183
+ <item>
184
+ <type>charge</type>
185
+ <unit>GB</unit>
186
+ <value>1</value>
187
+ </item>
188
+ </networkFlowSet>
189
+ </networkInfo>
190
+ <securityGroupInfo>
191
+ <securityGroupApplyTime>
192
+ <unit>hour</unit>
193
+ <value>1</value>
194
+ </securityGroupApplyTime>
195
+ <optionSet>
196
+ <item>
197
+ <type>group</type>
198
+ <unit>10groups</unit>
199
+ <value>1</value>
200
+ </item>
201
+ </optionSet>
202
+ </securityGroupInfo>
203
+ <loadBalancerInfo>
204
+ <vipSet>
205
+ <item>
206
+ <type>10</type>
207
+ <unit>VIP</unit>
208
+ <value>1</value>
209
+ </item>
210
+ </vipSet>
211
+ <vipMeasuredRateSet>
212
+ <item>
213
+ <type>10</type>
214
+ <unit>hour</unit>
215
+ <value>501</value>
216
+ </item>
217
+ </vipMeasuredRateSet>
218
+ <optionSet>
219
+ <item>
220
+ <type>session</type>
221
+ <unit>hour</unit>
222
+ <value>1</value>
223
+ </item>
224
+ <item>
225
+ <type>accelerator</type>
226
+ <unit>
227
+ </unit>
228
+ <value>598</value>
229
+ </item>
230
+ </optionSet>
231
+ </loadBalancerInfo>
232
+ <autoScaleInfo>
233
+ <autoScaleCount>
234
+ <unit>config</unit>
235
+ <value>1</value>
236
+ </autoScaleCount>
237
+ <runningScaleOutInstanceSet>
238
+ <item>
239
+ <type>mini</type>
240
+ <unit>hour</unit>
241
+ <value>1</value>
242
+ </item>
243
+ </runningScaleOutInstanceSet>
244
+ <stoppedScaleOutInstanceSet>
245
+ <item>
246
+ <type>mini</type>
247
+ <unit>hour</unit>
248
+ <value>1</value>
249
+ </item>
250
+ </stoppedScaleOutInstanceSet>
251
+ <runningScaleOutOsSet>
252
+ <item>
253
+ <type>windows</type>
254
+ <unit>hour</unit>
255
+ <value>1</value>
256
+ </item>
257
+ </runningScaleOutOsSet>
258
+ <stoppedScaleOutOsSet>
259
+ <item>
260
+ <type>windows</type>
261
+ <unit>hour</unit>
262
+ <value>1</value>
263
+ </item>
264
+ </stoppedScaleOutOsSet>
265
+ </autoScaleInfo>
266
+ <sslCertInfo>
267
+ <createSslCertSet>
268
+ <item>
269
+ <type>6</type>
270
+ <unit>cert</unit>
271
+ <value>1</value>
272
+ </item>
273
+ </createSslCertSet>
274
+ </sslCertInfo>
275
+ <privateLanInfo>
276
+ <privateLan>
277
+ <unit>LAN</unit>
278
+ </privateLan>
279
+ </privateLanInfo>
280
+ <chargeDetailInfo>
281
+ <chargeDetail>
282
+ <value>1</value>
283
+ </chargeDetail>
284
+ </chargeDetailInfo>
285
+ <premiumSupportInfo>
286
+ <premiumSupportSet>
287
+ <item>
288
+ <type>ヘルプデスク</type>
289
+ <value>1</value>
290
+ </item>
291
+ </premiumSupportSet>
292
+ </premiumSupportInfo>
293
+ <multiAccountInfo>
294
+ <multiAccount>
295
+ <unit>account</unit>
296
+ <value>3</value>
297
+ </multiAccount>
298
+ </multiAccountInfo>
299
+ <patternAuthInfo>
300
+ <patternAuthSet>
301
+ <item>
302
+ <type>child</type>
303
+ <unit>account</unit>
304
+ <value>4</value>
305
+ </item>
306
+ </patternAuthSet>
307
+ </patternAuthInfo>
308
+ <storageInfo>
309
+ <storageMonthlyRate>
310
+ <type>5TB</type>
311
+ <value>1</value>
312
+ </storageMonthlyRate>
313
+ <storageMeasuredRate>
314
+ <unit>GB</unit>
315
+ <value>411.5</value>
316
+ </storageMeasuredRate>
317
+ </storageInfo>
318
+ <mailSendInfo>
319
+ <mailSendInitial>
320
+ <value>1</value>
321
+ </mailSendInitial>
322
+ <mailSendMonthlyRate>
323
+ <type>3000</type>
324
+ <value>1</value>
325
+ </mailSendMonthlyRate>
326
+ <mailSendMeasuredRate>
327
+ <unit>mail</unit>
328
+ <value>999</value>
329
+ </mailSendMeasuredRate>
330
+ <mailSendMonthlyExceedRate>
331
+ <unit>mail</unit>
332
+ <value>999</value>
333
+ </mailSendMonthlyExceedRate>
334
+ <OptionSet>
335
+ <item>
336
+ <type>initial.decomail</type>
337
+ <value>1</value>
338
+ </item>
339
+ <item>
340
+ <type>decomail</type>
341
+ <value>1</value>
342
+ </item>
343
+ </OptionSet>
344
+ </mailSendInfo>
345
+ <extraChargeInfo>
346
+ <extraChargeMonthlyRateSet>
347
+ <item>
348
+ <type>Oracle11g</type>
349
+ <unit>machine</unit>
350
+ <value>2</value>
351
+ </item>
352
+ </extraChargeMonthlyRateSet>
353
+ </extraChargeInfo>
354
+ </DescribeUsageResponse>
355
+ RESPONSE
356
+
357
+ @describe_user_activities_response_body = <<-RESPONSE
358
+ <DescribeUserActivitiesResponse xmlns="https://cp.cloud.nifty.com/api/">
359
+ <requestId>b1d415ab-5916-49b2-a428-07ca18548c56</requestId>
360
+ <userActivitiesSet>
361
+ <item>
362
+ <dateTime>2012-05-25T18:11:05.000+09:00</dateTime>
363
+ <ipAddress>111.11.111.11</ipAddress>
364
+ <categoryName>API(サーバー)</categoryName>
365
+ <operator>XXX00001</operator>
366
+ <operation>RunInstances[instanceId:ad034c3e,instanceType :,imageId:2,osname:CentOS 5.3 64bit Plain,accountingType :2]SOAP/1.7</operation>
367
+ <result>true</result>
368
+ </item>
369
+ <item>
370
+ <dateTime>2012-05-25T18:11:05.000+09:00</dateTime>
371
+ <ipAddress>111.11.111.11</ipAddress>
372
+ <categoryName>API(サーバー)</categoryName>
373
+ <operator>XXX00001_child</operator>
374
+ <operation>RunInstances[instanceId:ad034c3e,instanceType :,imageId:2,osname:CentOS 5.3 64bit Plain,accountingType :2]SOAP/1.7</operation>
375
+ <result>true</result>
376
+ </item>
377
+ </userActivitiesSet>
378
+ </DescribeUserActivitiesResponse>
379
+ RESPONSE
380
+ end
381
+
382
+
383
+ # describe_resources
384
+ specify "describe_resources - レスポンスを正しく解析できるか" do
385
+ @api.stubs(:exec_request).returns stub(:body => @describe_resources_response_body, :is_a? => true)
386
+
387
+ response = @api.describe_resources
388
+ response.requestId.should.equal "b1d415ab-5916-49b2-a428-07ca18548c56"
389
+ response.resourceInfo.instanceItemSet.item[0].type.should.equal "mini"
390
+ response.resourceInfo.instanceItemSet.item[0]['count'].should.equal "5"
391
+ response.resourceInfo.dynamicIpCount.should.equal "1"
392
+ response.resourceInfo.customizeImageCount.should.equal "0"
393
+ response.resourceInfo.addDiskCount.should.equal "1"
394
+ response.resourceInfo.addDiskTotalSize.should.equal "100"
395
+ response.resourceInfo.networkFlowAmount.should.equal "1"
396
+ response.resourceInfo.securityGroupCount.should.equal "1"
397
+ response.resourceInfo.loadBalancerCount.should.equal "1"
398
+ response.resourceInfo.sslCertCount.should.equal "1"
399
+ response.resourceInfo.monitoringRuleCount.should.equal "1"
400
+ response.resourceInfo.autoScaleCount.should.equal "1"
401
+ response.resourceInfo.privateLanCount.should.equal "1"
402
+ response.resourceInfo.premiumSupportSet.item[0].supportName.should.equal "ヘルプデスク"
403
+ end
404
+
405
+ specify "describe_resources - パラメータが正しく作られるか" do
406
+ @api.stubs(:make_request).with('Action' => 'DescribeResources').returns stub(:body => @describe_resources_response_body, :is_a? => true)
407
+ @api.stubs(:exec_request).returns stub(:body => @describe_resources_response_body, :is_a? => true)
408
+ response = @api.describe_resources
409
+ end
410
+
411
+
412
+ # describe_service_status
413
+ specify "describe_service_status - レスポンスを正しく解析できるか" do
414
+ @api.stubs(:exec_request).returns stub(:body => @describe_service_status_response_body, :is_a? => true)
415
+ response = @api.describe_service_status
416
+ response.requestId.should.equal "b1d415ab-5916-49b2-a428-07ca18548c56"
417
+ response.serviceStatusSet.item[0].date.should.equal "2012/02/19"
418
+ response.serviceStatusSet.item[0].instanceStatus.should.equal "normal"
419
+ response.serviceStatusSet.item[0].diskStatus.should.equal "abnormal"
420
+ response.serviceStatusSet.item[0].networkStatus.should.equal "stop"
421
+ response.serviceStatusSet.item[0].controlPanelStatus.should.equal "stop"
422
+ response.serviceStatusSet.item[0].storageStatus.should.equal "normal"
423
+ response.serviceStatusSet.item[1].date.should.equal "2012/02/20"
424
+ response.serviceStatusSet.item[1].instanceStatus.should.equal "normal"
425
+ response.serviceStatusSet.item[1].diskStatus.should.equal "normal"
426
+ response.serviceStatusSet.item[1].networkStatus.should.equal "normal"
427
+ response.serviceStatusSet.item[1].controlPanelStatus.should.equal "normal"
428
+ response.serviceStatusSet.item[1].storageStatus.should.equal "normal"
429
+ end
430
+
431
+ specify "describe_service_status - パラメータが正しく作られるか" do
432
+ @api.stubs(:make_request).with('Action' => 'DescribeServiceStatus',
433
+ 'FromDate' => '2012/02/01',
434
+ 'ToDate' => '2012/02/10'
435
+ ).returns stub(:body => @describe_service_status_response_body, :is_a? => true)
436
+ @api.stubs(:exec_request).returns stub(:body => @describe_service_status_response_body, :is_a? => true)
437
+ response = @api.describe_service_status(:from_date => '2012/02/01', :to_date => '2012/02/10')
438
+ end
439
+
440
+ specify "describe_service_status - :from_date正常" do
441
+ @api.stubs(:exec_request).returns stub(:body => @describe_service_status_response_body, :is_a? => true)
442
+ lambda { @api.describe_service_status(:from_date => '20120201') }.should.not.raise(NIFTY::ArgumentError)
443
+ lambda { @api.describe_service_status(:from_date => '2012/02/01') }.should.not.raise(NIFTY::ArgumentError)
444
+ lambda { @api.describe_service_status(:from_date => '2012-02-01') }.should.not.raise(NIFTY::ArgumentError)
445
+ end
446
+
447
+ specify "describe_service_status - :to_date正常" do
448
+ @api.stubs(:exec_request).returns stub(:body => @describe_service_status_response_body, :is_a? => true)
449
+ lambda { @api.describe_service_status(:to_date => '20120201') }.should.not.raise(NIFTY::ArgumentError)
450
+ lambda { @api.describe_service_status(:to_date => '2012/02/01') }.should.not.raise(NIFTY::ArgumentError)
451
+ lambda { @api.describe_service_status(:to_date => '2012-02-01') }.should.not.raise(NIFTY::ArgumentError)
452
+ end
453
+
454
+ specify "describe_service_status - :from_date不正" do
455
+ lambda { @api.describe_service_status(:from_date => 'foo') }.should.raise(NIFTY::ArgumentError)
456
+ lambda { @api.describe_service_status(:from_date => 12345) }.should.raise(NIFTY::ArgumentError)
457
+ end
458
+
459
+ specify "describe_service_status - :to_date不正" do
460
+ lambda { @api.describe_service_status(:to_date => 'foo') }.should.raise(NIFTY::ArgumentError)
461
+ lambda { @api.describe_service_status(:to_date => 12345) }.should.raise(NIFTY::ArgumentError)
462
+ end
463
+
464
+
465
+ # describe_usage
466
+ specify "describe_usage - レスポンスを正しく解析できるか" do
467
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
468
+ response = @api.describe_service_status
469
+ response.requestId.should.equal "b1d415ab-5916-49b2-a428-07ca18548c56"
470
+ response.yearMonth.should.equal "201106"
471
+ response.instanceInfo.instanceMonthlyRateSet.item[0].type.should.equal "mini"
472
+ response.instanceInfo.instanceMonthlyRateSet.item[0].unit.should.equal "machine"
473
+ response.instanceInfo.instanceMonthlyRateSet.item[0].value.should.equal "1"
474
+ response.instanceInfo.runningInstanceMeasuredRateSet.item[0].type.should.equal "mini"
475
+ response.instanceInfo.runningInstanceMeasuredRateSet.item[0].unit.should.equal "hour"
476
+ response.instanceInfo.stoppedInstanceMeasuredRateSet.item[0].type.should.equal "mini"
477
+ response.instanceInfo.stoppedInstanceMeasuredRateSet.item[0].unit.should.equal "hour"
478
+ response.instanceInfo.stoppedInstanceMeasuredRateSet.item[0].value.should.equal "1"
479
+ response.instanceInfo.dynamicIpMonthlyRate.unit.should.equal "machine"
480
+ response.instanceInfo.dynamicIpMonthlyRate.value.should.equal "1"
481
+ response.instanceInfo.dynamicIpMeasuredRate.unit.should.equal "hour"
482
+ response.instanceInfo.dynamicIpMeasuredRate.value.should.equal "1"
483
+ response.instanceInfo.osMonthlyRate.item[0].type.should.equal "windows"
484
+ response.instanceInfo.osMonthlyRate.item[0].unit.should.equal "vCPU"
485
+ response.instanceInfo.osMonthlyRate.item[0].value.should.equal "1"
486
+ response.instanceInfo.osMeasuredRate.item[0].type.should.equal "windows"
487
+ response.instanceInfo.osMeasuredRate.item[0].unit.should.equal "hour"
488
+ response.instanceInfo.osMeasuredRate.item[0].value.should.equal "1"
489
+ response.instanceInfo.multiIpMonthlyRate.unit.should.equal "IP"
490
+ response.instanceInfo.multiIpMonthlyRate.value.should.equal "4"
491
+ response.copyInfo.instanceCopy.unit.should.equal "times"
492
+ response.copyInfo.instanceCopy.value.should.equal "1"
493
+ response.imageInfo.createImage.unit.should.equal "times"
494
+ response.imageInfo.createImage.value.should.equal "1"
495
+ response.imageInfo.keepImageSet.item[0].type.should.equal "linux"
496
+ response.imageInfo.keepImageSet.item[0].unit.should.equal "image"
497
+ response.imageInfo.keepImageSet.item[0].value.should.equal "1"
498
+ response.imageInfo.keepImageSet.item[1].type.should.equal "windows"
499
+ response.imageInfo.keepImageSet.item[1].unit.should.equal "image"
500
+ response.imageInfo.keepImageSet.item[1].value.should.equal "1"
501
+ response.volumeInfo.volumeSet.item[0].type.should.equal "Disk100"
502
+ response.volumeInfo.volumeSet.item[0].unit.should.equal "100GB"
503
+ response.volumeInfo.volumeSet.item[0].value.should.equal "1"
504
+ response.volumeInfo.volumeMeasuredRateSet.item[0].type.should.equal "Disk100"
505
+ response.volumeInfo.volumeMeasuredRateSet.item[0].unit.should.equal "hour"
506
+ response.volumeInfo.volumeMeasuredRateSet.item[0].value.should.equal "223"
507
+ response.volumeInfo.importInstanceDiskMonthlyRate.unit.should.equal "100GB"
508
+ response.volumeInfo.importInstanceDiskMonthlyRate.value.should.equal "1"
509
+ response.volumeInfo.importInstanceDiskMeasuredRate.unit.should.equal "hour"
510
+ response.volumeInfo.importInstanceDiskMeasuredRate.value.should.equal "1"
511
+ response.networkInfo.networkFlowSet.item[0].type.should.equal "free"
512
+ response.networkInfo.networkFlowSet.item[0].unit.should.equal "GB"
513
+ response.networkInfo.networkFlowSet.item[0].value.should.equal "1"
514
+ response.networkInfo.networkFlowSet.item[1].type.should.equal "charge"
515
+ response.networkInfo.networkFlowSet.item[1].unit.should.equal "GB"
516
+ response.networkInfo.networkFlowSet.item[1].value.should.equal "1"
517
+ response.securityGroupInfo.securityGroupApplyTime.unit.should.equal "hour"
518
+ response.securityGroupInfo.securityGroupApplyTime.value.should.equal "1"
519
+ response.securityGroupInfo.optionSet.item[0].type.should.equal "group"
520
+ response.securityGroupInfo.optionSet.item[0].unit.should.equal "10groups"
521
+ response.securityGroupInfo.optionSet.item[0].value.should.equal"1"
522
+ response.loadBalancerInfo.vipSet.item[0].type.should.equal "10"
523
+ response.loadBalancerInfo.vipSet.item[0].unit.should.equal "VIP"
524
+ response.loadBalancerInfo.vipSet.item[0].value.should.equal "1"
525
+ response.loadBalancerInfo.vipMeasuredRateSet.item[0].type.should.equal "10"
526
+ response.loadBalancerInfo.vipMeasuredRateSet.item[0].unit.should.equal "hour"
527
+ response.loadBalancerInfo.vipMeasuredRateSet.item[0].value.should.equal"501"
528
+ response.loadBalancerInfo.optionSet.item[0].type.should.equal "session"
529
+ response.loadBalancerInfo.optionSet.item[0].unit.should.equal "hour"
530
+ response.loadBalancerInfo.optionSet.item[0].value.should.equal "1"
531
+ response.loadBalancerInfo.optionSet.item[1].type.should.equal "accelerator"
532
+ response.loadBalancerInfo.optionSet.item[1].unit.should.equal ""
533
+ response.loadBalancerInfo.optionSet.item[1].value.should.equal "598"
534
+ response.autoScaleInfo.autoScaleCount.unit.should.equal "config"
535
+ response.autoScaleInfo.autoScaleCount.value.should.equal "1"
536
+ response.autoScaleInfo.runningScaleOutInstanceSet.item[0].type.should.equal "mini"
537
+ response.autoScaleInfo.runningScaleOutInstanceSet.item[0].unit.should.equal "hour"
538
+ response.autoScaleInfo.runningScaleOutInstanceSet.item[0].value.should.equal "1"
539
+ response.autoScaleInfo.stoppedScaleOutInstanceSet.item[0].type.should.equal "mini"
540
+ response.autoScaleInfo.stoppedScaleOutInstanceSet.item[0].unit.should.equal "hour"
541
+ response.autoScaleInfo.stoppedScaleOutInstanceSet.item[0].value.should.equal "1"
542
+ response.autoScaleInfo.runningScaleOutOsSet.item[0].type.should.equal "windows"
543
+ response.autoScaleInfo.runningScaleOutOsSet.item[0].unit.should.equal "hour"
544
+ response.autoScaleInfo.runningScaleOutOsSet.item[0].value.should.equal "1"
545
+ response.autoScaleInfo.stoppedScaleOutOsSet.item[0].type.should.equal "windows"
546
+ response.autoScaleInfo.stoppedScaleOutOsSet.item[0].unit.should.equal "hour"
547
+ response.autoScaleInfo.stoppedScaleOutOsSet.item[0].value.should.equal "1"
548
+ response.sslCertInfo.createSslCertSet.item[0].type.should.equal "6"
549
+ response.sslCertInfo.createSslCertSet.item[0].unit.should.equal "cert"
550
+ response.sslCertInfo.createSslCertSet.item[0].value.should.equal "1"
551
+ response.privateLanInfo.privateLan.unit.should.equal "LAN"
552
+ response.chargeDetailInfo.chargeDetail.value.should.equal "1"
553
+ response.premiumSupportInfo.premiumSupportSet.item[0].type.should.equal "ヘルプデスク"
554
+ response.premiumSupportInfo.premiumSupportSet.item[0].value.should.equal "1"
555
+ response.multiAccountInfo.multiAccount.unit.should.equal "account"
556
+ response.multiAccountInfo.multiAccount.value.should.equal "3"
557
+ response.patternAuthInfo.patternAuthSet.item[0].type.should.equal "child"
558
+ response.patternAuthInfo.patternAuthSet.item[0].unit.should.equal "account"
559
+ response.patternAuthInfo.patternAuthSet.item[0].value.should.equal "4"
560
+ response.storageInfo.storageMonthlyRate.type.should.equal "5TB"
561
+ response.storageInfo.storageMonthlyRate.value.should.equal "1"
562
+ response.storageInfo.storageMeasuredRate.unit.should.equal "GB"
563
+ response.storageInfo.storageMeasuredRate.value.should.equal "411.5"
564
+ response.mailSendInfo.mailSendInitial.value.should.equal "1"
565
+ response.mailSendInfo.mailSendMonthlyRate.type.should.equal "3000"
566
+ response.mailSendInfo.mailSendMonthlyRate.value.should.equal "1"
567
+ response.mailSendInfo.mailSendMeasuredRate.unit.should.equal "mail"
568
+ response.mailSendInfo.mailSendMeasuredRate.value.should.equal "999"
569
+ response.mailSendInfo.mailSendMonthlyExceedRate.unit.should.equal "mail"
570
+ response.mailSendInfo.mailSendMonthlyExceedRate.value.should.equal "999"
571
+ response.mailSendInfo.OptionSet.item[0].type.should.equal "initial.decomail"
572
+ response.mailSendInfo.OptionSet.item[0].value.should.equal "1"
573
+ response.mailSendInfo.OptionSet.item[1].type.should.equal "decomail"
574
+ response.mailSendInfo.OptionSet.item[1].value.should.equal "1"
575
+ response.extraChargeInfo.extraChargeMonthlyRateSet.item[0].type.should.equal "Oracle11g"
576
+ response.extraChargeInfo.extraChargeMonthlyRateSet.item[0].unit.should.equal "machine"
577
+ response.extraChargeInfo.extraChargeMonthlyRateSet.item[0].value.should.equal "2"
578
+ end
579
+
580
+ specify "describe_usage - パラメータが正しく作られるか" do
581
+ @api.stubs(:make_request).with('Action' => 'DescribeUsage',
582
+ 'YearMonth' => '2011-02',
583
+ 'Region' => 'east-1'
584
+ ).returns stub(:body => @describe_usage_response_body, :is_a? => true)
585
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
586
+ response = @api.describe_usage(:year_month => '2011-02', :region => 'east-1')
587
+ end
588
+
589
+ specify "describe_usage - :year_month正常" do
590
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
591
+ %w(201211 2012-11 2012/11).each do |year_month|
592
+ lambda { @api.describe_usage(:year_month => year_month) }.should.not.raise(NIFTY::ArgumentError)
593
+ end
594
+ end
595
+
596
+ specify "describe_usage - :region正常" do
597
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
598
+ lambda { @api.describe_usage }.should.not.raise(NIFTY::ArgumentError)
599
+ lambda { @api.describe_usage(:region => 'east-1') }.should.not.raise(NIFTY::ArgumentError)
600
+ end
601
+
602
+ specify "describe_usage - :year_month不正" do
603
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
604
+ lambda { @api.describe_usage(:year_month => '2012.11') }.should.raise(NIFTY::ArgumentError)
605
+ lambda { @api.describe_usage(:year_month => 20121103) }.should.raise(NIFTY::ArgumentError)
606
+ end
607
+
608
+
609
+ specify "describe_user_activities - パラメータが正しく作られるか" do
610
+ @api.stubs(:make_request).with('Action' => 'DescribeUserActivities',
611
+ 'YearMonth' => '2011-02'
612
+ ).returns stub(:body => @describe_usage_response_body, :is_a? => true)
613
+ @api.stubs(:exec_request).returns stub(:body => @describe_usage_response_body, :is_a? => true)
614
+ response = @api.describe_user_activities(:year_month => '2011-02')
615
+ end
616
+
617
+ specify "describe_user_activities - レスポンスを正しく解析できるか" do
618
+ @api.stubs(:exec_request).returns stub(:body => @describe_user_activities_response_body, :is_a? => true)
619
+ response = @api.describe_user_activities
620
+ response.requestId.should.equal "b1d415ab-5916-49b2-a428-07ca18548c56"
621
+ response.userActivitiesSet.item[0].dateTime.should.equal "2012-05-25T18:11:05.000+09:00"
622
+ response.userActivitiesSet.item[0].ipAddress.should.equal "111.11.111.11"
623
+ response.userActivitiesSet.item[0].categoryName.should.equal "API(サーバー)"
624
+ response.userActivitiesSet.item[0].operator.should.equal "XXX00001"
625
+ response.userActivitiesSet.item[0].operation.should.equal "RunInstances[instanceId:ad034c3e,instanceType :,imageId:2,osname:CentOS 5.3 64bit Plain,accountingType :2]SOAP/1.7"
626
+ response.userActivitiesSet.item[0].result.should.equal "true"
627
+ response.userActivitiesSet.item[1].dateTime.should.equal "2012-05-25T18:11:05.000+09:00"
628
+ response.userActivitiesSet.item[1].ipAddress.should.equal "111.11.111.11"
629
+ response.userActivitiesSet.item[1].categoryName.should.equal "API(サーバー)"
630
+ response.userActivitiesSet.item[1].operator.should.equal "XXX00001_child"
631
+ response.userActivitiesSet.item[1].operation.should.equal "RunInstances[instanceId:ad034c3e,instanceType :,imageId:2,osname:CentOS 5.3 64bit Plain,accountingType :2]SOAP/1.7"
632
+ response.userActivitiesSet.item[1].result.should.equal "true"
633
+ end
634
+
635
+ specify "describe_user_activities - :year_month正常" do
636
+ @api.stubs(:exec_request).returns stub(:body => @describe_user_activities_response_body, :is_a? => true)
637
+ lambda { @api.describe_user_activities }.should.not.raise(NIFTY::ArgumentError)
638
+ %w(201211 2012-11 2012/11).each do |year_month|
639
+ lambda { @api.describe_user_activities(:year_month => year_month) }.should.not.raise(NIFTY::ArgumentError)
640
+ end
641
+ end
642
+
643
+ specify "describe_user_activities - :year_month不正" do
644
+ @api.stubs(:exec_request).returns stub(:body => @describe_user_activities_response_body, :is_a? => true)
645
+ lambda { @api.describe_user_activities(:year_month => '2012.11') }.should.raise(NIFTY::ArgumentError)
646
+ lambda { @api.describe_user_activities(:year_month => 20121103) }.should.raise(NIFTY::ArgumentError)
647
+ end
648
+ end