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.
@@ -20,6 +20,8 @@ context "security_groups" do
20
20
 
21
21
  @valid_ip_protocol = %w(TCP UDP ICMP SSH HTTP HTTPS SMTP POP3 IMAP)
22
22
  @valid_in_out = %w(IN In in Out Out out)
23
+ @valid_course_update = [1, 2, '1', '2']
24
+ @valid_boolean = [true, false, 'true', 'false']
23
25
 
24
26
  @basic_ip_permissions = {:ip_protocol => 'HTTP', :group_name => 'gr2'}
25
27
  @basic_auth_security_params = {:group_name => 'gr1', :ip_permissions => @basic_ip_permissions}
@@ -85,6 +87,10 @@ context "security_groups" do
85
87
  <instanceId>server02</instanceId>
86
88
  </member>
87
89
  </instances>
90
+ <groupRuleLimit>10</groupRuleLimit>
91
+ <groupLogLimit>1000</groupLogLimit>
92
+ <groupLogFilterNetBios>true</groupLogFilterNetBios>
93
+ <availabilityZone>east-11</availabilityZone>
88
94
  </item>
89
95
  </securityGroupInfo>
90
96
  </DescribeSecurityGroupsResponse>
@@ -140,6 +146,21 @@ context "security_groups" do
140
146
  2011-01-09T11:21:53+09:00 Altor_VNF time=2297218603613 fw_id=4 src_ip=10.0.6.201 src_port=68 dst_ip=10.0.4.11 dst_port=67 ip_proto=17 action=accept vm_id=16853 rule_id=52 type=fw</log>
141
147
  </DescribeSecurityActivitiesResponse>
142
148
  RESPONSE
149
+
150
+ @update_security_group_option_response_body = <<-RESPONSE
151
+ <UpdateSecurityGroupOptionResponse xmlns="https://cp.cloud.nifty.com/api/">
152
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
153
+ <return>true</return>
154
+ </UpdateSecurityGroupOptionResponse>
155
+ RESPONSE
156
+
157
+ @describe_security_group_option_response_body = <<-RESPONSE
158
+ <DescribeSecurityGroupOptionResponse xmlns="https://cp.cloud.nifty.com/api/">
159
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
160
+ <course>2</course>
161
+ <securityGroupLimit>25</securityGroupLimit>
162
+ </DescribeSecurityGroupOptionResponse>
163
+ RESPONSE
143
164
  end
144
165
 
145
166
 
@@ -222,10 +243,12 @@ context "security_groups" do
222
243
  @api.stubs(:make_request).with("Action" => "UpdateSecurityGroup",
223
244
  "GroupName" => "a",
224
245
  "GroupNameUpdate" => "a",
225
- "GroupDescriptionUpdate" => "a"
246
+ "GroupDescriptionUpdate" => "a",
247
+ "GroupLogLimitUpdate" => "1000",
248
+ "GroupLogFilterNetBios" => "true"
226
249
  ).returns stub(:body => @update_security_group_response_body, :is_a? => true)
227
250
  @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
228
- response = @api.update_security_group(:group_name => "a", :group_name_update => "a", :group_description_update => "a")
251
+ response = @api.update_security_group(:group_name => "a", :group_name_update => "a", :group_description_update => "a", :group_log_limit_update => 1000, :group_log_filter_net_bios => true)
229
252
  end
230
253
 
231
254
  specify "update_security_group - :group_name正常" do
@@ -244,6 +267,20 @@ context "security_groups" do
244
267
  @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
245
268
  lambda { @api.update_security_group(:group_name => 'foo', :group_description_update => 'テスト') }.should.not.raise(NIFTY::ArgumentError)
246
269
  end
