fog-azure-rm 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -0
  3. data/lib/fog/azurerm/compute.rb +6 -0
  4. data/lib/fog/azurerm/docs/compute.md +67 -11
  5. data/lib/fog/azurerm/docs/network.md +59 -0
  6. data/lib/fog/azurerm/docs/storage.md +107 -35
  7. data/lib/fog/azurerm/models/compute/server.rb +15 -9
  8. data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +78 -0
  9. data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +30 -0
  10. data/lib/fog/azurerm/models/network/express_route_circuit.rb +21 -21
  11. data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +21 -21
  12. data/lib/fog/azurerm/models/network/express_route_service_provider.rb +8 -8
  13. data/lib/fog/azurerm/models/network/network_security_rule.rb +27 -0
  14. data/lib/fog/azurerm/models/network/network_security_rules.rb +31 -0
  15. data/lib/fog/azurerm/models/network/subnet.rb +16 -12
  16. data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -6
  17. data/lib/fog/azurerm/models/storage/{containers.rb → directories.rb} +10 -10
  18. data/lib/fog/azurerm/models/storage/{container.rb → directory.rb} +13 -13
  19. data/lib/fog/azurerm/models/storage/file.rb +151 -0
  20. data/lib/fog/azurerm/models/storage/files.rb +31 -0
  21. data/lib/fog/azurerm/network.rb +6 -0
  22. data/lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb +63 -0
  23. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +45 -8
  24. data/lib/fog/azurerm/requests/compute/delete_vm_extension.rb +28 -0
  25. data/lib/fog/azurerm/requests/compute/get_vm_extension.rb +46 -0
  26. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +44 -31
  27. data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +23 -13
  28. data/lib/fog/azurerm/requests/network/create_or_update_network_security_rule.rb +59 -0
  29. data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +23 -15
  30. data/lib/fog/azurerm/requests/network/delete_network_security_rule.rb +30 -0
  31. data/lib/fog/azurerm/requests/network/get_available_ipaddresses_count.rb +23 -0
  32. data/lib/fog/azurerm/requests/network/get_network_security_rule.rb +47 -0
  33. data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +1 -1
  34. data/lib/fog/azurerm/requests/network/list_network_security_rules.rb +51 -0
  35. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +29 -0
  36. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +29 -0
  37. data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +25 -0
  38. data/lib/fog/azurerm/requests/storage/compare_blob.rb +73 -0
  39. data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
  40. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
  41. data/lib/fog/azurerm/requests/storage/delete_blob.rb +27 -0
  42. data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +56 -0
  43. data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +37 -9
  44. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +53 -0
  45. data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +2 -2
  46. data/lib/fog/azurerm/requests/storage/list_blobs.rb +82 -0
  47. data/lib/fog/azurerm/requests/storage/list_containers.rb +1 -1
  48. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +27 -0
  49. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +27 -0
  50. data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +4 -4
  51. data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +26 -0
  52. data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +3 -3
  53. data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +60 -0
  54. data/lib/fog/azurerm/storage.rb +26 -8
  55. data/lib/fog/azurerm/utilities/general.rb +14 -1
  56. data/lib/fog/azurerm/version.rb +1 -1
  57. data/test/api_stub.rb +8 -4
  58. data/test/api_stub/models/compute/virtual_machine_extension.rb +31 -0
  59. data/test/api_stub/models/network/network_security_rule.rb +30 -0
  60. data/test/api_stub/models/storage/{container.rb → directory.rb} +1 -1
  61. data/test/api_stub/models/storage/file.rb +178 -0
  62. data/test/api_stub/requests/compute/virtual_machine.rb +119 -0
  63. data/test/api_stub/requests/compute/virtual_machine_extension.rb +46 -0
  64. data/test/api_stub/requests/network/network_security_rule.rb +72 -0
  65. data/test/api_stub/requests/storage/{container.rb → directory.rb} +2 -2
  66. data/test/api_stub/requests/storage/file.rb +164 -0
  67. data/test/integration/availability_set.rb +6 -0
  68. data/test/integration/blob.rb +205 -0
  69. data/test/integration/credentials/azure.yml +4 -4
  70. data/test/integration/deployment.rb +9 -0
  71. data/test/integration/external_load_balancer.rb +9 -0
  72. data/test/integration/internal_load_balancer.rb +8 -0
  73. data/test/integration/network_security_group.rb +9 -0
  74. data/test/integration/network_security_rule.rb +86 -0
  75. data/test/integration/server.rb +62 -9
  76. data/test/integration/server_custom_image.rb +118 -0
  77. data/test/integration/subnet.rb +12 -1
  78. data/test/integration/virtual_machine_extension.rb +148 -0
  79. data/test/integration/virtual_network.rb +9 -1
  80. data/test/integration/virtual_network_gateway.rb +7 -29
  81. data/test/integration/virtual_network_gateway_connection_to_express_route.rb +116 -0
  82. data/test/models/compute/test_virtual_machine_extension.rb +61 -0
  83. data/test/models/compute/test_virtual_machine_extensions.rb +36 -0
  84. data/test/models/network/test_express_route_circuit.rb +4 -10
  85. data/test/models/network/test_express_route_circuit_peering.rb +4 -10
  86. data/test/models/network/test_network_interface.rb +4 -8
  87. data/test/models/network/test_network_security_rule.rb +14 -0
  88. data/test/models/network/test_network_security_rules.rb +42 -0
  89. data/test/models/network/test_subnet.rb +5 -0
  90. data/test/models/storage/test_directories.rb +106 -0
  91. data/test/models/storage/test_directory.rb +125 -0
  92. data/test/models/storage/test_file.rb +258 -0
  93. data/test/models/storage/test_files.rb +67 -0
  94. data/test/models/storage/test_storage_account.rb +2 -4
  95. data/test/requests/compute/test_create_virtual_machine.rb +19 -5
  96. data/test/requests/compute/test_create_vm_extension.rb +35 -0
  97. data/test/requests/compute/test_get_vm_extension.rb +26 -0
  98. data/test/requests/compute/test_update_vm_extension.rb +35 -0
  99. data/test/requests/network/test_create_or_update_network_security_rule.rb +28 -0
  100. data/test/requests/network/test_delete_network_security_rule.rb +25 -0
  101. data/test/requests/network/test_get_available_ipaddresses_count.rb +18 -0
  102. data/test/requests/network/test_get_network_security_rule.rb +26 -0
  103. data/test/requests/network/test_list_network_security_groups.rb +2 -2
  104. data/test/requests/network/test_list_network_security_rules.rb +26 -0
  105. data/test/requests/storage/test_acquire_blob_lease.rb +17 -0
  106. data/test/requests/storage/test_acquire_container_lease.rb +17 -0
  107. data/test/requests/storage/test_check_blob_exist.rb +17 -0
  108. data/test/requests/storage/test_compare_blob.rb +17 -0
  109. data/test/requests/storage/test_copy_blob.rb +17 -0
  110. data/test/requests/storage/test_copy_blob_from_uri.rb +17 -0
  111. data/test/requests/storage/test_create_container.rb +2 -2
  112. data/test/requests/storage/test_delete_blob.rb +22 -0
  113. data/test/requests/storage/test_delete_container.rb +1 -1
  114. data/test/requests/storage/test_download_blob_to_file.rb +25 -0
  115. data/test/requests/storage/test_get_blob_metadata.rb +2 -2
  116. data/test/requests/storage/test_get_blob_properties.rb +23 -0
  117. data/test/requests/storage/test_get_container_access_control_list.rb +2 -2
  118. data/test/requests/storage/test_get_container_metadata.rb +2 -2
  119. data/test/requests/storage/test_get_container_properties.rb +2 -2
  120. data/test/requests/storage/test_list_blobs_in_container.rb +23 -0
  121. data/test/requests/storage/test_list_containers.rb +2 -2
  122. data/test/requests/storage/test_release_blob_lease.rb +16 -0
  123. data/test/requests/storage/test_release_container_lease.rb +16 -0
  124. data/test/requests/storage/test_set_blob_metadata.rb +1 -1
  125. data/test/requests/storage/test_set_blob_properties.rb +16 -0
  126. data/test/requests/storage/test_set_container_metadata.rb +1 -1
  127. data/test/requests/storage/test_upload_block_blob_from_file.rb +23 -0
  128. data/test/test_helper.rb +116 -3
  129. metadata +73 -15
  130. data/.DS_Store +0 -0
  131. data/lib/fog/azurerm/fog_azure_rm_exception.rb +0 -13
  132. data/lib/fog/azurerm/models/storage/blob.rb +0 -13
  133. data/lib/fog/azurerm/models/storage/blobs.rb +0 -22
  134. data/test/api_stub/models/storage/blob.rb +0 -17
  135. data/test/api_stub/requests/storage/blob.rb +0 -24
  136. data/test/models/storage/test_blobs.rb +0 -32
  137. data/test/models/storage/test_container.rb +0 -67
  138. data/test/models/storage/test_containers.rb +0 -56
