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,112 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for VirtualNetwork Model
|
4
|
+
class TestVirtualNetwork < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Network::AzureRM.new(credentials)
|
7
|
+
@virtual_network = virtual_network(@service)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_model_methods
|
11
|
+
methods = [
|
12
|
+
:save,
|
13
|
+
:add_dns_servers,
|
14
|
+
:remove_dns_servers,
|
15
|
+
:add_address_prefixes,
|
16
|
+
:remove_address_prefixes,
|
17
|
+
:add_subnets,
|
18
|
+
:remove_subnets,
|
19
|
+
:update,
|
20
|
+
:destroy
|
21
|
+
]
|
22
|
+
methods.each do |method|
|
23
|
+
assert @virtual_network.respond_to? method
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_model_attributes
|
28
|
+
attributes = [
|
29
|
+
:name,
|
30
|
+
:id,
|
31
|
+
:location,
|
32
|
+
:dns_servers,
|
33
|
+
:subnets,
|
34
|
+
:address_prefixes,
|
35
|
+
:resource_group
|
36
|
+
]
|
37
|
+
attributes.each do |attribute|
|
38
|
+
assert @virtual_network.respond_to? attribute
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_save_method_response
|
43
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
44
|
+
@service.stub :create_or_update_virtual_network, response do
|
45
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.save
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_add_dns_servers_method_response
|
50
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
51
|
+
@service.stub :add_dns_servers_in_virtual_network, response do
|
52
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.add_dns_servers(['10.3.0.0', '10.4.0.0'])
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_remove_dns_servers_method_response
|
57
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
58
|
+
@service.stub :remove_dns_servers_from_virtual_network, response do
|
59
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.remove_dns_servers(['10.3.0.0', '10.4.0.0'])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_add_address_prefixes_method_response
|
64
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
65
|
+
@service.stub :add_address_prefixes_in_virtual_network, response do
|
66
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.add_address_prefixes(['10.0.0.0/16'])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_remove_address_prefixes_method_response
|
71
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
72
|
+
@service.stub :remove_address_prefixes_from_virtual_network, response do
|
73
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.remove_address_prefixes(['10.0.0.0/16'])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_add_subnets_method_response
|
78
|
+
subnets = [{
|
79
|
+
name: 'test-subnet',
|
80
|
+
address_prefix: '10.0.0.0/16'
|
81
|
+
}]
|
82
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
83
|
+
@service.stub :add_subnets_in_virtual_network, response do
|
84
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.add_subnets(subnets)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_remove_subnets_method_response
|
89
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
90
|
+
@service.stub :remove_subnets_from_virtual_network, response do
|
91
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.remove_subnets(['test-subnet'])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_update_method_response
|
96
|
+
subnets = [{
|
97
|
+
name: 'test-subnet',
|
98
|
+
address_prefix: '10.0.0.0/16'
|
99
|
+
}]
|
100
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
101
|
+
@service.stub :create_or_update_virtual_network, response do
|
102
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_network.update(subnets: subnets, address_prefixes: ['10.0.0.0/16'])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_destroy_method_response
|
107
|
+
response = MsRestAzure::AzureOperationResponse.new(MsRest::HttpOperationRequest.new('', '', ''), Faraday::Response.new)
|
108
|
+
@service.stub :delete_virtual_network, response do
|
109
|
+
assert_instance_of MsRestAzure::AzureOperationResponse, @virtual_network.destroy
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for VirtualNetwork Collection
|
4
|
+
class TestVirtualNetworks < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Network::AzureRM.new(credentials)
|
7
|
+
@virtual_networks = Fog::Network::AzureRM::VirtualNetworks.new(resource_group: 'fog-test-rg', service: @service)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_collection_methods
|
11
|
+
methods = [
|
12
|
+
:all,
|
13
|
+
:get,
|
14
|
+
:check_if_exists
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @virtual_networks.respond_to? method
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_collection_attributes
|
22
|
+
assert @virtual_networks.respond_to? :resource_group
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_all_method_response
|
26
|
+
response = [ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response]
|
27
|
+
@service.stub :list_virtual_networks, response do
|
28
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetworks, @virtual_networks.all
|
29
|
+
assert @virtual_networks.all.size >= 1
|
30
|
+
@virtual_networks.all.each do |nic|
|
31
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, nic
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_get_method_response
|
37
|
+
response = ApiStub::Models::Network::VirtualNetwork.create_virtual_network_response
|
38
|
+
@service.stub :get_virtual_network, response do
|
39
|
+
assert_instance_of Fog::Network::AzureRM::VirtualNetwork, @virtual_networks.get('fog-rg', 'fog-test-virtual-network')
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_check_if_exists_method_success
|
44
|
+
@service.stub :check_for_virtual_network, true do
|
45
|
+
assert @virtual_networks.check_if_exists('fog-test-rg', 'fog-test-virtual-network')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_check_if_exists_method_failure
|
50
|
+
@service.stub :check_for_virtual_network, false do
|
51
|
+
assert !@virtual_networks.check_if_exists('fog-test-rg', 'fog-test-virtual-network')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Deployment Model
|
4
|
+
class TestDeployment < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@deployment = deployment(@service)
|
8
|
+
@response = ApiStub::Models::Resources::Deployment.create_deployment_response
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_model_methods
|
12
|
+
methods = [
|
13
|
+
:save,
|
14
|
+
:destroy
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @deployment.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_model_attributes
|
22
|
+
attributes = [
|
23
|
+
:name,
|
24
|
+
:id,
|
25
|
+
:resource_group,
|
26
|
+
:correlation_id,
|
27
|
+
:timestamp,
|
28
|
+
:outputs,
|
29
|
+
:providers,
|
30
|
+
:dependencies,
|
31
|
+
:template_link,
|
32
|
+
:parameters_link,
|
33
|
+
:mode,
|
34
|
+
:debug_setting,
|
35
|
+
:content_version,
|
36
|
+
:provisioning_state
|
37
|
+
]
|
38
|
+
attributes.each do |attribute|
|
39
|
+
assert @deployment.respond_to? attribute, true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_save_method_response
|
44
|
+
@service.stub :create_deployment, @response do
|
45
|
+
assert_instance_of Fog::Resources::AzureRM::Deployment, @deployment.save
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_destroy_method_response
|
50
|
+
@service.stub :delete_deployment, @response do
|
51
|
+
assert @deployment.destroy
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Deployment Collection
|
4
|
+
class TestDeployments < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@deployments = Fog::Resources::AzureRM::Deployments.new(resource_group: 'fog-test-rg', service: @service)
|
8
|
+
@response = ApiStub::Models::Resources::Deployment.list_deployments_response
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_collection_methods
|
12
|
+
methods = [
|
13
|
+
:all,
|
14
|
+
:get
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @deployments.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_all_method_response
|
22
|
+
@service.stub :list_deployments, @response do
|
23
|
+
assert_instance_of Fog::Resources::AzureRM::Deployments, @deployments.all
|
24
|
+
assert @deployments.all.size >= 1
|
25
|
+
@deployments.all.each do |deployment|
|
26
|
+
assert_instance_of Fog::Resources::AzureRM::Deployment, deployment
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_method_response
|
32
|
+
@service.stub :list_deployments, @response do
|
33
|
+
assert_instance_of Fog::Resources::AzureRM::Deployment, @deployments.get('fog-test-deployment')
|
34
|
+
assert @deployments.get('wrong-name').nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Resource Model
|
4
|
+
class TestResource < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@resource = Fog::Resources::AzureRM::AzureResource.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_model_attributes
|
11
|
+
attributes = [
|
12
|
+
:id,
|
13
|
+
:name,
|
14
|
+
:type,
|
15
|
+
:location,
|
16
|
+
:tags
|
17
|
+
]
|
18
|
+
attributes.each do |attribute|
|
19
|
+
assert @resource.respond_to? attribute, true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Resource Group Model
|
4
|
+
class TestResourceGroup < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@resource_group = resource_group(@service)
|
8
|
+
@response = ApiStub::Models::Resources::ResourceGroup.create_resource_group_response
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_model_methods
|
12
|
+
methods = [
|
13
|
+
:save,
|
14
|
+
:destroy
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @resource_group.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_model_attributes
|
22
|
+
attributes = [
|
23
|
+
:id,
|
24
|
+
:name,
|
25
|
+
:location
|
26
|
+
]
|
27
|
+
attributes.each do |attribute|
|
28
|
+
assert @resource_group.respond_to? attribute, true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_save_method_response
|
33
|
+
@service.stub :create_resource_group, @response do
|
34
|
+
assert_instance_of Fog::Resources::AzureRM::ResourceGroup, @resource_group.save
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_destroy_method_response
|
39
|
+
@service.stub :delete_resource_group, @response do
|
40
|
+
assert @resource_group.destroy
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Resource Groups Collection
|
4
|
+
class TestResourceGroups < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@resource_groups = Fog::Resources::AzureRM::ResourceGroups.new(service: @service)
|
8
|
+
@response = [ApiStub::Models::Resources::ResourceGroup.list_resource_groups_response]
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_collection_methods
|
12
|
+
methods = [
|
13
|
+
:all,
|
14
|
+
:get
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @resource_groups.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_all_method_response
|
22
|
+
@service.stub :list_resource_groups, @response do
|
23
|
+
assert_instance_of Fog::Resources::AzureRM::ResourceGroups, @resource_groups.all
|
24
|
+
assert @resource_groups.all.size >= 1
|
25
|
+
@resource_groups.all.each do |s|
|
26
|
+
assert_instance_of Fog::Resources::AzureRM::ResourceGroup, s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_method_response
|
32
|
+
@service.stub :list_resource_groups, @response do
|
33
|
+
assert_instance_of Fog::Resources::AzureRM::ResourceGroup, @resource_groups.get('fog-test-rg')
|
34
|
+
assert @resource_groups.get('wrong-name').nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Resources Collection
|
4
|
+
class TestResources < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Resources::AzureRM.new(credentials)
|
7
|
+
@resources = Fog::Resources::AzureRM::AzureResources.new(service: @service, tag_name: 'tag_name', tag_value: 'tag_value')
|
8
|
+
@response = ApiStub::Models::Resources::Resource.list_resources_response
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_collection_methods
|
12
|
+
methods = [
|
13
|
+
:all,
|
14
|
+
:get
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @resources.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_all_method_response
|
22
|
+
@service.stub :list_tagged_resources, @response do
|
23
|
+
assert_instance_of Fog::Resources::AzureRM::AzureResources, @resources.all
|
24
|
+
assert @resources.all.size >= 1
|
25
|
+
@resources.all.each do |r|
|
26
|
+
assert_instance_of Fog::Resources::AzureRM::AzureResource, r
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_get_method_response
|
32
|
+
@service.stub :list_tagged_resources, @response do
|
33
|
+
resource_id = '/subscriptions/########-####-####-####-############/resourceGroups/{RESOURCE-GROUP}/providers/Microsoft.Network/{PROVIDER-NAME}/{RESOURCE-NAME}'
|
34
|
+
assert_instance_of Fog::Resources::AzureRM::AzureResource, @resources.get(resource_id)
|
35
|
+
assert @resources.get('wrong-resource-id').nil?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Blob Collection
|
4
|
+
class TestBlobs < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
7
|
+
@blobs = Fog::Storage::AzureRM::Blobs.new(service: @service)
|
8
|
+
@response = ApiStub::Models::Storage::Blob.test_get_blob_metadata
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_collection_methods
|
12
|
+
methods = [
|
13
|
+
:set_blob_metadata,
|
14
|
+
:get_blob_metadata
|
15
|
+
]
|
16
|
+
methods.each do |method|
|
17
|
+
assert @blobs.respond_to? method, true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_get_blob_metadata
|
22
|
+
@service.stub :get_blob_metadata, @response do
|
23
|
+
assert_equal @response, @blobs.get_blob_metadata('Test-container', 'Test_Blob')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_set_blob_metadata
|
28
|
+
@service.stub :set_blob_metadata, true do
|
29
|
+
assert @blobs.set_blob_metadata('Test-container', 'Test_Blob', @response)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path '../../test_helper', __dir__
|
2
|
+
|
3
|
+
# Test class for Storage Container Model
|
4
|
+
class TestContainer < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@service = Fog::Storage::AzureRM.new(storage_account_credentials)
|
7
|
+
@container = storage_container(@service)
|
8
|
+
@create_result = ApiStub::Models::Storage::Container.create_container
|
9
|
+
@get_properties_result = ApiStub::Models::Storage::Container.get_container_properties
|
10
|
+
@get_access_control_list_result = ApiStub::Models::Storage::Container.get_container_access_control_list
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_model_methods
|
14
|
+
methods = [
|
15
|
+
:save,
|
16
|
+
:create,
|
17
|
+
:destroy
|
18
|
+
]
|
19
|
+
methods.each do |method|
|
20
|
+
assert @container.respond_to? method, true
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_model_attributes
|
25
|
+
attributes = [
|
26
|
+
:name,
|
27
|
+
:etag,
|
28
|
+
:last_modified,
|
29
|
+
:lease_duration,
|
30
|
+
:lease_state,
|
31
|
+
:lease_status,
|
32
|
+
:metadata
|
33
|
+
]
|
34
|
+
@service.stub :create_container, @create_result do
|
35
|
+
attributes.each do |attribute|
|
36
|
+
assert_respond_to @container, attribute
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_save_method_response
|
42
|
+
@service.stub :create_container, @create_result do
|
43
|
+
assert_instance_of Fog::Storage::AzureRM::Container, @container.save
|
44
|
+
end
|
45
|
+
@service.stub :create_container, @create_result do
|
46
|
+
assert_instance_of Fog::Storage::AzureRM::Container, @container.create
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_get_properties_method_response
|
51
|
+
@service.stub :get_container_properties, @get_properties_result do
|
52
|
+
assert_instance_of Fog::Storage::AzureRM::Container, @container.get_properties
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_get_access_control_list_method_response
|
57
|
+
@service.stub :get_container_access_control_list, @get_access_control_list_result do
|
58
|
+
assert_instance_of Fog::Storage::AzureRM::Container, @container.get_access_control_list
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_delete_method_true_response
|
63
|
+
@service.stub :delete_container, true do
|
64
|
+
assert @container.destroy
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|