fog-azure-rm 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +20 -0
  3. data/README.md +2 -1
  4. data/fog-azure-rm.gemspec +11 -9
  5. data/lib/fog/azurerm.rb +1 -0
  6. data/lib/fog/azurerm/compute.rb +3 -3
  7. data/lib/fog/azurerm/config.rb +33 -0
  8. data/lib/fog/azurerm/credentials.rb +1 -1
  9. data/lib/fog/azurerm/dns.rb +2 -2
  10. data/lib/fog/azurerm/docs/storage.md +120 -66
  11. data/lib/fog/azurerm/models/application_gateway/gateway.rb +30 -31
  12. data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -4
  13. data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -4
  14. data/lib/fog/azurerm/models/compute/server.rb +14 -14
  15. data/lib/fog/azurerm/models/compute/servers.rb +4 -4
  16. data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +3 -5
  17. data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +5 -5
  18. data/lib/fog/azurerm/models/dns/record_sets.rb +4 -4
  19. data/lib/fog/azurerm/models/dns/zones.rb +4 -4
  20. data/lib/fog/azurerm/models/network/express_route_circuit.rb +2 -5
  21. data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +1 -1
  22. data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +4 -4
  23. data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +3 -5
  24. data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +4 -4
  25. data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -4
  26. data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -2
  27. data/lib/fog/azurerm/models/network/load_balancers.rb +5 -5
  28. data/lib/fog/azurerm/models/network/local_network_gateway.rb +1 -1
  29. data/lib/fog/azurerm/models/network/local_network_gateways.rb +4 -4
  30. data/lib/fog/azurerm/models/network/network_interfaces.rb +5 -5
  31. data/lib/fog/azurerm/models/network/network_security_groups.rb +5 -5
  32. data/lib/fog/azurerm/models/network/network_security_rule.rb +3 -4
  33. data/lib/fog/azurerm/models/network/network_security_rules.rb +4 -4
  34. data/lib/fog/azurerm/models/network/public_ips.rb +4 -4
  35. data/lib/fog/azurerm/models/network/subnets.rb +4 -4
  36. data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -7
  37. data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +5 -5
  38. data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +4 -4
  39. data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -4
  40. data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -4
  41. data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -2
  42. data/lib/fog/azurerm/models/resources/deployments.rb +4 -4
  43. data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -4
  44. data/lib/fog/azurerm/models/sql/firewall_rule.rb +1 -1
  45. data/lib/fog/azurerm/models/sql/firewall_rules.rb +4 -4
  46. data/lib/fog/azurerm/models/sql/sql_database.rb +28 -24
  47. data/lib/fog/azurerm/models/sql/sql_databases.rb +5 -6
  48. data/lib/fog/azurerm/models/sql/sql_servers.rb +4 -4
  49. data/lib/fog/azurerm/models/storage/directories.rb +49 -24
  50. data/lib/fog/azurerm/models/storage/directory.rb +126 -40
  51. data/lib/fog/azurerm/models/storage/file.rb +226 -114
  52. data/lib/fog/azurerm/models/storage/files.rb +168 -13
  53. data/lib/fog/azurerm/models/storage/recovery_vault.rb +1 -1
  54. data/lib/fog/azurerm/models/storage/recovery_vaults.rb +4 -4
  55. data/lib/fog/azurerm/models/storage/storage_account.rb +5 -5
  56. data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -4
  57. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +1 -1
  58. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +4 -4
  59. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +4 -4
  60. data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -4
  61. data/lib/fog/azurerm/network.rb +1 -1
  62. data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +17 -13
  63. data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +1 -1
  64. data/lib/fog/azurerm/requests/resources/create_deployment.rb +1 -1
  65. data/lib/fog/azurerm/requests/resources/create_resource_group.rb +1 -1
  66. data/lib/fog/azurerm/requests/resources/delete_deployment.rb +1 -1
  67. data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +1 -1
  68. data/lib/fog/azurerm/requests/resources/get_deployment.rb +1 -1
  69. data/lib/fog/azurerm/requests/resources/get_resource_group.rb +1 -1
  70. data/lib/fog/azurerm/requests/resources/list_deployments.rb +1 -1
  71. data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +1 -1
  72. data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +1 -1
  73. data/lib/fog/azurerm/requests/resources/tag_resource.rb +1 -1
  74. data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +3 -3
  75. data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +3 -3
  76. data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +3 -3
  77. data/lib/fog/azurerm/requests/sql/delete_database.rb +2 -2
  78. data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +4 -4
  79. data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +4 -4
  80. data/lib/fog/azurerm/requests/sql/get_database.rb +3 -3
  81. data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +3 -3
  82. data/lib/fog/azurerm/requests/sql/get_sql_server.rb +3 -3
  83. data/lib/fog/azurerm/requests/sql/list_databases.rb +3 -3
  84. data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +3 -3
  85. data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +3 -3
  86. data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +5 -2
  87. data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +5 -2
  88. data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
  89. data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
  90. data/lib/fog/azurerm/requests/storage/copy_blob.rb +8 -8
  91. data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +8 -8
  92. data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
  93. data/lib/fog/azurerm/requests/storage/create_container.rb +12 -10
  94. data/lib/fog/azurerm/requests/storage/create_disk.rb +45 -19
  95. data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +2 -2
  96. data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
  97. data/lib/fog/azurerm/requests/storage/create_storage_account.rb +2 -2
  98. data/lib/fog/azurerm/requests/storage/delete_blob.rb +10 -5
  99. data/lib/fog/azurerm/requests/storage/delete_container.rb +6 -2
  100. data/lib/fog/azurerm/requests/storage/delete_disk.rb +19 -16
  101. data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +2 -2
  102. data/lib/fog/azurerm/requests/storage/get_backup_container.rb +2 -2
  103. data/lib/fog/azurerm/requests/storage/get_backup_item.rb +2 -2
  104. data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +1 -1
  105. data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +2 -2
  106. data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
  107. data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
  108. data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
  109. data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +37 -35
  110. data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
  111. data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
  112. data/lib/fog/azurerm/requests/storage/get_container_properties.rb +16 -12
  113. data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
  114. data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +2 -2
  115. data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +4 -3
  116. data/lib/fog/azurerm/requests/storage/get_storage_account.rb +2 -2
  117. data/lib/fog/azurerm/requests/storage/list_blobs.rb +110 -24
  118. data/lib/fog/azurerm/requests/storage/list_containers.rb +46 -23
  119. data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +2 -2
  120. data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +2 -2
  121. data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +2 -2
  122. data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
  123. data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
  124. data/lib/fog/azurerm/requests/storage/{set_blob_metadata.rb → put_blob_metadata.rb} +7 -3
  125. data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
  126. data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
  127. data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
  128. data/lib/fog/azurerm/requests/storage/{set_container_metadata.rb → put_container_metadata.rb} +7 -3
  129. data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +4 -1
  130. data/lib/fog/azurerm/requests/storage/release_container_lease.rb +4 -1
  131. data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
  132. data/lib/fog/azurerm/requests/storage/start_backup.rb +1 -1
  133. data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
  134. data/lib/fog/azurerm/resources.rb +2 -2
  135. data/lib/fog/azurerm/storage.rb +33 -19
  136. data/lib/fog/azurerm/traffic_manager.rb +1 -1
  137. data/lib/fog/azurerm/utilities/general.rb +70 -3
  138. data/lib/fog/azurerm/version.rb +1 -1
  139. data/rake-script.sh +5 -2
  140. data/test/api_stub/models/application_gateway/gateway.rb +1 -1
  141. data/test/api_stub/models/compute/server.rb +1 -1
  142. data/test/api_stub/models/dns/record_set.rb +2 -2
  143. data/test/api_stub/models/dns/zone.rb +1 -1
  144. data/test/api_stub/models/network/express_route_circuit.rb +1 -1
  145. data/test/api_stub/models/network/express_route_circuit_authorization.rb +1 -1
  146. data/test/api_stub/models/network/express_route_circuit_peering.rb +1 -1
  147. data/test/api_stub/models/network/express_route_service_provider.rb +1 -1
  148. data/test/api_stub/models/network/load_balancer.rb +1 -1
  149. data/test/api_stub/models/network/network_interface.rb +1 -1
  150. data/test/api_stub/models/network/network_security_group.rb +1 -1
  151. data/test/api_stub/models/network/network_security_rule.rb +1 -1
  152. data/test/api_stub/models/network/public_ip.rb +1 -1
  153. data/test/api_stub/models/network/subnet.rb +1 -1
  154. data/test/api_stub/models/network/virtual_network.rb +1 -1
  155. data/test/api_stub/models/network/virtual_network_gateway.rb +1 -1
  156. data/test/api_stub/models/network/virtual_network_gateway_connection.rb +1 -1
  157. data/test/api_stub/models/resources/resource.rb +2 -2
  158. data/test/api_stub/models/resources/resource_group.rb +1 -1
  159. data/test/api_stub/models/storage/directory.rb +148 -62
  160. data/test/api_stub/models/storage/file.rb +122 -119
  161. data/test/api_stub/models/traffic_manager/traffic_manager_end_point.rb +1 -1
  162. data/test/api_stub/models/traffic_manager/traffic_manager_profile.rb +1 -1
  163. data/test/api_stub/requests/application_gateway/gateway.rb +2 -2
  164. data/test/api_stub/requests/compute/availability_set.rb +3 -3
  165. data/test/api_stub/requests/compute/virtual_machine.rb +9 -9
  166. data/test/api_stub/requests/dns/record_set.rb +3 -3
  167. data/test/api_stub/requests/dns/zone.rb +18 -18
  168. data/test/api_stub/requests/network/express_route_circuit.rb +2 -2
  169. data/test/api_stub/requests/network/express_route_circuit_authorization.rb +1 -1
  170. data/test/api_stub/requests/network/express_route_circuit_peering.rb +2 -2
  171. data/test/api_stub/requests/network/express_route_service_provider.rb +1 -1
  172. data/test/api_stub/requests/network/load_balancer.rb +2 -2
  173. data/test/api_stub/requests/network/network_interface.rb +4 -4
  174. data/test/api_stub/requests/network/network_security_group.rb +3 -3
  175. data/test/api_stub/requests/network/network_security_rule.rb +2 -2
  176. data/test/api_stub/requests/network/public_ip.rb +2 -2
  177. data/test/api_stub/requests/network/subnet.rb +2 -2
  178. data/test/api_stub/requests/network/virtual_network.rb +2 -2
  179. data/test/api_stub/requests/network/virtual_network_gateway.rb +2 -2
  180. data/test/api_stub/requests/network/virtual_network_gateway_connection.rb +3 -3
  181. data/test/api_stub/requests/resources/resource.rb +2 -2
  182. data/test/api_stub/requests/resources/resource_group.rb +2 -2
  183. data/test/api_stub/requests/storage/directory.rb +59 -65
  184. data/test/api_stub/requests/storage/file.rb +183 -113
  185. data/test/api_stub/requests/storage/storageaccount.rb +1 -1
  186. data/test/api_stub/requests/traffic_manager/traffic_manager_endpoint.rb +1 -1
  187. data/test/api_stub/requests/traffic_manager/traffic_manager_profile.rb +2 -2
  188. data/test/integration/Virtual_network_gateway_connection.rb +189 -182
  189. data/test/integration/application_gateway.rb +208 -183
  190. data/test/integration/availability_set.rb +44 -27
  191. data/test/integration/blob.rb +293 -169
  192. data/test/integration/container.rb +93 -42
  193. data/test/integration/data_disk.rb +57 -46
  194. data/test/integration/deployment.rb +40 -32
  195. data/test/integration/express_route_circuit.rb +86 -82
  196. data/test/integration/external_load_balancer.rb +108 -100
  197. data/test/integration/internal_load_balancer.rb +115 -106
  198. data/test/integration/local_network_gateway.rb +46 -39
  199. data/test/integration/network_interface.rb +119 -107
  200. data/test/integration/network_security_group.rb +86 -74
  201. data/test/integration/network_security_rule.rb +65 -57
  202. data/test/integration/public_ip.rb +50 -42
  203. data/test/integration/record_set.rb +90 -78
  204. data/test/integration/resource_group.rb +26 -14
  205. data/test/integration/resource_tag.rb +56 -45
  206. data/test/integration/server.rb +152 -135
  207. data/test/integration/server_custom_image.rb +85 -76
  208. data/test/integration/sql_server.rb +130 -117
  209. data/test/integration/storage_account.rb +82 -70
  210. data/test/integration/subnet.rb +87 -74
  211. data/test/integration/traffic_manager.rb +86 -74
  212. data/test/integration/virtual_machine_extension.rb +115 -106
  213. data/test/integration/virtual_network.rb +121 -100
  214. data/test/integration/virtual_network_gateway.rb +86 -79
  215. data/test/integration/virtual_network_gateway_connection_to_express_route.rb +94 -87
  216. data/test/integration/zone.rb +36 -28
  217. data/test/models/storage/test_directories.rb +26 -71
  218. data/test/models/storage/test_directory.rb +111 -58
  219. data/test/models/storage/test_file.rb +179 -143
  220. data/test/models/storage/test_files.rb +197 -30
  221. data/test/models/storage/test_storage_account.rb +1 -1
  222. data/test/requests/compute/test_attach_data_disk_to_vm.rb +15 -17
  223. data/test/requests/storage/test_acquire_blob_lease.rb +23 -4
  224. data/test/requests/storage/test_acquire_container_lease.rb +24 -5
  225. data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
  226. data/test/requests/storage/test_compare_container_blobs.rb +36 -0
  227. data/test/requests/storage/test_copy_blob.rb +22 -3
  228. data/test/requests/storage/test_copy_blob_from_uri.rb +23 -4
  229. data/test/requests/storage/test_create_block_blob.rb +80 -0
  230. data/test/requests/storage/test_create_container.rb +18 -13
  231. data/test/requests/storage/test_create_disk.rb +57 -4
  232. data/test/requests/storage/test_create_page_blob.rb +34 -0
  233. data/test/requests/storage/test_delete_blob.rb +25 -5
  234. data/test/requests/storage/test_delete_container.rb +21 -9
  235. data/test/requests/storage/test_delete_disk.rb +14 -7
  236. data/test/requests/storage/test_get_blob.rb +141 -0
  237. data/test/requests/storage/test_get_blob_http_url.rb +30 -0
  238. data/test/requests/storage/test_get_blob_https_url.rb +30 -0
  239. data/test/requests/storage/test_get_blob_properties.rb +29 -7
  240. data/test/requests/storage/test_get_blob_url.rb +33 -0
  241. data/test/requests/storage/test_get_container_acl.rb +37 -0
  242. data/test/requests/storage/test_get_container_properties.rb +25 -11
  243. data/test/requests/storage/test_get_container_url.rb +33 -0
  244. data/test/requests/storage/test_list_blobs.rb +77 -0
  245. data/test/requests/storage/test_list_containers.rb +38 -7
  246. data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
  247. data/test/requests/storage/test_put_blob_block.rb +34 -0
  248. data/test/requests/storage/test_put_blob_metadata.rb +36 -0
  249. data/test/requests/storage/test_put_blob_pages.rb +34 -0
  250. data/test/requests/storage/test_put_blob_properties.rb +39 -0
  251. data/test/requests/storage/test_put_container_acl.rb +34 -0
  252. data/test/requests/storage/test_put_container_metadata.rb +36 -0
  253. data/test/requests/storage/test_release_blob_lease.rb +20 -2
  254. data/test/requests/storage/test_release_container_lease.rb +21 -3
  255. data/test/requests/storage/test_save_page_blob.rb +115 -0
  256. data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
  257. data/test/test_helper.rb +34 -21
  258. metadata +92 -46
  259. data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +0 -25
  260. data/lib/fog/azurerm/requests/storage/compare_blob.rb +0 -73
  261. data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +0 -56
  262. data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +0 -59
  263. data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +0 -30
  264. data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +0 -32
  265. data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +0 -26
  266. data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +0 -60
  267. data/test/requests/storage/test_check_blob_exist.rb +0 -17
  268. data/test/requests/storage/test_compare_blob.rb +0 -17
  269. data/test/requests/storage/test_download_blob_to_file.rb +0 -25
  270. data/test/requests/storage/test_get_blob_metadata.rb +0 -18
  271. data/test/requests/storage/test_get_container_access_control_list.rb +0 -31
  272. data/test/requests/storage/test_get_container_metadata.rb +0 -18
  273. data/test/requests/storage/test_list_blobs_in_container.rb +0 -23
  274. data/test/requests/storage/test_set_blob_metadata.rb +0 -17
  275. data/test/requests/storage/test_set_blob_properties.rb +0 -16
  276. data/test/requests/storage/test_set_container_metadata.rb +0 -17
  277. data/test/requests/storage/test_upload_block_blob_from_file.rb +0 -23