270
+
271
+ specify "update_security_group - :group_log_limit_update正常" do
272
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
273
+ [1, 1000, '1', '1000'].each do |limit|
274
+ lambda { @api.update_security_group(:group_name => 'foo', :group_log_limit_update => limit) }.should.not.raise(NIFTY::ArgumentError)
275
+ end
276
+ end
277
+
278
+ specify "update_security_group - :group_log_filter_net_bios正常" do
279
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
280
+ @valid_boolean.each do |boolean|
281
+ lambda { @api.update_security_group(:group_name => 'foo', :group_log_filter_net_bios => boolean) }.should.not.raise(NIFTY::ArgumentError)
282
+ end
283
+ end
247
284
 
248
285
  specify "update_security_group - :group_name未指定/不正" do
249
286
  lambda { @api.update_security_group }.should.raise(NIFTY::ArgumentError)
@@ -252,6 +289,20 @@ context "security_groups" do
252
289
  lambda { @api.update_security_group(:group_name => 'Group_name') }.should.raise(NIFTY::ArgumentError)
253
290
  end
254
291
 
292
+ specify "update_security_group - :group_log_limit_update不正" do
293
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
294
+ ['hoge'].each do |limit|
295
+ lambda { @api.update_security_group(:group_name => 'foo', :group_log_limit_update => limit) }.should.raise(NIFTY::ArgumentError)
296
+ end
297
+ end
298
+
299
+ specify "update_security_group - :group_log_filter_net_bios不正" do
300
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_response_body, :is_a? => true)
301
+ [1, 'foobar'].each do |boolean|
302
+ lambda { @api.update_security_group(:group_name => 'foo', :group_log_filter_net_bios => boolean) }.should.raise(NIFTY::ArgumentError)
303
+ end
304
+ end
305
+
255
306
 
256
307
  # describe_security_groups
257
308
  specify "describe_security_groups - レスポンスを正しく解析できるか" do
@@ -275,6 +326,10 @@ context "security_groups" do
275
326
  response.securityGroupInfo.item[0].ipPermissions.item[1].groups.item[0].groupName.should.equal 'Web'
276
327
  response.securityGroupInfo.item[0].instances.member[0].instanceId[0].should.equal 'server01'
277
328
  response.securityGroupInfo.item[0].instances.member[0].instanceId[1].should.equal 'server02'
329
+ response.securityGroupInfo.item[0].groupRuleLimit.should.equal '10'
330
+ response.securityGroupInfo.item[0].groupLogLimit.should.equal '1000'
331
+ response.securityGroupInfo.item[0].groupLogFilterNetBios.should.equal 'true'
332
+ response.securityGroupInfo.item[0].availabilityZone.should.equal 'east-11'
278
333
  end
279
334
 
280
335
  specify "describe_security_groups - パラメータが正しく作られるか" do
@@ -697,4 +752,88 @@ context "security_groups" do
697
752
  lambda { @api.describe_security_activities(:group_name => 'foo', :range_end_number => 0) }.should.raise(NIFTY::ArgumentError)
698
753
  lambda { @api.describe_security_activities(:group_name => 'foo', :range_start_number => 5, :range_end_number => 1) }.should.raise(NIFTY::ArgumentError)
699
754
  end
