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
data/test/integration/zone.rb
CHANGED
@@ -27,39 +27,47 @@ dns = Fog::DNS.new(
|
|
27
27
|
###################### Prerequisites ######################
|
28
28
|
########################################################################################################################
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
begin
|
31
|
+
resource_group = rs.resource_groups.create(
|
32
|
+
name: 'TestRG-ZN',
|
33
|
+
location: LOCATION
|
34
|
+
)
|
34
35
|
|
35
|
-
########################################################################################################################
|
36
|
-
###################### Create Zone ######################
|
37
|
-
########################################################################################################################
|
36
|
+
########################################################################################################################
|
37
|
+
###################### Create Zone ######################
|
38
|
+
########################################################################################################################
|
38
39
|
|
39
|
-
dns.zones.create(
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
)
|
40
|
+
zone = dns.zones.create(
|
41
|
+
name: 'test-zone.com',
|
42
|
+
location: 'global',
|
43
|
+
resource_group: 'TestRG-ZN'
|
44
|
+
)
|
45
|
+
puts "Created zone: #{zone.name}"
|
44
46
|
|
45
|
-
########################################################################################################################
|
46
|
-
###################### Get All Zones in a Subscription ######################
|
47
|
-
########################################################################################################################
|
47
|
+
########################################################################################################################
|
48
|
+
###################### Get All Zones in a Subscription ######################
|
49
|
+
########################################################################################################################
|
48
50
|
|
49
|
-
|
50
|
-
|
51
|
-
|
51
|
+
puts 'List zones in a subscription:'
|
52
|
+
dns.zones.each do |z|
|
53
|
+
puts "Resource Group:#{z.resource_group} name:#{z.name}"
|
54
|
+
end
|
52
55
|
|
53
|
-
########################################################################################################################
|
54
|
-
###################### Get and Destroy Zone in a Resource Group ######################
|
55
|
-
########################################################################################################################
|
56
|
+
########################################################################################################################
|
57
|
+
###################### Get and Destroy Zone in a Resource Group ######################
|
58
|
+
########################################################################################################################
|
56
59
|
|
57
|
-
zone = dns.zones.get('TestRG-ZN', 'test-zone.com')
|
58
|
-
zone.
|
60
|
+
zone = dns.zones.get('TestRG-ZN', 'test-zone.com')
|
61
|
+
puts "Get zone: #{zone.name}"
|
62
|
+
puts "Deleted zone: #{zone.destroy}"
|
59
63
|
|
60
|
-
########################################################################################################################
|
61
|
-
###################### CleanUp ######################
|
62
|
-
########################################################################################################################
|
64
|
+
########################################################################################################################
|
65
|
+
###################### CleanUp ######################
|
66
|
+
########################################################################################################################
|
63
67
|
|
64
|
-
rg = rs.resource_groups.get('TestRG-ZN')
|
65
|
-
rg.destroy
|
68
|
+
rg = rs.resource_groups.get('TestRG-ZN')
|
69
|
+
rg.destroy
|
70
|
+
rescue
|
71
|
+
puts 'Integration Test for zone is failing'
|
72
|
+
resource_group.destroy unless resource_group.nil?
|
73
|
+
end
|
@@ -3,23 +3,16 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Container Collection
|
4
4
|
class TestDirectories < Minitest::Test
|
5
5
|
def setup
|
6
|
-
Fog.mock!
|
7
|
-
@mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
-
@mock_directories = Fog::Storage::AzureRM::Directories.new(service: @mock_service)
|
9
|
-
Fog.unmock!
|
10
6
|
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
11
|
-
@blob_client = @service.instance_variable_get(:@blob_client)
|
12
7
|
@directories = Fog::Storage::AzureRM::Directories.new(service: @service)
|
13
|
-
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@
|
8
|
+
|
9
|
+
@container_list = ApiStub::Models::Storage::Directory.container_list
|
10
|
+
@container = ApiStub::Models::Storage::Directory.container
|
11
|
+
@blob_list = ApiStub::Models::Storage::Directory.blob_list
|
17
12
|
end
|
18
13
|
|
19
14
|
def test_collection_methods
|
20
15
|
methods = [
|
21
|
-
:get_metadata,
|
22
|
-
:set_metadata,
|
23
16
|
:all,
|
24
17
|
:get
|
25
18
|
]
|
@@ -28,78 +21,40 @@ class TestDirectories < Minitest::Test
|
|
28
21
|
end
|
29
22
|
end
|
30
23
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
24
|
+
def test_all_method_success
|
25
|
+
@service.stub :list_containers, @container_list do
|
26
|
+
dirs = @directories.all
|
27
|
+
assert_instance_of Fog::Storage::AzureRM::Directories, dirs
|
28
|
+
assert_equal @container_list.size, dirs.size
|
29
|
+
dirs.each do |directory|
|
30
|
+
assert_instance_of Fog::Storage::AzureRM::Directory, directory
|
31
|
+
assert_equal 'unknown', directory.attributes[:acl]
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
39
35
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_get_container_metadata
|
49
|
-
@service.stub :get_container_metadata, @get_metadata_result do
|
50
|
-
assert_equal @get_metadata_result, @directories.get_metadata('Test-container')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_get_container_metadata_http_exception
|
55
|
-
http_exception = -> (_container_name, _option) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
56
|
-
@blob_client.stub :get_container_metadata, http_exception do
|
57
|
-
assert_raises(RuntimeError) do
|
58
|
-
@directories.get_metadata 'Test-container'
|
36
|
+
def test_get_method_success
|
37
|
+
@service.stub :get_container_properties, @container do
|
38
|
+
@service.stub :list_blobs, @blob_list do
|
39
|
+
directory = @directories.get('test_container')
|
40
|
+
assert_instance_of Fog::Storage::AzureRM::Directory, directory
|
41
|
+
assert_equal 'unknown', directory.attributes[:acl]
|
59
42
|
end
|
60
43
|
end
|
61
44
|
end
|
62
45
|
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
def test_set_container_metadata
|
69
|
-
@service.stub :set_container_metadata, true do
|
70
|
-
assert @directories.set_metadata('Test-container', @get_metadata_result)
|
46
|
+
def test_get_method_container_not_found
|
47
|
+
exception = ->(*) { raise 'NotFound' }
|
48
|
+
@service.stub :get_container_properties, exception do
|
49
|
+
assert @directories.get('test_container').nil?
|
71
50
|
end
|
72
51
|
end
|
73
52
|
|
74
|
-
def
|
75
|
-
|
76
|
-
@
|
53
|
+
def test_get_method_exception
|
54
|
+
exception = ->(*) { raise 'Error' }
|
55
|
+
@service.stub :get_container_properties, exception do
|
77
56
|
assert_raises(RuntimeError) do
|
78
|
-
@directories.
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_set_container_metadata_mock
|
84
|
-
assert @mock_directories.set_metadata('Test-container', @get_metadata_result)
|
85
|
-
end
|
86
|
-
|
87
|
-
def test_all_method
|
88
|
-
directories = Fog::Storage::AzureRM::Directories.new(service: @service)
|
89
|
-
@service.stub :list_containers, @list_results do
|
90
|
-
assert_instance_of Fog::Storage::AzureRM::Directories, directories.all
|
91
|
-
assert directories.all.size >= 1
|
92
|
-
directories.all.each do |directory|
|
93
|
-
assert_instance_of Fog::Storage::AzureRM::Directory, directory
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def test_get_method
|
99
|
-
@service.stub :list_containers, @list_results do
|
100
|
-
@service.stub :get_container_access_control_list, @acl_results do
|
101
|
-
assert_instance_of Fog::Storage::AzureRM::Directory, @directories.get('testcontainer1')
|
102
|
-
assert @directories.get('wrong-name').nil?, true
|
57
|
+
@directories.get('test_container')
|
103
58
|
end
|
104
59
|
end
|
105
60
|
end
|
@@ -3,24 +3,24 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Storage Container Model
|
4
4
|
class TestDirectory < Minitest::Test
|
5
5
|
def setup
|
6
|
-
Fog.mock!
|
7
|
-
@mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
-
@mock_directory = storage_container(@mock_service)
|
9
|
-
Fog.unmock!
|
10
6
|
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
11
|
-
@directory =
|
12
|
-
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@mocked_response = mocked_storage_http_error
|
7
|
+
@directory = directory(@service)
|
8
|
+
|
9
|
+
@container = ApiStub::Models::Storage::Directory.container
|
10
|
+
@container_acl = ApiStub::Models::Storage::Directory.container_acl
|
11
|
+
@container_https_url = ApiStub::Models::Storage::Directory.container_https_url
|
17
12
|
end
|
18
13
|
|
19
14
|
def test_model_methods
|
20
15
|
methods = [
|
16
|
+
:acl=,
|
17
|
+
:acl,
|
18
|
+
:destroy,
|
19
|
+
:files,
|
20
|
+
:public=,
|
21
|
+
:public_url,
|
21
22
|
:save,
|
22
|
-
:
|
23
|
-
:destroy
|
23
|
+
:persisted?
|
24
24
|
]
|
25
25
|
methods.each do |method|
|
26
26
|
assert_respond_to @directory, method
|
@@ -37,89 +37,142 @@ class TestDirectory < Minitest::Test
|
|
37
37
|
:lease_status,
|
38
38
|
:metadata
|
39
39
|
]
|
40
|
-
@service.stub :create_container, @
|
40
|
+
@service.stub :create_container, @container do
|
41
41
|
attributes.each do |attribute|
|
42
42
|
assert_respond_to @directory, attribute
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
@
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
def test_set_acl_method_success
|
48
|
+
result = @directory.acl = 'container'
|
49
|
+
assert_equal 'container', result
|
50
|
+
assert_equal 'container', @directory.attributes[:acl]
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_set_acl_method_exception
|
54
|
+
assert_raises(ArgumentError) do
|
55
|
+
@directory.acl = 'invalid-acl'
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
56
|
-
def
|
57
|
-
|
58
|
-
@
|
59
|
-
|
60
|
-
|
59
|
+
def test_get_acl_method_success
|
60
|
+
# Return 'unknonw' when directory is not persist and acl is 'unknown'
|
61
|
+
@directory.acl = 'unknown'
|
62
|
+
@directory.stub :persisted?, false do
|
63
|
+
assert_equal 'unknown', @directory.acl
|
64
|
+
end
|
65
|
+
|
66
|
+
# Return actual value directly when directory is not persist and acl is not 'unknown'
|
67
|
+
@directory.acl = 'blob'
|
68
|
+
@directory.stub :persisted?, false do
|
69
|
+
assert_equal 'blob', @directory.acl
|
70
|
+
end
|
71
|
+
|
72
|
+
# Query actual value and return it when directory is persist and acl is 'unknown'
|
73
|
+
@directory.acl = 'unknown'
|
74
|
+
@directory.stub :persisted?, true do
|
75
|
+
@service.stub :get_container_acl, @container_acl do
|
76
|
+
assert_equal 'container', @directory.acl
|
77
|
+
assert_equal 'container', @directory.attributes[:acl]
|
61
78
|
end
|
62
79
|
end
|
63
80
|
end
|
64
81
|
|
65
|
-
def
|
66
|
-
|
82
|
+
def test_get_acl_method_without_key_exception
|
83
|
+
@directory.attributes.delete(:key)
|
84
|
+
assert_raises(ArgumentError) do
|
85
|
+
@directory.acl
|
86
|
+
end
|
67
87
|
end
|
68
88
|
|
69
|
-
def
|
70
|
-
@service.stub :
|
71
|
-
|
89
|
+
def test_destroy_method_success
|
90
|
+
@service.stub :delete_container, true do
|
91
|
+
assert @directory.destroy
|
72
92
|
end
|
73
93
|
end
|
74
94
|
|
75
|
-
def
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
@directory.get_properties
|
80
|
-
end
|
95
|
+
def test_destroy_method_without_key_exception
|
96
|
+
@directory.attributes.delete(:key)
|
97
|
+
assert_raises(ArgumentError) do
|
98
|
+
@directory.destroy
|
81
99
|
end
|
82
100
|
end
|
83
101
|
|
84
|
-
def
|
85
|
-
assert_instance_of Fog::Storage::AzureRM::
|
102
|
+
def test_files_method_success
|
103
|
+
assert_instance_of Fog::Storage::AzureRM::Files, @directory.files
|
86
104
|
end
|
87
105
|
|
88
|
-
def
|
89
|
-
|
90
|
-
|
91
|
-
|
106
|
+
def test_set_public_method_success
|
107
|
+
# Set public
|
108
|
+
result = @directory.public = true
|
109
|
+
assert result
|
110
|
+
assert_equal 'container', @directory.attributes[:acl]
|
111
|
+
|
112
|
+
# Set private
|
113
|
+
result = @directory.public = false
|
114
|
+
assert !result
|
115
|
+
assert_equal nil, @directory.attributes[:acl]
|
92
116
|
end
|
93
117
|
|
94
|
-
def
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
@directory.access_control_list
|
118
|
+
def test_public_url_method_with_public_success
|
119
|
+
@directory.stub :acl, 'container' do
|
120
|
+
@service.stub :get_container_url, @container_https_url do
|
121
|
+
assert_equal @container_https_url, @directory.public_url
|
99
122
|
end
|
100
123
|
end
|
101
124
|
end
|
102
125
|
|
103
|
-
def
|
104
|
-
|
126
|
+
def test_public_url_method_with_private_success
|
127
|
+
@directory.stub :acl, nil do
|
128
|
+
assert @directory.public_url.nil?
|
129
|
+
end
|
105
130
|
end
|
106
131
|
|
107
|
-
def
|
108
|
-
@
|
109
|
-
|
132
|
+
def test_public_url_method_without_key_exception
|
133
|
+
@directory.attributes.delete(:key)
|
134
|
+
assert_raises(ArgumentError) do
|
135
|
+
@directory.public_url
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_save_method_create_success
|
140
|
+
@service.stub :create_container, @container do
|
141
|
+
assert @directory.save
|
142
|
+
assert @directory.attributes[:is_persisted]
|
110
143
|
end
|
111
144
|
end
|
112
145
|
|
113
|
-
def
|
114
|
-
|
115
|
-
@
|
116
|
-
|
117
|
-
|
146
|
+
def test_save_method_update_success
|
147
|
+
options = { is_create: false }
|
148
|
+
@service.stub :put_container_acl, true do
|
149
|
+
@service.stub :put_container_metadata, true do
|
150
|
+
@service.stub :get_container_properties, @container do
|
151
|
+
assert @directory.save(options)
|
152
|
+
assert @directory.attributes[:is_persisted]
|
153
|
+
end
|
118
154
|
end
|
119
155
|
end
|
120
156
|
end
|
121
157
|
|
122
|
-
def
|
123
|
-
|
158
|
+
def test_save_method_without_key_exception
|
159
|
+
@directory.attributes.delete(:key)
|
160
|
+
assert_raises(ArgumentError) do
|
161
|
+
@directory.save
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_persisted_method_success
|
166
|
+
@directory.attributes[:is_persisted] = true
|
167
|
+
@directory.attributes[:last_modified] = nil
|
168
|
+
assert @directory.persisted?
|
169
|
+
|
170
|
+
@directory.attributes[:is_persisted] = false
|
171
|
+
@directory.attributes[:last_modified] = 'datetime'
|
172
|
+
assert @directory.persisted?
|
173
|
+
|
174
|
+
@directory.attributes[:is_persisted] = false
|
175
|
+
@directory.attributes[:last_modified] = nil
|
176
|
+
assert !@directory.persisted?
|
124
177
|
end
|
125
178
|
end
|
@@ -3,31 +3,29 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Storage Container Model
|
4
4
|
class TestFile < Minitest::Test
|
5
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
6
|
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
7
|
+
@directory = directory(@service)
|
8
|
+
@file = file(@service)
|
9
|
+
@raw_cloud_blob = storage_blob
|
10
|
+
|
14
11
|
@mocked_response = mocked_storage_http_error
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
18
|
-
@
|
19
|
-
@get_properties_result = ApiStub::Models::Storage::File.get_blob_properties
|
12
|
+
@blob = ApiStub::Models::Storage::File.blob
|
13
|
+
@metadata = ApiStub::Models::Storage::File.blob_metadata
|
14
|
+
@blob_list = ApiStub::Models::Storage::File.blob_list
|
15
|
+
@blob_https_url = ApiStub::Models::Storage::File.blob_https_url
|
20
16
|
end
|
21
17
|
|
22
18
|
def test_model_methods
|
23
19
|
methods = [
|
24
20
|
:save,
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
21
|
+
:body,
|
22
|
+
:body=,
|
23
|
+
:copy,
|
24
|
+
:copy_from_uri,
|
25
|
+
:destroy,
|
26
|
+
:public?,
|
27
|
+
:public_url,
|
28
|
+
:url
|
31
29
|
]
|
32
30
|
methods.each do |method|
|
33
31
|
assert_respond_to @file, method
|
@@ -37,14 +35,15 @@ class TestFile < Minitest::Test
|
|
37
35
|
def test_model_attributes
|
38
36
|
attributes = [
|
39
37
|
:key,
|
38
|
+
:body,
|
39
|
+
:directory,
|
40
40
|
:accept_ranges,
|
41
|
-
:cache_control,
|
42
|
-
:committed_block_count,
|
43
41
|
:content_length,
|
44
42
|
:content_type,
|
45
43
|
:content_md5,
|
46
44
|
:content_encoding,
|
47
45
|
:content_language,
|
46
|
+
:cache_control,
|
48
47
|
:content_disposition,
|
49
48
|
:copy_completion_time,
|
50
49
|
:copy_status,
|
@@ -52,207 +51,244 @@ class TestFile < Minitest::Test
|
|
52
51
|
:copy_id,
|
53
52
|
:copy_progress,
|
54
53
|
:copy_source,
|
55
|
-
:directory,
|
56
54
|
:etag,
|
57
|
-
:file_path,
|
58
55
|
:last_modified,
|
59
56
|
:lease_duration,
|
60
57
|
:lease_state,
|
61
58
|
:lease_status,
|
62
|
-
:metadata,
|
63
59
|
:sequence_number,
|
64
|
-
:blob_type
|
60
|
+
:blob_type,
|
61
|
+
:metadata
|
65
62
|
]
|
66
63
|
attributes.each do |attribute|
|
67
64
|
assert_respond_to @file, attribute
|
68
65
|
end
|
69
66
|
end
|
70
67
|
|
71
|
-
def
|
72
|
-
@file.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
@service.stub :upload_block_blob_from_file, @create_result do
|
77
|
-
assert_instance_of Fog::Storage::AzureRM::File, @file.create
|
68
|
+
def test_save_method_with_small_block_blob_success
|
69
|
+
@file.body = 'd' * 1025 # SINGLE_BLOB_PUT_THRESHOLD is 32 * 1024 * 1024
|
70
|
+
|
71
|
+
@service.stub :create_block_blob, @raw_cloud_blob do
|
72
|
+
assert @file.save
|
78
73
|
end
|
79
74
|
end
|
80
75
|
|
81
|
-
def
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
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
|
76
|
+
def test_save_method_with_large_block_blob_success
|
77
|
+
@file.body = 'd' * (32 * 1024 * 1024 + 1) # SINGLE_BLOB_PUT_THRESHOLD is 32 * 1024 * 1024
|
78
|
+
|
79
|
+
@service.stub :multipart_save_block_blob, true do
|
80
|
+
@service.stub :get_blob_properties, @raw_cloud_blob do
|
81
|
+
assert @file.save
|
100
82
|
end
|
101
83
|
end
|
102
|
-
File.delete(small_file_name)
|
103
84
|
end
|
104
85
|
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
86
|
+
def test_save_method_with_page_blob_success
|
87
|
+
options = { blob_type: 'PageBlob' }
|
88
|
+
@file.metadata = @metadata
|
89
|
+
@file.body = 'd' * 5 * 1024 * 1024 # MAXIMUM_CHUNK_SIZE is 4 * 1024 * 1024
|
90
|
+
|
91
|
+
@service.stub :save_page_blob, true do
|
92
|
+
@service.stub :get_blob_properties, @raw_cloud_blob do
|
93
|
+
assert @file.save(options)
|
116
94
|
end
|
117
95
|
end
|
118
|
-
File.delete(large_file_name)
|
119
96
|
end
|
120
97
|
|
121
|
-
def
|
122
|
-
|
123
|
-
|
98
|
+
def test_save_method_with_not_update_body_success
|
99
|
+
options = { update_body: false }
|
100
|
+
@file.metadata = @metadata
|
101
|
+
|
102
|
+
@service.stub :put_blob_metadata, true do
|
103
|
+
@service.stub :put_blob_properties, true do
|
104
|
+
@service.stub :get_blob_properties, @raw_cloud_blob do
|
105
|
+
assert @file.save(options)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
124
109
|
end
|
125
110
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
111
|
+
def test_save_method_without_directory_exception
|
112
|
+
assert_raises(ArgumentError) do
|
113
|
+
@file.attributes.delete(:directory)
|
114
|
+
@file.save
|
129
115
|
end
|
130
116
|
end
|
131
117
|
|
132
|
-
def
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
@file.save_to_file('test.txt')
|
137
|
-
end
|
118
|
+
def test_save_method_without_key_exception
|
119
|
+
assert_raises(ArgumentError) do
|
120
|
+
@file.attributes.delete(:key)
|
121
|
+
@file.save
|
138
122
|
end
|
139
123
|
end
|
140
124
|
|
141
|
-
def
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@file.save_to_file('test.txt')
|
146
|
-
end
|
125
|
+
def test_save_method_create_without_body_exception
|
126
|
+
assert_raises(ArgumentError) do
|
127
|
+
@file.attributes.delete(:body)
|
128
|
+
@file.save
|
147
129
|
end
|
148
130
|
end
|
149
131
|
|
150
|
-
def
|
151
|
-
|
132
|
+
def test_get_body_method_local_success
|
133
|
+
@file.attributes[:body] = 'body'
|
134
|
+
assert_equal 'body', @file.body
|
135
|
+
|
136
|
+
@file.attributes[:body] = nil
|
137
|
+
@file.attributes[:last_modified] = nil
|
138
|
+
assert_equal '', @file.body
|
152
139
|
end
|
153
140
|
|
154
|
-
def
|
155
|
-
@
|
156
|
-
|
141
|
+
def test_get_body_method_remote_success
|
142
|
+
@file.attributes[:body] = nil
|
143
|
+
remote_file = @file.dup
|
144
|
+
body_content = 'data'
|
145
|
+
@file.collection.stub :get, remote_file do
|
146
|
+
remote_file.stub :body, body_content do
|
147
|
+
body = @file.body
|
148
|
+
assert_equal body_content, body
|
149
|
+
assert_equal body_content, @file.attributes[:body]
|
150
|
+
end
|
157
151
|
end
|
158
152
|
end
|
159
153
|
|
160
|
-
def
|
161
|
-
@
|
162
|
-
|
154
|
+
def test_get_body_method_remote_not_found_success
|
155
|
+
@file.attributes[:body] = nil
|
156
|
+
@file.collection.stub :get, nil do
|
157
|
+
body = @file.body
|
158
|
+
assert_equal '', body
|
159
|
+
assert_equal '', @file.attributes[:body]
|
163
160
|
end
|
164
161
|
end
|
165
162
|
|
166
|
-
def
|
167
|
-
|
168
|
-
@
|
169
|
-
|
170
|
-
|
163
|
+
def test_set_body_method_success
|
164
|
+
@file.body = 'new_body'
|
165
|
+
assert_equal 'new_body', @file.attributes[:body]
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_copy_method_success
|
169
|
+
copy_id = @raw_cloud_blob.properties[:copy_id]
|
170
|
+
copy_status = 'pending'
|
171
|
+
|
172
|
+
@service.stub :get_blob_properties, @raw_cloud_blob do
|
173
|
+
@service.stub :copy_blob, [copy_id, copy_status] do
|
174
|
+
@service.stub :wait_blob_copy_operation_to_finish, true do
|
175
|
+
target_file = @file.copy('target_container', 'target_blob')
|
176
|
+
assert_instance_of Fog::Storage::AzureRM::File, target_file
|
177
|
+
end
|
171
178
|
end
|
172
179
|
end
|
173
180
|
end
|
174
181
|
|
175
|
-
def
|
176
|
-
|
182
|
+
def test_copy_from_uri_method_success
|
183
|
+
copy_id = @raw_cloud_blob.properties[:copy_id]
|
184
|
+
copy_status = 'pending'
|
185
|
+
|
186
|
+
@service.stub :get_blob_properties, @raw_cloud_blob do
|
187
|
+
@service.stub :copy_blob_from_uri, [copy_id, copy_status] do
|
188
|
+
@service.stub :wait_blob_copy_operation_to_finish, true do
|
189
|
+
assert @file.copy_from_uri('source_uri')
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
177
193
|
end
|
178
194
|
|
179
|
-
def
|
180
|
-
|
181
|
-
|
195
|
+
def test_copy_from_uri_method_without_directory_exception
|
196
|
+
assert_raises(ArgumentError) do
|
197
|
+
@file.attributes.delete(:directory)
|
198
|
+
@file.copy_from_uri('source_uri')
|
182
199
|
end
|
183
200
|
end
|
184
201
|
|
185
|
-
def
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
@file.set_properties
|
190
|
-
end
|
202
|
+
def test_copy_from_uri_method_without_key_exception
|
203
|
+
assert_raises(ArgumentError) do
|
204
|
+
@file.attributes.delete(:key)
|
205
|
+
@file.copy_from_uri('source_uri')
|
191
206
|
end
|
192
207
|
end
|
193
208
|
|
194
|
-
def
|
195
|
-
|
209
|
+
def test_destroy_method_success
|
210
|
+
@service.stub :delete_blob, true do
|
211
|
+
assert @file.destroy
|
212
|
+
assert @file.attributes[:body].nil?
|
213
|
+
end
|
196
214
|
end
|
197
215
|
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
assert_equal @get_metadata_result, file.metadata
|
216
|
+
def test_destroy_method_without_directory_exception
|
217
|
+
assert_raises(ArgumentError) do
|
218
|
+
@file.attributes.delete(:directory)
|
219
|
+
@file.destroy
|
203
220
|
end
|
204
221
|
end
|
205
222
|
|
206
|
-
def
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
@file.get_metadata
|
211
|
-
end
|
223
|
+
def test_destroy_method_without_key_exception
|
224
|
+
assert_raises(ArgumentError) do
|
225
|
+
@file.attributes.delete(:key)
|
226
|
+
@file.destroy
|
212
227
|
end
|
213
228
|
end
|
214
229
|
|
215
|
-
def
|
216
|
-
|
217
|
-
|
218
|
-
|
230
|
+
def test_public_method_success
|
231
|
+
@file.directory.acl = 'container'
|
232
|
+
assert @file.public?
|
233
|
+
|
234
|
+
@file.directory.acl = 'blob'
|
235
|
+
assert @file.public?
|
236
|
+
|
237
|
+
@file.directory.acl = nil
|
238
|
+
assert !@file.public?
|
219
239
|
end
|
220
240
|
|
221
|
-
def
|
222
|
-
|
223
|
-
|
241
|
+
def test_public_method_without_directory_exception
|
242
|
+
assert_raises(ArgumentError) do
|
243
|
+
@file.attributes.delete(:directory)
|
244
|
+
@file.public?
|
224
245
|
end
|
225
246
|
end
|
226
247
|
|
227
|
-
def
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
248
|
+
def test_public_url_method_success
|
249
|
+
@file.stub :public?, false do
|
250
|
+
assert @file.public_url.nil?
|
251
|
+
end
|
252
|
+
|
253
|
+
@file.stub :public?, true do
|
254
|
+
@service.stub :get_blob_url, @blob_https_url do
|
255
|
+
assert @file.public_url, @blob_https_url
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
http_url = @blob_https_url.gsub('https:', 'http:')
|
260
|
+
options = { scheme: 'https' }
|
261
|
+
@file.stub :public?, true do
|
262
|
+
@service.stub :get_blob_url, http_url do
|
263
|
+
assert @file.public_url(options), http_url
|
232
264
|
end
|
233
265
|
end
|
234
266
|
end
|
235
267
|
|
236
|
-
def
|
237
|
-
|
268
|
+
def test_public_url_method_without_directory_exception
|
269
|
+
assert_raises(ArgumentError) do
|
270
|
+
@file.attributes.delete(:directory)
|
271
|
+
@file.public_url
|
272
|
+
end
|
238
273
|
end
|
239
274
|
|
240
|
-
def
|
241
|
-
|
242
|
-
|
275
|
+
def test_public_url_method_without_key_exception
|
276
|
+
assert_raises(ArgumentError) do
|
277
|
+
@file.attributes.delete(:key)
|
278
|
+
@file.public_url
|
243
279
|
end
|
244
280
|
end
|
245
281
|
|
246
|
-
def
|
247
|
-
|
248
|
-
|
249
|
-
assert_raises(RuntimeError) do
|
250
|
-
assert @file.destroy
|
251
|
-
end
|
282
|
+
def test_url_method_success
|
283
|
+
@file.collection.stub :get_url, @blob_https_url do
|
284
|
+
assert @file.url(Time.now + 3600), @blob_https_url
|
252
285
|
end
|
253
286
|
end
|
254
287
|
|
255
|
-
def
|
256
|
-
|
288
|
+
def test_url_method_without_key_exception
|
289
|
+
assert_raises(ArgumentError) do
|
290
|
+
@file.attributes.delete(:key)
|
291
|
+
@file.url(Time.now + 3600)
|
292
|
+
end
|
257
293
|
end
|
258
294
|
end
|