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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/fog/azurerm/compute.rb +6 -0
- data/lib/fog/azurerm/docs/compute.md +67 -11
- data/lib/fog/azurerm/docs/network.md +59 -0
- data/lib/fog/azurerm/docs/storage.md +107 -35
- data/lib/fog/azurerm/models/compute/server.rb +15 -9
- data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +78 -0
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +30 -0
- data/lib/fog/azurerm/models/network/express_route_circuit.rb +21 -21
- data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +21 -21
- data/lib/fog/azurerm/models/network/express_route_service_provider.rb +8 -8
- data/lib/fog/azurerm/models/network/network_security_rule.rb +27 -0
- data/lib/fog/azurerm/models/network/network_security_rules.rb +31 -0
- data/lib/fog/azurerm/models/network/subnet.rb +16 -12
- data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -6
- data/lib/fog/azurerm/models/storage/{containers.rb → directories.rb} +10 -10
- data/lib/fog/azurerm/models/storage/{container.rb → directory.rb} +13 -13
- data/lib/fog/azurerm/models/storage/file.rb +151 -0
- data/lib/fog/azurerm/models/storage/files.rb +31 -0
- data/lib/fog/azurerm/network.rb +6 -0
- data/lib/fog/azurerm/requests/compute/create_or_update_vm_extension.rb +63 -0
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +45 -8
- data/lib/fog/azurerm/requests/compute/delete_vm_extension.rb +28 -0
- data/lib/fog/azurerm/requests/compute/get_vm_extension.rb +46 -0
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +44 -31
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit_peering.rb +23 -13
- data/lib/fog/azurerm/requests/network/create_or_update_network_security_rule.rb +59 -0
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway.rb +23 -15
- data/lib/fog/azurerm/requests/network/delete_network_security_rule.rb +30 -0
- data/lib/fog/azurerm/requests/network/get_available_ipaddresses_count.rb +23 -0
- data/lib/fog/azurerm/requests/network/get_network_security_rule.rb +47 -0
- data/lib/fog/azurerm/requests/network/list_network_security_groups.rb +1 -1
- data/lib/fog/azurerm/requests/network/list_network_security_rules.rb +51 -0
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +29 -0
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +29 -0
- data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +25 -0
- data/lib/fog/azurerm/requests/storage/compare_blob.rb +73 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +30 -0
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +30 -0
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +27 -0
- data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +56 -0
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +37 -9
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +53 -0
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +82 -0
- data/lib/fog/azurerm/requests/storage/list_containers.rb +1 -1
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +27 -0
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +27 -0
- data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +4 -4
- data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +26 -0
- data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +3 -3
- data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +60 -0
- data/lib/fog/azurerm/storage.rb +26 -8
- data/lib/fog/azurerm/utilities/general.rb +14 -1
- data/lib/fog/azurerm/version.rb +1 -1
- data/test/api_stub.rb +8 -4
- data/test/api_stub/models/compute/virtual_machine_extension.rb +31 -0
- data/test/api_stub/models/network/network_security_rule.rb +30 -0
- data/test/api_stub/models/storage/{container.rb → directory.rb} +1 -1
- data/test/api_stub/models/storage/file.rb +178 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +119 -0
- data/test/api_stub/requests/compute/virtual_machine_extension.rb +46 -0
- data/test/api_stub/requests/network/network_security_rule.rb +72 -0
- data/test/api_stub/requests/storage/{container.rb → directory.rb} +2 -2
- data/test/api_stub/requests/storage/file.rb +164 -0
- data/test/integration/availability_set.rb +6 -0
- data/test/integration/blob.rb +205 -0
- data/test/integration/credentials/azure.yml +4 -4
- data/test/integration/deployment.rb +9 -0
- data/test/integration/external_load_balancer.rb +9 -0
- data/test/integration/internal_load_balancer.rb +8 -0
- data/test/integration/network_security_group.rb +9 -0
- data/test/integration/network_security_rule.rb +86 -0
- data/test/integration/server.rb +62 -9
- data/test/integration/server_custom_image.rb +118 -0
- data/test/integration/subnet.rb +12 -1
- data/test/integration/virtual_machine_extension.rb +148 -0
- data/test/integration/virtual_network.rb +9 -1
- data/test/integration/virtual_network_gateway.rb +7 -29
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +116 -0
- data/test/models/compute/test_virtual_machine_extension.rb +61 -0
- data/test/models/compute/test_virtual_machine_extensions.rb +36 -0
- data/test/models/network/test_express_route_circuit.rb +4 -10
- data/test/models/network/test_express_route_circuit_peering.rb +4 -10
- data/test/models/network/test_network_interface.rb +4 -8
- data/test/models/network/test_network_security_rule.rb +14 -0
- data/test/models/network/test_network_security_rules.rb +42 -0
- data/test/models/network/test_subnet.rb +5 -0
- data/test/models/storage/test_directories.rb +106 -0
- data/test/models/storage/test_directory.rb +125 -0
- data/test/models/storage/test_file.rb +258 -0
- data/test/models/storage/test_files.rb +67 -0
- data/test/models/storage/test_storage_account.rb +2 -4
- data/test/requests/compute/test_create_virtual_machine.rb +19 -5
- data/test/requests/compute/test_create_vm_extension.rb +35 -0
- data/test/requests/compute/test_get_vm_extension.rb +26 -0
- data/test/requests/compute/test_update_vm_extension.rb +35 -0
- data/test/requests/network/test_create_or_update_network_security_rule.rb +28 -0
- data/test/requests/network/test_delete_network_security_rule.rb +25 -0
- data/test/requests/network/test_get_available_ipaddresses_count.rb +18 -0
- data/test/requests/network/test_get_network_security_rule.rb +26 -0
- data/test/requests/network/test_list_network_security_groups.rb +2 -2
- data/test/requests/network/test_list_network_security_rules.rb +26 -0
- data/test/requests/storage/test_acquire_blob_lease.rb +17 -0
- data/test/requests/storage/test_acquire_container_lease.rb +17 -0
- data/test/requests/storage/test_check_blob_exist.rb +17 -0
- data/test/requests/storage/test_compare_blob.rb +17 -0
- data/test/requests/storage/test_copy_blob.rb +17 -0
- data/test/requests/storage/test_copy_blob_from_uri.rb +17 -0
- data/test/requests/storage/test_create_container.rb +2 -2
- data/test/requests/storage/test_delete_blob.rb +22 -0
- data/test/requests/storage/test_delete_container.rb +1 -1
- data/test/requests/storage/test_download_blob_to_file.rb +25 -0
- data/test/requests/storage/test_get_blob_metadata.rb +2 -2
- data/test/requests/storage/test_get_blob_properties.rb +23 -0
- data/test/requests/storage/test_get_container_access_control_list.rb +2 -2
- data/test/requests/storage/test_get_container_metadata.rb +2 -2
- data/test/requests/storage/test_get_container_properties.rb +2 -2
- data/test/requests/storage/test_list_blobs_in_container.rb +23 -0
- data/test/requests/storage/test_list_containers.rb +2 -2
- data/test/requests/storage/test_release_blob_lease.rb +16 -0
- data/test/requests/storage/test_release_container_lease.rb +16 -0
- data/test/requests/storage/test_set_blob_metadata.rb +1 -1
- data/test/requests/storage/test_set_blob_properties.rb +16 -0
- data/test/requests/storage/test_set_container_metadata.rb +1 -1
- data/test/requests/storage/test_upload_block_blob_from_file.rb +23 -0
- data/test/test_helper.rb +116 -3
- metadata +73 -15
- data/.DS_Store +0 -0
- data/lib/fog/azurerm/fog_azure_rm_exception.rb +0 -13
- data/lib/fog/azurerm/models/storage/blob.rb +0 -13
- data/lib/fog/azurerm/models/storage/blobs.rb +0 -22
- data/test/api_stub/models/storage/blob.rb +0 -17
- data/test/api_stub/requests/storage/blob.rb +0 -24
- data/test/models/storage/test_blobs.rb +0 -32
- data/test/models/storage/test_container.rb +0 -67
- 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
|
-
|
34
|
-
|
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
|
-
|
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(
|
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
|
-
|
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(
|
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
|