755
+
756
+
757
+ # update_security_group_option
758
+ specify "update_security_group_option - レスポンスを正しく解析できるか" do
759
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
760
+ response = @api.update_security_group_option(:group_name => 'default(Linux)')
761
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
762
+ response.return.should.equal 'true'
763
+ end
764
+
765
+ specify "update_security_group_option - パラメータが正しく作られるか" do
766
+ @api.stubs(:make_request).with("Action" => "UpdateSecurityGroupOption",
767
+ "CourseUpdate" => "2",
768
+ "CourseUpdate.Agreement" => "true",
769
+ "SecurityGroupLimitUpdate" => "20"
770
+ ).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
771
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
772
+ response = @api.update_security_group_option(:course_update => 2, :agreement => true, :security_group_limit_update => 20)
773
+ end
774
+
775
+ specify "update_security_group_option - :course_update正常" do
776
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
777
+ @valid_course_update.each do |course_update|
778
+ lambda { @api.update_security_group_option(:course_update => course_update, :agreement => true) }.should.not.raise(NIFTY::ArgumentError)
779
+ end
780
+ end
781
+
782
+ specify "update_security_group_option - :agreement正常" do
783
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
784
+ @valid_boolean.each do |agreement|
785
+ lambda { @api.update_security_group_option(:agreement => agreement) }.should.not.raise(NIFTY::ArgumentError)
786
+ end
787
+ end
788
+
789
+ specify "update_security_group_option - :security_group_limit_update正常" do
790
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
791
+ [1, 1000, '1', '1000'].each do |limit|
792
+ lambda { @api.update_security_group_option(:security_group_limit_update => limit) }.should.not.raise(NIFTY::ArgumentError)
793
+ end
794
+ end
795
+
796
+ specify "update_security_group_option - :course_update不正" do
797
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
798
+ [3 ,'hoge'].each do |course_update|
799
+ lambda { @api.update_security_group_option(:course_update => course_update, :agreement => true) }.should.raise(NIFTY::ArgumentError)
800
+ end
801
+ end
802
+
803
+ specify "update_security_group_option - :agreement不正" do
804
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
805
+ [1, 'fuga'].each do |agreement|
806
+ lambda { @api.update_security_group_option(:agreement => agreement) }.should.raise(NIFTY::ArgumentError)
807
+ end
808
+ end
809
+
810
+ specify "update_security_group_option - :agreement未指定 - :course_update=2指定時" do
811
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
812
+ [2, '2'].each do |x|
813
+ lambda { @api.update_security_group_option(:course_update => x) }.should.raise(NIFTY::ArgumentError)
814
+ end
815
+ end
816
+
817
+
818
+ specify "update_security_group_option - :security_group_limit_update不正" do
819
+ @api.stubs(:exec_request).returns stub(:body => @update_security_group_option_response_body, :is_a? => true)
820
+ ['foobar'].each do |limit|
821
+ lambda { @api.update_security_group_option(:security_group_limit_update => limit) }.should.raise(NIFTY::ArgumentError)
822
+ end
823
+ end
824
+
825
+ # describe_security_group_option
826
+ specify "describe_security_group_option - レスポンスを正しく解析できるか" do
827
+ @api.stubs(:exec_request).returns stub(:body => @describe_security_group_option_response_body, :is_a? => true)
828
+ response = @api.describe_security_group_option(:group_name => 'default(Linux)')
829
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
830
+ response.course.should.equal '2'
831
+ response.securityGroupLimit.should.equal '25'
832
+ end
833
+
834
+ specify "describe_security_group_option - パラメータが正しく作られるか" do
835
+ @api.stubs(:make_request).with("Action" => "DescribeSecurityGroupOption").returns stub(:body => @describe_security_group_option_response_body, :is_a? => true)
836
+ @api.stubs(:exec_request).returns stub(:body => @describe_security_group_option_response_body, :is_a? => true)
837
+ response = @api.describe_security_group_option()
838
+ end
700
839
  end