@@ -1,16 +1,34 @@
1
1
  require File.expand_path '../../test_helper', __dir__
2
2
 
3
3
  # Storage Blob Class
4
- class TestListBlobs < Minitest::Test
4
+ class TestReleaseBlobLease < Minitest::Test
5
5
  # This class posesses the test cases for the requests of releasing blob lease.
6
6
  def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
7
12
  @service = Fog::Storage::AzureRM.new(storage_account_credentials)
8
13
  @blob_client = @service.instance_variable_get(:@blob_client)
9
14
  end
10
15
 
11
16
  def test_release_blob_lease_success
12
17
  @blob_client.stub :release_blob_lease, true do
13
- assert @service.release_blob_lease('test_container', 'test_blob', '78659cee-b7cb-4f18-b9f8-0e9e8bf849f6'), true
18
+ assert @service.release_blob_lease('test_container', 'test_blob', 'lease_id')
19
+ end
20
+ end
21
+
22
+ def test_release_blob_lease_http_exception
23
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
24
+ @blob_client.stub :release_blob_lease, http_exception do
25
+ assert_raises(RuntimeError) do
26
+ @service.release_blob_lease('test_container', 'test_blob', 'lease_id')
27
+ end
14
28
  end
15
29
  end
30
+
31
+ def test_release_blob_lease_mock
32
+ assert @mock_service.release_blob_lease('test_container', 'test_blob', 'lease_id')
33
+ end
16
34
  end