@@ -0,0 +1,258 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Storage Container Model
4
+ class TestFile < Minitest::Test
5
+ def setup
6
+ Fog.mock!
7
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
8
+ @mock_file = storage_blob(@mock_service)
9
+ Fog.unmock!
10
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
11
+ @file = storage_blob(@service)
12
+ @cloud_blob = storage_cloud_blob
13
+ @blob_client = @service.instance_variable_get(:@blob_client)
14
+ @mocked_response = mocked_storage_http_error
15
+ @content = Array.new(1024 * 1024) { 'a' }.join
16
+ @get_metadata_result = ApiStub::Models::Storage::File.test_get_blob_metadata
17
+ @create_result = ApiStub::Models::Storage::File.upload_block_blob_from_file
18
+ @download_result = ApiStub::Models::Storage::File.download_blob_to_file
19
+ @get_properties_result = ApiStub::Models::Storage::File.get_blob_properties
20
+ end
21
+
22
+ def test_model_methods
23
+ methods = [
24
+ :save,
25
+ :save_to_file,
26
+ :get_properties,
27
+ :set_properties,
28
+ :set_metadata,
29
+ :get_metadata,
30
+ :destroy
31
+ ]
32
+ methods.each do |method|
33
+ assert @file.respond_to? method, true
34
+ end
35
+ end
36
+
37
+ def test_model_attributes
38
+ attributes = [
39
+ :key,
40
+ :accept_ranges,
41
+ :cache_control,
42
+ :committed_block_count,
43
+ :content_length,
44
+ :content_type,
45
+ :content_md5,
46
+ :content_encoding,
47
+ :content_language,
48
+ :content_disposition,
49
+ :copy_completion_time,
50
+ :copy_status,
51
+ :copy_status_description,
52
+ :copy_id,
53
+ :copy_progress,
54
+ :copy_source,
55
+ :directory,
56
+ :etag,
57
+ :file_path,
58
+ :last_modified,
59
+ :lease_duration,
60
+ :lease_state,
61
+ :lease_status,
62
+ :metadata,
63
+ :sequence_number,
64
+ :blob_type
65
+ ]
66
+ attributes.each do |attribute|
67
+ assert_respond_to @file, attribute
68
+ end
69
+ end
70
+
71
+ def test_save_method_response
72
+ @file.file_path = 'test.txt'
73
+ @service.stub :upload_block_blob_from_file, @create_result do
74
+ assert_instance_of Fog::Storage::AzureRM::File, @file.save
75
+ end
76
+ @service.stub :upload_block_blob_from_file, @create_result do
77
+ assert_instance_of Fog::Storage::AzureRM::File, @file.create
78
+ end
79
+ end
80
+
81
+ def test_save_small_blob_method_response
82
+ small_file_name = 'small_test_file.dat'
83
+ small_file = File.new(small_file_name, 'w')
84
+ small_file.puts(@content)
85
+ small_file.close
86
+ @file.file_path = small_file_name
87
+ @blob_client.stub :create_block_blob, @create_result do
88
+ assert_instance_of Fog::Storage::AzureRM::File, @file.create
89
+ end
90
+ io_exception = -> (_container_name, _blob_name, _file_path, _option) { raise IOError.new }
91
+ @blob_client.stub :create_block_blob, io_exception do
92
+ assert_raises(RuntimeError) do
93
+ @file.create
94
+ end
95
+ end
96
+ http_exception = -> (_container_name, _blob_name, _file_path, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
97
+ @blob_client.stub :create_block_blob, http_exception do
98
+ assert_raises(RuntimeError) do
99
+ @file.create
100
+ end
101
+ end
102
+ File.delete(small_file_name)
103
+ end
104
+
105
+ def test_save_large_blob_method_response
106
+ large_file_name = 'large_test_file.dat'
107
+ large_file = File.new(large_file_name, 'w')
108
+ 33.times do
109
+ large_file.puts(@content)
110
+ end
111
+ large_file.close
112
+ @file.file_path = large_file_name
113
+ @blob_client.stub :put_blob_block, true do
114
+ @blob_client.stub :commit_blob_blocks, @create_result do
115
+ assert_instance_of Fog::Storage::AzureRM::File, @file.create
116
+ end
117
+ end
118
+ File.delete(large_file_name)
119
+ end
120
+
121
+ def test_save_method_response_mock
122
+ @mock_file.file_path = 'mock_test.txt'
123
+ assert_instance_of Fog::Storage::AzureRM::File, @mock_file.save
124
+ end
125
+
126
+ def test_save_to_file
127
+ @service.stub :download_blob_to_file, @download_result do
128
+ assert_instance_of Fog::Storage::AzureRM::File, @file.save_to_file('test.txt')
129
+ end
130
+ end
131
+
132
+ def test_save_to_file_io_exception
133
+ io_exception = -> (_container_name, _blob_name, _option) { raise IOError.new }
134
+ @blob_client.stub :get_blob, io_exception do
135
+ assert_raises(RuntimeError) do
136
+ @file.save_to_file('test.txt')
137
+ end
138
+ end
139
+ end
140
+
141
+ def test_save_to_file_http_exception
142
+ http_exception = -> (_container_name, _blob_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
143
+ @blob_client.stub :get_blob, http_exception do
144
+ assert_raises(RuntimeError) do
145
+ @file.save_to_file('test.txt')
146
+ end
147
+ end
148
+ end
149
+
150
+ def test_save_to_file_mock
151
+ assert_instance_of Fog::Storage::AzureRM::File, @mock_file.save_to_file('test.txt')
152
+ end
153
+
154
+ def test_get_blob_properties
155
+ @service.stub :get_blob_properties, @get_properties_result do
156
+ assert_instance_of Fog::Storage::AzureRM::File, @file.get_properties
157
+ end
158
+ end
159
+
160
+ def test_get_cloud_blob_properties
161
+ @service.stub :get_blob_properties, @cloud_blob do
162
+ assert_instance_of Fog::Storage::AzureRM::File, @file.get_properties
163
+ end
164
+ end
165
+
166
+ def test_get_blob_properties_http_exception
167
+ http_exception = -> (_container_name, _blob_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
168
+ @blob_client.stub :get_blob_properties, http_exception do
169
+ assert_raises(RuntimeError) do
170
+ @file.get_properties
171
+ end
172
+ end
173
+ end
174
+
175
+ def test_get_blob_properties_mock
176
+ assert_instance_of Fog::Storage::AzureRM::File, @mock_file.get_properties
177
+ end
178
+
179
+ def test_set_blob_properties
180
+ @service.stub :set_blob_properties, true do
181
+ assert @file.set_properties
182
+ end
183
+ end
184
+
185
+ def test_set_blob_properties_http_exception
186
+ http_exception = -> (_container_name, _blob_name, _properties) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
187
+ @blob_client.stub :set_blob_properties, http_exception do
188
+ assert_raises(RuntimeError) do
189
+ @file.set_properties
190
+ end
191
+ end
192
+ end
193
+
194
+ def test_set_blob_properties_mock
195
+ assert @mock_file.set_properties
196
+ end
197
+
198
+ def test_get_blob_metadata
199
+ @service.stub :get_blob_metadata, @get_metadata_result do
200
+ file = @file.get_metadata
201
+ assert_instance_of Fog::Storage::AzureRM::File, file
202
+ assert_equal @get_metadata_result, file.metadata
203
+ end
204
+ end
205
+
206
+ def test_get_blob_metadata_http_exception
207
+ http_exception = -> (_container_name, _blob_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
208
+ @blob_client.stub :get_blob_metadata, http_exception do
209
+ assert_raises(RuntimeError) do
210
+ @file.get_metadata
211
+ end
212
+ end
213
+ end
214
+
215
+ def test_get_blob_metadata_mock
216
+ blob = @mock_file.get_metadata
217
+ assert_instance_of Fog::Storage::AzureRM::File, blob
218
+ assert_equal @get_metadata_result, blob.metadata
219
+ end
220
+
221
+ def test_set_blob_metadata
222
+ @service.stub :set_blob_metadata, true do
223
+ assert @file.set_metadata(@get_metadata_result)
224
+ end
225
+ end
226
+
227
+ def test_set_blob_metadata_http_exception
228
+ http_exception = -> (_container_name, _blob_name, _metadata, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
229
+ @blob_client.stub :set_blob_metadata, http_exception do
230
+ assert_raises(RuntimeError) do
231
+ @file.set_metadata @get_metadata_result
232
+ end
233
+ end
234
+ end
235
+
236
+ def test_set_blob_metadata_mock
237
+ assert @mock_file.set_metadata(@get_metadata_result)
238
+ end
239
+
240
+ def test_delete_method_true_response
241
+ @service.stub :delete_blob, true do
242
+ assert @file.destroy
243
+ end
244
+ end
245
+
246
+ def test_delete_method_exception
247
+ exception = -> (_container_name, _blob_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
248
+ @blob_client.stub :delete_blob, exception do
249
+ assert_raises(RuntimeError) do
250
+ assert @file.destroy
251
+ end
252
+ end
253
+ end
254
+
255
+ def test_delete_method_response_mock
256
+ assert @mock_file.destroy
257
+ end
258
+ end
@@ -0,0 +1,67 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Blob Collection
4
+ class TestFiles < Minitest::Test
5
+ def setup
6
+ Fog.mock!
7
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
8
+ @mock_files = Fog::Storage::AzureRM::Files.new(directory: 'test-container', service: @mock_service)
9
+ Fog.unmock!
10
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
11
+ @blob_client = @service.instance_variable_get(:@blob_client)
12
+ @files = Fog::Storage::AzureRM::Files.new(directory: 'test-container', service: @service)
13
+ @mocked_response = mocked_storage_http_error
14
+ @list_results = ApiStub::Models::Storage::File.list_blobs
15
+ end
16
+
17
+ def test_collection_methods
18
+ methods = [
19
+ :all,
20
+ :get
21
+ ]
22
+ methods.each do |method|
23
+ assert @files.respond_to? method, true
24
+ end
25
+ end
26
+
27
+ def test_all_method
28
+ @service.stub :list_blobs, @list_results do
29
+ assert_instance_of Fog::Storage::AzureRM::Files, @files.all
30
+ assert @files.all.size >= 1
31
+ @files.all.each do |file|
32
+ assert_instance_of Fog::Storage::AzureRM::File, file
33
+ end
34
+ end
35
+ end
36
+
37
+ def test_all_method_http_exception
38
+ http_exception = -> (_container_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
39
+ @blob_client.stub :list_blobs, http_exception do
40
+ assert_raises(RuntimeError) do
41
+ @files.all
42
+ end
43
+ end
44
+ end
45
+
46
+ def test_all_method_mock
47
+ assert_instance_of Fog::Storage::AzureRM::Files, @mock_files.all
48
+ assert @mock_files.all.size >= 1
49
+ @mock_files.all.each do |file|
50
+ assert_instance_of Fog::Storage::AzureRM::File, file
51
+ end
52
+ end
53
+
54
+ def test_get_method
55
+ @service.stub :list_blobs, @list_results do
56
+ assert_instance_of Fog::Storage::AzureRM::File, @files.get('test-container', 'testblob1')
57
+ assert !@files.get('test-container', 'wrong-name').nil?
58
+ end
59
+ end
60
+
61
+ def test_get_method_mock
62
+ @service.stub :list_blobs, @list_results do
63
+ assert_instance_of Fog::Storage::AzureRM::File, @mock_files.get('test-container', 'testblob1')
64
+ assert !@mock_files.get('test-container', 'wrong-name').nil?
65
+ end
66
+ end
67
+ end
@@ -30,10 +30,8 @@ class TestStorageAccount < Minitest::Test
30
30
  :sku_name,
31
31
  :replication
32
32
  ]
33
- @service.stub :create_storage_account, @storage_account_response do
34
- attributes.each do |attribute|
35
- assert_respond_to @storage_account, attribute
36
- end
33
+ attributes.each do |attribute|
34
+ assert_respond_to @storage_account, attribute
37
35
  end
38
36
  end
39
37
 
@@ -9,6 +9,7 @@ class TestCreateVirtualMachine < Minitest::Test
9
9
  @response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response(compute_client)
10
10
  @custom_data_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_with_custom_data_response(compute_client)
11
11
  @linux_virtual_machine_hash = ApiStub::Requests::Compute::VirtualMachine.linux_virtual_machine_params
12
+ @windows_virtual_machine_hash = ApiStub::Requests::Compute::VirtualMachine.windows_virtual_machine_params
12
13
  end
13
14
 
14
15
  def test_create_linux_virtual_machine_success
@@ -18,23 +19,36 @@ class TestCreateVirtualMachine < Minitest::Test
18
19
  end
19
20
 
20
21
  def test_create_windows_virtual_machine_success
21
- @windows_virtual_machine_hash = ApiStub::Requests::Compute::VirtualMachine.windows_virtual_machine_params
22
22
  @virtual_machines.stub :create_or_update, @response do
23
23
  assert_equal @service.create_virtual_machine(@windows_virtual_machine_hash), @response
24
24
  end
25
25
  end
26
26
 
27
+ def test_create_linux_virtual_machine_from_custom_image_success
28
+ linux_virtual_machine_with_custom_image_hash = ApiStub::Requests::Compute::VirtualMachine.linux_virtual_machine_with_custom_image_params
29
+ @virtual_machines.stub :create_or_update, @response do
30
+ assert_equal @service.create_virtual_machine(linux_virtual_machine_with_custom_image_hash), @response
31
+ end
32
+ end
33
+
34
+ def test_create_windows_virtual_machine_from_custom_image_success
35
+ windows_virtual_machine_with_custom_image_hash = ApiStub::Requests::Compute::VirtualMachine.windows_virtual_machine_with_custom_image_params
36
+ @virtual_machines.stub :create_or_update, @response do
37
+ assert_equal @service.create_virtual_machine(windows_virtual_machine_with_custom_image_hash), @response
38
+ end
39
+ end
40
+
27
41
  def test_create_linux_virtual_machine_with_custom_data_success
28
- @linux_virtual_machine_with_custom_data_hash = ApiStub::Requests::Compute::VirtualMachine.linux_virtual_machine_with_custom_data_params
42
+ linux_virtual_machine_with_custom_data_hash = ApiStub::Requests::Compute::VirtualMachine.linux_virtual_machine_with_custom_data_params
29
43
  @virtual_machines.stub :create_or_update, @custom_data_response do
30
- assert_equal @service.create_virtual_machine(@linux_virtual_machine_with_custom_data_hash), @custom_data_response
44
+ assert_equal @service.create_virtual_machine(linux_virtual_machine_with_custom_data_hash), @custom_data_response
31
45
  end
32
46
  end
33
47
 
34
48
  def test_create_windows_virtual_machine_with_custom_data_success
35
- @windows_virtual_machine_with_custom_data_hash = ApiStub::Requests::Compute::VirtualMachine.windows_virtual_machine_with_custom_data_params
49
+ windows_virtual_machine_with_custom_data_hash = ApiStub::Requests::Compute::VirtualMachine.windows_virtual_machine_with_custom_data_params
36
50
  @virtual_machines.stub :create_or_update, @custom_data_response do
37
- assert_equal @service.create_virtual_machine(@windows_virtual_machine_with_custom_data_hash), @custom_data_response
51
+ assert_equal @service.create_virtual_machine(windows_virtual_machine_with_custom_data_hash), @custom_data_response
38
52
  end
39
53
  end
40
54
 
@@ -0,0 +1,35 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Create VM Extension request
4
+ class TestCreateVMExtension < Minitest::Test
5
+ def setup
6
+ @service = Fog::Compute::AzureRM.new(credentials)
7
+ compute_client = @service.instance_variable_get(:@compute_mgmt_client)
8
+ @vm_extension = compute_client.virtual_machine_extensions
9
+ @response = ApiStub::Requests::Compute::VirtualMachineExtension.create_vm_extension_response(compute_client)
10
+ @vm_extension_params = ApiStub::Requests::Compute::VirtualMachineExtension.vm_extension_params
11
+ end
12
+
13
+ def test_create_vm_extension_success
14
+ @vm_extension.stub :create_or_update, @response do
15
+ assert_equal @service.create_or_update_vm_extension(@vm_extension_params), @response
16
+ end
17
+ end
18
+
19
+ def test_create_vm_extension_argument_error
20
+ @vm_extension.stub :create_or_update, @response do
21
+ assert_raises ArgumentError do
22
+ @service.create_or_update_vm_extension
23
+ end
24
+ end
25
+ end
26
+
27
+ def test_create_vm_extension_failure
28
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
29
+ @vm_extension.stub :create_or_update, response do
30
+ assert_raises RuntimeError do
31
+ @service.create_or_update_vm_extension(@vm_extension_params)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,26 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Test class for Get VM Extension request
4
+ class TestGetVMExtension < Minitest::Test
5
+ def setup
6
+ @service = Fog::Compute::AzureRM.new(credentials)
7
+ @compute_client = @service.instance_variable_get(:@compute_mgmt_client)
8
+ @vm_extension = @compute_client.virtual_machine_extensions
9
+ end
10
+
11
+ def test_get_vm_extension_success
12
+ response = ApiStub::Requests::Compute::VirtualMachineExtension.create_vm_extension_response(@compute_client)
13
+ @vm_extension.stub :get, response do
14
+ assert_equal @service.get_vm_extension('fog-test-rg', 'fog-test-vm', 'fog-test-extension'), response
15
+ end
16
+ end
17
+
18
+ def test_update_vm_extension_failure
19
+ response = proc { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
20
+ @vm_extension.stub :get, response do
21
+ assert_raises RuntimeError do
22
+ @service.get_vm_extension('fog-test-rg', 'fog-test-vm', 'fog-test-extension')
23
+ end
24
+ end
25
+ end
26
+ end