@@ -0,0 +1,105 @@
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_uploads_response_body = <<-RESPONSE
22
+ <DescribeUploadsResponse xmlns="https://cp.cloud.nifty.com/api/">
23
+ <uploads>
24
+ <item>
25
+ <conversionTaskId>d6f1ba72-0a76-4b1d-8421-a4f6089d3d7a</conversionTaskId>
26
+ <expirationTime>2010-10-13T19:17:28.799+09:00</expirationTime>
27
+ <importInstance>
28
+ <availabilityZone>east-11</availabilityZone>
29
+ <image>
30
+ <format>VMDK</format>
31
+ <size>3489231321</size>
32
+ </image>
33
+ <instanceId>server01</instanceId>
34
+ </importInstance>
35
+ </item>
36
+ </uploads>
37
+ </DescribeUploadsResponse>
38
+ RESPONSE
39
+
40
+ @cancel_upload_response_body = <<-RESPONSE
41
+ <CancelUploadResponse xmlns="https://cp.cloud.nifty.com/api/">
42
+ <requestId>f6dd8353-eb6b-6b4fd32e4f05</requestId>
43
+ <return>true</return>
44
+ </CancelUploadResponse>
45
+ RESPONSE
46
+ end
47
+
48
+
49
+ # describe_uploads
50
+ specify "describe_uploads - レスポンスを正しく解析できるか" do
51
+ @api.stubs(:exec_request).returns stub(:body => @describe_uploads_response_body, :is_a? => true)
52
+
53
+ response = @api.describe_uploads( :conversion_task_id => "server01" )
54
+ response.uploads.item[0].conversionTaskId.should.equal "d6f1ba72-0a76-4b1d-8421-a4f6089d3d7a"
55
+ response.uploads.item[0].expirationTime.should.equal "2010-10-13T19:17:28.799+09:00"
56
+ response.uploads.item[0].importInstance.availabilityZone.should.equal "east-11"
57
+ response.uploads.item[0].importInstance.image.format.should.equal "VMDK"
58
+ response.uploads.item[0].importInstance.image["size"].should.equal "3489231321"
59
+ response.uploads.item[0].importInstance.instanceId.should.equal "server01"
60
+ end
61
+
62
+ specify "describe_uploads - パラメータが正しく作られるか" do
63
+ @api.stubs(:make_request).with('Action' => 'DescribeUploads',
64
+ 'ConversionTaskId.1' => 'd6f1ba72-0a76-4b1d-8421-a4f6089d3d7a',
65
+ 'ConversionTaskId.2' => 'd6f1ba72-0a76-4b1d-8421-a4f6089d3d7b').returns stub(:body => @describe_uploads_response_body, :is_a? => true)
66
+ @api.stubs(:exec_request).returns stub(:body => @describe_uploads_response_body, :is_a? => true)
67
+ response = @api.describe_uploads( :conversion_task_id => %w(d6f1ba72-0a76-4b1d-8421-a4f6089d3d7a d6f1ba72-0a76-4b1d-8421-a4f6089d3d7b) )
68
+ end
69
+
70
+ specify "describe_uploads - :conversion_task_id正常" do
71
+ @api.stubs(:exec_request).returns stub(:body => @describe_uploads_response_body, :is_a? => true)
72
+ lambda { @api.describe_uploads }.should.not.raise(NIFTY::ArgumentError)
73
+ lambda { @api.describe_uploads(:conversion_task_id => 12345) }.should.not.raise(NIFTY::ArgumentError)
74
+ lambda { @api.describe_uploads(:conversion_task_id => %w(foo bar hoge)) }.should.not.raise(NIFTY::ArgumentError)
75
+ end
76
+
77
+
78
+ # cancel_upload
79
+ specify "cancel_upload - レスポンスを正しく解析できるか" do
80
+ @api.stubs(:exec_request).returns stub(:body => @cancel_upload_response_body, :is_a? => true)
81
+ response = @api.cancel_upload(:conversion_task_id => 'copyserver')
82
+ response.requestId.should.equal "f6dd8353-eb6b-6b4fd32e4f05"
83
+ response.return.should.equal "true"
84
+ end
85
+
86
+ specify "cancel_upload - パラメータが正しく作られるか" do
87
+ @api.stubs(:make_request).with('Action' => 'CancelUpload',
88
+ 'ConversionTaskId' => 'd6f1ba72-0a76-4b1d-8421-a4f6089d3d7a1'
89
+ ).returns stub(:body => @cancel_upload_response_body, :is_a? => true)
90
+ @api.stubs(:exec_request).returns stub(:body => @cancel_upload_response_body, :is_a? => true)
91
+ response = @api.cancel_upload( :conversion_task_id => "d6f1ba72-0a76-4b1d-8421-a4f6089d3d7a1" )
92
+ end
93
+
94
+ specify "cancel_upload - :conversion_task_id正常" do
95
+ @api.stubs(:exec_request).returns stub(:body => @cancel_upload_response_body, :is_a? => true)
96
+ lambda { @api.cancel_upload(:conversion_task_id => 'foo') }.should.not.raise(NIFTY::ArgumentError)
97
+ lambda { @api.cancel_upload(:conversion_task_id => 12345) }.should.not.raise(NIFTY::ArgumentError)
98
+ end
99
+
100
+ specify "cancel_upload - :conversion_task_id未指定" do
101
+ lambda { @api.cancel_upload }.should.raise(NIFTY::ArgumentError)
102
+ lambda { @api.cancel_upload(:conversion_task_id => nil) }.should.raise(NIFTY::ArgumentError)
103
+ lambda { @api.cancel_upload(:conversion_task_id => '') }.should.raise(NIFTY::ArgumentError)
104
+ end
105
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nifty-cloud-sdk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196225
4
+ hash: 62196233
5
5
  prerelease: 4