@@ -1,16 +1,34 @@
1
1
  require File.expand_path '../../test_helper', __dir__
2
2
 
3
- # Storage Blob Class
4
- class TestListBlobs < Minitest::Test
3
+ # Storage Container Class
4
+ class TestReleaseContainerLease < Minitest::Test
5
5
  # This class posesses the test cases for the requests of releasing container lease.
6
6
  def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
7
12
  @service = Fog::Storage::AzureRM.new(storage_account_credentials)
8
13
  @blob_client = @service.instance_variable_get(:@blob_client)
9
14
  end
10
15
 
11
16
  def test_release_container_lease_success
12
17
  @blob_client.stub :release_container_lease, true do
13
- assert @service.release_container_lease('test_container', '78659cee-b7cb-4f18-b9f8-0e9e8bf849f6'), true
18
+ assert @service.release_container_lease('test_container', 'lease_id')
19
+ end
20
+ end
21
+
22
+ def test_release_container_lease_http_exception
23
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
24
+ @blob_client.stub :release_container_lease, http_exception do
25
+ assert_raises(RuntimeError) do
26
+ @service.release_container_lease('test_container', 'lease_id')
27
+ end
14
28
  end
15
29
  end
30
+
31
+ def test_release_container_lease_mock
32
+ assert @mock_service.release_container_lease('test_container', 'lease_id')
33
+ end
16
34
  end
