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
@@ -3,65 +3,232 @@ require File.expand_path '../../test_helper', __dir__
|
|
3
3
|
# Test class for Blob Collection
|
4
4
|
class TestFiles < Minitest::Test
|
5
5
|
def setup
|
6
|
-
Fog.mock!
|
7
|
-
@mock_service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
-
@mock_files = Fog::Storage::AzureRM::Files.new(directory: 'test-container', service: @mock_service)
|
9
|
-
Fog.unmock!
|
10
6
|
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
11
|
-
@
|
12
|
-
@files =
|
7
|
+
@directory = directory(@service)
|
8
|
+
@files = @directory.files
|
9
|
+
|
13
10
|
@mocked_response = mocked_storage_http_error
|
14
|
-
@
|
11
|
+
@container = ApiStub::Models::Storage::File.container
|
12
|
+
@blob = ApiStub::Models::Storage::File.blob
|
13
|
+
@blob_list = ApiStub::Models::Storage::File.blob_list
|
14
|
+
@blob_https_url = ApiStub::Models::Storage::File.blob_https_url
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_collection_methods
|
18
18
|
methods = [
|
19
19
|
:all,
|
20
|
-
:
|
20
|
+
:each,
|
21
|
+
:each_file_this_page,
|
22
|
+
:get,
|
23
|
+
:get_url,
|
24
|
+
:get_http_url,
|
25
|
+
:get_https_url,
|
26
|
+
:head,
|
27
|
+
:new
|
21
28
|
]
|
22
29
|
methods.each do |method|
|
23
30
|
assert_respond_to @files, method
|
24
31
|
end
|
25
32
|
end
|
26
33
|
|
34
|
+
def test_collection_attributes
|
35
|
+
attributes = [
|
36
|
+
:directory,
|
37
|
+
:delimiter,
|
38
|
+
:marker,
|
39
|
+
:max_results,
|
40
|
+
:next_marker,
|
41
|
+
:prefix
|
42
|
+
]
|
43
|
+
attributes.each do |attribute|
|
44
|
+
assert_respond_to @files, attribute
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
27
48
|
def test_all_method
|
28
|
-
@service.stub :
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
49
|
+
@service.stub :get_container_properties, @container do
|
50
|
+
@service.stub :list_blobs, @blob_list do
|
51
|
+
files = @files.all
|
52
|
+
assert_instance_of Fog::Storage::AzureRM::Files, files
|
53
|
+
assert_equal @blob_list[:blobs].size, files.size
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_all_method_without_directory_exception
|
59
|
+
assert_raises(ArgumentError) do
|
60
|
+
@files.attributes.delete(:directory)
|
61
|
+
@files.all
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_all_method_container_not_found
|
66
|
+
@directory.collection.stub :get, nil do
|
67
|
+
assert @files.all.nil?
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_each_method_with_all
|
72
|
+
@blob_list[:next_marker] = nil
|
73
|
+
@blob_list[:marker] = nil
|
74
|
+
@service.stub :get_container_properties, @container do
|
75
|
+
@service.stub :list_blobs, @blob_list do
|
76
|
+
@files.next_marker = nil
|
77
|
+
j = 0
|
78
|
+
@files.each do |file|
|
79
|
+
assert_instance_of Fog::Storage::AzureRM::File, file
|
80
|
+
j += 1
|
81
|
+
end
|
82
|
+
assert_equal @blob_list[:blobs].size, j
|
33
83
|
end
|
34
84
|
end
|
35
85
|
end
|
36
86
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
87
|
+
def test_each_method_with_parts
|
88
|
+
assert_instance_of Fog::Storage::AzureRM::Files, @files.each
|
89
|
+
|
90
|
+
multiple_values = lambda do |_container_name, options|
|
91
|
+
if options[:marker] == 'marker'
|
92
|
+
return {
|
93
|
+
next_marker: nil,
|
94
|
+
blobs: @blob_list[:blobs][2, 2]
|
95
|
+
}
|
96
|
+
end
|
97
|
+
return {
|
98
|
+
next_marker: 'marker',
|
99
|
+
blobs: @blob_list[:blobs][0, 2]
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
@service.stub :get_container_properties, @container do
|
104
|
+
@service.stub :list_blobs, multiple_values do
|
105
|
+
j = 0
|
106
|
+
@files.each do |file|
|
107
|
+
assert_instance_of Fog::Storage::AzureRM::File, file
|
108
|
+
j += 1
|
109
|
+
end
|
110
|
+
assert_equal @blob_list[:blobs].size, j
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_get_method_success
|
116
|
+
content = 'data'
|
117
|
+
@service.stub :get_blob, [@blob, content] do
|
118
|
+
file = @files.get('test_blob')
|
119
|
+
assert_instance_of Fog::Storage::AzureRM::File, file
|
120
|
+
assert_equal content, file.body
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_get_method_without_directory_exception
|
125
|
+
assert_raises(ArgumentError) do
|
126
|
+
@files.attributes.delete(:directory)
|
127
|
+
@files.get('test_blob')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_get_method_blob_not_found
|
132
|
+
exception = ->(*) { raise 'NotFound' }
|
133
|
+
@service.stub :get_blob, exception do
|
134
|
+
assert @files.get('test_blob').nil?
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_get_method_http_exception
|
139
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
140
|
+
@service.stub :get_blob, http_exception do
|
141
|
+
assert_raises(Azure::Core::Http::HTTPError) do
|
142
|
+
@files.get('test_blob')
|
42
143
|
end
|
43
144
|
end
|
44
145
|
end
|
45
146
|
|
46
|
-
def
|
47
|
-
|
48
|
-
|
49
|
-
|
147
|
+
def test_get_url_method_success
|
148
|
+
@files.stub :get_https_url, @blob_https_url do
|
149
|
+
assert_equal @blob_https_url, @files.get_url('test_blob', Time.now + 3600)
|
150
|
+
end
|
151
|
+
|
152
|
+
options = { scheme: 'http' }
|
153
|
+
http_url = @blob_https_url.gsub('https:', 'http:')
|
154
|
+
@files.stub :get_http_url, http_url do
|
155
|
+
assert_equal http_url, @files.get_url('test_blob', Time.now + 3600, options)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_get_url_method_without_directory_exception
|
160
|
+
assert_raises(ArgumentError) do
|
161
|
+
@files.attributes.delete(:directory)
|
162
|
+
@files.get_url('test_blob', Time.now + 3600)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_get_http_url_method_success
|
167
|
+
http_url = @blob_https_url.gsub('https:', 'http:')
|
168
|
+
@service.stub :get_blob_http_url, http_url do
|
169
|
+
assert_equal http_url, @files.get_http_url('test_blob', Time.now + 3600)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_get_http_url_method_without_directory_exception
|
174
|
+
assert_raises(ArgumentError) do
|
175
|
+
@files.attributes.delete(:directory)
|
176
|
+
@files.get_http_url('test_blob', Time.now + 3600)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_get_https_url_method_success
|
181
|
+
@service.stub :get_blob_https_url, @blob_https_url do
|
182
|
+
assert_equal @blob_https_url, @files.get_https_url('test_blob', Time.now + 3600)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_get_https_url_method_without_directory_exception
|
187
|
+
assert_raises(ArgumentError) do
|
188
|
+
@files.attributes.delete(:directory)
|
189
|
+
@files.get_https_url('test_blob', Time.now + 3600)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_head_method_success
|
194
|
+
@service.stub :get_blob_properties, @blob do
|
195
|
+
file = @files.head('test_blob')
|
50
196
|
assert_instance_of Fog::Storage::AzureRM::File, file
|
197
|
+
assert file.attributes[:body].nil?
|
51
198
|
end
|
52
199
|
end
|
53
200
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
201
|
+
def test_head_method_without_directory_exception
|
202
|
+
assert_raises(ArgumentError) do
|
203
|
+
@files.attributes.delete(:directory)
|
204
|
+
@files.head('test_blob')
|
58
205
|
end
|
59
206
|
end
|
60
207
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
assert
|
208
|
+
def test_head_method_blob_not_found
|
209
|
+
exception = ->(*) { raise 'NotFound' }
|
210
|
+
@service.stub :get_blob_properties, exception do
|
211
|
+
assert @files.head('test_blob').nil?
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_head_method_http_exception
|
216
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
217
|
+
@service.stub :get_blob_properties, http_exception do
|
218
|
+
assert_raises(Azure::Core::Http::HTTPError) do
|
219
|
+
@files.head('test_blob')
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_new_method_success
|
225
|
+
assert_instance_of Fog::Storage::AzureRM::File, @files.new
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_new_method_without_directory_exception
|
229
|
+
assert_raises(ArgumentError) do
|
230
|
+
@files.attributes.delete(:directory)
|
231
|
+
@files.new
|
65
232
|
end
|
66
233
|
end
|
67
234
|
end
|
@@ -66,7 +66,7 @@ class TestStorageAccount < Minitest::Test
|
|
66
66
|
def test_get_access_keys_method_response
|
67
67
|
key1 = Azure::ARM::Storage::Models::StorageAccountKey.new
|
68
68
|
key1.key_name = 'key1'
|
69
|
-
key1.value = '
|
69
|
+
key1.value = 'YWNjZXNzLWtleQ=='
|
70
70
|
key1.permissions = 'Full'
|
71
71
|
response = [key1]
|
72
72
|
@service.stub :get_storage_access_keys, response do
|
@@ -14,11 +14,15 @@ class TestAttachDataDiskToVM < Minitest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_attach_data_disk_to_vm_success
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
blob_service = Minitest::Mock.new
|
18
|
+
blob_service.expect :get_blob_properties, 'blob_props' do
|
19
|
+
Azure::Storage::Blob::BlobService.stub :new, blob_service do
|
20
|
+
@virtual_machines.stub :get, @get_vm_response do
|
21
|
+
@storage_accounts.stub :list_keys, @storage_access_keys_response do
|
22
|
+
@virtual_machines.stub :create_or_update, @update_vm_response do
|
23
|
+
assert_equal @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1'), @update_vm_response
|
24
|
+
blob_service.verify
|
25
|
+
end
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
@@ -30,10 +34,8 @@ class TestAttachDataDiskToVM < Minitest::Test
|
|
30
34
|
@virtual_machines.stub :get, get_vm_response do
|
31
35
|
@storage_accounts.stub :list_keys, @storage_access_keys_response do
|
32
36
|
@virtual_machines.stub :create_or_update, @update_vm_response do
|
33
|
-
|
34
|
-
|
35
|
-
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
36
|
-
end
|
37
|
+
assert_raises RuntimeError do
|
38
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -45,10 +47,8 @@ class TestAttachDataDiskToVM < Minitest::Test
|
|
45
47
|
@virtual_machines.stub :get, @get_vm_response do
|
46
48
|
@storage_accounts.stub :list_keys, @storage_access_keys_response do
|
47
49
|
@virtual_machines.stub :create_or_update, update_vm_response do
|
48
|
-
|
49
|
-
|
50
|
-
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
51
|
-
end
|
50
|
+
assert_raises RuntimeError do
|
51
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -60,10 +60,8 @@ class TestAttachDataDiskToVM < Minitest::Test
|
|
60
60
|
@virtual_machines.stub :get, @get_vm_response do
|
61
61
|
@storage_accounts.stub :list_keys, @storage_access_keys_response do
|
62
62
|
@virtual_machines.stub :create_or_update, update_vm_response do
|
63
|
-
|
64
|
-
|
65
|
-
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
66
|
-
end
|
63
|
+
assert_raises RuntimeError do
|
64
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
67
65
|
end
|
68
66
|
end
|
69
67
|
end
|
@@ -1,17 +1,36 @@
|
|
1
1
|
require File.expand_path '../../test_helper', __dir__
|
2
2
|
|
3
3
|
# Storage Blob Class
|
4
|
-
class
|
4
|
+
class TestAcquireBlobLease < Minitest::Test
|
5
5
|
# This class posesses the test cases for the requests of acquire 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)
|
14
|
+
|
15
|
+
@blob_lease_id = ApiStub::Requests::Storage::File.blob_lease_id
|
9
16
|
end
|
10
17
|
|
11
18
|
def test_acquire_blob_lease_success
|
12
|
-
|
13
|
-
|
14
|
-
assert @service.acquire_blob_lease('test_container', 'test_blob'), lease_id
|
19
|
+
@blob_client.stub :acquire_blob_lease, @blob_lease_id do
|
20
|
+
assert_equal @blob_lease_id, @service.acquire_blob_lease('test_container', 'test_blob')
|
15
21
|
end
|
16
22
|
end
|
23
|
+
|
24
|
+
def test_acquire_blob_lease_http_exception
|
25
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
26
|
+
@blob_client.stub :acquire_blob_lease, http_exception do
|
27
|
+
assert_raises(RuntimeError) do
|
28
|
+
@service.acquire_blob_lease('test_container', 'test_blob')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_acquire_blob_lease_mock
|
34
|
+
assert_equal @blob_lease_id, @mock_service.acquire_blob_lease('test_container', 'test_blob')
|
35
|
+
end
|
17
36
|
end
|
@@ -1,17 +1,36 @@
|
|
1
1
|
require File.expand_path '../../test_helper', __dir__
|
2
2
|
|
3
|
-
# Storage
|
4
|
-
class
|
3
|
+
# Storage Container Class
|
4
|
+
class TestAcquireContainerLease < Minitest::Test
|
5
5
|
# This class posesses the test cases for the requests of acquire 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)
|
14
|
+
|
15
|
+
@container_lease_id = ApiStub::Requests::Storage::Directory.container_lease_id
|
9
16
|
end
|
10
17
|
|
11
18
|
def test_acquire_container_lease_success
|
12
|
-
|
13
|
-
|
14
|
-
assert @service.acquire_container_lease('test_container'), lease_id
|
19
|
+
@blob_client.stub :acquire_container_lease, @container_lease_id do
|
20
|
+
assert_equal @container_lease_id, @service.acquire_container_lease('test_container')
|
15
21
|
end
|
16
22
|
end
|
23
|
+
|
24
|
+
def test_acquire_container_lease_http_exception
|
25
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
26
|
+
@blob_client.stub :acquire_container_lease, http_exception do
|
27
|
+
assert_raises(RuntimeError) do
|
28
|
+
@service.acquire_container_lease('test_container')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_acquire_container_lease_mock
|
34
|
+
assert_equal @container_lease_id, @mock_service.acquire_container_lease('test_container')
|
35
|
+
end
|
17
36
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Blob Class
|
4
|
+
class TestCommitBlobBlocks < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of committing blob blocks.
|
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_commit_blob_blocks_success
|
17
|
+
@blob_client.stub :commit_blob_blocks, true do
|
18
|
+
assert @service.commit_blob_blocks('test_container', 'test_blob', [])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_commit_blob_blocks_http_exception
|
23
|
+
http_exception = ->(*) { raise Azure::Core::Http::HTTPError.new(@mocked_response) }
|
24
|
+
@blob_client.stub :commit_blob_blocks, http_exception do
|
25
|
+
assert_raises(RuntimeError) do
|
26
|
+
@service.commit_blob_blocks('test_container', 'test_blob', [])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_commit_blob_blocks_mock
|
32
|
+
assert @mock_service.commit_blob_blocks('test_container', 'test_blob', [])
|
33
|
+
end
|
34
|
+
end
|