nifty-cloud-sdk 1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGELOG +112 -0
  2. data/Gemfile +4 -0
  3. data/INSTALL +30 -0
  4. data/LICENSE.txt +58 -0
  5. data/README.rdoc +375 -0
  6. data/Rakefile +61 -0
  7. data/lib/NIFTY.rb +405 -0
  8. data/lib/NIFTY/Cloud.rb +24 -0
  9. data/lib/NIFTY/Cloud/availability_zones.rb +23 -0
  10. data/lib/NIFTY/Cloud/certificates.rb +283 -0
  11. data/lib/NIFTY/Cloud/images.rb +134 -0
  12. data/lib/NIFTY/Cloud/instances.rb +372 -0
  13. data/lib/NIFTY/Cloud/keypairs.rb +76 -0
  14. data/lib/NIFTY/Cloud/load_balancers.rb +433 -0
  15. data/lib/NIFTY/Cloud/security_groups.rb +357 -0
  16. data/lib/NIFTY/Cloud/volumes.rb +140 -0
  17. data/lib/NIFTY/config.rb +41 -0
  18. data/lib/NIFTY/exceptions.rb +32 -0
  19. data/lib/NIFTY/responses.rb +19 -0
  20. data/lib/NIFTY/version.rb +3 -0
  21. data/nifty-cloud-sdk.gemspec +28 -0
  22. data/sample/availability_zones/describe-availability-zones.rb +37 -0
  23. data/sample/certificate/create-ssl-certificate.rb +41 -0
  24. data/sample/certificate/delete-ssl-certificate.rb +28 -0
  25. data/sample/certificate/describe-ssl-certificate-attribute.rb +58 -0
  26. data/sample/certificate/describe-ssl-certificates.rb +49 -0
  27. data/sample/certificate/download-ssl-certificate.rb +31 -0
  28. data/sample/certificate/modify-ssl-certificate-attribute.rb +29 -0
  29. data/sample/certificate/register-corporate-info-for-certificate.rb +57 -0
  30. data/sample/certificate/upload-ssl-certificate.rb +32 -0
  31. data/sample/images/create-image.rb +33 -0
  32. data/sample/images/delete-image.rb +26 -0
  33. data/sample/images/describe-images.rb +70 -0
  34. data/sample/images/modify-image-attribute.rb +33 -0
  35. data/sample/instances/cancel_copy_instances.rb +26 -0
  36. data/sample/instances/copy-instances.rb +41 -0
  37. data/sample/instances/describe-instance-attribute.rb +78 -0
  38. data/sample/instances/describe-instances.rb +100 -0
  39. data/sample/instances/modify-instance-attribute.rb +30 -0
  40. data/sample/instances/reboot-instances.rb +29 -0
  41. data/sample/instances/run-instances.rb +104 -0
  42. data/sample/instances/start-instances.rb +36 -0
  43. data/sample/instances/stop-instances.rb +35 -0
  44. data/sample/instances/terminate-instances.rb +34 -0
  45. data/sample/keypairs/create-key-pair.rb +31 -0
  46. data/sample/keypairs/delete-key-pair.rb +28 -0
  47. data/sample/keypairs/describe-key-pairs.rb +31 -0
  48. data/sample/load_balancers/configure-health-check.rb +41 -0
  49. data/sample/load_balancers/create-load-balancer.rb +35 -0
  50. data/sample/load_balancers/delete-load-balancer.rb +28 -0
  51. data/sample/load_balancers/deregister-instances-from-load-balancer.rb +35 -0
  52. data/sample/load_balancers/describe-instance-health.rb +36 -0
  53. data/sample/load_balancers/describe-load-balancers.rb +89 -0
  54. data/sample/load_balancers/register-instances-with-load-balancer.rb +33 -0
  55. data/sample/load_balancers/register-port-with-load-balancer.rb +37 -0
  56. data/sample/load_balancers/set-filter-for-load-balancer.rb +38 -0
  57. data/sample/load_balancers/update-load-balancer.rb +33 -0
  58. data/sample/security_groups/authorize-security-group-ingress.rb +36 -0
  59. data/sample/security_groups/create-security-group.rb +29 -0
  60. data/sample/security_groups/delete-security-group.rb +28 -0
  61. data/sample/security_groups/deregister-instances-from-security-group.rb +31 -0
  62. data/sample/security_groups/describe-security-activities.rb +33 -0
  63. data/sample/security_groups/describe-security-groups.rb +59 -0
  64. data/sample/security_groups/register-instances-with-security-group.rb +31 -0
  65. data/sample/security_groups/revoke-security-group-ingress.rb +36 -0
  66. data/sample/security_groups/update-security-group.rb +30 -0
  67. data/sample/volumes/attach-volumes.rb +34 -0
  68. data/sample/volumes/create-volume.rb +38 -0
  69. data/sample/volumes/delete-volume.rb +28 -0
  70. data/sample/volumes/describe-volumes.rb +44 -0
  71. data/sample/volumes/detach-volume.rb +35 -0
  72. data/test/test_Cloud.rb +186 -0
  73. data/test/test_Cloud_availability_zones.rb +50 -0
  74. data/test/test_Cloud_certificates.rb +627 -0
  75. data/test/test_Cloud_images.rb +284 -0
  76. data/test/test_Cloud_instances.rb +941 -0
  77. data/test/test_Cloud_keypairs.rb +177 -0
  78. data/test/test_Cloud_load_balancers.rb +1183 -0
  79. data/test/test_Cloud_responses.rb +43 -0
  80. data/test/test_Cloud_security_groups.rb +699 -0
  81. data/test/test_Cloud_volumes.rb +325 -0
  82. data/test/test_helper.rb +23 -0
  83. metadata +275 -0
