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
@@ -12,31 +12,27 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
16
|
-
require
|
15
|
+
require 'test_helper'
|
16
|
+
require 'azure'
|
17
17
|
|
18
18
|
Azure::Core.configure do |config|
|
19
|
-
config.storage_access_key = ENV.fetch(
|
20
|
-
config.storage_account_name = ENV.fetch(
|
21
|
-
|
22
|
-
|
23
|
-
# config.storage_queue_host = ENV.fetch("AZURE_STORAGE_QUEUE_HOST")
|
24
|
-
|
25
|
-
config.sb_namespace = ENV.fetch("AZURE_SERVICEBUS_NAMESPACE")
|
26
|
-
config.sb_access_key = ENV.fetch("AZURE_SERVICEBUS_ACCESS_KEY")
|
27
|
-
# config.sb_issuer = ENV.fetch("AZURE_SERVICEBUS_ISSUER")
|
19
|
+
config.storage_access_key = ENV.fetch('AZURE_STORAGE_ACCESS_KEY')
|
20
|
+
config.storage_account_name = ENV.fetch('AZURE_STORAGE_ACCOUNT')
|
21
|
+
config.sb_namespace = ENV.fetch('AZURE_SERVICEBUS_NAMESPACE')
|
22
|
+
config.sb_access_key = ENV.fetch('AZURE_SERVICEBUS_ACCESS_KEY')
|
28
23
|
config.management_certificate = ENV.fetch('AZURE_MANAGEMENT_CERTIFICATE')
|
29
|
-
|
30
|
-
config.subscription_id = ENV.fetch("AZURE_SUBSCRIPTION_ID")
|
24
|
+
config.subscription_id = ENV.fetch('AZURE_SUBSCRIPTION_ID')
|
31
25
|
end
|
32
26
|
|
33
|
-
|
27
|
+
util = Class.new.extend(Azure::Core::Utility)
|
28
|
+
|
29
|
+
StorageAccountName = util.random_string('storagetest',10)
|
34
30
|
Images = Azure::VirtualMachineImageManagementService.new.list_virtual_machine_images
|
35
31
|
LinuxImage = Images.select{|image| image.os_type == 'Linux'}.first
|
36
32
|
WindowsImage = Images.select{|image| image.os_type == 'Windows'}.first
|
37
33
|
WindowsImageLocation = WindowsImage.locations.split(';').first
|
38
34
|
LinuxImageLocation = LinuxImage.locations.split(';').first
|
39
35
|
|
40
|
-
MiniTest
|
36
|
+
MiniTest.after_run {
|
41
37
|
VirtualMachineNameGenerator.cleanup
|
42
38
|
}
|
@@ -15,6 +15,8 @@
|
|
15
15
|
require 'integration/test_helper'
|
16
16
|
|
17
17
|
describe Azure::VirtualMachineManagementService do
|
18
|
+
include Azure::Core::Utility
|
19
|
+
|
18
20
|
subject { Azure::VirtualMachineManagementService.new }
|
19
21
|
let(:cloud_service) { Azure::CloudServiceManagementService.new }
|
20
22
|
let(:names) { VirtualMachineNameHelper.name }
|
@@ -23,7 +25,6 @@ describe Azure::VirtualMachineManagementService do
|
|
23
25
|
let(:storage_account_name) { StorageAccountName }
|
24
26
|
let(:username) { 'adminuser' }
|
25
27
|
let(:password) { 'Admin123' }
|
26
|
-
let(:certificate) { Fixtures['certificate.pem'] }
|
27
28
|
let(:private_key) { Fixtures['privatekey.key'] }
|
28
29
|
|
29
30
|
let(:params)do
|
@@ -62,7 +63,7 @@ describe Azure::VirtualMachineManagementService do
|
|
62
63
|
end
|
63
64
|
|
64
65
|
before do
|
65
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
66
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
66
67
|
end
|
67
68
|
|
68
69
|
describe '#deployment' do
|
@@ -74,7 +75,6 @@ describe Azure::VirtualMachineManagementService do
|
|
74
75
|
options.delete(:cloud_service_name)
|
75
76
|
params.delete(:location)
|
76
77
|
params[:vm_name] = "add-#{virtual_machine_name}"
|
77
|
-
sleep 30
|
78
78
|
end
|
79
79
|
|
80
80
|
it 'should add role to existing storage account and cloud service' do
|
@@ -89,26 +89,28 @@ describe Azure::VirtualMachineManagementService do
|
|
89
89
|
params[:vm_name] = "Add-storage-#{virtual_machine_name}"
|
90
90
|
vm = subject.add_role(params)
|
91
91
|
vm.cloud_service_name.must_equal params[:cloud_service_name]
|
92
|
-
vm.vm_name.must_equal params[:vm_name]
|
92
|
+
vm.vm_name.must_equal params[:vm_name]
|
93
93
|
vm.deployment_name.must_equal @vm_obj.deployment_name
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
describe '#virtual_network' do
|
98
|
+
let(:subnet_name) { 'Subnet-1' }
|
99
|
+
let(:geo_location) { LinuxImageLocation }
|
98
100
|
before do
|
99
101
|
options[:virtual_network_name] = 'v-net'
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
'AG1'
|
105
|
-
) rescue nil
|
102
|
+
inputoptions = {
|
103
|
+
subnet: [{ name: subnet_name, ip_address: '172.16.0.0', cidr: 12 }],
|
104
|
+
dns: [{ name: 'DNS', ip_address: '1.2.3.4' }]
|
105
|
+
}
|
106
106
|
vnet_service = Azure::VirtualNetworkManagementService
|
107
107
|
vnet_service.new.set_network_configuration(
|
108
108
|
options[:virtual_network_name],
|
109
|
-
|
110
|
-
['172.16.0.0/12']
|
109
|
+
geo_location,
|
110
|
+
['172.16.0.0/12'],
|
111
|
+
inputoptions
|
111
112
|
) rescue nil
|
113
|
+
options[:subnet_name] = subnet_name
|
112
114
|
subject.create_virtual_machine(params, options)
|
113
115
|
end
|
114
116
|
|
@@ -117,6 +119,7 @@ describe Azure::VirtualMachineManagementService do
|
|
117
119
|
virtual_machine.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
118
120
|
virtual_machine.vm_name.must_equal virtual_machine_name
|
119
121
|
virtual_machine.virtual_network_name.must_equal options[:virtual_network_name]
|
122
|
+
virtual_machine.subnet.must_equal subnet_name
|
120
123
|
end
|
121
124
|
end
|
122
125
|
|
@@ -147,14 +150,12 @@ describe Azure::VirtualMachineManagementService do
|
|
147
150
|
end
|
148
151
|
tcp_endpoints_names.must_include 'PowerShell'
|
149
152
|
tcp_endpoints_names.must_include 'WinRm-Http'
|
150
|
-
sleep 30
|
151
153
|
end
|
152
154
|
|
153
155
|
it 'should creates https enabled winrm virtual machine using certificate.' do
|
154
156
|
default_options.merge!(
|
155
157
|
winrm_transport: ['https'],
|
156
|
-
private_key_file: private_key
|
157
|
-
certificate_file: certificate
|
158
|
+
private_key_file: private_key
|
158
159
|
)
|
159
160
|
result = subject.create_virtual_machine(windows_params, default_options)
|
160
161
|
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
@@ -181,13 +182,11 @@ describe Azure::VirtualMachineManagementService do
|
|
181
182
|
|
182
183
|
it 'created linux virtual machine should be accessible using password and certificate' do
|
183
184
|
default_options.merge!(
|
184
|
-
private_key_file: private_key
|
185
|
-
certificate_file: certificate
|
185
|
+
private_key_file: private_key
|
186
186
|
)
|
187
187
|
result = subject.create_virtual_machine(params, default_options)
|
188
188
|
result.must_be_kind_of Azure::VirtualMachineManagement::VirtualMachine
|
189
189
|
assert_equal(result.os_type, 'Linux')
|
190
|
-
sleep 30
|
191
190
|
end
|
192
191
|
|
193
192
|
it 'throws error as port value is beyond or less than actual range' do
|
@@ -22,7 +22,7 @@ describe Azure::VirtualMachineManagementService do
|
|
22
22
|
let(:csn) { names.last }
|
23
23
|
let(:username) { 'admin' }
|
24
24
|
before do
|
25
|
-
Loggerx.expects(:puts).at_least_once.returns(nil)
|
25
|
+
Azure::Loggerx.expects(:puts).at_least_once.returns(nil)
|
26
26
|
params = {
|
27
27
|
vm_name: virtual_machine_name,
|
28
28
|
vm_user: 'user',
|
@@ -35,19 +35,17 @@ describe Azure::VirtualMachineManagementService do
|
|
35
35
|
cloud_service_name: csn,
|
36
36
|
}
|
37
37
|
subject.create_virtual_machine(params, options)
|
38
|
-
sleep 60
|
39
38
|
end
|
40
39
|
|
41
40
|
describe '#delete_virtual_machine' do
|
42
41
|
|
43
42
|
it 'delete existing virtual machine and cloud service' do
|
44
43
|
subject.delete_virtual_machine(virtual_machine_name, csn)
|
45
|
-
sleep 60
|
46
44
|
vm = subject.get_virtual_machine(virtual_machine_name, csn)
|
47
45
|
vm.must_be_nil
|
48
46
|
cloud_service = Azure::CloudServiceManagementService.new
|
49
47
|
cloud_presence = cloud_service.get_cloud_service(csn)
|
50
|
-
cloud_presence.must_equal
|
48
|
+
cloud_presence.must_equal nil
|
51
49
|
end
|
52
50
|
|
53
51
|
end
|
@@ -20,7 +20,7 @@ describe Azure::VirtualMachineManagementService do
|
|
20
20
|
subject { Azure::VirtualMachineManagementService.new }
|
21
21
|
|
22
22
|
before do
|
23
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
23
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
24
24
|
params = {
|
25
25
|
vm_name: vm_name,
|
26
26
|
vm_user: 'user',
|
@@ -35,7 +35,6 @@ describe Azure::VirtualMachineManagementService do
|
|
35
35
|
vm = subject.get_virtual_machine(vm_name, csn)
|
36
36
|
if vm.nil?
|
37
37
|
subject.create_virtual_machine(params, options)
|
38
|
-
sleep 60 # Wait to finish provision.
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
@@ -17,7 +17,7 @@ require 'support/virtual_network_helper'
|
|
17
17
|
|
18
18
|
describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
19
19
|
let(:in_vnet_name) { 'newvnet' }
|
20
|
-
let(:
|
20
|
+
let(:geo_location) { 'West US' }
|
21
21
|
let(:in_address_space) { ['172.16.0.0/12'] }
|
22
22
|
let(:invalid_address_space) { ['', ''] }
|
23
23
|
let(:invalid_cidr_address_space) { ['10.0.0.0'] }
|
@@ -32,25 +32,19 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
32
32
|
subject { Azure::VirtualNetworkManagementService.new }
|
33
33
|
|
34
34
|
before do
|
35
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
36
|
-
|
37
|
-
affinity_group_service = Azure::BaseManagementService.new
|
38
|
-
affinity_group_service.create_affinity_group(in_affinity_name,
|
39
|
-
WindowsImageLocation,
|
40
|
-
'Label'
|
41
|
-
) rescue nil
|
35
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
42
36
|
end
|
43
37
|
|
44
38
|
describe 'Create virtual network valid params' do
|
45
39
|
it 'Create virtual network with valid params' do
|
46
40
|
subject.set_network_configuration(in_vnet_name,
|
47
|
-
|
41
|
+
geo_location,
|
48
42
|
in_address_space,
|
49
43
|
inputoptions)
|
50
44
|
|
51
45
|
VirtualNetworkHelper.check_config(subject.list_virtual_networks,
|
52
46
|
in_vnet_name,
|
53
|
-
|
47
|
+
geo_location,
|
54
48
|
created_state,
|
55
49
|
in_address_space,
|
56
50
|
inputoptions)
|
@@ -66,7 +60,7 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
66
60
|
|
67
61
|
exception = assert_raises(RuntimeError) do
|
68
62
|
subject.set_network_configuration(in_vnet_name,
|
69
|
-
|
63
|
+
geo_location,
|
70
64
|
in_address_space,
|
71
65
|
options)
|
72
66
|
end
|
@@ -78,7 +72,7 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
78
72
|
it 'Create virtual network with invalid options' do
|
79
73
|
exception = assert_raises(RuntimeError) do
|
80
74
|
subject.set_network_configuration(in_vnet_name,
|
81
|
-
|
75
|
+
geo_location,
|
82
76
|
invalid_address_space,
|
83
77
|
inputoptions)
|
84
78
|
end
|
@@ -95,12 +89,12 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
95
89
|
}
|
96
90
|
|
97
91
|
subject.set_network_configuration(in_vnet_name,
|
98
|
-
|
92
|
+
geo_location,
|
99
93
|
update_address_space,
|
100
94
|
update_options)
|
101
95
|
VirtualNetworkHelper.check_config(subject.list_virtual_networks,
|
102
96
|
in_vnet_name,
|
103
|
-
|
97
|
+
geo_location,
|
104
98
|
created_state,
|
105
99
|
update_address_space,
|
106
100
|
update_options)
|
@@ -111,7 +105,7 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
111
105
|
it 'Create virtual network with invalid options' do
|
112
106
|
exception = assert_raises(RuntimeError) do
|
113
107
|
subject.set_network_configuration(in_vnet_name,
|
114
|
-
|
108
|
+
geo_location,
|
115
109
|
invalid_cidr_address_space,
|
116
110
|
inputoptions)
|
117
111
|
end
|
@@ -19,21 +19,16 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
19
19
|
subject { Azure::VirtualNetworkManagementService.new }
|
20
20
|
|
21
21
|
let(:affinity_group_name) { 'my-affinity-group' }
|
22
|
-
let(:
|
22
|
+
let(:geo_location) { 'West US' }
|
23
23
|
let(:vnet_name) { 'vnet-integration-test' }
|
24
24
|
|
25
25
|
before do
|
26
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
27
|
-
affinity_group_service = Azure::BaseManagementService.new
|
28
|
-
affinity_group_service.create_affinity_group(affinity_group_name,
|
29
|
-
location,
|
30
|
-
'Label Name'
|
31
|
-
) rescue nil
|
26
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
32
27
|
address_space = %w(172.16.0.0/12 10.0.0.0/8 192.168.0.0/24)
|
33
28
|
unless subject.list_virtual_networks.map(&:name).include?(vnet_name)
|
34
29
|
subject.set_network_configuration(
|
35
30
|
vnet_name,
|
36
|
-
|
31
|
+
location,
|
37
32
|
address_space
|
38
33
|
)
|
39
34
|
end
|
@@ -45,7 +40,7 @@ describe Azure::VirtualNetworkManagement::VirtualNetwork do
|
|
45
40
|
virtual_networks.wont_be_nil
|
46
41
|
virtual_networks.must_be_kind_of Array
|
47
42
|
virtual_networks.first.must_be_kind_of(
|
48
|
-
|
43
|
+
Azure::VirtualNetworkManagement::VirtualNetwork
|
49
44
|
)
|
50
45
|
assert_operator virtual_networks.size, :>=, 1
|
51
46
|
end
|
@@ -57,6 +57,14 @@ QueueNameHelper = NameGenerator.new do |name|
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
+
ServiceBusRelayNameHelper = NameGenerator.new do |name|
|
61
|
+
svc = Azure::ServiceBus::ServiceBusService.new
|
62
|
+
begin
|
63
|
+
svc.delete_relay name
|
64
|
+
rescue
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
60
68
|
ServiceBusQueueNameHelper = NameGenerator.new do |name|
|
61
69
|
svc = Azure::ServiceBus::ServiceBusService.new
|
62
70
|
begin
|
@@ -16,7 +16,7 @@
|
|
16
16
|
class VirtualNetworkHelper
|
17
17
|
def self.check_config(virtual_networks,
|
18
18
|
in_vnet_name,
|
19
|
-
|
19
|
+
location,
|
20
20
|
created_state,
|
21
21
|
in_address_space,
|
22
22
|
inputoptions)
|
@@ -38,7 +38,7 @@ class VirtualNetworkHelper
|
|
38
38
|
|
39
39
|
# Verify global properties
|
40
40
|
created_virtual_network[0].name.must_equal in_vnet_name
|
41
|
-
created_virtual_network[0].
|
41
|
+
created_virtual_network[0].location.must_equal location
|
42
42
|
created_virtual_network[0].state.must_equal created_state
|
43
43
|
|
44
44
|
# Verify address_space
|
data/test/test_helper.rb
CHANGED
@@ -12,42 +12,31 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
#--------------------------------------------------------------------------
|
15
|
-
require
|
16
|
-
require
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
require "turn"
|
21
|
-
Turn.config.format = :pretty
|
22
|
-
Turn.config.natural = true
|
23
|
-
rescue LoadError
|
24
|
-
end
|
15
|
+
require 'minitest/autorun'
|
16
|
+
require 'mocha/mini_test'
|
17
|
+
require 'minitest/reporters'
|
18
|
+
Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
|
19
|
+
require 'timecop'
|
25
20
|
|
26
21
|
# add to the MiniTest DSL
|
27
22
|
module Kernel
|
28
23
|
def need_tests_for(name)
|
29
24
|
describe "##{name}" do
|
30
|
-
it
|
31
|
-
skip
|
25
|
+
it 'needs unit tests' do
|
26
|
+
skip ''
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
30
|
end
|
36
31
|
|
37
32
|
|
38
|
-
Dir[
|
33
|
+
Dir['./test/support/**/*.rb'].each { |dep| require dep }
|
39
34
|
|
40
35
|
# mock configuration setup
|
41
36
|
require 'azure'
|
42
37
|
|
43
|
-
Azure.config.storage_account_name =
|
44
|
-
Azure.config.storage_access_key =
|
45
|
-
Azure.config.management_certificate = File.expand_path(
|
46
|
-
Azure.config.management_endpoint =
|
47
|
-
Azure.config.subscription_id =
|
48
|
-
# Azure.config.storage_table_host =
|
49
|
-
# Azure.config.storage_blob_host =
|
50
|
-
# Azure.config.storage_queue_host =
|
51
|
-
# Azure.config.sb_namespace =
|
52
|
-
# Azure.config.sb_access_key =
|
53
|
-
# Azure.config.sb_issuer =
|
38
|
+
Azure.config.storage_account_name = 'accountname'
|
39
|
+
Azure.config.storage_access_key = 'YWNjZXNzLWtleQ=='
|
40
|
+
Azure.config.management_certificate = File.expand_path('test/fixtures/management_certificate.pem')
|
41
|
+
Azure.config.management_endpoint = 'https://management.core.windows.net'
|
42
|
+
Azure.config.subscription_id = 'subscription-id'
|
@@ -23,17 +23,16 @@ describe Azure::BaseManagementService do
|
|
23
23
|
let(:response_xml) { nil }
|
24
24
|
|
25
25
|
before do
|
26
|
-
Loggerx.expects(:puts).returns(nil).at_least(0)
|
26
|
+
Azure::Loggerx.expects(:puts).returns(nil).at_least(0)
|
27
27
|
mock_request.expects(:call).returns(Nokogiri::XML response_xml).at_least(0)
|
28
28
|
end
|
29
29
|
|
30
30
|
describe '#list_affinity_groups' do
|
31
31
|
let(:request_path) { '/affinitygroups' }
|
32
32
|
let(:response_xml) { Fixtures['list_affinity_groups'] }
|
33
|
-
let(:method) { :get }
|
34
33
|
|
35
34
|
before do
|
36
|
-
ManagementHttpRequest.stubs(:new).with(
|
35
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(:get,
|
37
36
|
request_path,
|
38
37
|
nil).returns(mock_request)
|
39
38
|
end
|
@@ -76,10 +75,9 @@ describe Azure::BaseManagementService do
|
|
76
75
|
end
|
77
76
|
|
78
77
|
describe '#create_affinity_group' do
|
79
|
-
let(:method) { :post }
|
80
78
|
let(:request_path) { '/affinitygroups' }
|
81
|
-
let(:
|
82
|
-
let(:
|
79
|
+
let(:ag_name) { 'AG1' }
|
80
|
+
let(:geo_location) { 'West US' }
|
83
81
|
let(:label) { 'Label Name' }
|
84
82
|
|
85
83
|
let(:location_request_path) { '/locations' }
|
@@ -92,7 +90,7 @@ describe Azure::BaseManagementService do
|
|
92
90
|
let(:location_response_body) { Nokogiri::XML location_response.body }
|
93
91
|
|
94
92
|
before do
|
95
|
-
ManagementHttpRequest.stubs(:new).with(
|
93
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(:post,
|
96
94
|
request_path,
|
97
95
|
anything).returns(mock_request)
|
98
96
|
mock_request.expects(:call).returns(
|
@@ -100,13 +98,13 @@ describe Azure::BaseManagementService do
|
|
100
98
|
).at_least(0)
|
101
99
|
mock_request = mock
|
102
100
|
|
103
|
-
ManagementHttpRequest.stubs(:new).with(:get,
|
101
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(:get,
|
104
102
|
location_request_path,
|
105
103
|
nil).returns(mock_request)
|
106
104
|
mock_request.expects(:call).returns(location_response_body).at_least(0)
|
107
105
|
mock_request = mock
|
108
106
|
|
109
|
-
ManagementHttpRequest.stubs(:new).with(:get,
|
107
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(:get,
|
110
108
|
request_path,
|
111
109
|
nil).returns(mock_request)
|
112
110
|
mock_request.expects(:call).returns(
|
@@ -116,10 +114,10 @@ describe Azure::BaseManagementService do
|
|
116
114
|
|
117
115
|
it 'error if affinity group already exists' do
|
118
116
|
exception = assert_raises(Azure::Error::Error) do
|
119
|
-
subject.create_affinity_group(
|
117
|
+
subject.create_affinity_group(ag_name, geo_location, label)
|
120
118
|
end
|
121
119
|
assert_match(
|
122
|
-
/An affinity group #{
|
120
|
+
/An affinity group #{ag_name} already exists in the current subscription/i,
|
123
121
|
exception.message
|
124
122
|
)
|
125
123
|
end
|
@@ -140,13 +138,12 @@ describe Azure::BaseManagementService do
|
|
140
138
|
let(:affinity_group_name) { 'AG1' }
|
141
139
|
let(:request_path) { '/affinitygroups/' + affinity_group_name }
|
142
140
|
let(:response_xml) { Fixtures['affinity_group'] }
|
143
|
-
let(:method) { :get }
|
144
141
|
|
145
142
|
before do
|
146
143
|
Azure::BaseManagementService.any_instance.stubs(
|
147
144
|
:affinity_group
|
148
145
|
).returns(true)
|
149
|
-
ManagementHttpRequest.stubs(:new).with(
|
146
|
+
Azure::BaseManagement::ManagementHttpRequest.stubs(:new).with(
|
150
147
|
:get,
|
151
148
|
request_path,
|
152
149
|
nil
|