@@ -0,0 +1,115 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestSavePageBlob < Minitest::Test
5
+ # This class posesses the test cases for the requests of saving storage page blob.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+
12
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
13
+ end
14
+
15
+ def test_save_page_blob_success
16
+ body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
17
+
18
+ @service.stub :create_page_blob, true do
19
+ @service.stub :put_blob_pages, true do
20
+ assert @service.save_page_blob('test_container', 'test_blob', body, worker_thread_num: 6, content_md5: 'oafL1+HS78x65+e39PGIIg==')
21
+ end
22
+ end
23
+ end
24
+
25
+ def test_save_page_blob_with_file_handle_success
26
+ data_length = 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
27
+ i = 0
28
+ multiple_values = lambda do |*|
29
+ i += 1
30
+ return 'd' * 4 * 1024 * 1024 if i == 1
31
+ return 'd' * 1 * 1024 * 1024 if i == 2
32
+ return nil
33
+ end
34
+ temp_file = '/dev/null'
35
+ File.open(temp_file, 'r') do |file_handle|
36
+ file_handle.stub :read, multiple_values do
37
+ file_handle.stub :size, data_length do
38
+ file_handle.stub :rewind, nil do
39
+ @service.stub :create_page_blob, true do
40
+ @service.stub :put_blob_pages, true do
41
+ assert @service.save_page_blob('test_container', 'test_blob', file_handle, worker_thread_num: 0)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def test_save_page_blob_with_file_handle_do_not_support_rewind_success
51
+ data_length = 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
52
+ i = 0
53
+ multiple_values = lambda do |*|
54
+ i += 1
55
+ return 'd' * 4 * 1024 * 1024 if i == 1
56
+ return 'd' * 1 * 1024 * 1024 if i == 2
57
+ return nil
58
+ end
59
+ temp_file = '/dev/null'
60
+ exception = ->(*) { raise 'do not support rewind' }
61
+ File.open(temp_file, 'r') do |file_handle|
62
+ file_handle.stub :read, multiple_values do
63
+ file_handle.stub :size, data_length do
64
+ file_handle.stub :rewind, exception do
65
+ @service.stub :create_page_blob, true do
66
+ @service.stub :put_blob_pages, true do
67
+ assert @service.save_page_blob('test_container', 'test_blob', file_handle, worker_thread_num: 'invalid')
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+
76
+ def test_save_page_blob_http_exception
77
+ body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
78
+
79
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
80
+ @service.stub :create_page_blob, http_exception do
81
+ @service.stub :delete_blob, true do
82
+ assert_raises(Azure::Core::Http::HTTPError) do
83
+ @service.save_page_blob('test_container', 'test_blob', body, {})
84
+ end
85
+ end
86
+ end
87
+ end
88
+
89
+ def test_save_page_blob_invalid_size_exception
90
+ body = 'd' * 1025 # The page blob size must be aligned to a 512-byte boundary.
91
+
92
+ @service.stub :delete_blob, true do
93
+ assert_raises(RuntimeError) do
94
+ @service.save_page_blob('test_container', 'test_blob', body, {})
95
+ end
96
+ end
97
+ end
98
+
99
+ def test_save_page_blob_fail_when_delete_blob_http_exception
100
+ body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
101
+
102
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
103
+ @service.stub :create_page_blob, http_exception do
104
+ @service.stub :delete_blob, http_exception do
105
+ assert_raises(Azure::Core::Http::HTTPError) do
106
+ @service.save_page_blob('test_container', 'test_blob', body, {})
107
+ end
108
+ end
109
+ end
110
+ end
111
+
112
+ def test_save_page_blob_mock
113
+ assert @mock_service.save_page_blob('test_container', 'test_blob', 'content', {})
114
+ end
115
+ end
@@ -0,0 +1,148 @@
1
+ require File.expand_path '../../test_helper', __dir__
2
+
3
+ # Storage Blob Class
4
+ class TestWaitBlobCopyOperationToFinish < Minitest::Test
5
+ # This class posesses the test cases for the requests of waiting storage blob copy operation to finish.
6
+ def setup
7
+ Fog.mock!
8
+ @mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
9
+ Fog.unmock!
10
+ @mocked_response = mocked_storage_http_error
11
+ @blob = storage_blob
12
+
13
+ @service = Fog::Storage::AzureRM.new(storage_account_credentials)
14
+ @blob_client = @service.instance_variable_get(:@blob_client)
15
+ end
16
+
17
+ def test_wait_blob_copy_operation_to_finish_with_success
18
+ copy_id = @blob.properties[:copy_id]
19
+ copy_status = 'pending'
20
+
21
+ i = 0
22
+ multiple_values = lambda do |*|
23
+ i += 1
24
+ if i == 1
25
+ @blob.properties[:copy_status] = copy_status
26
+ @blob.properties[:copy_progress] = '0/1024'
27
+ @blob.properties[:copy_status_description] = 'in progress'
28
+ return @blob
29
+ end
30
+
31
+ if i == 2
32
+ @blob.properties[:copy_status] = copy_status
33
+ @blob.properties[:copy_progress] = '2/1024'
34
+ @blob.properties[:copy_status_description] = 'in progress'
35
+ return @blob
36
+ end
37
+
38
+ if i == 3
39
+ @blob.properties[:copy_status] = copy_status
40
+ @blob.properties[:copy_progress] = '1023/1024'
41
+ @blob.properties[:copy_status_description] = 'in progress'
42
+ return @blob
43
+ end
44
+
45
+ @blob.properties[:copy_status] = 'success'
46
+ @blob.properties[:copy_progress] = '1024/1024'
47
+ @blob.properties[:copy_status_description] = 'finish'
48
+ @blob
49
+ end
50
+
51
+ @service.stub :get_blob_properties, multiple_values do
52
+ assert @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
53
+ end
54
+ end
55
+
56
+ def test_wait_blob_copy_operation_to_finish_with_copy_finished_success
57
+ copy_id = nil
58
+ copy_status = 'success'
59
+
60
+ @service.stub :get_blob_properties, @blob do
61
+ assert @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
62
+ end
63
+ end
64
+
65
+ def test_wait_blob_copy_operation_to_finish_with_copy_id_is_nil
66
+ copy_id = nil
67
+ copy_status = 'pending'
68
+
69
+ @service.stub :get_blob_properties, @blob do
70
+ assert @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
71
+ end
72
+ end
73
+
74
+ def test_wait_blob_copy_operation_to_finish_with_copy_id_not_match_exception
75
+ copy_id = 'copy_id'
76
+ copy_status = 'pending'
77
+
78
+ @service.stub :get_blob_properties, @blob do
79
+ @service.stub :delete_blob, true do
80
+ assert_raises(RuntimeError) do
81
+ @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
82
+ end
83
+ end
84
+ end
85
+ end
86
+
87
+ def test_wait_blob_copy_operation_to_finish_with_timeout_exception
88
+ copy_id = @blob.properties[:copy_id]
89
+ copy_status = 'pending'
90
+
91
+ i = 0
92
+ multiple_values = lambda do |*|
93
+ i += 1
94
+ if i == 1
95
+ @blob.properties[:copy_status] = copy_status
96
+ @blob.properties[:copy_progress] = '0/1024'
97
+ @blob.properties[:copy_status_description] = 'in progress'
98
+ return @blob
99
+ end
100
+
101
+ @blob.properties[:copy_status] = copy_status
102
+ @blob.properties[:copy_progress] = '0/1024'
103
+ @blob.properties[:copy_status_description] = 'in progress'
104
+ @blob
105
+ end
106
+
107
+ @service.stub :get_blob_properties, multiple_values do
108
+ @service.stub :delete_blob, true do
109
+ assert_raises(TimeoutError) do
110
+ @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status, 2)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ def test_wait_blob_copy_operation_to_finish_with_fail_exception
117
+ copy_id = @blob.properties[:copy_id]
118
+ copy_status = 'pending'
119
+
120
+ @blob.properties[:copy_status] = 'failed'
121
+ @service.stub :get_blob_properties, @blob do
122
+ @service.stub :delete_blob, true do
123
+ assert_raises(RuntimeError) do
124
+ @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
125
+ end
126
+ end
127
+ end
128
+ end
129
+
130
+ def test_wait_blob_copy_operation_to_finish_with_fail_when_delete_blob_http_exception
131
+ copy_id = @blob.properties[:copy_id]
132
+ copy_status = 'pending'
133
+
134
+ @blob.properties[:copy_status] = 'failed'
135
+ http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
136
+ @service.stub :get_blob_properties, @blob do
137
+ @service.stub :delete_blob, http_exception do
138
+ assert_raises(RuntimeError) do
139
+ @service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', copy_id, copy_status)
140
+ end
141
+ end
142
+ end
143
+ end
144
+
145
+ def test_wait_blob_copy_operation_to_finish_mock
146
+ assert @mock_service.wait_blob_copy_operation_to_finish('test_container', 'test_blob', 'copy_id', 'pending')
147
+ end
148
+ end
data/test/test_helper.rb CHANGED
@@ -7,11 +7,16 @@ if ENV['COVERAGE']
7
7
  end
