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,56 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Container Collection
|
4
|
+
class TestContainers < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
7
|
+
@containers = Fog::Storage::AzureRM::Containers.new(service: @service)
|
8
|
+
@response = ApiStub::Models::Storage::Container.test_get_container_metadata
|
9
|
+
@list_results = ApiStub::Models::Storage::Container.list_containers
|
10
|
+
@acl_results = ApiStub::Models::Storage::Container.get_container_access_control_list
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_collection_methods
|
14
|
+
methods = [
|
15
|
+
:set_container_metadata,
|
16
|
+
:get_container_metadata,
|
17
|
+
:all,
|
18
|
+
:get
|
19
|
+
]
|
20
|
+
methods.each do |method|
|
21
|
+
assert @containers.respond_to? method, true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_get_container_metadata
|
26
|
+
@service.stub :get_container_metadata, @response do
|
27
|
+
assert_equal @response, @containers.get_container_metadata('Test-container')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_set_container_metadata
|
32
|
+
@service.stub :set_container_metadata, true do
|
33
|
+
assert @containers.set_container_metadata('Test-container', @response)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_all_method
|
38
|
+
containers = Fog::Storage::AzureRM::Containers.new(service: @service)
|
39
|
+
@service.stub :list_containers, @list_results do
|
40
|
+
assert_instance_of Fog::Storage::AzureRM::Containers, containers.all
|
41
|
+
assert containers.all.size >= 1
|
42
|
+
containers.all.each do |container|
|
43
|
+
assert_instance_of Fog::Storage::AzureRM::Container, container
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_get_method
|
49
|
+
@service.stub :list_containers, @list_results do
|
50
|
+
@service.stub :get_container_access_control_list, @acl_results do
|
51
|
+
assert_instance_of Fog::Storage::AzureRM::Container, @containers.get('testcontainer1')
|
52
|
+
assert @containers.get('wrong-name').nil?, true
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Data Disk Model
|
4
|
+
class TestDataDisk < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Storage::AzureRM.new(credentials)
|
7
|
+
@data_disk = Fog::Storage::AzureRM::DataDisk.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_model_attributes
|
11
|
+
attributes = [
|
12
|
+
:name,
|
13
|
+
:disk_size_gb,
|
14
|
+
:lun,
|
15
|
+
:vhd_uri,
|
16
|
+
:caching,
|
17
|
+
:create_option
|
18
|
+
]
|
19
|
+
attributes.each do |attribute|
|
20
|
+
assert @data_disk.respond_to? attribute, true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_parse_method_response
|
25
|
+
mocked_response = ApiStub::Models::Storage::DataDisk.create_data_disk_response
|
26
|
+
expected_response = ApiStub::Models::Storage::DataDisk.expected_create_data_disk_response
|
27
|
+
assert_equal Fog::Storage::AzureRM::DataDisk.parse(mocked_response), expected_response
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
# Test class for Storage Account Model
|
3
|
+
class TestStorageAccount < Minitest::Test
|
4
|
+
def setup
|
5
|
+
@service = Fog::Storage::AzureRM.new(credentials)
|
6
|
+
@storage_account = storage_account(@service)
|
7
|
+
@response = ApiStub::Models::Storage::StorageAccount.create_storage_account
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_model_methods
|
11
|
+
methods = [
|
12
|
+
:save,
|
13
|
+
:destroy,
|
14
|
+
:get_access_keys
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @storage_account.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_model_attributes
|
22
|
+
attributes = [
|
23
|
+
:name,
|
24
|
+
:location,
|
25
|
+
:resource_group,
|
26
|
+
:account_type
|
27
|
+
]
|
28
|
+
@service.stub :create_storage_account, @response do
|
29
|
+
attributes.each do |attribute|
|
30
|
+
assert_respond_to @storage_account, attribute
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_save_method_response
|
36
|
+
@service.stub :create_storage_account, @response do
|
37
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccount, @storage_account.save
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_get_access_keys_method_response
|
42
|
+
response = {
|
43
|
+
'key1' => 'key1 value',
|
44
|
+
'key2' => 'key2 value'
|
45
|
+
}
|
46
|
+
@service.stub :get_storage_access_keys, response do
|
47
|
+
assert_equal @storage_account.get_access_keys, response
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_destroy_method_true_response
|
52
|
+
@service.stub :delete_storage_account, true do
|
53
|
+
assert @storage_account.destroy
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_destroy_method_false_response
|
58
|
+
@service.stub :delete_storage_account, false do
|
59
|
+
assert !@storage_account.destroy
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Availability Set Collection
|
4
|
+
class TestStorageAccounts < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Storage::AzureRM.new(credentials)
|
7
|
+
@storage_accounts = Fog::Storage::AzureRM::StorageAccounts.new(resource_group: 'fog-test-rg', service: @service)
|
8
|
+
@response = [ApiStub::Models::Storage::StorageAccount.list_storage_account]
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_collection_methods
|
12
|
+
methods = [
|
13
|
+
:all,
|
14
|
+
:get
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @storage_accounts.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_collection_attributes
|
22
|
+
assert @storage_accounts.respond_to? :resource_group, true
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_all_method_response_for_rg
|
26
|
+
@service.stub :list_storage_account_for_rg, @response do
|
27
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccounts, @storage_accounts.all
|
28
|
+
assert @storage_accounts.all.size >= 1
|
29
|
+
@storage_accounts.all.each do |s|
|
30
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccount, s
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_all_method_response
|
36
|
+
storage_accounts = Fog::Storage::AzureRM::StorageAccounts.new(service: @service)
|
37
|
+
@service.stub :list_storage_accounts, @response do
|
38
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccounts, storage_accounts.all
|
39
|
+
assert storage_accounts.all.size >= 1
|
40
|
+
storage_accounts.all.each do |s|
|
41
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccount, s
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_get_method_response
|
47
|
+
response = [ApiStub::Models::Storage::StorageAccount.list_storage_account]
|
48
|
+
@service.stub :list_storage_account_for_rg, response do
|
49
|
+
assert_instance_of Fog::Storage::AzureRM::StorageAccount, @storage_accounts.get('fog-test-storage-account')
|
50
|
+
assert @storage_accounts.get('wrong-name').nil?, true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_check_name_availability_true_case
|
55
|
+
@service.stub :check_storage_account_name_availability, true do
|
56
|
+
assert @storage_accounts.check_name_availability('fog-test-storage-account')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_check_name_availability_false_case
|
61
|
+
@service.stub :check_storage_account_name_availability, false do
|
62
|
+
assert !@storage_accounts.check_name_availability('fog-test-storage-account')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Attach Data Disk to VM Request
|
4
|
+
class TestAttachDataDiskToVM < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Compute::AzureRM.new(credentials)
|
7
|
+
vm_client = @service.instance_variable_get(:@compute_mgmt_client)
|
8
|
+
storage_client = @service.instance_variable_get(:@storage_mgmt_client)
|
9
|
+
@virtual_machines = vm_client.virtual_machines
|
10
|
+
@storage_accounts = storage_client.storage_accounts
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_attach_data_disk_to_vm_success
|
14
|
+
promise_get_vm = Concurrent::Promise.execute do
|
15
|
+
end
|
16
|
+
|
17
|
+
promise_update_vm = Concurrent::Promise.execute do
|
18
|
+
end
|
19
|
+
|
20
|
+
promise_storage_access_keys = Concurrent::Promise.execute do
|
21
|
+
end
|
22
|
+
|
23
|
+
get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
24
|
+
update_vm_response = ApiStub::Requests::Compute::VirtualMachine.update_virtual_machine_response
|
25
|
+
expected_update_vm_response = Azure::ARM::Compute::Models::VirtualMachine.serialize_object(update_vm_response.body)
|
26
|
+
storage_access_keys_response = ApiStub::Requests::Storage::StorageAccount.list_keys_response
|
27
|
+
promise_get_vm.stub :value!, get_vm_response do
|
28
|
+
@virtual_machines.stub :get, promise_get_vm do
|
29
|
+
promise_storage_access_keys.stub :value!, storage_access_keys_response do
|
30
|
+
@storage_accounts.stub :list_keys, promise_storage_access_keys do
|
31
|
+
promise_update_vm.stub :value!, update_vm_response do
|
32
|
+
@virtual_machines.stub :create_or_update, promise_update_vm do
|
33
|
+
@service.stub :check_blob_exist, true do
|
34
|
+
assert_equal @service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1'), expected_update_vm_response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_attach_data_disk_to_vm_failure
|
45
|
+
promise_get_vm = Concurrent::Promise.execute do
|
46
|
+
end
|
47
|
+
|
48
|
+
promise_update_vm = Concurrent::Promise.execute do
|
49
|
+
end
|
50
|
+
|
51
|
+
promise_storage_access_keys = Concurrent::Promise.execute do
|
52
|
+
end
|
53
|
+
|
54
|
+
get_vm_response = ApiStub::Requests::Compute::VirtualMachine.virtual_machine_15_data_disks_response
|
55
|
+
update_vm_response = ApiStub::Requests::Compute::VirtualMachine.update_virtual_machine_response
|
56
|
+
storage_access_keys_response = ApiStub::Requests::Storage::StorageAccount.list_keys_response
|
57
|
+
promise_get_vm.stub :value!, get_vm_response do
|
58
|
+
@virtual_machines.stub :get, promise_get_vm do
|
59
|
+
promise_storage_access_keys.stub :value!, storage_access_keys_response do
|
60
|
+
@storage_accounts.stub :list_keys, promise_storage_access_keys do
|
61
|
+
promise_update_vm.stub :value!, update_vm_response do
|
62
|
+
@virtual_machines.stub :create_or_update, promise_update_vm do
|
63
|
+
@service.stub :check_blob_exist, true do
|
64
|
+
assert_raises RuntimeError do
|
65
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_update_vm_failure
|
77
|
+
promise_get_vm = Concurrent::Promise.execute do
|
78
|
+
end
|
79
|
+
|
80
|
+
promise_update_vm = Concurrent::Promise.execute do
|
81
|
+
end
|
82
|
+
|
83
|
+
promise_storage_access_keys = Concurrent::Promise.execute do
|
84
|
+
end
|
85
|
+
|
86
|
+
get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
87
|
+
update_vm_response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
88
|
+
storage_access_keys_response = ApiStub::Requests::Storage::StorageAccount.list_keys_response
|
89
|
+
promise_get_vm.stub :value!, get_vm_response do
|
90
|
+
@virtual_machines.stub :get, promise_get_vm do
|
91
|
+
promise_storage_access_keys.stub :value!, storage_access_keys_response do
|
92
|
+
@storage_accounts.stub :list_keys, promise_storage_access_keys do
|
93
|
+
promise_update_vm.stub :value!, update_vm_response do
|
94
|
+
@virtual_machines.stub :create_or_update, promise_update_vm do
|
95
|
+
@service.stub :check_blob_exist, true do
|
96
|
+
assert_raises RuntimeError do
|
97
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_update_vm_blob_not_exist_failure
|
109
|
+
promise_get_vm = Concurrent::Promise.execute do
|
110
|
+
end
|
111
|
+
|
112
|
+
promise_update_vm = Concurrent::Promise.execute do
|
113
|
+
end
|
114
|
+
|
115
|
+
promise_storage_access_keys = Concurrent::Promise.execute do
|
116
|
+
end
|
117
|
+
|
118
|
+
get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
119
|
+
update_vm_response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
120
|
+
storage_access_keys_response = ApiStub::Requests::Storage::StorageAccount.list_keys_response
|
121
|
+
promise_get_vm.stub :value!, get_vm_response do
|
122
|
+
@virtual_machines.stub :get, promise_get_vm do
|
123
|
+
promise_storage_access_keys.stub :value!, storage_access_keys_response do
|
124
|
+
@storage_accounts.stub :list_keys, promise_storage_access_keys do
|
125
|
+
promise_update_vm.stub :value!, update_vm_response do
|
126
|
+
@virtual_machines.stub :create_or_update, promise_update_vm do
|
127
|
+
@service.stub :check_blob_exist, false do
|
128
|
+
assert_raises RuntimeError do
|
129
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_get_vm_failure
|
141
|
+
promise_get_vm = Concurrent::Promise.execute do
|
142
|
+
end
|
143
|
+
|
144
|
+
get_vm_response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
145
|
+
promise_get_vm.stub :value!, get_vm_response do
|
146
|
+
@virtual_machines.stub :get, promise_get_vm do
|
147
|
+
assert_raises RuntimeError do
|
148
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_get_storage_key_failure
|
155
|
+
promise_get_vm = Concurrent::Promise.execute do
|
156
|
+
end
|
157
|
+
|
158
|
+
promise_storage_access_keys = Concurrent::Promise.execute do
|
159
|
+
end
|
160
|
+
|
161
|
+
get_vm_response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
162
|
+
storage_access_keys_response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
163
|
+
promise_get_vm.stub :value!, get_vm_response do
|
164
|
+
@virtual_machines.stub :get, promise_get_vm do
|
165
|
+
promise_storage_access_keys.stub :value!, storage_access_keys_response do
|
166
|
+
@storage_accounts.stub :list_keys, promise_storage_access_keys do
|
167
|
+
assert_raises RuntimeError do
|
168
|
+
@service.attach_data_disk_to_vm('fog-test-rg', 'fog-test-vm', 'disk1', 1, 'mystorage1')
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Create Availability Set Request
|
4
|
+
class TestCreateAvailabilitySet < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Compute::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@compute_mgmt_client)
|
8
|
+
@availability_sets = client.availability_sets
|
9
|
+
@promise = Concurrent::Promise.execute do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_create_availability_set_success
|
14
|
+
response = ApiStub::Requests::Compute::AvailabilitySet.create_availability_set_response
|
15
|
+
@promise.stub :value!, response do
|
16
|
+
@availability_sets.stub :create_or_update, @promise do
|
17
|
+
assert_equal @service.create_availability_set('fog-test-rg', 'fog-test-as', 'west us'), Azure::ARM::Compute::Models::AvailabilitySet.serialize_object(response.body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_create_availability_set_failure
|
23
|
+
response = -> { fail MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
24
|
+
@promise.stub :value!, response do
|
25
|
+
@availability_sets.stub :create_or_update, @promise do
|
26
|
+
assert_raises(RuntimeError) { @service.create_availability_set('fog-test-rg', 'fog-test-as', 'west us') }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Create Virtual Machine Request
|
4
|
+
class TestCreateVirtualMachine < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Compute::AzureRM.new(credentials)
|
7
|
+
client = @service.instance_variable_get(:@compute_mgmt_client)
|
8
|
+
@virtual_machines = client.virtual_machines
|
9
|
+
@promise = Concurrent::Promise.execute do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_create_linux_virtual_machine_success
|
14
|
+
response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
15
|
+
@promise.stub :value!, response do
|
16
|
+
@virtual_machines.stub :create_or_update, @promise do
|
17
|
+
assert_equal @service.create_virtual_machine('fog-test-rg', 'fog-test-server', 'westus', 'Basic_A0',
|
18
|
+
'fogstrg', 'fog', 'fog', false, '/home', 'key', 'nic-id',
|
19
|
+
'as-id', 'Canonical', 'UbuntuServer', '14.04.2-LTS', 'latest', 'Linux', nil, nil),
|
20
|
+
Azure::ARM::Compute::Models::VirtualMachine.serialize_object(response.body)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_create_windows_virtual_machine_success
|
26
|
+
response = ApiStub::Requests::Compute::VirtualMachine.create_virtual_machine_response
|
27
|
+
@promise.stub :value!, response do
|
28
|
+
@virtual_machines.stub :create_or_update, @promise do
|
29
|
+
assert_equal @service.create_virtual_machine('fog-test-rg', 'fog-test-server', 'westus', 'Basic_A0',
|
30
|
+
'fogstrg', 'fog', 'fog', nil, '/home', 'key', 'nic-id',
|
31
|
+
'as-id', 'MicrosoftWindowsServerEssentials', 'WindowsServerEssentials',
|
32
|
+
'WindowsServerEssentials', 'latest', 'Windows', true, true),
|
33
|
+
Azure::ARM::Compute::Models::VirtualMachine.serialize_object(response.body)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_create_virtual_machine_failure
|
39
|
+
response = -> { raise MsRestAzure::AzureOperationError.new(nil, nil, 'error' => { 'message' => 'mocked exception' }) }
|
40
|
+
@promise.stub :value!, response do
|
41
|
+
@virtual_machines.stub :create_or_update, @promise do
|
42
|
+
assert_raises RuntimeError do
|
43
|
+
@service.create_virtual_machine('fog-test-rg', 'fog-test-server', 'westus', 'Basic_A0', 'fogstrg', 'fog',
|
44
|
+
'fog', false, '/home', 'key', 'nic-id', 'as-id', 'Canonical',
|
45
|
+
'UbuntuServer', '14.04.2-LTS', 'latest', 'Linux', nil, nil)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|