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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +2 -1
- data/fog-azure-rm.gemspec +11 -9
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/compute.rb +3 -3
- data/lib/fog/azurerm/config.rb +33 -0
- data/lib/fog/azurerm/credentials.rb +1 -1
- data/lib/fog/azurerm/dns.rb +2 -2
- data/lib/fog/azurerm/docs/storage.md +120 -66
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +30 -31
- data/lib/fog/azurerm/models/application_gateway/gateways.rb +4 -4
- data/lib/fog/azurerm/models/compute/availability_sets.rb +4 -4
- data/lib/fog/azurerm/models/compute/server.rb +14 -14
- data/lib/fog/azurerm/models/compute/servers.rb +4 -4
- data/lib/fog/azurerm/models/compute/virtual_machine_extension.rb +3 -5
- data/lib/fog/azurerm/models/compute/virtual_machine_extensions.rb +5 -5
- data/lib/fog/azurerm/models/dns/record_sets.rb +4 -4
- data/lib/fog/azurerm/models/dns/zones.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit.rb +2 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_authorization.rb +1 -1
- data/lib/fog/azurerm/models/network/express_route_circuit_authorizations.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuit_peering.rb +3 -5
- data/lib/fog/azurerm/models/network/express_route_circuit_peerings.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_circuits.rb +4 -4
- data/lib/fog/azurerm/models/network/express_route_service_providers.rb +2 -2
- data/lib/fog/azurerm/models/network/load_balancers.rb +5 -5
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +1 -1
- data/lib/fog/azurerm/models/network/local_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/network_interfaces.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_groups.rb +5 -5
- data/lib/fog/azurerm/models/network/network_security_rule.rb +3 -4
- data/lib/fog/azurerm/models/network/network_security_rules.rb +4 -4
- data/lib/fog/azurerm/models/network/public_ips.rb +4 -4
- data/lib/fog/azurerm/models/network/subnets.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateway.rb +6 -7
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connection.rb +5 -5
- data/lib/fog/azurerm/models/network/virtual_network_gateway_connections.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_network_gateways.rb +4 -4
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -4
- data/lib/fog/azurerm/models/resources/azure_resources.rb +2 -2
- data/lib/fog/azurerm/models/resources/deployments.rb +4 -4
- data/lib/fog/azurerm/models/resources/resource_groups.rb +4 -4
- data/lib/fog/azurerm/models/sql/firewall_rule.rb +1 -1
- data/lib/fog/azurerm/models/sql/firewall_rules.rb +4 -4
- data/lib/fog/azurerm/models/sql/sql_database.rb +28 -24
- data/lib/fog/azurerm/models/sql/sql_databases.rb +5 -6
- data/lib/fog/azurerm/models/sql/sql_servers.rb +4 -4
- data/lib/fog/azurerm/models/storage/directories.rb +49 -24
- data/lib/fog/azurerm/models/storage/directory.rb +126 -40
- data/lib/fog/azurerm/models/storage/file.rb +226 -114
- data/lib/fog/azurerm/models/storage/files.rb +168 -13
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +1 -1
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +4 -4
- data/lib/fog/azurerm/models/storage/storage_account.rb +5 -5
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_end_points.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +4 -4
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profiles.rb +4 -4
- data/lib/fog/azurerm/network.rb +1 -1
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +17 -13
- data/lib/fog/azurerm/requests/network/list_virtual_networks.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_deployment.rb +1 -1
- data/lib/fog/azurerm/requests/resources/get_resource_group.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_deployments.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_resource_groups.rb +1 -1
- data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +1 -1
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +1 -1
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/delete_database.rb +2 -2
- data/lib/fog/azurerm/requests/sql/delete_firewall_rule.rb +4 -4
- data/lib/fog/azurerm/requests/sql/delete_sql_server.rb +4 -4
- data/lib/fog/azurerm/requests/sql/get_database.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_firewall_rule.rb +3 -3
- data/lib/fog/azurerm/requests/sql/get_sql_server.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_databases.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_firewall_rules.rb +3 -3
- data/lib/fog/azurerm/requests/sql/list_sql_servers.rb +3 -3
- data/lib/fog/azurerm/requests/storage/acquire_blob_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/acquire_container_lease.rb +5 -2
- data/lib/fog/azurerm/requests/storage/commit_blob_blocks.rb +30 -0
- data/lib/fog/azurerm/requests/storage/compare_container_blobs.rb +148 -0
- data/lib/fog/azurerm/requests/storage/copy_blob.rb +8 -8
- data/lib/fog/azurerm/requests/storage/copy_blob_from_uri.rb +8 -8
- data/lib/fog/azurerm/requests/storage/create_block_blob.rb +108 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +12 -10
- data/lib/fog/azurerm/requests/storage/create_disk.rb +45 -19
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/create_page_blob.rb +31 -0
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/delete_blob.rb +10 -5
- data/lib/fog/azurerm/requests/storage/delete_container.rb +6 -2
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +19 -16
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +1 -1
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_blob.rb +163 -0
- data/lib/fog/azurerm/requests/storage/get_blob_http_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_https_url.rb +39 -0
- data/lib/fog/azurerm/requests/storage/get_blob_properties.rb +37 -35
- data/lib/fog/azurerm/requests/storage/get_blob_url.rb +28 -0
- data/lib/fog/azurerm/requests/storage/get_container_acl.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +16 -12
- data/lib/fog/azurerm/requests/storage/get_container_url.rb +34 -0
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +2 -2
- data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +4 -3
- data/lib/fog/azurerm/requests/storage/get_storage_account.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_blobs.rb +110 -24
- data/lib/fog/azurerm/requests/storage/list_containers.rb +46 -23
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +2 -2
- data/lib/fog/azurerm/requests/storage/list_storage_accounts.rb +2 -2
- data/lib/fog/azurerm/requests/storage/multipart_save_block_blob.rb +110 -0
- data/lib/fog/azurerm/requests/storage/put_blob_block.rb +30 -0
- data/lib/fog/azurerm/requests/storage/{set_blob_metadata.rb → put_blob_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/put_blob_pages.rb +30 -0
- data/lib/fog/azurerm/requests/storage/put_blob_properties.rb +31 -0
- data/lib/fog/azurerm/requests/storage/put_container_acl.rb +31 -0
- data/lib/fog/azurerm/requests/storage/{set_container_metadata.rb → put_container_metadata.rb} +7 -3
- data/lib/fog/azurerm/requests/storage/release_blob_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/release_container_lease.rb +4 -1
- data/lib/fog/azurerm/requests/storage/save_page_blob.rb +111 -0
- data/lib/fog/azurerm/requests/storage/start_backup.rb +1 -1
- data/lib/fog/azurerm/requests/storage/wait_blob_copy_operation_to_finish.rb +56 -0
- data/lib/fog/azurerm/resources.rb +2 -2
- data/lib/fog/azurerm/storage.rb +33 -19
- data/lib/fog/azurerm/traffic_manager.rb +1 -1
- data/lib/fog/azurerm/utilities/general.rb +70 -3
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +5 -2
- data/test/api_stub/models/application_gateway/gateway.rb +1 -1
- data/test/api_stub/models/compute/server.rb +1 -1
- data/test/api_stub/models/dns/record_set.rb +2 -2
- data/test/api_stub/models/dns/zone.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/models/network/express_route_circuit_peering.rb +1 -1
- data/test/api_stub/models/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/models/network/load_balancer.rb +1 -1
- data/test/api_stub/models/network/network_interface.rb +1 -1
- data/test/api_stub/models/network/network_security_group.rb +1 -1
- data/test/api_stub/models/network/network_security_rule.rb +1 -1
- data/test/api_stub/models/network/public_ip.rb +1 -1
- data/test/api_stub/models/network/subnet.rb +1 -1
- data/test/api_stub/models/network/virtual_network.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway.rb +1 -1
- data/test/api_stub/models/network/virtual_network_gateway_connection.rb +1 -1
- data/test/api_stub/models/resources/resource.rb +2 -2
- data/test/api_stub/models/resources/resource_group.rb +1 -1
- data/test/api_stub/models/storage/directory.rb +148 -62
- data/test/api_stub/models/storage/file.rb +122 -119
- data/test/api_stub/models/traffic_manager/traffic_manager_end_point.rb +1 -1
- data/test/api_stub/models/traffic_manager/traffic_manager_profile.rb +1 -1
- data/test/api_stub/requests/application_gateway/gateway.rb +2 -2
- data/test/api_stub/requests/compute/availability_set.rb +3 -3
- data/test/api_stub/requests/compute/virtual_machine.rb +9 -9
- data/test/api_stub/requests/dns/record_set.rb +3 -3
- data/test/api_stub/requests/dns/zone.rb +18 -18
- data/test/api_stub/requests/network/express_route_circuit.rb +2 -2
- data/test/api_stub/requests/network/express_route_circuit_authorization.rb +1 -1
- data/test/api_stub/requests/network/express_route_circuit_peering.rb +2 -2
- data/test/api_stub/requests/network/express_route_service_provider.rb +1 -1
- data/test/api_stub/requests/network/load_balancer.rb +2 -2
- data/test/api_stub/requests/network/network_interface.rb +4 -4
- data/test/api_stub/requests/network/network_security_group.rb +3 -3
- data/test/api_stub/requests/network/network_security_rule.rb +2 -2
- data/test/api_stub/requests/network/public_ip.rb +2 -2
- data/test/api_stub/requests/network/subnet.rb +2 -2
- data/test/api_stub/requests/network/virtual_network.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway.rb +2 -2
- data/test/api_stub/requests/network/virtual_network_gateway_connection.rb +3 -3
- data/test/api_stub/requests/resources/resource.rb +2 -2
- data/test/api_stub/requests/resources/resource_group.rb +2 -2
- data/test/api_stub/requests/storage/directory.rb +59 -65
- data/test/api_stub/requests/storage/file.rb +183 -113
- data/test/api_stub/requests/storage/storageaccount.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_endpoint.rb +1 -1
- data/test/api_stub/requests/traffic_manager/traffic_manager_profile.rb +2 -2
- data/test/integration/Virtual_network_gateway_connection.rb +189 -182
- data/test/integration/application_gateway.rb +208 -183
- data/test/integration/availability_set.rb +44 -27
- data/test/integration/blob.rb +293 -169
- data/test/integration/container.rb +93 -42
- data/test/integration/data_disk.rb +57 -46
- data/test/integration/deployment.rb +40 -32
- data/test/integration/express_route_circuit.rb +86 -82
- data/test/integration/external_load_balancer.rb +108 -100
- data/test/integration/internal_load_balancer.rb +115 -106
- data/test/integration/local_network_gateway.rb +46 -39
- data/test/integration/network_interface.rb +119 -107
- data/test/integration/network_security_group.rb +86 -74
- data/test/integration/network_security_rule.rb +65 -57
- data/test/integration/public_ip.rb +50 -42
- data/test/integration/record_set.rb +90 -78
- data/test/integration/resource_group.rb +26 -14
- data/test/integration/resource_tag.rb +56 -45
- data/test/integration/server.rb +152 -135
- data/test/integration/server_custom_image.rb +85 -76
- data/test/integration/sql_server.rb +130 -117
- data/test/integration/storage_account.rb +82 -70
- data/test/integration/subnet.rb +87 -74
- data/test/integration/traffic_manager.rb +86 -74
- data/test/integration/virtual_machine_extension.rb +115 -106
- data/test/integration/virtual_network.rb +121 -100
- data/test/integration/virtual_network_gateway.rb +86 -79
- data/test/integration/virtual_network_gateway_connection_to_express_route.rb +94 -87
- data/test/integration/zone.rb +36 -28
- data/test/models/storage/test_directories.rb +26 -71
- data/test/models/storage/test_directory.rb +111 -58
- data/test/models/storage/test_file.rb +179 -143
- data/test/models/storage/test_files.rb +197 -30
- data/test/models/storage/test_storage_account.rb +1 -1
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +15 -17
- data/test/requests/storage/test_acquire_blob_lease.rb +23 -4
- data/test/requests/storage/test_acquire_container_lease.rb +24 -5
- data/test/requests/storage/test_commit_blob_blocks.rb +34 -0
- data/test/requests/storage/test_compare_container_blobs.rb +36 -0
- data/test/requests/storage/test_copy_blob.rb +22 -3
- data/test/requests/storage/test_copy_blob_from_uri.rb +23 -4
- data/test/requests/storage/test_create_block_blob.rb +80 -0
- data/test/requests/storage/test_create_container.rb +18 -13
- data/test/requests/storage/test_create_disk.rb +57 -4
- data/test/requests/storage/test_create_page_blob.rb +34 -0
- data/test/requests/storage/test_delete_blob.rb +25 -5
- data/test/requests/storage/test_delete_container.rb +21 -9
- data/test/requests/storage/test_delete_disk.rb +14 -7
- data/test/requests/storage/test_get_blob.rb +141 -0
- data/test/requests/storage/test_get_blob_http_url.rb +30 -0
- data/test/requests/storage/test_get_blob_https_url.rb +30 -0
- data/test/requests/storage/test_get_blob_properties.rb +29 -7
- data/test/requests/storage/test_get_blob_url.rb +33 -0
- data/test/requests/storage/test_get_container_acl.rb +37 -0
- data/test/requests/storage/test_get_container_properties.rb +25 -11
- data/test/requests/storage/test_get_container_url.rb +33 -0
- data/test/requests/storage/test_list_blobs.rb +77 -0
- data/test/requests/storage/test_list_containers.rb +38 -7
- data/test/requests/storage/test_multipart_save_block_blob.rb +105 -0
- data/test/requests/storage/test_put_blob_block.rb +34 -0
- data/test/requests/storage/test_put_blob_metadata.rb +36 -0
- data/test/requests/storage/test_put_blob_pages.rb +34 -0
- data/test/requests/storage/test_put_blob_properties.rb +39 -0
- data/test/requests/storage/test_put_container_acl.rb +34 -0
- data/test/requests/storage/test_put_container_metadata.rb +36 -0
- data/test/requests/storage/test_release_blob_lease.rb +20 -2
- data/test/requests/storage/test_release_container_lease.rb +21 -3
- data/test/requests/storage/test_save_page_blob.rb +115 -0
- data/test/requests/storage/test_wait_blob_copy_operation_to_finish.rb +148 -0
- data/test/test_helper.rb +34 -21
- metadata +92 -46
- data/lib/fog/azurerm/requests/storage/check_blob_exist.rb +0 -25
- data/lib/fog/azurerm/requests/storage/compare_blob.rb +0 -73
- data/lib/fog/azurerm/requests/storage/download_blob_to_file.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +0 -59
- data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +0 -30
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +0 -32
- data/lib/fog/azurerm/requests/storage/set_blob_properties.rb +0 -26
- data/lib/fog/azurerm/requests/storage/upload_block_blob_from_file.rb +0 -60
- data/test/requests/storage/test_check_blob_exist.rb +0 -17
- data/test/requests/storage/test_compare_blob.rb +0 -17
- data/test/requests/storage/test_download_blob_to_file.rb +0 -25
- data/test/requests/storage/test_get_blob_metadata.rb +0 -18
- data/test/requests/storage/test_get_container_access_control_list.rb +0 -31
- data/test/requests/storage/test_get_container_metadata.rb +0 -18
- data/test/requests/storage/test_list_blobs_in_container.rb +0 -23
- data/test/requests/storage/test_set_blob_metadata.rb +0 -17
- data/test/requests/storage/test_set_blob_properties.rb +0 -16
- data/test/requests/storage/test_set_container_metadata.rb +0 -17
- data/test/requests/storage/test_upload_block_blob_from_file.rb +0 -23
@@ -0,0 +1,77 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestListBlobs < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of listing blobs in storage containers.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
|
15
|
+
@blob_list = ApiStub::Requests::Storage::File.blob_list
|
16
|
+
@blobs1 = Azure::Service::EnumerationResults.new
|
17
|
+
@blobs1.continuation_token = 'marker'
|
18
|
+
@blobs1.push(@blob_list[0])
|
19
|
+
@blobs1.push(@blob_list[1])
|
20
|
+
@blobs2 = Azure::Service::EnumerationResults.new
|
21
|
+
@blobs2.push(@blob_list[2])
|
22
|
+
@blobs2.push(@blob_list[3])
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_list_blobs_success
|
26
|
+
multiple_values = lambda do |_container_name, options|
|
27
|
+
return @blobs2 if options[:marker] == 'marker'
|
28
|
+
return @blobs1
|
29
|
+
end
|
30
|
+
@blob_client.stub :list_blobs, multiple_values do
|
31
|
+
result = @service.list_blobs('test_container')
|
32
|
+
assert result[:next_marker].nil?
|
33
|
+
assert_equal @blob_list, result[:blobs]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_list_blobs_with_max_results_success
|
38
|
+
@blob_client.stub :list_blobs, @blobs1 do
|
39
|
+
options = { max_results: 2 }
|
40
|
+
result = @service.list_blobs('test_container', options)
|
41
|
+
assert_equal 'marker', result[:next_marker]
|
42
|
+
assert_equal @blob_list[0, 2], result[:blobs]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_list_blobs_not_found
|
47
|
+
exception = ->(*) { raise StandardError.new('Not found(404). Not exist') }
|
48
|
+
@blob_client.stub :list_blobs, exception do
|
49
|
+
assert_raises('NotFound') do
|
50
|
+
@service.list_blobs('test_container')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_list_blobs_http_exception
|
56
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
57
|
+
@blob_client.stub :list_blobs, http_exception do
|
58
|
+
assert_raises(RuntimeError) do
|
59
|
+
@service.list_blobs('test_container')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_list_blobs_exception
|
65
|
+
@blob_client.stub :list_blobs, 'exception' do
|
66
|
+
assert_raises(RuntimeError) do
|
67
|
+
@service.list_blobs('test_container')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_list_blobs_mock
|
73
|
+
result = @mock_service.list_blobs('test_container')
|
74
|
+
assert_equal 'marker', result[:next_marker]
|
75
|
+
assert_equal @blob_list, result[:blobs]
|
76
|
+
end
|
77
|
+
end
|
@@ -4,20 +4,51 @@ require File.expand_path '../../test_helper', __dir__
|
|
4
4
|
class TestListContainers < Minitest::Test
|
5
5
|
# This class posesses the test cases for the requests of listing storage containers.
|
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
|
+
|
15
|
+
@containers = ApiStub::Requests::Storage::Directory.container_list
|
16
|
+
@containers1 = Azure::Service::EnumerationResults.new
|
17
|
+
@containers1.continuation_token = 'marker'
|
18
|
+
@containers1.push(@containers[0])
|
19
|
+
@containers1.push(@containers[1])
|
20
|
+
@containers2 = Azure::Service::EnumerationResults.new
|
21
|
+
@containers2.push(@containers[2])
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_list_containers_success
|
25
|
+
multiple_values = lambda do |options|
|
26
|
+
return @containers2 if options[:marker] == 'marker'
|
27
|
+
return @containers1
|
28
|
+
end
|
29
|
+
@blob_client.stub :list_containers, multiple_values do
|
30
|
+
assert_equal @containers, @service.list_containers
|
31
|
+
end
|
10
32
|
end
|
11
33
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
34
|
+
def test_list_containers_http_exception
|
35
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
36
|
+
@blob_client.stub :list_containers, http_exception do
|
37
|
+
assert_raises(RuntimeError) do
|
38
|
+
@service.list_containers
|
39
|
+
end
|
15
40
|
end
|
16
41
|
end
|
17
42
|
|
18
|
-
def
|
19
|
-
@blob_client.stub :list_containers,
|
20
|
-
|
43
|
+
def test_list_containers_exception
|
44
|
+
@blob_client.stub :list_containers, 'exception' do
|
45
|
+
assert_raises(RuntimeError) do
|
46
|
+
@service.list_containers
|
47
|
+
end
|
21
48
|
end
|
22
49
|
end
|
50
|
+
|
51
|
+
def test_list_containers_mock
|
52
|
+
assert_equal @containers, @mock_service.list_containers
|
53
|
+
end
|
23
54
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestMultipartSaveBlockBlob < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of saving storage block blob with multiple parts.
|
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_multipart_save_block_blob_success
|
16
|
+
body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
|
17
|
+
|
18
|
+
@service.stub :create_block_blob, true do
|
19
|
+
@service.stub :put_blob_block, true do
|
20
|
+
@service.stub :commit_blob_blocks, true do
|
21
|
+
assert @service.multipart_save_block_blob('test_container', 'test_blob', body, worker_thread_num: 6, content_md5: 'oafL1+HS78x65+e39PGIIg==')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_multipart_save_block_blob_with_file_handle_success
|
28
|
+
i = 0
|
29
|
+
multiple_values = lambda do |*|
|
30
|
+
i += 1
|
31
|
+
return 'd' * 4 * 1024 * 1024 if i == 1
|
32
|
+
return 'd' * (1 * 1024 * 1024 + 1) if i == 2
|
33
|
+
return nil
|
34
|
+
end
|
35
|
+
temp_file = '/dev/null'
|
36
|
+
File.open(temp_file, 'r') do |file_handle|
|
37
|
+
file_handle.stub :read, multiple_values do
|
38
|
+
file_handle.stub :rewind, nil do
|
39
|
+
@service.stub :create_block_blob, @raw_cloud_blob do
|
40
|
+
@service.stub :put_blob_block, true do
|
41
|
+
@service.stub :commit_blob_blocks, true do
|
42
|
+
assert @service.multipart_save_block_blob('test_container', 'test_blob', file_handle, worker_thread_num: 0)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_multipart_save_block_blob_with_file_handle_do_not_support_rewind_success
|
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 + 1) 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 :rewind, exception do
|
64
|
+
@service.stub :create_block_blob, @raw_cloud_blob do
|
65
|
+
@service.stub :put_blob_block, true do
|
66
|
+
@service.stub :commit_blob_blocks, true do
|
67
|
+
assert @service.multipart_save_block_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_multipart_save_block_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_block_blob, http_exception do
|
81
|
+
@service.stub :delete_blob, true do
|
82
|
+
assert_raises(Azure::Core::Http::HTTPError) do
|
83
|
+
@service.multipart_save_block_blob('test_container', 'test_blob', body, {})
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_multipart_save_block_blob_fail_when_delete_blob_http_exception
|
90
|
+
body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
|
91
|
+
|
92
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
93
|
+
@service.stub :create_block_blob, http_exception do
|
94
|
+
@service.stub :delete_blob, http_exception do
|
95
|
+
assert_raises(Azure::Core::Http::HTTPError) do
|
96
|
+
@service.multipart_save_block_blob('test_container', 'test_blob', body, {})
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_multipart_save_block_blob_mock
|
103
|
+
assert @mock_service.multipart_save_block_blob('test_container', 'test_blob', 'content', {})
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestPutBlobBlock < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of putting blob block.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_put_blob_block_success
|
17
|
+
@blob_client.stub :put_blob_block, true do
|
18
|
+
assert @service.put_blob_block('test_container', 'test_blob', 'id', 'data')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_put_blob_block_http_exception
|
23
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
24
|
+
@blob_client.stub :put_blob_block, http_exception do
|
25
|
+
assert_raises(RuntimeError) do
|
26
|
+
@service.put_blob_block('test_container', 'test_blob', 'id', 'data')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_put_blob_block_mock
|
32
|
+
assert @mock_service.put_blob_block('test_container', 'test_blob', 'id', 'data')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestPutBlobMetadata < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of setting blob metadata.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
|
15
|
+
@metadata = ApiStub::Requests::Storage::File.blob_metadata
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_put_blob_metadata_success
|
19
|
+
@blob_client.stub :set_blob_metadata, true do
|
20
|
+
assert @service.put_blob_metadata('test_container', 'test_blob', @metadata)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_put_blob_metadata_http_exception
|
25
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
26
|
+
@blob_client.stub :set_blob_metadata, http_exception do
|
27
|
+
assert_raises(RuntimeError) do
|
28
|
+
@service.put_blob_metadata('test_container', 'test_blob', @metadata)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_put_blob_metadata_mock
|
34
|
+
assert @mock_service.put_blob_metadata('test_container', 'test_blob', @metadata)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestPutBlobPages < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of putting blob page.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_put_blob_pages_success
|
17
|
+
@blob_client.stub :put_blob_pages, true do
|
18
|
+
assert @service.put_blob_pages('test_container', 'test_blob', 0, 1024, 'data')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_put_blob_pages_http_exception
|
23
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
24
|
+
@blob_client.stub :put_blob_pages, http_exception do
|
25
|
+
assert_raises(RuntimeError) do
|
26
|
+
@service.put_blob_pages('test_container', 'test_blob', 0, 1024, 'data')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_put_blob_pages_mock
|
32
|
+
assert @mock_service.put_blob_pages('test_container', 'test_blob', 0, 1024, 'data')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestPutBlobProperties < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of setting blob properties.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
|
15
|
+
@properties = {
|
16
|
+
content_language: 'english',
|
17
|
+
content_disposition: 'attachment'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_put_blob_properties_success
|
22
|
+
@blob_client.stub :set_blob_properties, true do
|
23
|
+
assert @service.put_blob_properties('test_container', 'test_blob', @properties)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_put_blob_properties_http_exception
|
28
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
29
|
+
@blob_client.stub :set_blob_properties, http_exception do
|
30
|
+
assert_raises(RuntimeError) do
|
31
|
+
@service.put_blob_properties('test_container', 'test_blob', @properties)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_put_blob_properties_mock
|
37
|
+
assert @mock_service.put_blob_properties('test_container', 'test_blob', @properties)
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestPutContainerACL < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of setting storage container acl.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_put_container_acl_success
|
17
|
+
@blob_client.stub :set_container_acl, true do
|
18
|
+
assert @service.put_container_acl('test_container', 'container')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_put_container_acl_http_exception
|
23
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
24
|
+
@blob_client.stub :set_container_acl, http_exception do
|
25
|
+
assert_raises(RuntimeError) do
|
26
|
+
@service.put_container_acl('test_container', 'container')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_put_container_acl_mock
|
32
|
+
assert @mock_service.put_container_acl('test_container', 'container')
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestPutContainerMetadata < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of container service.
|
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
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
14
|
+
|
15
|
+
@metadata = ApiStub::Requests::Storage::Directory.container_metadata
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_put_container_metadata_success
|
19
|
+
@blob_client.stub :set_container_metadata, true do
|
20
|
+
assert @service.put_container_metadata('test_container', @metadata)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_put_container_metadata_http_exception
|
25
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
26
|
+
@blob_client.stub :set_container_metadata, http_exception do
|
27
|
+
assert_raises(RuntimeError) do
|
28
|
+
@service.put_container_metadata('test_container', @metadata)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_put_container_metadata_mock
|
34
|
+
assert @mock_service.put_container_metadata('test_container', @metadata)
|
35
|
+
end
|
36
|
+
end
|