8
8
 
9
9
  if ENV['CODECLIMATE_REPO_TOKEN']
10
- require 'codeclimate-test-reporter'
11
- CodeClimate::TestReporter.start
10
+ require 'simplecov'
11
+ SimpleCov.start do
12
+ add_filter 'test'
13
+ command_name 'Minitest'
14
+ end
12
15
  end
13
16
 
14
17
  require 'minitest/autorun'
18
+ require 'azure/core/http/http_error'
19
+ require 'azure/core/http/http_response'
15
20
  $LOAD_PATH.unshift(File.expand_path '../lib', __dir__)
16
21
  require File.expand_path '../lib/fog/azurerm', __dir__
17
22
  require File.expand_path './api_stub', __dir__
@@ -65,6 +70,11 @@ def mocked_storage_http_error
65
70
  Azure::Core::Http::HttpResponse.new mocked_net_response, 'mocked_uri'
66
71
  end
67
72
 
73
+ def mocked_storage_http_not_found_error
74
+ mocked_net_response = MockResponse.new '404', 'mocked_body', a: 'a', b: 'b'
75
+ Azure::Core::Http::HttpResponse.new mocked_net_response, 'mocked_uri'
76
+ end
77
+
68
78
  def server(service)
69
79
  Fog::Compute::AzureRM::Server.new(
70
80
  name: 'fog-test-server',
@@ -170,28 +180,29 @@ def premium_check_for_invalid_replications(service)
170
180
  )
