fog-azure-rm 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +17 -0
- data/.gitignore +6 -0
- data/.hound.yml +2 -0
- data/.rubocop.yml +36 -0
- data/.travis.yml +14 -0
- data/CHANGELOG.md +28 -0
- data/CONTRIBUTING.md +2 -0
- data/CONTRIBUTORS.md +2 -0
- data/Gemfile +3 -0
- data/fog-azure-rm.gemspec +34 -0
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/compute.rb +0 -1
- data/lib/fog/azurerm/config.rb +4 -0
- data/lib/fog/azurerm/credentials.rb +10 -3
- data/lib/fog/azurerm/docs/compute.md +172 -0
- data/lib/fog/azurerm/docs/dns.md +112 -0
- data/lib/fog/azurerm/docs/network.md +794 -0
- data/lib/fog/azurerm/docs/resources.md +155 -0
- data/lib/fog/azurerm/docs/storage.md +222 -0
- data/lib/fog/azurerm/docs/structure.md +53 -0
- data/lib/fog/azurerm/models/compute/server.rb +3 -2
- data/lib/fog/azurerm/models/network/frontend_ip_configuration.rb +5 -1
- data/lib/fog/azurerm/models/network/network_interface.rb +49 -4
- data/lib/fog/azurerm/models/network/network_interfaces.rb +4 -2
- data/lib/fog/azurerm/models/network/network_security_group.rb +27 -4
- data/lib/fog/azurerm/models/network/network_security_groups.rb +4 -2
- data/lib/fog/azurerm/models/network/network_security_rule.rb +1 -1
- data/lib/fog/azurerm/models/network/subnet.rb +26 -6
- data/lib/fog/azurerm/models/network/subnets.rb +4 -2
- data/lib/fog/azurerm/models/network/virtual_network.rb +72 -10
- data/lib/fog/azurerm/models/network/virtual_networks.rb +4 -2
- data/lib/fog/azurerm/models/resources/azure_resource.rb +25 -0
- data/lib/fog/azurerm/models/resources/azure_resources.rb +31 -0
- data/lib/fog/azurerm/models/resources/dependency.rb +27 -0
- data/lib/fog/azurerm/models/resources/deployment.rb +65 -0
- data/lib/fog/azurerm/models/resources/deployments.rb +27 -0
- data/lib/fog/azurerm/models/resources/provider.rb +27 -0
- data/lib/fog/azurerm/models/resources/provider_resource_type.rb +22 -0
- data/lib/fog/azurerm/models/storage/blob.rb +13 -0
- data/lib/fog/azurerm/models/storage/blobs.rb +22 -0
- data/lib/fog/azurerm/models/storage/container.rb +65 -0
- data/lib/fog/azurerm/models/storage/containers.rb +44 -0
- data/lib/fog/azurerm/models/storage/data_disk.rb +26 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -0
- data/lib/fog/azurerm/network.rb +21 -3
- data/lib/fog/azurerm/requests/network/add_address_prefixes_in_virtual_network.rb +68 -0
- data/lib/fog/azurerm/requests/network/add_dns_servers_in_virtual_network.rb +74 -0
- data/lib/fog/azurerm/requests/network/add_security_rules.rb +152 -0
- data/lib/fog/azurerm/requests/network/add_subnets_in_virtual_network.rb +69 -0
- data/lib/fog/azurerm/requests/network/attach_network_security_group_to_subnet.rb +59 -0
- data/lib/fog/azurerm/requests/network/attach_resource_to_nic.rb +88 -0
- data/lib/fog/azurerm/requests/network/attach_route_table_to_subnet.rb +59 -0
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
- data/lib/fog/azurerm/requests/network/{create_network_interface.rb → create_or_update_network_interface.rb} +14 -13
- data/lib/fog/azurerm/requests/network/{create_network_security_group.rb → create_or_update_network_security_group.rb} +17 -35
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +116 -0
- data/lib/fog/azurerm/requests/network/create_subnet.rb +28 -14
- data/lib/fog/azurerm/requests/network/detach_network_security_group_from_subnet.rb +53 -0
- data/lib/fog/azurerm/requests/network/detach_resource_from_nic.rb +80 -0
- data/lib/fog/azurerm/requests/network/detach_route_table_from_subnet.rb +53 -0
- data/lib/fog/azurerm/requests/network/get_network_interface.rb +60 -0
- data/lib/fog/azurerm/requests/network/get_network_security_group.rb +161 -0
- data/lib/fog/azurerm/requests/network/get_subnet.rb +36 -0
- data/lib/fog/azurerm/requests/network/get_virtual_network.rb +64 -0
- data/lib/fog/azurerm/requests/network/remove_address_prefixes_from_virtual_network.rb +67 -0
- data/lib/fog/azurerm/requests/network/remove_dns_servers_from_virtual_network.rb +67 -0
- data/lib/fog/azurerm/requests/network/remove_security_rule.rb +155 -0
- data/lib/fog/azurerm/requests/network/remove_subnets_from_virtual_network.rb +57 -0
- data/lib/fog/azurerm/requests/resources/create_deployment.rb +90 -0
- data/lib/fog/azurerm/requests/resources/delete_deployment.rb +28 -0
- data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +48 -0
- data/lib/fog/azurerm/requests/resources/list_deployments.rb +75 -0
- data/lib/fog/azurerm/requests/resources/list_tagged_resources.rb +46 -0
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +46 -0
- data/lib/fog/azurerm/requests/storage/create_container.rb +37 -0
- data/lib/fog/azurerm/requests/storage/delete_container.rb +26 -0
- data/lib/fog/azurerm/requests/storage/delete_disk.rb +36 -0
- data/lib/fog/azurerm/requests/storage/get_blob_metadata.rb +30 -0
- data/lib/fog/azurerm/requests/storage/get_container_access_control_list.rb +29 -0
- data/lib/fog/azurerm/requests/storage/get_container_metadata.rb +31 -0
- data/lib/fog/azurerm/requests/storage/get_container_properties.rb +36 -0
- data/lib/fog/azurerm/requests/storage/get_storage_access_keys.rb +31 -0
- data/lib/fog/azurerm/requests/storage/list_containers.rb +49 -0
- data/lib/fog/azurerm/requests/storage/list_storage_account_for_rg.rb +0 -1
- data/lib/fog/azurerm/requests/storage/set_blob_metadata.rb +26 -0
- data/lib/fog/azurerm/requests/storage/set_container_metadata.rb +26 -0
- data/lib/fog/azurerm/resources.rb +13 -0
- data/lib/fog/azurerm/storage.rb +46 -6
- data/lib/fog/azurerm/utilities/general.rb +18 -0
- data/lib/fog/azurerm/version.rb +1 -1
- data/rakefile +21 -0
- data/test/api_stub.rb +44 -0
- data/test/api_stub/models/compute/availability_set.rb +21 -0
- data/test/api_stub/models/compute/server.rb +191 -0
- data/test/api_stub/models/dns/record_set.rb +59 -0
- data/test/api_stub/models/dns/zone.rb +47 -0
- data/test/api_stub/models/network/application_gateway.rb +135 -0
- data/test/api_stub/models/network/load_balancer.rb +132 -0
- data/test/api_stub/models/network/network_interface.rb +71 -0
- data/test/api_stub/models/network/network_security_group.rb +94 -0
- data/test/api_stub/models/network/public_ip.rb +35 -0
- data/test/api_stub/models/network/subnet.rb +35 -0
- data/test/api_stub/models/network/traffic_manager_end_point.rb +26 -0
- data/test/api_stub/models/network/traffic_manager_profile.rb +74 -0
- data/test/api_stub/models/network/virtual_network.rb +61 -0
- data/test/api_stub/models/resources/deployment.rb +110 -0
- data/test/api_stub/models/resources/resource.rb +40 -0
- data/test/api_stub/models/resources/resource_group.rb +38 -0
- data/test/api_stub/models/storage/blob.rb +17 -0
- data/test/api_stub/models/storage/container.rb +92 -0
- data/test/api_stub/models/storage/data_disk.rb +30 -0
- data/test/api_stub/models/storage/storageaccount.rb +29 -0
- data/test/api_stub/requests/compute/availability_set.rb +46 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +654 -0
- data/test/api_stub/requests/dns/record_set.rb +105 -0
- data/test/api_stub/requests/dns/zone.rb +67 -0
- data/test/api_stub/requests/network/application_gateway.rb +433 -0
- data/test/api_stub/requests/network/load_balancer.rb +366 -0
- data/test/api_stub/requests/network/network_interface.rb +268 -0
- data/test/api_stub/requests/network/network_security_group.rb +240 -0
- data/test/api_stub/requests/network/public_ip.rb +73 -0
- data/test/api_stub/requests/network/subnet.rb +73 -0
- data/test/api_stub/requests/network/traffic_manager_endpoint.rb +25 -0
- data/test/api_stub/requests/network/traffic_manager_profile.rb +140 -0
- data/test/api_stub/requests/network/virtual_network.rb +127 -0
- data/test/api_stub/requests/resources/deployment.rb +23 -0
- data/test/api_stub/requests/resources/resource.rb +47 -0
- data/test/api_stub/requests/resources/resource_group.rb +53 -0
- data/test/api_stub/requests/storage/blob.rb +24 -0
- data/test/api_stub/requests/storage/container.rb +95 -0
- data/test/api_stub/requests/storage/storageaccount.rb +112 -0
- data/test/integration/README.md +14 -0
- data/test/integration/application_gateway.rb +129 -0
- data/test/integration/availability_set.rb +56 -0
- data/test/integration/container.rb +81 -0
- data/test/integration/credentials/azure.yml +4 -0
- data/test/integration/external_load_balancer.rb +119 -0
- data/test/integration/internal_load_balancer.rb +126 -0
- data/test/integration/network_interface.rb +135 -0
- data/test/integration/network_security_group.rb +104 -0
- data/test/integration/public_ip.rb +63 -0
- data/test/integration/record_set.rb +88 -0
- data/test/integration/server.rb +139 -0
- data/test/integration/storage_account.rb +62 -0
- data/test/integration/subnet.rb +91 -0
- data/test/integration/traffic_manager.rb +81 -0
- data/test/integration/virtual_network.rb +124 -0
- data/test/integration/zone.rb +64 -0
- data/test/models/compute/test_availability_set.rb +53 -0
- data/test/models/compute/test_availability_sets.rb +41 -0
- data/test/models/compute/test_server.rb +143 -0
- data/test/models/compute/test_servers.rb +49 -0
- data/test/models/dns/test_record_set.rb +59 -0
- data/test/models/dns/test_record_sets.rb +51 -0
- data/test/models/dns/test_zone.rb +49 -0
- data/test/models/dns/test_zones.rb +49 -0
- data/test/models/network/test_application_gateway.rb +62 -0
- data/test/models/network/test_application_gateways.rb +42 -0
- data/test/models/network/test_load_balancer.rb +56 -0
- data/test/models/network/test_load_balancers.rb +42 -0
- data/test/models/network/test_network_interface.rb +106 -0
- data/test/models/network/test_network_interfaces.rb +41 -0
- data/test/models/network/test_network_security_group.rb +88 -0
- data/test/models/network/test_network_security_groups.rb +40 -0
- data/test/models/network/test_network_security_rule.rb +30 -0
- data/test/models/network/test_public_ip.rb +58 -0
- data/test/models/network/test_public_ips.rb +55 -0
- data/test/models/network/test_subnet.rb +84 -0
- data/test/models/network/test_subnets.rb +42 -0
- data/test/models/network/test_traffic_manager_end_point.rb +53 -0
- data/test/models/network/test_traffic_manager_end_points.rb +42 -0
- data/test/models/network/test_traffic_manager_profile.rb +54 -0
- data/test/models/network/test_traffic_manager_profiles.rb +41 -0
- data/test/models/network/test_virtual_network.rb +112 -0
- data/test/models/network/test_virtual_networks.rb +54 -0
- data/test/models/resources/test_deployment.rb +54 -0
- data/test/models/resources/test_deployments.rb +37 -0
- data/test/models/resources/test_resource.rb +22 -0
- data/test/models/resources/test_resource_group.rb +43 -0
- data/test/models/resources/test_resource_groups.rb +37 -0
- data/test/models/resources/test_resources.rb +38 -0
- data/test/models/storage/test_blobs.rb +32 -0
- data/test/models/storage/test_container.rb +67 -0
- data/test/models/storage/test_containers.rb +56 -0
- data/test/models/storage/test_data_disk.rb +29 -0
- data/test/models/storage/test_storage_account.rb +62 -0
- data/test/models/storage/test_storage_accounts.rb +65 -0
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +175 -0
- data/test/requests/compute/test_create_availability_set.rb +30 -0
- data/test/requests/compute/test_create_virtual_machine.rb +50 -0
- data/test/requests/compute/test_deallocate_virtual_machine.rb +29 -0
- data/test/requests/compute/test_delete_availability_set.rb +29 -0
- data/test/requests/compute/test_delete_virtual_machine.rb +29 -0
- data/test/requests/compute/test_detach_data_disk_from_vm.rb +53 -0
- data/test/requests/compute/test_generalize_virtual_machine.rb +29 -0
- data/test/requests/compute/test_get_virtual_machine.rb +31 -0
- data/test/requests/compute/test_get_vm_status.rb +31 -0
- data/test/requests/compute/test_list_availability_sets.rb +30 -0
- data/test/requests/compute/test_list_available_sizes_for_virtual_machine.rb +31 -0
- data/test/requests/compute/test_list_virtual_machines.rb +30 -0
- data/test/requests/compute/test_power_off_virtual_machine.rb +29 -0
- data/test/requests/compute/test_redeploy_virtual_machine.rb +29 -0
- data/test/requests/compute/test_restart_virtual_machine.rb +29 -0
- data/test/requests/compute/test_start_virtual_machine.rb +29 -0
- data/test/requests/dns/test_check_for_zone.rb +52 -0
- data/test/requests/dns/test_create_record_set.rb +45 -0
- data/test/requests/dns/test_create_zone.rb +36 -0
- data/test/requests/dns/test_delete_record_set.rb +35 -0
- data/test/requests/dns/test_delete_zone.rb +35 -0
- data/test/requests/dns/test_get_records_from_record_set.rb +55 -0
- data/test/requests/dns/test_list_record_sets.rb +36 -0
- data/test/requests/dns/test_list_zones.rb +40 -0
- data/test/requests/network/test_add_address_prefixes_in_virtual_network.rb +45 -0
- data/test/requests/network/test_add_dns_servers_in_virtual_network.rb +45 -0
- data/test/requests/network/test_add_security_rules.rb +63 -0
- data/test/requests/network/test_add_subnets_in_virtual_network.rb +45 -0
- data/test/requests/network/test_attach_network_security_group_to_subnet.rb +33 -0
- data/test/requests/network/test_attach_resource_to_nic.rb +65 -0
- data/test/requests/network/test_attach_route_table_to_subnet.rb +33 -0
- data/test/requests/network/test_check_for_public_ip.rb +38 -0
- data/test/requests/network/test_check_for_virtual_network.rb +38 -0
- data/test/requests/network/test_create_application_gateway.rb +61 -0
- data/test/requests/network/test_create_load_balancer.rb +56 -0
- data/test/requests/network/test_create_network_interface.rb +54 -0
- data/test/requests/network/test_create_network_security_group.rb +45 -0
- data/test/requests/network/test_create_or_update_virtual_network.rb +63 -0
- data/test/requests/network/test_create_public_ip.rb +44 -0
- data/test/requests/network/test_create_subnet.rb +44 -0
- data/test/requests/network/test_create_traffic_manager_endpoint.rb +32 -0
- data/test/requests/network/test_create_traffic_manager_profile.rb +32 -0
- data/test/requests/network/test_delete_application_gateway.rb +30 -0
- data/test/requests/network/test_delete_load_balancer.rb +30 -0
- data/test/requests/network/test_delete_network_interface.rb +30 -0
- data/test/requests/network/test_delete_network_security_group.rb +32 -0
- data/test/requests/network/test_delete_public_ip.rb +30 -0
- data/test/requests/network/test_delete_subnet.rb +30 -0
- data/test/requests/network/test_delete_traffic_manager_endpoint.rb +28 -0
- data/test/requests/network/test_delete_traffic_manager_profile.rb +28 -0
- data/test/requests/network/test_delete_virtual_network.rb +30 -0
- data/test/requests/network/test_detach_network_security_group_from_subnet.rb +33 -0
- data/test/requests/network/test_detach_resource_from_nic.rb +60 -0
- data/test/requests/network/test_detach_route_table_from_subnet.rb +33 -0
- data/test/requests/network/test_get_network_interface.rb +31 -0
- data/test/requests/network/test_get_network_security_group.rb +33 -0
- data/test/requests/network/test_get_subnet.rb +33 -0
- data/test/requests/network/test_get_traffic_manager_profile.rb +29 -0
- data/test/requests/network/test_list_application_gateways.rb +31 -0
- data/test/requests/network/test_list_load_balancers.rb +31 -0
- data/test/requests/network/test_list_network_interfaces.rb +31 -0
- data/test/requests/network/test_list_network_security_groups.rb +33 -0
- data/test/requests/network/test_list_public_ips.rb +31 -0
- data/test/requests/network/test_list_subnets.rb +31 -0
- data/test/requests/network/test_list_traffic_manager_profiles.rb +29 -0
- data/test/requests/network/test_list_virtual_networks.rb +31 -0
- data/test/requests/network/test_remove_address_prefixes_from_virtual_network.rb +45 -0
- data/test/requests/network/test_remove_dns_servers_from_virtual_network.rb +45 -0
- data/test/requests/network/test_remove_security_rule.rb +49 -0
- data/test/requests/network/test_remove_subnets_from_virtual_network.rb +45 -0
- data/test/requests/resources/test_create_deployment.rb +49 -0
- data/test/requests/resources/test_create_resource_group.rb +31 -0
- data/test/requests/resources/test_delete_deployment.rb +31 -0
- data/test/requests/resources/test_delete_resource_group.rb +30 -0
- data/test/requests/resources/test_delete_resource_tag.rb +51 -0
- data/test/requests/resources/test_list_deployments.rb +32 -0
- data/test/requests/resources/test_list_resource_groups.rb +31 -0
- data/test/requests/resources/test_list_tagged_resources.rb +31 -0
- data/test/requests/resources/test_tag_resource.rb +51 -0
- data/test/requests/storage/test_check_storage_account_name_availability.rb +59 -0
- data/test/requests/storage/test_create_container.rb +31 -0
- data/test/requests/storage/test_create_storage_account.rb +56 -0
- data/test/requests/storage/test_delete_container.rb +30 -0
- data/test/requests/storage/test_delete_storage_account.rb +34 -0
- data/test/requests/storage/test_get_blob_metadata.rb +18 -0
- data/test/requests/storage/test_get_container_access_control_list.rb +31 -0
- data/test/requests/storage/test_get_container_metadata.rb +18 -0
- data/test/requests/storage/test_get_container_properties.rb +31 -0
- data/test/requests/storage/test_get_storage_access_keys.rb +31 -0
- data/test/requests/storage/test_list_containers.rb +23 -0
- data/test/requests/storage/test_list_storage_accounts.rb +47 -0
- data/test/requests/storage/test_list_storage_accounts_for_rg.rb +51 -0
- data/test/requests/storage/test_set_blob_metadata.rb +17 -0
- data/test/requests/storage/test_set_container_metadata.rb +17 -0
- data/test/test_credentials.rb +39 -0
- data/test/test_helper.rb +428 -0
- metadata +273 -14
- data/lib/fog/azurerm/models/compute/data_disk.rb +0 -26
- data/lib/fog/azurerm/requests/network/create_virtual_network.rb +0 -115
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for List Deployment Request
|
4
|
+
class TestListDeployment < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@rmc)
|
8
|
+
@deployments = client.deployments
|
9
|
+
@promise = Concurrent::Promise.execute do
|
10
|
+
end
|
11
|
+
@resource_group = 'fog-test-rg'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_list_deployment_success
|
15
|
+
mocked_response = ApiStub::Requests::Resources::Deployment.list_deployment_response
|
16
|
+
expected_response = Azure::ARM::Resources::Models::DeploymentListResult.serialize_object(mocked_response.body)['value']
|
17
|
+
@promise.stub :value!, mocked_response do
|
18
|
+
@deployments.stub :list, @promise do
|
19
|
+
assert_equal @service.list_deployments(@resource_group), expected_response
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_list_deployment_failure
|
25
|
+
response = -> { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
26
|
+
@promise.stub :value!, response do
|
27
|
+
@deployments.stub :list, @promise do
|
28
|
+
assert_raises(RuntimeError) { @service.list_deployments(@resource_group) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for List Resource Groups Request
|
4
|
+
class TestListResourceGroups < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@rmc)
|
8
|
+
@resource_groups = client.resource_groups
|
9
|
+
@promise = Concurrent::Promise.execute do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_list_resource_group_success
|
14
|
+
mokced_response = ApiStub::Requests::Resources::ResourceGroup.list_resource_group_response
|
15
|
+
expected_response = Azure::ARM::Resources::Models::ResourceGroupListResult.serialize_object(mokced_response.body)['value']
|
16
|
+
@promise.stub :value!, mokced_response do
|
17
|
+
@resource_groups.stub :list, @promise do
|
18
|
+
assert_equal @service.list_resource_groups, expected_response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_list_resource_group_failure
|
24
|
+
response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
25
|
+
@promise.stub :value!, response do
|
26
|
+
@resource_groups.stub :list, @promise do
|
27
|
+
assert_raises(RuntimeError) { @service.list_resource_groups }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for List Tags Request
|
4
|
+
class TestListTags < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@rmc)
|
8
|
+
@resources = client.resources
|
9
|
+
@promise = Concurrent::Promise.execute do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_list_tagged_resources_success
|
14
|
+
mokced_response = ApiStub::Requests::Resources::AzureResource.list_tagged_resources_response
|
15
|
+
expected_response = Azure::ARM::Resources::Models::ResourceListResult.serialize_object(mokced_response.body)['value']
|
16
|
+
@promise.stub :value!, mokced_response do
|
17
|
+
@resources.stub :list, @promise do
|
18
|
+
assert_equal @service.list_tagged_resources('test_key'), expected_response
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_list_tagged_resources_failure
|
24
|
+
response = -> { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
25
|
+
@promise.stub :value!, response do
|
26
|
+
@resources.stub :list, @promise do
|
27
|
+
assert_raises(RuntimeError) { @service.list_tagged_resources('test_key') }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Create Azure Resources Request
|
4
|
+
class TestTagResource < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@rmc)
|
8
|
+
@resources = client.resources
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_tag_resource_success
|
12
|
+
mocked_response = ApiStub::Requests::Resources::AzureResource.azure_resource_response
|
13
|
+
promise_get = Concurrent::Promise.execute do
|
14
|
+
end
|
15
|
+
promise_create = Concurrent::Promise.execute do
|
16
|
+
end
|
17
|
+
promise_get.stub :value!, mocked_response do
|
18
|
+
@resources.stub :get, promise_get do
|
19
|
+
promise_create.stub :value!, mocked_response do
|
20
|
+
@resources.stub :create_or_update, promise_create do
|
21
|
+
resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
|
22
|
+
assert_equal @service.tag_resource(resource_id, 'tag_name', 'tag_value'), true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_tag_resource_failure
|
30
|
+
response = -> { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
31
|
+
promise_get = Concurrent::Promise.execute do
|
32
|
+
end
|
33
|
+
promise_create = Concurrent::Promise.execute do
|
34
|
+
end
|
35
|
+
promise_get.stub :value!, response do
|
36
|
+
@resources.stub :get, promise_get do
|
37
|
+
promise_create.stub :value!, response do
|
38
|
+
@resources.stub :create_or_update, promise_create do
|
39
|
+
resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
|
40
|
+
assert_raises(RuntimeError) { @service.tag_resource(resource_id, 'tag_name', 'tag_value') }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_invalid_resource_id_exeception
|
48
|
+
resource_id = 'Invalid-Resource-ID'
|
49
|
+
assert_raises(RuntimeError) { @service.tag_resource(resource_id, 'tag_name', 'tag_value') }
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Account Class
|
4
|
+
class TestCheckStorageAccountNameAvailability < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of storage account service.
|
6
|
+
def setup
|
7
|
+
@azure_credentials = Fog::Storage::AzureRM.new(credentials)
|
8
|
+
client = @azure_credentials.instance_variable_get(:@storage_mgmt_client)
|
9
|
+
@storage_accounts = client.storage_accounts
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_check_storage_account_name_availability_success
|
13
|
+
params = Azure::ARM::Storage::Models::StorageAccountCheckNameAvailabilityParameters.new
|
14
|
+
params.name = 'teststorageaccount'
|
15
|
+
params.type = 'Microsoft.Storage/storageAccounts'
|
16
|
+
mock_promise = Concurrent::Promise.execute do
|
17
|
+
end
|
18
|
+
true_case_response = ApiStub::Requests::Storage::StorageAccount.true_case_for_check_name_availability
|
19
|
+
result = ApiStub::Requests::Storage::StorageAccount.azure_operation_response(true_case_response)
|
20
|
+
mock_promise.stub :value!, result do
|
21
|
+
@storage_accounts.stub :check_name_availability, mock_promise do
|
22
|
+
assert_equal @azure_credentials.check_storage_account_name_availability(params), true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_check_storage_account_name_availability_failure
|
28
|
+
params = Azure::ARM::Storage::Models::StorageAccountCheckNameAvailabilityParameters.new
|
29
|
+
params.name = 'teststorageaccount'
|
30
|
+
params.type = 'Microsoft.Storage/storageAccounts'
|
31
|
+
mock_promise = Concurrent::Promise.execute do
|
32
|
+
end
|
33
|
+
false_case_response = ApiStub::Requests::Storage::StorageAccount.false_case_for_check_name_availability
|
34
|
+
result = ApiStub::Requests::Storage::StorageAccount
|
35
|
+
.azure_operation_response(false_case_response)
|
36
|
+
mock_promise.stub :value!, result do
|
37
|
+
@storage_accounts.stub :check_name_availability, mock_promise do
|
38
|
+
assert_equal @azure_credentials.check_storage_account_name_availability(params), false
|
39
|
+
assert_raises ArgumentError do
|
40
|
+
@azure_credentials.check_storage_account_name_availability(params, 'wrong arg')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_check_storage_account_name_availability_exception
|
47
|
+
params = Azure::ARM::Storage::Models::StorageAccountCheckNameAvailabilityParameters.new
|
48
|
+
params.name = 'teststorageaccount'
|
49
|
+
params.type = 'Microsoft.Storage/storageAccounts'
|
50
|
+
raise_exception = -> { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception', 'code' => 'ResourceGroupNotFound' }) }
|
51
|
+
mock_promise = Concurrent::Promise.execute do
|
52
|
+
end
|
53
|
+
mock_promise.stub :value!, raise_exception do
|
54
|
+
@storage_accounts.stub :check_name_availability, mock_promise do
|
55
|
+
assert_raises(RuntimeError) { @azure_credentials.check_storage_account_name_availability(params) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestCreateContaienr < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of creating storage containers.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@storage_container_object = ApiStub::Requests::Storage::Container.create_container
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create_container_with_service_success
|
13
|
+
@blob_client.stub :create_container, @storage_container_object do
|
14
|
+
assert @service.create_container('testcontainer1')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_container_with_internal_client_success
|
19
|
+
@blob_client.stub :create_container, @storage_container_object do
|
20
|
+
assert @blob_client.create_container('testcontainer1')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_create_container_with_service_exception
|
25
|
+
assert_raises(URI::InvalidURIError) { @service.create_container('testcontainer1#@#@') }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_container_with_internal_client_exception
|
29
|
+
assert_raises(URI::InvalidURIError) { @blob_client.create_container('testcontainer1#@#@') }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Create Storage Account Class
|
4
|
+
class TestCreateStorageAccount < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of storage account service.
|
6
|
+
def setup
|
7
|
+
@azure_credentials = Fog::Storage::AzureRM.new(credentials)
|
8
|
+
client = @azure_credentials.instance_variable_get(:@storage_mgmt_client)
|
9
|
+
@storage_accounts = client.storage_accounts
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_create_storage_account_success
|
13
|
+
mock_promise = Concurrent::Promise.execute do
|
14
|
+
end
|
15
|
+
storage_acc_obj = ApiStub::Requests::Storage::StorageAccount.storage_account_request
|
16
|
+
properties = Azure::ARM::Storage::Models::StorageAccountPropertiesCreateParameters.new
|
17
|
+
properties.account_type = 'Standard_LRS' # This might change in the near future!
|
18
|
+
params = Azure::ARM::Storage::Models::StorageAccountCreateParameters.new
|
19
|
+
params.properties = properties
|
20
|
+
params.location = location
|
21
|
+
mock_promise.stub :value!, storage_acc_obj do
|
22
|
+
@storage_accounts.stub :create, mock_promise do
|
23
|
+
assert_equal @azure_credentials.create_storage_account('gateway-RG', 'fog_test_storage_account', params), Azure::ARM::Storage::Models::StorageAccount.serialize_object(storage_acc_obj.body)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_create_storage_account_failure
|
29
|
+
mock_promise = Concurrent::Promise.execute do
|
30
|
+
end
|
31
|
+
storage_acc_obj = ApiStub::Requests::Storage::StorageAccount.create_storage_account
|
32
|
+
mock_promise.stub :value!, storage_acc_obj do
|
33
|
+
@storage_accounts.stub :create, mock_promise do
|
34
|
+
assert_raises ArgumentError do
|
35
|
+
@azure_credentials.create_storage_account('gateway-RG', 'fog_test_storage_account')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_create_storage_account_exception
|
42
|
+
properties = Azure::ARM::Storage::Models::StorageAccountPropertiesCreateParameters.new
|
43
|
+
properties.account_type = 'Standard_LRS' # This might change in the near future!
|
44
|
+
params = Azure::ARM::Storage::Models::StorageAccountCreateParameters.new
|
45
|
+
params.properties = properties
|
46
|
+
params.location = location
|
47
|
+
mock_promise = Concurrent::Promise.execute do
|
48
|
+
end
|
49
|
+
raise_exception = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
50
|
+
mock_promise.stub :value!, raise_exception do
|
51
|
+
@storage_accounts.stub :create, mock_promise do
|
52
|
+
assert_raises(RuntimeError) { @azure_credentials.create_storage_account('gateway-RG', 'fog_test_storage_account', params) }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestDeleteContaienr < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of deleting storage containers.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_delete_container_with_service_success
|
12
|
+
@blob_client.stub :delete_container, true do
|
13
|
+
assert @service.delete_container('testcontainer1')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_delete_container_with_internal_client_success
|
18
|
+
@blob_client.stub :delete_container, true do
|
19
|
+
assert @blob_client.delete_container('testcontainer1')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_delete_container_with_service_exception
|
24
|
+
assert_raises(URI::InvalidURIError) { @service.delete_container('testcontainer1#@#@') }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_delete_container_with_internal_client_exception
|
28
|
+
assert_raises(URI::InvalidURIError) { @blob_client.delete_container('testcontainer1#@#@') }
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Account Class
|
4
|
+
class TestDeleteStorageAccount < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of storage account service.
|
6
|
+
def setup
|
7
|
+
@azure_credentials = Fog::Storage::AzureRM.new(credentials)
|
8
|
+
client = @azure_credentials.instance_variable_get(:@storage_mgmt_client)
|
9
|
+
@storage_accounts = client.storage_accounts
|
10
|
+
@promise = Concurrent::Promise.execute do
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_delete_storage_account_success
|
15
|
+
@promise.stub :value!, true do
|
16
|
+
@storage_accounts.stub :delete, @promise do
|
17
|
+
assert @azure_credentials.delete_storage_account('gateway-RG', 'fog_test_storage_account')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_delete_storage_account_failure
|
23
|
+
assert_raises(ArgumentError) { @azure_credentials.delete_storage_account('gateway-RG', 'fog_test_storage_account', 'Hi') }
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_delete_storage_account_exception
|
27
|
+
raise_exception = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
28
|
+
@promise.stub :value!, raise_exception do
|
29
|
+
@storage_accounts.stub :delete, @promise do
|
30
|
+
assert_raises(RuntimeError) { @azure_credentials.delete_storage_account('gateway-RG', 'fog_test_storage_account') }
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Blob Class
|
4
|
+
class TestGetBlobMetadata < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of Blob service.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@blob_object = ApiStub::Requests::Storage::Blob.test_get_blob_metadata
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_blob_metadata_success
|
13
|
+
metadata_response = ApiStub::Requests::Storage::Blob.metadata_response
|
14
|
+
@blob_client.stub :get_blob_metadata, @blob_object do
|
15
|
+
assert_equal @service.get_blob_metadata('Test-container', 'Test-blob'), metadata_response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestGetContaienrACL < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of getting storage container properties.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@storage_container_object = ApiStub::Requests::Storage::Container.get_container_access_control_list
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_container_acl_with_service_success
|
13
|
+
@blob_client.stub :get_container_acl, @storage_container_object do
|
14
|
+
assert @service.get_container_access_control_list('testcontainer1')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_container_acl_with_internal_client_success
|
19
|
+
@blob_client.stub :get_container_acl, @storage_container_object do
|
20
|
+
assert @blob_client.get_container_acl('testcontainer1')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_container_acl_with_service_exception
|
25
|
+
assert_raises(URI::InvalidURIError) { @service.get_container_access_control_list('testcontainer1#@#@') }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_container_acl_with_internal_client_exception
|
29
|
+
assert_raises(URI::InvalidURIError) { @blob_client.get_container_acl('testcontainer1#@#@') }
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Container Class
|
4
|
+
class TestGetContainerMetadata < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of container service.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@container_object = ApiStub::Requests::Storage::Container.test_get_container_metadata
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_container_metadata_success
|
13
|
+
metadata_response = ApiStub::Requests::Storage::Container.metadata_response
|
14
|
+
@blob_client.stub :get_container_metadata, @container_object do
|
15
|
+
assert_equal @service.get_container_metadata('Test-container'), metadata_response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Storage Container Class
|
4
|
+
class TestGetContaienrProperties < Minitest::Test
|
5
|
+
# This class posesses the test cases for the requests of getting storage container properties.
|
6
|
+
def setup
|
7
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
8
|
+
@blob_client = @service.instance_variable_get(:@blob_client)
|
9
|
+
@storage_container_object = ApiStub::Requests::Storage::Container.get_container_properties
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_get_container_properties_with_service_success
|
13
|
+
@blob_client.stub :get_container_properties, @storage_container_object do
|
14
|
+
assert @service.get_container_properties('testcontainer1')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_container_properties_with_internal_client_success
|
19
|
+
@blob_client.stub :get_container_properties, @storage_container_object do
|
20
|
+
assert @blob_client.get_container_properties('testcontainer1')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_get_container_properties_with_service_exception
|
25
|
+
assert_raises(URI::InvalidURIError) { @service.get_container_properties('testcontainer1#@#@') }
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_get_container_properties_with_internal_client_exception
|
29
|
+
assert_raises(URI::InvalidURIError) { @blob_client.get_container_properties('testcontainer1#@#@') }
|
30
|
+
end
|
31
|
+
end
|