@@ -0,0 +1,50 @@
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 "availability_zones" 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
+ @describe_availability_zones_response_body = <<-RESPONSE
21
+ <DescribeAvailabilityZonesResponse xmlns="http://xxxx.nifty.com/xxx/xxx/">
22
+ <availabilityZoneInfo>
23
+ <item>
24
+ <zoneName>ap-japan-1a</zoneName>
25
+ <zoneState>available</zoneState>
26
+ <regionName>ap-japan-1</regionName>
27
+ </item>
28
+ </availabilityZoneInfo>
29
+ </DescribeAvailabilityZonesResponse>
30
+ RESPONSE
31
+
32
+ end
33
+
34
+
35
+ # describe_availability_zones
36
+ specify "describe_availability_zones - レスポンスを正しく解析できるか" do
37
+ @api.stubs(:exec_request).returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
38
+ response = @api.describe_availability_zones(:zone_name => 'ap-japan-1a')
39
+ response.availabilityZoneInfo.item[0].zoneName.should.equal 'ap-japan-1a'
40
+ response.availabilityZoneInfo.item[0].zoneState.should.equal 'available'
41
+ response.availabilityZoneInfo.item[0].regionName.should.equal 'ap-japan-1'
42
+ end
43
+
44
+ specify "describe_availability_zones - :key_name正常" do
45
+ @api.stubs(:exec_request).returns stub(:body => @describe_availability_zones_response_body, :is_a? => true)
46
+ lambda { @api.describe_availability_zones(:zone_name => 'foo') }.should.not.raise(NIFTY::ArgumentError)
47
+ lambda { @api.describe_availability_zones(:zone_name => %w(foo bar)) }.should.not.raise(NIFTY::ArgumentError)
48
+ end
49
+
50
+ end
@@ -0,0 +1,627 @@
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 "certificates" 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
+ @basic_reg_corp_info_params = {
20
+ :agreement => true, :corp_name => 'corpname', :corp_grade => 'grade',
21
+ :president_name1 => 'pre1', :president_name2 => 'pre2', :zip1 => 123, :zip2 => 4567, :pref => 'TOKYO',
22
+ :city => 'city', :name1 => 'name1', :name2 => 'name2', :kana_name1 => 'kana1', :kana_name2 => 'kana2',
23
+ :post_name => 'post', :division_name => 'div'
24
+ }
25
+ @basic_create_ssl_cert = {
26
+ :fqdn => 'ccc.aaa.com', :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => 'org',
27
+ :organization_unit_name => 'orgunit', :state_name => 'TOKYO', :location_name => 'loc'
28
+ }
29
+ @basic_upload_ssl_cert = {:certificate => 'cert', :key => 'key'}
30
+
31
+ @valid_validity_term = [6, 12, 24, '6', '12', '24']
32
+ @valid_key_length = [1024, 2048, '1024', '2048']
33
+ @valid_attribute = %w(count certState period keyLength uploadState description certInfo)
34
+ @valid_file_type = [1, 2, 3, '1', '2', '3']
35
+
36
+ @register_corporate_info_for_certificate_response_body = <<-RESPONSE
37
+ <RegisterCorporateInfoForCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
38
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
39
+ <tdbCode />
40
+ <corpName>サンプル</corpName>
41
+ <corpGrade>株式会社</corpGrade>
42
+ <presidentName1>山田</presidentName1>
43
+ <presidentName2>太郎</presidentName2>
44
+ <zip1>123</zip1>
45
+ <zip2>4567</zip2>
46
+ <pref>TOKYO</pref>
47
+ <city>品川区</city>
48
+ <name1>山田</name1>
49
+ <name2>花子</name2>
50
+ <kanaName1>やまだ</kanaName1>
51
+ <kanaName2>はなこ</kanaName2>
52
+ <postName>部長</postName>
53
+ <divisionName>技術部</divisionName>
54
+ </RegisterCorporateInfoForCertificateResponse>
55
+ RESPONSE
56
+
57
+ @create_ssl_certificate_response_body = <<-RESPONSE
58
+ <CreateSslCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
59
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
60
+ <fqdnId>1</fqdnId>
61
+ <fqdn>ccc.aaa.com</fqdn>
62
+ <validityTerm>24</validityTerm>
63
+ <certState>waiting</certState>
64
+ </CreateSslCertificateResponse>
65
+ RESPONSE
66
+
67
+ @describe_ssl_certificates_response_body = <<-RESPONSE
68
+ <DescribeSslCertificatesResponse xmlns="https://cp.cloud.nifty.com/api/">
69
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
70
+ <certsSet>
71
+ <item>
72
+ <fqdnId>2</fqdnId>
73
+ <fqdn>ccc.aaa.com</fqdn>
74
+ <count>2</count>
75
+ <certState>valid</certState>
76
+ <period>
77
+ <startDate>2011-02-01</startDate>
78
+ <endDate>2013-01-31</endDate>
79
+ </period>
80
+ <keyLength>1024</keyLength>
81
+ <uploadState>false</uploadState>
82
+ <description />
83
+ <certInfo>
84
+ <countryName>JP</countryName>
85
+ <stateName>TOKYO</stateName>
86
+ <locationName>Shinagawa-ku</locationName>
87
+ <organizationName>NIFTY Co.,LTD</organizationName>
88
+ <organizationUnitName>Center Department</organizationUnitName>
89
+ <commonName>Center Department</commonName>
90
+ <emailAddress>admin@nifty.co.jp</emailAddress>
91
+ </certInfo>
92
+ </item>
93
+ </certsSet>
94
+ </DescribeSslCertificatesResponse>
95
+ RESPONSE
96
+
97
+ @describe_ssl_certificate_attribute_response_body = <<-RESPONSE
98
+ <DescribeSslCertificateAttributeResponse xmlns="https://cp.cloud.nifty.com/api/">
99
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
100
+ <fqdnId>2</fqdnId>
101
+ <fqdn>ccc.aaa.com</fqdn>
102
+ <certState>
103
+ <value>valid</value>
104
+ </certState>
105
+ </DescribeSslCertificateAttributeResponse>
106
+ RESPONSE
107
+
108
+ @modify_ssl_certificate_attribute_response_body = <<-RESPONSE
109
+ <UpdateSslCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
110
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
111
+ <return>true</return>
112
+ </UpdateSslCertificateResponse>
113
+ RESPONSE
114
+
115
+ @delete_ssl_certificate_response_body = <<-RESPONSE
116
+ <DeleteSslCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
117
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
118
+ <fqdn>ccc.aaa.com</fqdn>
119
+ </DeleteSslCertificateResponse>
120
+ RESPONSE
121
+
122
+ @upload_ssl_certificate_response_body = <<-RESPONSE
123
+ <UploadSslCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
124
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
125
+ <fqdnId>2</fqdnId>
126
+ <fqdn>ccc.aaa.com</fqdn>
127
+ <keyFingerPrint>xxxxxxxxxxxxx</keyFingerPrint>
128
+ </UploadSslCertificateResponse>
129
+ RESPONSE
130
+
131
+ @download_ssl_certificate_response_body = <<-RESPONSE
132
+ <DownloadSslCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
133
+ <requestId>320fc738-a1c7-4a2f-abcb-20813a4e997c</requestId>
134
+ <fqdnId>2</fqdnId>
135
+ <fqdn>ccc.aaa.com</fqdn>
136
+ <fileData>・・・・・・・・・</fileData>
137
+ </DownloadSslCertificateResponse>
138
+ RESPONSE
139
+ end
140
+
141
+
142
+ # register_corporate_info_for_certificate
143
+ specify "register_corporate_info_for_certificate - レスポンスを正しく解析できるか" do
144
+ @api.stubs(:exec_request).returns stub(:body => @register_corporate_info_for_certificate_response_body, :is_a? => true)
145
+ response = @api.register_corporate_info_for_certificate(:agreement => true, :corp_name => 'foo', :corp_grade => 'bar',
146
+ :president_name1 => 'hoge', :president_name2 => 'hoge', :zip1 => 123, :zip2 => 4567,
147
+ :pref => 'TOKYO', :city => 'foo', :name1 => 'name1', :name2 => 'name2',
148
+ :kana_name1 => 'kana1', :kana_name2 => 'kana2', :post_name => 'post', :division_name => 'div')
149
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
150
+ response.tdbCode.should.equal nil
151
+ response.corpName.should.equal 'サンプル'
152
+ response.corpGrade.should.equal '株式会社'
153
+ response.presidentName1.should.equal '山田'
154
+ response.presidentName2.should.equal '太郎'
155
+ response.zip1.should.equal '123'
156
+ response.zip2.should.equal '4567'
157
+ response.pref.should.equal 'TOKYO'
158
+ response.city.should.equal '品川区'
159
+ response.name1.should.equal '山田'
160
+ response.name2.should.equal '花子'
161
+ response.kanaName1.should.equal 'やまだ'
162
+ response.kanaName2.should.equal 'はなこ'
163
+ response.postName.should.equal '部長'
164
+ response.divisionName.should.equal '技術部'
165
+ end
166
+
167
+ specify "register_corporate_info_for_certificate - パラメータが正しく作られるか" do
168
+ @api.stubs(:make_request).with("Action" => "RegisterCorporateInfoForCertificate",
169
+ "Agreement" => "true",
170
+ "TdbCode" => "a",
171
+ "CorpName" => "ニフティ",
172
+ "CorpGrade" => "株式会社",
173
+ "PresidentName1" => "ニフティ",
174
+ "PresidentName2" => "太郎",
175
+ "Zip1" => "140",
176
+ "Zip2" => "8544",
177
+ "Pref" => "東京都",
178
+ "City" => "品川区",
179
+ "Name1" => "山田",
180
+ "Name2" => "花子",
181
+ "KanaName1" => "やまだ",
182
+ "KanaName2" => "はなこ",
183
+ "PostName" => "部長",
184
+ "DivisionName" => "技術部"
185
+ ).returns stub(:body => @register_corporate_info_for_certificate_response_body, :is_a? => true)
186
+ @api.stubs(:exec_request).returns stub(:body => @register_corporate_info_for_certificate_response_body, :is_a? => true)
187
+ response = @api.register_corporate_info_for_certificate(:agreement => true, :tdb_code => "a", :corp_name => "ニフティ", :corp_grade => "株式会社", :president_name1 => "ニフティ", :president_name2 => "太郎", :zip1 => "140", :zip2 => "8544", :pref => "東京都", :city => "品川区", :name1 => "山田", :name2 => "花子", :kana_name1 => "やまだ", :kana_name2 => "はなこ", :post_name => "部長", :division_name => "技術部")
188
+ end
189
+
190
+ specify "register_corporate_info_for_certificate - 必須パラメータ正常" do
191
+ @api.stubs(:exec_request).returns stub(:body => @register_corporate_info_for_certificate_response_body, :is_a? => true)
192
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params) }.should.not.raise(NIFTY::ArgumentError)
193
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:agreement => false)) }.should.not.raise(NIFTY::ArgumentError)
194
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip1 => '999')) }.should.not.raise(NIFTY::ArgumentError)
195
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip2 => '8888')) }.should.not.raise(NIFTY::ArgumentError)
196
+ end
197
+
198
+ specify "register_corporate_info_for_certificate - :tdb_code正常" do
199
+ @api.stubs(:exec_request).returns stub(:body => @register_corporate_info_for_certificate_response_body, :is_a? => true)
200
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:tdb_code => 'code')) }.should.not.raise(NIFTY::ArgumentError)
201
+ end
202
+
203
+ specify "register_corporate_info_for_certificate - :agreement未指定/不正" do
204
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :agreement}) }.should.raise(NIFTY::ArgumentError)
205
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:agreement => nil)) }.should.raise(NIFTY::ArgumentError)
206
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:agreement => '')) }.should.raise(NIFTY::ArgumentError)
207
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:agreement => 'foo')) }.should.raise(NIFTY::ArgumentError)
208
+ end
209
+
210
+ specify "register_corporate_info_for_certificate - :corp_name未指定" do
211
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :corp_name}) }.should.raise(NIFTY::ArgumentError)
212
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:corp_name => nil)) }.should.raise(NIFTY::ArgumentError)
213
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:corp_name => '')) }.should.raise(NIFTY::ArgumentError)
214
+ end
215
+
216
+ specify "register_corporate_info_for_certificate - :corp_grade未指定" do
217
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :corp_grade}) }.should.raise(NIFTY::ArgumentError)
218
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:corp_grade => nil)) }.should.raise(NIFTY::ArgumentError)
219
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:corp_grade => '')) }.should.raise(NIFTY::ArgumentError)
220
+ end
221
+
222
+ specify "register_corporate_info_for_certificate - :president_name1未指定" do
223
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :president_name1}) }.should.raise(NIFTY::ArgumentError)
224
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:president_name1 => nil)) }.should.raise(NIFTY::ArgumentError)
225
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:president_name1 => '')) }.should.raise(NIFTY::ArgumentError)
226
+ end
227
+
228
+ specify "register_corporate_info_for_certificate - :president_name2未指定" do
229
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :president_name2}) }.should.raise(NIFTY::ArgumentError)
230
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:president_name2 => nil)) }.should.raise(NIFTY::ArgumentError)
231
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:president_name2 => '')) }.should.raise(NIFTY::ArgumentError)
232
+ end
233
+
234
+ specify "register_corporate_info_for_certificate - :zip1未指定" do
235
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :zip1}) }.should.raise(NIFTY::ArgumentError)
236
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip1 => nil)) }.should.raise(NIFTY::ArgumentError)
237
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip1 => '')) }.should.raise(NIFTY::ArgumentError)
238
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip1 => 12)) }.should.raise(NIFTY::ArgumentError)
239
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip1 => 1234)) }.should.raise(NIFTY::ArgumentError)
240
+ end
241
+
242
+ specify "register_corporate_info_for_certificate - :zip2未指定" do
243
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :zip2}) }.should.raise(NIFTY::ArgumentError)
244
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip2 => nil)) }.should.raise(NIFTY::ArgumentError)
245
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip2 => '')) }.should.raise(NIFTY::ArgumentError)
246
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip2 => 123)) }.should.raise(NIFTY::ArgumentError)
247
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:zip2 => 12345)) }.should.raise(NIFTY::ArgumentError)
248
+ end
249
+
250
+ specify "register_corporate_info_for_certificate - :pref未指定" do
251
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :pref}) }.should.raise(NIFTY::ArgumentError)
252
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:pref => nil)) }.should.raise(NIFTY::ArgumentError)
253
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:pref => '')) }.should.raise(NIFTY::ArgumentError)
254
+ end
255
+
256
+ specify "register_corporate_info_for_certificate - :city未指定" do
257
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :city}) }.should.raise(NIFTY::ArgumentError)
258
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:city => nil)) }.should.raise(NIFTY::ArgumentError)
259
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:city => '')) }.should.raise(NIFTY::ArgumentError)
260
+ end
261
+
262
+ specify "register_corporate_info_for_certificate - :name1未指定" do
263
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :name1}) }.should.raise(NIFTY::ArgumentError)
264
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:name1 => nil)) }.should.raise(NIFTY::ArgumentError)
265
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:name1 => '')) }.should.raise(NIFTY::ArgumentError)
266
+ end
267
+
268
+ specify "register_corporate_info_for_certificate - :name2未指定" do
269
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :name2}) }.should.raise(NIFTY::ArgumentError)
270
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:name2 => nil)) }.should.raise(NIFTY::ArgumentError)
271
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:name2 => '')) }.should.raise(NIFTY::ArgumentError)
272
+ end
273
+
274
+ specify "register_corporate_info_for_certificate - :kana_name1未指定" do
275
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :kana_name1}) }.should.raise(NIFTY::ArgumentError)
276
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:kana_name1 => nil)) }.should.raise(NIFTY::ArgumentError)
277
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:kana_name1 => '')) }.should.raise(NIFTY::ArgumentError)
278
+ end
279
+
280
+ specify "register_corporate_info_for_certificate - :kana_name2未指定" do
281
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :kana_name2}) }.should.raise(NIFTY::ArgumentError)
282
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:kana_name2 => nil)) }.should.raise(NIFTY::ArgumentError)
283
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:kana_name2 => '')) }.should.raise(NIFTY::ArgumentError)
284
+ end
285
+
286
+ specify "register_corporate_info_for_certificate - :post_name未指定" do
287
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :post_name}) }.should.raise(NIFTY::ArgumentError)
288
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:post_name => nil)) }.should.raise(NIFTY::ArgumentError)
289
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:post_name => '')) }.should.raise(NIFTY::ArgumentError)
290
+ end
291
+
292
+ specify "register_corporate_info_for_certificate - :division_name未指定" do
293
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.reject{|k,v| k == :division_name}) }.should.raise(NIFTY::ArgumentError)
294
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:division_name => nil)) }.should.raise(NIFTY::ArgumentError)
295
+ lambda { @api.register_corporate_info_for_certificate(@basic_reg_corp_info_params.merge(:division_name => '')) }.should.raise(NIFTY::ArgumentError)
296
+ end
297
+
298
+
299
+ # create_ssl_certificate
300
+ specify "create_ssl_certificate - レスポンスを正しく解析できるか" do
301
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
302
+ response = @api.create_ssl_certificate(:fqdn_id => 'fqdn')
303
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
304
+ response.fqdnId.should.equal '1'
305
+ response.fqdn.should.equal 'ccc.aaa.com'
306
+ response.validityTerm.should.equal '24'
307
+ response.certState.should.equal 'waiting'
308
+ end
309
+
310
+ specify "create_ssl_certificate - パラメータが正しく作られるか" do
311
+ @api.stubs(:make_request).with("Action" => "CreateSslCertificate",
312
+ "FqdnId" => "a",
313
+ "Fqdn" => "aaa.aaa.aaa",
314
+ "Count" => "1",
315
+ "ValidityTerm" => "6",
316
+ "KeyLength" => "1024",
317
+ "CertInfo.OrganizationName" => "a",
318
+ "CertInfo.OrganizationUnitName" => "a",
319
+ "CertInfo.CountryName" => "a",
320
+ "CertInfo.StateName" => "a",
321
+ "CertInfo.LocationName" => "a",
322
+ "CertInfo.EmailAddress" => "a"
323
+ ).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
324
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
325
+ response = @api.create_ssl_certificate(:fqdn_id => "a", :fqdn => "aaa.aaa.aaa", :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => "a", :organization_unit_name => "a", :country_name => "a", :state_name => "a", :location_name => "a", :email_address => "a")
326
+ end
327
+
328
+ specify "create_ssl_certificate - :fqdn_id正常" do
329
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
330
+ lambda { @api.create_ssl_certificate(:fqdn_id => 3) }.should.not.raise(NIFTY::ArgumentError)
331
+ end
332
+
333
+ specify "create_ssl_certificate - :必須パラメータ正常" do
334
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
335
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert) }.should.not.raise(NIFTY::ArgumentError)
336
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => 15)) }.should.not.raise(NIFTY::ArgumentError)
337
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => 30)) }.should.not.raise(NIFTY::ArgumentError)
338
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => '20')) }.should.not.raise(NIFTY::ArgumentError)
339
+ @valid_validity_term.each do |term|
340
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => term)) }.should.not.raise(NIFTY::ArgumentError)
341
+ end
342
+ @valid_key_length.each do |len|
343
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:key_length => len)) }.should.not.raise(NIFTY::ArgumentError)
344
+ end
345
+ end
346
+
347
+ specify "create_ssl_certificate - :country_name正常" do
348
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
349
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:country_name => 'JP')) }.should.not.raise(NIFTY::ArgumentError)
350
+ end
351
+
352
+ specify "create_ssl_certificate - :email_address正常" do
353
+ @api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
354
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:email_address => 'aaa@bbb.com')) }.should.not.raise(NIFTY::ArgumentError)
355
+ end
356
+
357
+ specify "create_ssl_certificate - :fqdn_id, fqdn未指定" do
358
+ lambda { @api.create_ssl_certificate }.should.raise(NIFTY::ArgumentError)
359
+ lambda { @api.create_ssl_certificate }.should.raise(NIFTY::ArgumentError)
360
+ lambda { @api.create_ssl_certificate(:fqdn_id => nil) }.should.raise(NIFTY::ArgumentError)
361
+ lambda { @api.create_ssl_certificate(:fqdn_id => '') }.should.raise(NIFTY::ArgumentError)
362
+ lambda { @api.create_ssl_certificate(:fqdn => nil) }.should.raise(NIFTY::ArgumentError)
363
+ lambda { @api.create_ssl_certificate(:fqdn => '') }.should.raise(NIFTY::ArgumentError)
364
+ lambda { @api.create_ssl_certificate(:fqdn_id => '', :fqdn => '') }.should.raise(NIFTY::ArgumentError)
365
+ end
366
+
367
+ specify "create_ssl_certificate - :count未指定" do
368
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :count}) }.should.raise(NIFTY::ArgumentError)
369
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => nil)) }.should.raise(NIFTY::ArgumentError)
370
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => '')) }.should.raise(NIFTY::ArgumentError)
371
+ end
372
+
373
+ specify "create_ssl_certificate - :validity_term未指定" do
374
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :validity_term}) }.should.raise(NIFTY::ArgumentError)
375
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => nil)) }.should.raise(NIFTY::ArgumentError)
376
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => '')) }.should.raise(NIFTY::ArgumentError)
377
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => 36)) }.should.raise(NIFTY::ArgumentError)
378
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => 'foo')) }.should.raise(NIFTY::ArgumentError)
379
+ end
380
+
381
+ specify "create_ssl_certificate - :key_length未指定" do
382
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :key_length}) }.should.raise(NIFTY::ArgumentError)
383
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:key_length => nil)) }.should.raise(NIFTY::ArgumentError)
384
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:key_length => '')) }.should.raise(NIFTY::ArgumentError)
385
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:key_length => 4072)) }.should.raise(NIFTY::ArgumentError)
386
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:key_length => 'foo')) }.should.raise(NIFTY::ArgumentError)
387
+ end
388
+
389
+ specify "create_ssl_certificate - :organization_name未指定" do
390
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :organization_name}) }.should.raise(NIFTY::ArgumentError)
391
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:organization_name => nil)) }.should.raise(NIFTY::ArgumentError)
392
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:organization_name => '')) }.should.raise(NIFTY::ArgumentError)
393
+ end
394
+
395
+ specify "create_ssl_certificate - :organization_unit_name未指定" do
396
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :organization_unit_name}) }.should.raise(NIFTY::ArgumentError)
397
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:organization_unit_name => nil)) }.should.raise(NIFTY::ArgumentError)
398
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:organization_unit_name => '')) }.should.raise(NIFTY::ArgumentError)
399
+ end
400
+
401
+ specify "create_ssl_certificate - :state_name未指定" do
402
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :state_name}) }.should.raise(NIFTY::ArgumentError)
403
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:state_name => nil)) }.should.raise(NIFTY::ArgumentError)
404
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:state_name => '')) }.should.raise(NIFTY::ArgumentError)
405
+ end
406
+
407
+ specify "create_ssl_certificate - :location_name未指定" do
408
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :location_name}) }.should.raise(NIFTY::ArgumentError)
409
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:location_name => nil)) }.should.raise(NIFTY::ArgumentError)
410
+ lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:location_name => '')) }.should.raise(NIFTY::ArgumentError)
411
+ end
412
+
413
+
414
+ # describe_ssl_certificates
415
+ specify "describe_ssl_certificates - レスポンスを正しく解析できるか" do
416
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificates_response_body, :is_a? => true)
417
+ response = @api.describe_ssl_certificates
418
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
419
+ response.certsSet.item[0].fqdnId.should.equal '2'
420
+ response.certsSet.item[0].fqdn.should.equal 'ccc.aaa.com'
421
+ response.certsSet.item[0]['count'].should.equal '2'
422
+ response.certsSet.item[0].certState.should.equal 'valid'
423
+ response.certsSet.item[0].period.startDate.should.equal '2011-02-01'
424
+ response.certsSet.item[0].period.endDate.should.equal '2013-01-31'
425
+ response.certsSet.item[0].keyLength.should.equal '1024'
426
+ response.certsSet.item[0].uploadState.should.equal 'false'
427
+ response.certsSet.item[0].description.should.equal nil
428
+ response.certsSet.item[0].certInfo.countryName.should.equal 'JP'
429
+ response.certsSet.item[0].certInfo.stateName.should.equal 'TOKYO'
430
+ response.certsSet.item[0].certInfo.locationName.should.equal 'Shinagawa-ku'
431
+ response.certsSet.item[0].certInfo.organizationName.should.equal 'NIFTY Co.,LTD'
432
+ response.certsSet.item[0].certInfo.organizationUnitName.should.equal 'Center Department'
433
+ response.certsSet.item[0].certInfo.commonName.should.equal 'Center Department'
434
+ response.certsSet.item[0].certInfo.emailAddress.should.equal 'admin@nifty.co.jp'
435
+ end
436
+
437
+ specify "describe_ssl_certificates - パラメータが正しく作られるか" do
438
+ @api.stubs(:make_request).with("Action" => "DescribeSslCertificates",
439
+ "FqdnId.1" => "a",
440
+ "FqdnId.2" => "a",
441
+ "Fqdn.1" => "aaa.aaa.aaa",
442
+ "Fqdn.2" => "aaa.aaa.aaa"
443
+ ).returns stub(:body => @describe_ssl_certificates_response_body, :is_a? => true)
444
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificates_response_body, :is_a? => true)
445
+ response = @api.describe_ssl_certificates(:fqdn_id => %w(a a), :fqdn => %w(aaa.aaa.aaa aaa.aaa.aaa))
446
+ end
447
+
448
+ specify "describe_ssl_certificates - :fqdn正常" do
449
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificates_response_body, :is_a? => true)
450
+ lambda { @api.describe_ssl_certificates(:fqdn => 'ccc.aaa.com') }.should.not.raise(NIFTY::ArgumentError)
451
+ lambda { @api.describe_ssl_certificates(:fqdn => %w(ccc.aaa.com aaa.bbb.com)) }.should.not.raise(NIFTY::ArgumentError)
452
+ end
453
+
454
+ specify "describe_ssl_certificates - :fqdn_id正常" do
455
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificates_response_body, :is_a? => true)
456
+ lambda { @api.describe_ssl_certificates(:fqdn_id => 2) }.should.not.raise(NIFTY::ArgumentError)
457
+ lambda { @api.describe_ssl_certificates(:fqdn_id => [2, 3, 4]) }.should.not.raise(NIFTY::ArgumentError)
458
+ end
459
+
460
+
461
+ # describe_ssl_certificate_attribute
462
+ specify "describe_ssl_certificate_attribute - レスポンスを正しく解析できるか" do
463
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificate_attribute_response_body, :is_a? => true)
464
+ response = @api.describe_ssl_certificate_attribute(:fqdn_id => 'fqdn')
465
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
466
+ response.fqdnId.should.equal '2'
467
+ response.fqdn.should.equal 'ccc.aaa.com'
468
+ response.certState.value.should.equal 'valid'
469
+ end
470
+
471
+ specify "describe_ssl_certificate_attribute - パラメータが正しく作られるか" do
472
+ @api.stubs(:make_request).with("Action" => "DescribeSslCertificateAttribute",
473
+ "FqdnId" => "a",
474
+ "Attribute" => "certInfo"
475
+ ).returns stub(:body => @describe_ssl_certificate_attribute_response_body, :is_a? => true)
476
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificate_attribute_response_body, :is_a? => true)
477
+ response = @api.describe_ssl_certificate_attribute(:fqdn_id => "a", :attribute => "certInfo")
478
+ end
479
+
480
+ specify "describe_ssl_certificate_attribute - :attribute正常" do
481
+ @api.stubs(:exec_request).returns stub(:body => @describe_ssl_certificate_attribute_response_body, :is_a? => true)
482
+ @valid_attribute.each do |attr|
483
+ lambda { @api.describe_ssl_certificate_attribute(:fqdn_id => 2, :attribute => attr) }.should.not.raise(NIFTY::ArgumentError)
484
+ end
485
+ end
486
+
487
+ specify "describe_ssl_certificate_attribute - :fqdn_id未指定" do
488
+ lambda { @api.describe_ssl_certificate_attribute }.should.raise(NIFTY::ArgumentError)
489
+ lambda { @api.describe_ssl_certificate_attribute(:fqdn_id => nil) }.should.raise(NIFTY::ArgumentError)
490
+ lambda { @api.describe_ssl_certificate_attribute(:fqdn_id => '') }.should.raise(NIFTY::ArgumentError)
491
+ end
492
+
493
+ specify "describe_ssl_certificate_attribute - :attribute不正" do
494
+ lambda { @api.describe_ssl_certificate_attribute(:fqdn_id => 2, :attribute => 'attr') }.should.raise(NIFTY::ArgumentError)
495
+ lambda { @api.describe_ssl_certificate_attribute(:fqdn_id => 2, :attribute => 64) }.should.raise(NIFTY::ArgumentError)
496
+ end
497
+
498
+
499
+ # modify_ssl_certificate_attribute
500
+ specify "modify_ssl_certificate_attribute - レスポンスを正しく解析できるか" do
501
+ @api.stubs(:exec_request).returns stub(:body => @modify_ssl_certificate_attribute_response_body, :is_a? => true)
502
+ response = @api.modify_ssl_certificate_attribute(:fqdn_id => 'fqdn')
503
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
504
+ response.return.should.equal 'true'
505
+ end
506
+
507
+ specify "modify_ssl_certificate_attribute - パラメータが正しく作られるか" do
508
+ @api.stubs(:make_request).with("Action" => "ModifySslCertificateAttribute",
509
+ "FqdnId" => "a",
510
+ "Description.Value" => "a"
511
+ ).returns stub(:body => @modify_ssl_certificate_attribute_response_body, :is_a? => true)
512
+ @api.stubs(:exec_request).returns stub(:body => @modify_ssl_certificate_attribute_response_body, :is_a? => true)
513
+ response = @api.modify_ssl_certificate_attribute(:fqdn_id => "a", :description => "a")
514
+ end
515
+
516
+ specify "modify_ssl_certificate_attribute - :description正常" do
517
+ @api.stubs(:exec_request).returns stub(:body => @modify_ssl_certificate_attribute_response_body, :is_a? => true)
518
+ lambda { @api.modify_ssl_certificate_attribute(:fqdn_id => 2, :description => 'メモ') }.should.not.raise(NIFTY::ArgumentError)
519
+ end
520
+
521
+ specify "modify_ssl_certificate_attribute - :fqdn_id未指定" do
522
+ lambda { @api.modify_ssl_certificate_attribute }.should.raise(NIFTY::ArgumentError)
523
+ lambda { @api.modify_ssl_certificate_attribute(:fqdn_id => nil) }.should.raise(NIFTY::ArgumentError)
524
+ lambda { @api.modify_ssl_certificate_attribute(:fqdn_id => '') }.should.raise(NIFTY::ArgumentError)
525
+ end
526
+
527
+
528
+ # delete_ssl_certificate
529
+ specify "delete_ssl_certificate - レスポンスを正しく解析できるか" do
530
+ @api.stubs(:exec_request).returns stub(:body => @delete_ssl_certificate_response_body, :is_a? => true)
531
+ response = @api.delete_ssl_certificate(:fqdn_id => 'fqdn')
532
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
533
+ response.fqdn.should.equal 'ccc.aaa.com'
534
+ end
535
+
536
+ specify "delete_ssl_certificate - パラメータが正しく作られるか" do
537
+ @api.stubs(:make_request).with("Action" => "DeleteSslCertificate", "FqdnId" => "a"
538
+ ).returns stub(:body => @delete_ssl_certificate_response_body, :is_a? => true)
539
+ @api.stubs(:exec_request).returns stub(:body => @delete_ssl_certificate_response_body, :is_a? => true)
540
+ response = @api.delete_ssl_certificate(:fqdn_id => "a")
541
+ end
542
+
543
+ specify "delete_ssl_certificate - :fqdn_id未指定" do
544
+ lambda { @api.delete_ssl_certificate }.should.raise(NIFTY::ArgumentError)
545
+ lambda { @api.delete_ssl_certificate(:fqdn_id => nil) }.should.raise(NIFTY::ArgumentError)
546
+ lambda { @api.delete_ssl_certificate(:fqdn_id => '') }.should.raise(NIFTY::ArgumentError)
547
+ end
548
+
549
+
550
+ # upload_ssl_certificate
551
+ specify "upload_ssl_certificate - レスポンスを正しく解析できるか" do
552
+ @api.stubs(:exec_request).returns stub(:body => @upload_ssl_certificate_response_body, :is_a? => true)
553
+ response = @api.upload_ssl_certificate(:certificate => 'foo', :key => 'bar')
554
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
555
+ response.fqdnId.should.equal '2'
556
+ response.fqdn.should.equal 'ccc.aaa.com'
557
+ response.keyFingerPrint.should.equal 'xxxxxxxxxxxxx'
558
+ end
559
+
560
+ specify "upload_ssl_certificate - パラメータが正しく作られるか" do
561
+ @api.stubs(:make_request).with("Action" => "UploadSslCertificate",
562
+ "Certificate" => "a",
563
+ "Key" => "a",
564
+ "Ca" => "a"
565
+ ).returns stub(:body => @upload_ssl_certificate_response_body, :is_a? => true)
566
+ @api.stubs(:exec_request).returns stub(:body => @upload_ssl_certificate_response_body, :is_a? => true)
567
+ response = @api.upload_ssl_certificate(:certificate => "a", :key => "a", :ca => "a")
568
+ end
569
+
570
+ specify "upload_ssl_certificate - :ca正常" do
571
+ @api.stubs(:exec_request).returns stub(:body => @upload_ssl_certificate_response_body, :is_a? => true)
572
+ lambda { @api.upload_ssl_certificate(@basic_upload_ssl_cert.merge(:ca => 'foo')) }.should.not.raise(NIFTY::ArgumentError)
573
+ end
574
+
575
+ specify "upload_ssl_certificate - :certificate未指定" do
576
+ lambda { @api.upload_ssl_certificate }.should.raise(NIFTY::ArgumentError)
577
+ lambda { @api.upload_ssl_certificate(:certificate => nil) }.should.raise(NIFTY::ArgumentError)
578
+ lambda { @api.upload_ssl_certificate(:certificate => '') }.should.raise(NIFTY::ArgumentError)
579
+ end
580
+
581
+ specify "upload_ssl_certificate - :key未指定" do
582
+ lambda { @api.upload_ssl_certificate(:certificate => 'foo') }.should.raise(NIFTY::ArgumentError)
583
+ lambda { @api.upload_ssl_certificate(:certificate => 'foo', :key => nil) }.should.raise(NIFTY::ArgumentError)
584
+ lambda { @api.upload_ssl_certificate(:certificate => 'foo', :key => '') }.should.raise(NIFTY::ArgumentError)
585
+ end
586
+
587
+
588
+ # download_ssl_certificate
589
+ specify "download_ssl_certificate - レスポンスを正しく解析できるか" do
590
+ @api.stubs(:exec_request).returns stub(:body => @download_ssl_certificate_response_body, :is_a? => true)
591
+ response = @api.download_ssl_certificate(:fqdn_id => 'fqdn', :file_type => 1)
592
+ response.requestId.should.equal '320fc738-a1c7-4a2f-abcb-20813a4e997c'
593
+ response.fqdnId.should.equal '2'
594
+ response.fqdn.should.equal 'ccc.aaa.com'
595
+ response.fileData.should.equal '・・・・・・・・・'
596
+ end
597
+
598
+ specify "download_ssl_certificate - パラメータが正しく作られるか" do
599
+ @api.stubs(:make_request).with("Action" => "DownloadSslCertificate",
600
+ "FqdnId" => "a",
601
+ "FileType" => "1"
602
+ ).returns stub(:body => @download_ssl_certificate_response_body, :is_a? => true)
603
+ @api.stubs(:exec_request).returns stub(:body => @download_ssl_certificate_response_body, :is_a? => true)
604
+ response = @api.download_ssl_certificate(:fqdn_id => "a", :file_type => 1)
605
+ end
606
+
607
+ specify "download_ssl_certificate - :必須パラメータ正常" do
608
+ @api.stubs(:exec_request).returns stub(:body => @download_ssl_certificate_response_body, :is_a? => true)
609
+ @valid_file_type.each do |type|
610
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo', :file_type => type) }.should.not.raise(NIFTY::ArgumentError)
611
+ end
612
+ end
613
+
614
+ specify "download_ssl_certificate - :fqdn_id未指定" do
615
+ lambda { @api.download_ssl_certificate }.should.raise(NIFTY::ArgumentError)
616
+ lambda { @api.download_ssl_certificate(:fqdn_id => nil) }.should.raise(NIFTY::ArgumentError)
617
+ lambda { @api.download_ssl_certificate(:fqdn_id => '') }.should.raise(NIFTY::ArgumentError)
618
+ end
619
+
620
+ specify "download_ssl_certificate - :file_type未指定" do
621
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo') }.should.raise(NIFTY::ArgumentError)
622
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo', :file_type => nil) }.should.raise(NIFTY::ArgumentError)
623
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo', :file_type => '') }.should.raise(NIFTY::ArgumentError)
624
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo', :file_type => 4) }.should.raise(NIFTY::ArgumentError)
625
+ lambda { @api.download_ssl_certificate(:fqdn_id => 'foo', :file_type => 'foo') }.should.raise(NIFTY::ArgumentError)
626
+ end
627
+ end