azure 0.6.4 → 0.7.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env_sample +11 -0
- data/.gitignore +4 -1
- data/.travis.yml +3 -1
- data/ChangeLog.txt +17 -1
- data/LICENSE.txt +202 -0
- data/README.md +58 -20
- data/Rakefile +27 -35
- data/azure.gemspec +17 -13
- data/bin/pfxer +35 -0
- data/lib/azure.rb +8 -0
- data/lib/azure/base_management/base_management_service.rb +24 -26
- data/lib/azure/base_management/management_http_request.rb +17 -14
- data/lib/azure/base_management/serialization.rb +1 -0
- data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
- data/lib/azure/blob/blob_service.rb +221 -217
- data/lib/azure/cloud_service_management/cloud_service_management_service.rb +27 -30
- data/lib/azure/cloud_service_management/serialization.rb +1 -0
- data/lib/azure/core.rb +17 -15
- data/lib/azure/core/configuration.rb +7 -0
- data/lib/azure/core/http/http_error.rb +1 -1
- data/lib/azure/core/http/http_request.rb +4 -1
- data/lib/azure/core/utility.rb +16 -1
- data/lib/azure/queue/queue_service.rb +13 -13
- data/lib/azure/service/cors.rb +11 -0
- data/lib/azure/service/cors_rule.rb +15 -0
- data/lib/azure/service/serialization.rb +69 -10
- data/lib/azure/service/storage_service.rb +10 -6
- data/lib/azure/service/storage_service_properties.rb +8 -3
- data/lib/azure/service_bus/brokered_message.rb +1 -1
- data/lib/azure/service_bus/relay.rb +88 -0
- data/lib/azure/service_bus/serialization.rb +1 -0
- data/lib/azure/service_bus/service_bus_service.rb +70 -4
- data/lib/azure/sql_database_management/serialization.rb +1 -0
- data/lib/azure/sql_database_management/sql_database_management_service.rb +22 -22
- data/lib/azure/storage_management/serialization.rb +34 -14
- data/lib/azure/storage_management/storage_account.rb +9 -1
- data/lib/azure/storage_management/storage_management_service.rb +74 -32
- data/lib/azure/table/batch.rb +6 -6
- data/lib/azure/table/table_service.rb +13 -13
- data/lib/azure/version.rb +3 -3
- data/lib/azure/virtual_machine_image_management/serialization.rb +19 -0
- data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +1 -1
- data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +30 -7
- data/lib/azure/virtual_machine_management/serialization.rb +32 -12
- data/lib/azure/virtual_machine_management/virtual_machine.rb +1 -0
- data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +92 -81
- data/lib/azure/virtual_network_management/serialization.rb +12 -5
- data/lib/azure/virtual_network_management/virtual_network.rb +1 -0
- data/lib/azure/virtual_network_management/virtual_network_management_service.rb +11 -11
- data/test/fixtures/get_storage_account_properties.xml +6 -4
- data/test/fixtures/{list_images.xml → list_os_images.xml} +1 -1
- data/test/fixtures/list_storage_accounts.xml +2 -0
- data/test/fixtures/list_vm_images.xml +21 -0
- data/test/fixtures/metrics.xml +2 -2
- data/test/fixtures/sb_default_create_relay_response.xml +15 -0
- data/test/fixtures/storage_service_keys.xml +8 -0
- data/test/fixtures/storage_service_properties.xml +35 -3
- data/test/fixtures/updated_storage_accounts.xml +2 -0
- data/test/fixtures/virtual_machine.xml +3 -1
- data/test/integration/affinity_group/Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Create_Affinity_test.rb +8 -7
- data/test/integration/affinity_group/Delete_Affinity_test.rb +3 -3
- data/test/integration/affinity_group/List_Affinity_test.rb +1 -1
- data/test/integration/affinity_group/Update_Affinity_test.rb +9 -8
- data/test/integration/cloud_service/Cloud_Create_test.rb +3 -2
- data/test/integration/cloud_service/Cloud_Delete_test.rb +5 -4
- data/test/integration/database/create_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/create_sql_server_test.rb +1 -1
- data/test/integration/database/delete_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/delete_sql_server_test.rb +1 -1
- data/test/integration/database/list_sql_server_firewall_test.rb +1 -1
- data/test/integration/database/list_sql_servers_test.rb +1 -1
- data/test/integration/database/reset_password_sql_server_test.rb +1 -1
- data/test/integration/service_bus/queues_test.rb +22 -22
- data/test/integration/service_bus/relay_test.rb +132 -0
- data/test/integration/storage_management/storage_management_test.rb +58 -33
- data/test/integration/test_helper.rb +11 -15
- data/test/integration/vm/VM_Create_test.rb +17 -18
- data/test/integration/vm/VM_Delete_test.rb +2 -4
- data/test/integration/vm/VM_Operations_test.rb +1 -2
- data/test/integration/vnet/Virtual_Network_Create_test.rb +9 -15
- data/test/integration/vnet/Virtual_Network_list_test.rb +4 -9
- data/test/support/name_generator.rb +8 -0
- data/test/support/virtual_network_helper.rb +2 -2
- data/test/test_helper.rb +13 -24
- data/test/unit/affinity_group/affinity_group_test.rb +10 -13
- data/test/unit/affinity_group/serialization_test.rb +7 -8
- data/test/unit/base_management/location_test.rb +1 -2
- data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
- data/test/unit/blob/blob_service_test.rb +393 -371
- data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +16 -16
- data/test/unit/core/auth/shared_key_lite_test.rb +4 -4
- data/test/unit/core/auth/shared_key_test.rb +2 -2
- data/test/unit/core/http/http_error_test.rb +10 -5
- data/test/unit/core/http/http_request_test.rb +72 -25
- data/test/unit/database/serialization_test.rb +7 -7
- data/test/unit/database/sql_database_server_service_test.rb +43 -47
- data/test/unit/service/serialization_test.rb +40 -9
- data/test/unit/service/storage_service_test.rb +13 -11
- data/test/unit/storage_management/serialization_test.rb +26 -14
- data/test/unit/storage_management/storage_management_service_test.rb +48 -62
- data/test/unit/virtual_machine_image_management/serialization_test.rb +20 -5
- data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +78 -29
- data/test/unit/virtual_machine_management/serialization_test.rb +112 -43
- data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +123 -100
- data/test/unit/vnet/serialization_test.rb +7 -7
- data/test/unit/vnet/virtual_network_management_service_test.rb +1 -1
- metadata +70 -16
- data/test/fixtures/certificate.pem +0 -21
@@ -214,7 +214,7 @@ describe Azure::Service::Serialization do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
describe "#retention_policy_from_xml" do
|
217
|
-
let(:retention_policy_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.
|
217
|
+
let(:retention_policy_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics.RetentionPolicy }
|
218
218
|
|
219
219
|
it "accepts an XML Node" do
|
220
220
|
subject.retention_policy_from_xml retention_policy_xml
|
@@ -233,7 +233,7 @@ describe Azure::Service::Serialization do
|
|
233
233
|
end
|
234
234
|
end
|
235
235
|
|
236
|
-
describe "#
|
236
|
+
describe "#hour_metrics_to_xml" do
|
237
237
|
let(:metrics) {
|
238
238
|
metrics = Azure::Service::Metrics.new
|
239
239
|
metrics.version = "1.0"
|
@@ -250,20 +250,20 @@ describe Azure::Service::Serialization do
|
|
250
250
|
|
251
251
|
it "accepts a Metrics instance and an Nokogiri::XML::Builder instance" do
|
252
252
|
Nokogiri::XML::Builder.new do |xml|
|
253
|
-
subject.
|
253
|
+
subject.hour_metrics_to_xml metrics, xml
|
254
254
|
end
|
255
255
|
end
|
256
256
|
|
257
257
|
it "adds to the XML Builder, which will create the XML graph of the provided values" do
|
258
258
|
builder = Nokogiri::XML::Builder.new do |xml|
|
259
|
-
subject.
|
259
|
+
subject.hour_metrics_to_xml metrics, xml
|
260
260
|
end
|
261
261
|
builder.to_xml.must_equal metrics_xml
|
262
262
|
end
|
263
263
|
end
|
264
264
|
|
265
265
|
describe "#metrics_from_xml" do
|
266
|
-
let(:metrics_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.
|
266
|
+
let(:metrics_xml) { Nokogiri.Slop(Fixtures["storage_service_properties"]).root.HourMetrics }
|
267
267
|
let(:mock_retention_policy) { mock }
|
268
268
|
|
269
269
|
before {
|
@@ -362,7 +362,7 @@ describe Azure::Service::Serialization do
|
|
362
362
|
retention_policy.enabled = true
|
363
363
|
retention_policy.days = 7
|
364
364
|
|
365
|
-
metrics = service_properties.
|
365
|
+
metrics = service_properties.hour_metrics = Azure::Service::Metrics.new
|
366
366
|
metrics.version = "1.0"
|
367
367
|
metrics.enabled = true
|
368
368
|
metrics.include_apis = false
|
@@ -370,6 +370,35 @@ describe Azure::Service::Serialization do
|
|
370
370
|
retention_policy.enabled = true
|
371
371
|
retention_policy.days = 7
|
372
372
|
|
373
|
+
service_properties.minute_metrics = metrics
|
374
|
+
|
375
|
+
service_properties.cors = Azure::Service::Cors.new do |cors|
|
376
|
+
cors.cors_rules = []
|
377
|
+
cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
|
378
|
+
cors_rule.allowed_origins = ["http://www.contoso.com", "http://dummy.uri"]
|
379
|
+
cors_rule.allowed_methods = ["PUT", "HEAD"]
|
380
|
+
cors_rule.max_age_in_seconds = 5
|
381
|
+
cors_rule.exposed_headers = ["x-ms-*"]
|
382
|
+
cors_rule.allowed_headers = ["x-ms-blob-content-type", "x-ms-blob-content-disposition"]
|
383
|
+
})
|
384
|
+
|
385
|
+
cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
|
386
|
+
cors_rule.allowed_origins = ["*"]
|
387
|
+
cors_rule.allowed_methods = ["PUT", "GET"]
|
388
|
+
cors_rule.max_age_in_seconds = 5
|
389
|
+
cors_rule.exposed_headers = ["x-ms-*"]
|
390
|
+
cors_rule.allowed_headers = ["x-ms-blob-content-type", "x-ms-blob-content-disposition"]
|
391
|
+
})
|
392
|
+
|
393
|
+
cors.cors_rules.push(Azure::Service::CorsRule.new { |cors_rule|
|
394
|
+
cors_rule.allowed_origins = ["http://www.contoso.com"]
|
395
|
+
cors_rule.allowed_methods = ["GET"]
|
396
|
+
cors_rule.max_age_in_seconds = 5
|
397
|
+
cors_rule.exposed_headers = ["x-ms-*"]
|
398
|
+
cors_rule.allowed_headers = ["x-ms-client-request-id"]
|
399
|
+
})
|
400
|
+
end
|
401
|
+
|
373
402
|
service_properties
|
374
403
|
}
|
375
404
|
|
@@ -389,10 +418,12 @@ describe Azure::Service::Serialization do
|
|
389
418
|
let(:service_properties_xml) { Fixtures["storage_service_properties"]}
|
390
419
|
let(:mock_logging) { mock }
|
391
420
|
let(:mock_metrics) { mock }
|
421
|
+
let(:mock_cors) { mock }
|
392
422
|
|
393
423
|
before {
|
394
424
|
subject.expects(:logging_from_xml).returns(mock_logging)
|
395
|
-
subject.expects(:metrics_from_xml).returns(mock_metrics)
|
425
|
+
subject.expects(:metrics_from_xml).twice.returns(mock_metrics)
|
426
|
+
subject.expects(:cors_from_xml).returns(mock_cors)
|
396
427
|
}
|
397
428
|
|
398
429
|
it "accepts an XML string" do
|
@@ -407,9 +438,9 @@ describe Azure::Service::Serialization do
|
|
407
438
|
|
408
439
|
it "sets the properties of the StorageServiceProperties instance" do
|
409
440
|
service_properties = subject.service_properties_from_xml service_properties_xml
|
410
|
-
service_properties.default_service_version.must_equal "2011-08-18"
|
411
441
|
service_properties.logging.must_equal mock_logging
|
412
|
-
service_properties.
|
442
|
+
service_properties.hour_metrics.must_equal mock_metrics
|
443
|
+
service_properties.minute_metrics.must_equal mock_metrics
|
413
444
|
end
|
414
445
|
end
|
415
446
|
|
@@ -21,7 +21,7 @@ require "azure/service/storage_service_properties"
|
|
21
21
|
describe Azure::Service::StorageService do
|
22
22
|
|
23
23
|
let(:uri){ URI.parse "http://dummy.uri/resource" }
|
24
|
-
let(:
|
24
|
+
let(:verb){ :get }
|
25
25
|
|
26
26
|
subject do
|
27
27
|
storage_service = Azure::Service::StorageService.new
|
@@ -34,7 +34,7 @@ describe Azure::Service::StorageService do
|
|
34
34
|
let(:mock_signer_filter){ mock() }
|
35
35
|
|
36
36
|
before do
|
37
|
-
Azure::Core::Http::HttpRequest.stubs(:new).with(
|
37
|
+
Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, nil).returns(mock_request)
|
38
38
|
Azure::Core::Http::SignerFilter.stubs(:new).returns(mock_signer_filter)
|
39
39
|
|
40
40
|
mock_request.expects(:call)
|
@@ -42,7 +42,7 @@ describe Azure::Service::StorageService do
|
|
42
42
|
|
43
43
|
it "adds a SignerFilter to the HTTP pipeline" do
|
44
44
|
mock_request.expects(:with_filter).with(mock_signer_filter)
|
45
|
-
subject.call(
|
45
|
+
subject.call(verb, uri)
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "when passed the optional headers arguement" do
|
@@ -58,7 +58,7 @@ describe Azure::Service::StorageService do
|
|
58
58
|
|
59
59
|
it "merges the custom headers with the HttpRequest headers" do
|
60
60
|
mock_request.expects(:headers).returns(mock_headers).at_least(2)
|
61
|
-
subject.call(
|
61
|
+
subject.call(verb, uri, nil, { "Custom-Header"=>"CustomValue"} )
|
62
62
|
|
63
63
|
mock_headers["Other-Header"].must_equal "SomeValue"
|
64
64
|
mock_headers["Custom-Header"].must_equal "CustomValue"
|
@@ -72,8 +72,8 @@ describe Azure::Service::StorageService do
|
|
72
72
|
end
|
73
73
|
|
74
74
|
it "passes the body to the to HttpRequest" do
|
75
|
-
Azure::Core::Http::HttpRequest.stubs(:new).with(
|
76
|
-
subject.call(
|
75
|
+
Azure::Core::Http::HttpRequest.stubs(:new).with(verb, uri, 'body').returns(mock_request)
|
76
|
+
subject.call(verb, uri, "body")
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
@@ -92,7 +92,7 @@ describe Azure::Service::StorageService do
|
|
92
92
|
mock_request.expects(:with_filter).with(filter)
|
93
93
|
mock_request.expects(:with_filter).with(filter1)
|
94
94
|
|
95
|
-
subject.call(
|
95
|
+
subject.call(verb, uri)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -142,11 +142,12 @@ describe Azure::Service::StorageService do
|
|
142
142
|
}
|
143
143
|
|
144
144
|
let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
|
145
|
+
let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
|
145
146
|
|
146
147
|
before do
|
147
148
|
Azure::Service::Serialization.stubs(:service_properties_from_xml).with(service_properties_xml).returns(service_properties)
|
148
149
|
subject.stubs(:service_properties_uri).returns(service_properties_uri)
|
149
|
-
subject.stubs(:call).with(:get, service_properties_uri).returns(response)
|
150
|
+
subject.stubs(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
|
150
151
|
end
|
151
152
|
|
152
153
|
it "calls the service_properties_uri method to determine the correct uri" do
|
@@ -155,7 +156,7 @@ describe Azure::Service::StorageService do
|
|
155
156
|
end
|
156
157
|
|
157
158
|
it "gets the response from the HTTP API" do
|
158
|
-
subject.expects(:call).with(:get, service_properties_uri).returns(response)
|
159
|
+
subject.expects(:call).with(:get, service_properties_uri, nil, service_properties_headers).returns(response)
|
159
160
|
subject.get_service_properties
|
160
161
|
end
|
161
162
|
|
@@ -180,11 +181,12 @@ describe Azure::Service::StorageService do
|
|
180
181
|
}
|
181
182
|
|
182
183
|
let(:service_properties_uri) { URI.parse 'http://dummy.uri/service/properties' }
|
184
|
+
let(:service_properties_headers) { {"x-ms-version" => "2013-08-15"} }
|
183
185
|
|
184
186
|
before do
|
185
187
|
Azure::Service::Serialization.stubs(:service_properties_to_xml).with(service_properties).returns(service_properties_xml)
|
186
188
|
subject.stubs(:service_properties_uri).returns(service_properties_uri)
|
187
|
-
subject.stubs(:call).with(:put, service_properties_uri, service_properties_xml).returns(response)
|
189
|
+
subject.stubs(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
|
188
190
|
end
|
189
191
|
|
190
192
|
it "calls the service_properties_uri method to determine the correct uri" do
|
@@ -193,7 +195,7 @@ describe Azure::Service::StorageService do
|
|
193
195
|
end
|
194
196
|
|
195
197
|
it "posts to the HTTP API" do
|
196
|
-
subject.expects(:call).with(:put, service_properties_uri, service_properties_xml).returns(response)
|
198
|
+
subject.expects(:call).with(:put, service_properties_uri, service_properties_xml, service_properties_headers).returns(response)
|
197
199
|
subject.set_service_properties service_properties
|
198
200
|
end
|
199
201
|
|
@@ -34,7 +34,7 @@ describe Azure::StorageManagement::Serialization do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
describe "#storage_services_to_xml" do
|
37
|
-
let(:storage_service_name) {'storage-service'}
|
37
|
+
let(:storage_service_name) { 'storage-service' }
|
38
38
|
let(:storage_options) { {
|
39
39
|
:extended_properties=> {
|
40
40
|
:prop_1_name=>"prop_1_value"
|
@@ -57,14 +57,18 @@ describe Azure::StorageManagement::Serialization do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "serializes the options hash to xml" do
|
60
|
-
results = subject.storage_services_to_xml(storage_service_name,
|
60
|
+
results = subject.storage_services_to_xml(storage_service_name, :location => 'East US')
|
61
61
|
doc = Nokogiri::XML results
|
62
62
|
doc.css('Location').text.must_equal 'East US'
|
63
63
|
results.must_be_kind_of String
|
64
64
|
end
|
65
65
|
|
66
66
|
it "uses affinity_group from the hash instead of location" do
|
67
|
-
|
67
|
+
params = {
|
68
|
+
:affinity_group_name => 'my-affinity-group',
|
69
|
+
:location => 'East US'
|
70
|
+
}
|
71
|
+
results = subject.storage_services_to_xml(storage_service_name, params)
|
68
72
|
doc = Nokogiri::XML results
|
69
73
|
doc.css('AffinityGroup').text.must_equal 'my-affinity-group'
|
70
74
|
results.must_be_kind_of String
|
@@ -142,15 +146,10 @@ describe Azure::StorageManagement::Serialization do
|
|
142
146
|
}
|
143
147
|
}
|
144
148
|
|
145
|
-
let(:no_options_message) {'No options specified'}
|
146
|
-
let(:label_or_desc_required) {
|
147
|
-
|
148
|
-
|
149
|
-
exception = assert_raises RuntimeError do
|
150
|
-
subject.storage_update_to_xml nil
|
151
|
-
end
|
152
|
-
assert_match no_options_message, exception.message
|
153
|
-
end
|
149
|
+
let(:no_options_message) { 'No options specified' }
|
150
|
+
let(:label_or_desc_required) {
|
151
|
+
'Either one of Label or Description has to be provided.'
|
152
|
+
}
|
154
153
|
|
155
154
|
it "checks if the parameter is empty" do
|
156
155
|
exception = assert_raises RuntimeError do
|
@@ -224,9 +223,22 @@ describe Azure::StorageManagement::Serialization do
|
|
224
223
|
update_xml.css('GeoReplicationEnabled').size.must_equal(1)
|
225
224
|
update_xml.css('ExtendedProperties ExtendedProperty').size.must_equal(1)
|
226
225
|
update_xml.css('ExtendedProperties ExtendedProperty Name').text
|
227
|
-
|
226
|
+
.must_equal("#{:prop_1_name}")
|
228
227
|
update_xml.css('ExtendedProperties ExtendedProperty Value')
|
229
|
-
|
228
|
+
.text.must_equal(options[:extended_properties][:prop_1_name])
|
230
229
|
end
|
231
230
|
end
|
231
|
+
|
232
|
+
describe "#regenerate_storage_account_keys_from_xml" do
|
233
|
+
let(:storage_services_access_keys) { Fixtures["storage_service_keys"] }
|
234
|
+
|
235
|
+
it "returns an Array of StorageService instances" do
|
236
|
+
storage_keys_xml = Nokogiri::XML(storage_services_access_keys)
|
237
|
+
result = subject.storage_account_keys_from_xml storage_keys_xml
|
238
|
+
result.must_be_kind_of Azure::StorageManagement::StorageAccountKeys
|
239
|
+
result.primary_key.wont_be_nil
|
240
|
+
result.secondary_key.wont_be_nil
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
232
244
|
end
|
@@ -17,11 +17,11 @@ require "test_helper"
|
|
17
17
|
describe Azure::StorageManagementService do
|
18
18
|
|
19
19
|
subject { Azure::StorageManagementService.new }
|
20
|
-
let(:request_path) {'/services/storageservices'}
|
20
|
+
let(:request_path) { '/services/storageservices' }
|
21
21
|
let(:storage_accounts_xml) { Fixtures["list_storage_accounts"] }
|
22
|
-
let(:one_storage_account_xml) { Fixtures['list_storage_account_single']}
|
23
|
-
let(:
|
24
|
-
let(:mock_request){ mock() }
|
22
|
+
let(:one_storage_account_xml) { Fixtures['list_storage_account_single'] }
|
23
|
+
let(:verb) { :get }
|
24
|
+
let(:mock_request) { mock() }
|
25
25
|
|
26
26
|
let(:response) {
|
27
27
|
response = mock()
|
@@ -35,16 +35,16 @@ describe Azure::StorageManagementService do
|
|
35
35
|
single_response
|
36
36
|
}
|
37
37
|
|
38
|
-
let(:response_body) {Nokogiri::XML response.body}
|
38
|
+
let(:response_body) { Nokogiri::XML response.body }
|
39
39
|
let(:single_response_body) { Nokogiri::XML single_response.body }
|
40
40
|
|
41
|
-
before{
|
42
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
41
|
+
before {
|
42
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
43
43
|
}
|
44
44
|
|
45
45
|
describe "#list_storage_accounts" do
|
46
46
|
before {
|
47
|
-
ManagementHttpRequest.stubs(:new).with(
|
47
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
48
48
|
mock_request.expects(:call).returns(response_body)
|
49
49
|
}
|
50
50
|
|
@@ -67,8 +67,8 @@ describe Azure::StorageManagementService do
|
|
67
67
|
|
68
68
|
describe "#list_storage_accounts_single" do
|
69
69
|
before {
|
70
|
-
ManagementHttpRequest.stubs(:new).with(
|
71
|
-
|
70
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
|
71
|
+
verb, request_path, nil
|
72
72
|
).returns(mock_request)
|
73
73
|
mock_request.expects(:call).returns(single_response_body)
|
74
74
|
}
|
@@ -84,7 +84,7 @@ describe Azure::StorageManagementService do
|
|
84
84
|
|
85
85
|
describe "#get_storage_account" do
|
86
86
|
before {
|
87
|
-
ManagementHttpRequest.stubs(:new).with(
|
87
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
88
88
|
mock_request.expects(:call).returns(response_body)
|
89
89
|
}
|
90
90
|
|
@@ -92,22 +92,24 @@ describe Azure::StorageManagementService do
|
|
92
92
|
subject.get_storage_account 'storage1'
|
93
93
|
end
|
94
94
|
|
95
|
-
it "returns
|
96
|
-
|
97
|
-
result.
|
95
|
+
it "returns storage account instance" do
|
96
|
+
storage_account_name = 'storage1'
|
97
|
+
result = subject.get_storage_account storage_account_name
|
98
|
+
result.must_be_kind_of Azure::StorageManagement::StorageAccount
|
99
|
+
result.name.must_equal storage_account_name
|
98
100
|
end
|
99
101
|
|
100
102
|
it "returns false if storage account with given name doesn't exists" do
|
101
103
|
result = subject.get_storage_account 'storage3'
|
102
|
-
result.must_equal
|
104
|
+
result.must_equal nil
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
106
108
|
describe "#create_storage_account" do
|
107
109
|
let(:options) {
|
108
110
|
{
|
109
|
-
|
110
|
-
|
111
|
+
location: 'East Asia',
|
112
|
+
description: 'Test Storage Description'
|
111
113
|
}
|
112
114
|
}
|
113
115
|
|
@@ -133,14 +135,14 @@ describe Azure::StorageManagementService do
|
|
133
135
|
end
|
134
136
|
|
135
137
|
it "Create storage account return message if storage account exists of given name." do
|
136
|
-
ManagementHttpRequest.any_instance.expects(:call).returns response_body
|
138
|
+
Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns response_body
|
137
139
|
msg = subject.create_storage_account 'storage1'
|
138
140
|
assert_match(/^Storage Account storage1 already exist.*/, msg)
|
139
141
|
end
|
140
142
|
|
141
143
|
it "Create storage account if storage account doesn't exists of given name." do
|
142
144
|
Azure::StorageManagementService.any_instance.stubs(:get_storage_account).with('storage3').returns(false)
|
143
|
-
ManagementHttpRequest.any_instance.expects(:call).returns nil
|
145
|
+
Azure::BaseManagement::ManagementHttpRequest.any_instance.expects(:call).returns nil
|
144
146
|
subject.create_storage_account 'storage3'
|
145
147
|
end
|
146
148
|
|
@@ -149,15 +151,12 @@ describe Azure::StorageManagementService do
|
|
149
151
|
describe "#update_storage_account" do
|
150
152
|
let(:updated_accounts_xml) { Fixtures["updated_storage_accounts"] }
|
151
153
|
let(:no_options_specified) { 'No options specified' }
|
152
|
-
let(:
|
153
|
-
|
154
|
-
let(:updated_storage_account_mock_request){ mock() }
|
155
|
-
let(:updated_storage_account_response) {
|
154
|
+
let(:sa_response) {
|
156
155
|
updated_storage_account_response = mock()
|
157
156
|
updated_storage_account_response.stubs(:body).returns(updated_accounts_xml)
|
158
157
|
updated_storage_account_response
|
158
|
+
Nokogiri::XML updated_storage_account_response.body
|
159
159
|
}
|
160
|
-
let(:updated_storage_account_response_body) {Nokogiri::XML updated_storage_account_response.body}
|
161
160
|
|
162
161
|
let(:update_request) {
|
163
162
|
update_request = mock()
|
@@ -166,10 +165,8 @@ describe Azure::StorageManagementService do
|
|
166
165
|
}
|
167
166
|
|
168
167
|
before {
|
169
|
-
ManagementHttpRequest.stubs(:new).with(
|
168
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(verb, request_path, nil).returns(mock_request)
|
170
169
|
mock_request.expects(:call).returns(response_body)
|
171
|
-
|
172
|
-
Azure::StorageManagement::Serialization.stubs(:update_storage_account).returns(update_storage_account_req)
|
173
170
|
}
|
174
171
|
|
175
172
|
let(:options) { {
|
@@ -177,18 +174,11 @@ describe Azure::StorageManagementService do
|
|
177
174
|
label: 'Test Label',
|
178
175
|
geo_replication_enabled: false,
|
179
176
|
extended_properties: {
|
180
|
-
|
181
|
-
|
177
|
+
prop_1_name: 'prop_1_value',
|
178
|
+
prop_2_name: 'prop_2_value'
|
182
179
|
}
|
183
|
-
}
|
184
180
|
}
|
185
|
-
|
186
|
-
it "checks if nil options is provided" do
|
187
|
-
exception = assert_raises RuntimeError do
|
188
|
-
subject.update_storage_account 'storage2', nil
|
189
|
-
end
|
190
|
-
assert_match no_options_specified, exception.message
|
191
|
-
end
|
181
|
+
}
|
192
182
|
|
193
183
|
it "checks if empty options is provided" do
|
194
184
|
exception = assert_raises RuntimeError do
|
@@ -203,26 +193,20 @@ describe Azure::StorageManagementService do
|
|
203
193
|
end
|
204
194
|
|
205
195
|
it "updates the specified account" do
|
206
|
-
ManagementHttpRequest.stubs(:new).with(
|
207
|
-
|
208
|
-
|
196
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
|
197
|
+
:put,
|
198
|
+
"#{request_path}/storage2",
|
199
|
+
Fixtures['update_storage_account']
|
200
|
+
).returns(update_request)
|
201
|
+
update_request.expects(:call)
|
209
202
|
subject.update_storage_account 'storage2', options
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
next unless account.name == 'storage2'
|
218
|
-
|
219
|
-
account.name.must_equal 'storage2'
|
220
|
-
account.label.must_equal options[:label]
|
221
|
-
account.geo_replication_enabled.must_equal "#{options[:geo_replication_enabled]}"
|
222
|
-
|
223
|
-
account.extended_properties.each { |prop|
|
224
|
-
prop[:value].must_equal "#{options[:extended_properties][:"#{prop[:name]}"]}"
|
225
|
-
}
|
203
|
+
mock_request.expects(:call).returns(sa_response)
|
204
|
+
storage_account = subject.list_storage_accounts.last
|
205
|
+
storage_account.name.must_equal 'storage2'
|
206
|
+
storage_account.label.must_equal options[:label]
|
207
|
+
storage_account.geo_replication_enabled.must_equal "#{options[:geo_replication_enabled]}"
|
208
|
+
storage_account.extended_properties.each { |prop|
|
209
|
+
prop[:value].must_equal "#{options[:extended_properties][:"#{prop[:name]}"]}"
|
226
210
|
}
|
227
211
|
end
|
228
212
|
end
|
@@ -244,18 +228,20 @@ describe Azure::StorageManagementService do
|
|
244
228
|
}
|
245
229
|
|
246
230
|
before {
|
247
|
-
ManagementHttpRequest.stubs(:new).with(
|
248
|
-
|
231
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
|
232
|
+
:get, request_path, nil
|
249
233
|
).returns(get_account_mock_request)
|
250
234
|
get_account_mock_request.expects(:call).returns(
|
251
|
-
|
235
|
+
get_account_response_body
|
252
236
|
)
|
253
237
|
}
|
254
238
|
|
255
239
|
it 'returns the label as a Base64 decoded string' do
|
256
|
-
|
257
|
-
|
258
|
-
|
240
|
+
storage_account = subject.get_storage_account_properties(account_name)
|
241
|
+
storage_account.label.must_be_kind_of(String)
|
242
|
+
storage_account.label.must_equal(label)
|
243
|
+
storage_account.account_type.must_equal 'Standard_GRS'
|
244
|
+
storage_account.geo_primary_region.must_equal 'West US'
|
259
245
|
end
|
260
246
|
end
|
261
247
|
end
|