171
181
  end
172
182
 
173
- def storage_container(service)
183
+ def directory(service)
174
184
  Fog::Storage::AzureRM::Directory.new(
175
- key: 'storage-test-container',
176
- last_modified: 'Tue, 04 Aug 2015 06:01:08 GMT',
185
+ key: 'test_container',
186
+ acl: 'container',
177
187
  etag: '0x8D29C92176C8352',
178
- lease_status: 'unlocked',
179
- lease_state: 'available',
188
+ last_modified: Time.parse('Tue, 04 Aug 2015 06:01:08 GMT'),
180
189
  lease_duration: nil,
190
+ lease_state: 'available',
191
+ lease_status: 'unlocked',
181
192
  metadata: {
182
193
  'key1' => 'value1',
183
194
  'key2' => 'value2'
184
195
  },
185
- public_access_level: nil,
186
- service: service
196
+ service: service,
197
+ collection: Fog::Storage::AzureRM::Directories.new(service: @service)
187
198
  )
188
199
  end
189
200
 
190
- def storage_blob(service)
201
+ def file(service)
191
202
  Fog::Storage::AzureRM::File.new(
192
- key: 'storage-test-blob',
193
- directory: 'storage-test-container',
194
- last_modified: 'Tue, 04 Aug 2015 06:01:08 GMT',
203
+ key: 'test_blob',
204
+ directory: directory(service),
205
+ last_modified: Time.parse('Tue, 04 Aug 2015 06:01:08 GMT'),
195
206
  etag: '0x8D29C92176C8352',
196
207
  metadata: {
197
208
  'key1' => 'value1',
@@ -208,7 +219,7 @@ def storage_blob(service)
208
219
  content_md5: 'tXAohIyxuu/t94Lp/ujeRw==',
209
220
  cache_control: nil,
210
221
  sequence_number: 0,
211
- blob_type: 'PageBlob',
222
+ blob_type: 'BlockBlob',
212
223
  copy_id: '095adc3b-e277-4c3d-97e0-0abca881f60c',
213
224
  copy_status: 'success',
214
225
  copy_source: 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
@@ -216,14 +227,14 @@ def storage_blob(service)
216
227
  copy_completion_time: 'Thu, 04 Feb 2016 08:35:52 GMT',
217
228
  copy_status_description: nil,
218
229
  accept_ranges: 0,
219
- service: service
230
+ service: service,
231
+ collection: Fog::Storage::AzureRM::Files.new(service: @service, directory: directory(service))
220
232
  )
221
233
  end
222
234
 
223
- def storage_cloud_blob
235
+ def storage_blob
224
236
  mock_blob = MockBlob.new
225
- mock_blob.name = 'storage-test-blob'
226
- mock_blob.snapshot = nil
237
+ mock_blob.name = 'test_blob'
227
238
  mock_blob.properties = {
228
239
  lease_status: 'unlocked',
229
240
  lease_state: 'available',
@@ -239,11 +250,13 @@ def storage_cloud_blob
239
250
  blob_type: 'PageBlob',
240
251
  copy_id: '095adc3b-e277-4c3d-97e0-0abca881f60c',
241
252
  copy_status: 'success',
242
- copy_source: 'https://testaccount.blob.core.windows.net/testblob/4m?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
253
+ copy_source: 'https://sa.blob.core.windows.net/test_container/test_blob?snapshot=2016-02-04T08%3A35%3A50.3157696Z',
243
254
  copy_progress: '4194304/4194304',
244
255
  copy_completion_time: 'Thu, 04 Feb 2016 08:35:52 GMT',
245
256
  copy_status_description: nil,
246
- accept_ranges: 0
257
+ accept_ranges: 0,
258
+ last_modified: 'Tue, 04 Aug 2015 06:01:08 GMT',
259
+ etag: '"0x8D29C92176C8352"'
247
260
  }
248
261
  mock_blob.metadata = {
249
262
  'key1' => 'value1',
@@ -541,7 +554,7 @@ def gateway(service)
541
554
  backend_address_pool_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendAddressPools/AG-BackEndAddressPool',
542
555
  backend_http_settings_id: '/subscriptions/########-####-####-####-############/resourceGroups/fogRM-rg/providers/Microsoft.Network/applicationGateways/gateway/backendHttpSettingsCollection/gateway_settings',
543
556
  paths: [
544
- %w('/usr', '/etc')
557
+ %w(/usr /etc)
545
558
  ]
546
559
  }
547
560
  ]