6
6
  segments:
7
7
  - 1
8
- - 8
8
+ - 9
9
9
  - beta
10
10
  - 1
11
- version: 1.8.beta1
11
+ version: 1.9.beta1
12
12
  platform: ruby
13
13
  authors:
14
14
  - NIFTY Corporation
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-11-12 00:00:00 +09:00
19
+ date: 2012-11-24 00:00:00 +09:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -150,7 +150,9 @@ files:
150
150
  - README.rdoc
151
151
  - lib/NIFTY/Cloud/certificates.rb
152
152
  - lib/NIFTY/Cloud/availability_zones.rb
153
+ - lib/NIFTY/Cloud/resources.rb
153
154
  - lib/NIFTY/Cloud/images.rb
155
+ - lib/NIFTY/Cloud/uploads.rb
154
156
  - lib/NIFTY/Cloud/security_groups.rb
155
157
  - lib/NIFTY/Cloud/instances.rb
156
158
  - lib/NIFTY/Cloud/keypairs.rb
@@ -213,6 +215,7 @@ files:
213
215
  - sample/load_balancers/describe-instance-health.rb
214
216
  - sample/load_balancers/register-instances-with-load-balancer.rb
215
217
  - test/test_Cloud.rb
218
+ - test/test_Cloud_uploads.rb
216
219
  - test/test_Cloud_load_balancers.rb
217
220
  - test/test_Cloud_instances.rb
218
221
  - test/test_Cloud_responses.rb
@@ -221,6 +224,7 @@ files:
221
224
  - test/test_Cloud_availability_zones.rb
222
225
  - test/test_Cloud_images.rb
223
226
  - test/test_helper.rb
227
+ - test/test_Cloud_resources.rb
224
228
  - test/test_Cloud_security_groups.rb
225
229
  - test/test_Cloud_keypairs.rb
226
230
  has_rdoc: true
@@ -267,6 +271,7 @@ specification_version: 3
267
271
  summary: NIFTY Cloud SDK for Ruby
268
272
  test_files:
269
273
  - test/test_Cloud.rb
274
+ - test/test_Cloud_uploads.rb
270
275
  - test/test_Cloud_load_balancers.rb
271
276
  - test/test_Cloud_instances.rb
272
277
  - test/test_Cloud_responses.rb
@@ -275,5 +280,6 @@ test_files:
275
280
  - test/test_Cloud_availability_zones.rb
276
281
  - test/test_Cloud_images.rb
277
282
  - test/test_helper.rb
283
+ - test/test_Cloud_resources.rb
278
284
  - test/test_Cloud_security_groups.rb
279
285
  - test/test_Cloud_keypairs.rb