From 8d8ef13cc51608fc59d499655ffc0fe035a93360 Mon Sep 17 00:00:00 2001 From: Athir Nuaimi Date: Mon, 22 Dec 2014 08:43:00 -0500 Subject: [PATCH] add a number of tests for cloudstack requests --- lib/fog/cloudstack/compute.rb | 73 ++++++++++++++++++- .../models/compute/public_ip_address.rb | 6 +- .../requests/compute/associate_ip_address.rb | 29 ++++++++ .../requests/compute/create_firewall_rule.rb | 28 ++++++- .../compute/create_network_offering.rb | 38 ++++++++-- .../compute/create_port_forwarding_rule.rb | 38 ++++++++-- .../compute/create_service_offering.rb | 35 ++++++++- .../requests/compute/delete_firewall_rule.rb | 13 +++- .../compute/delete_network_offering.rb | 13 +++- .../compute/delete_service_offering.rb | 13 +++- .../compute/disassociate_ip_address.rb | 14 +++- .../requests/compute/list_firewall_rules.rb | 7 ++ .../compute/list_network_offerings.rb | 9 ++- .../compute/list_port_forwarding_rules.rb | 12 +++ .../compute/list_public_ip_addresses.rb | 7 ++ .../compute/list_service_offerings.rb | 23 ++---- .../requests/firewall_rule_tests.rb | 29 ++++++++ .../requests/network_offering_tests.rb | 32 ++++++++ .../requests/port_forwarding_rule_tests.rb | 33 +++++++++ .../requests/public_ip_address_tests.rb | 38 ++++++++++ .../requests/service_offering_tests.rb | 23 ++---- tests/cloudstack/requests/volume_tests.rb | 11 ++- 22 files changed, 454 insertions(+), 70 deletions(-) create mode 100644 tests/cloudstack/requests/firewall_rule_tests.rb create mode 100644 tests/cloudstack/requests/network_offering_tests.rb create mode 100644 tests/cloudstack/requests/port_forwarding_rule_tests.rb create mode 100644 tests/cloudstack/requests/public_ip_address_tests.rb diff --git a/lib/fog/cloudstack/compute.rb b/lib/fog/cloudstack/compute.rb index 737f2464f..2d33c681c 100644 --- a/lib/fog/cloudstack/compute.rb +++ b/lib/fog/cloudstack/compute.rb @@ -741,6 +741,27 @@ module Fog "restartrequired" => false, "specifyipranges" => true} }, + :public_ip_addresses => { "0e276270-7950-4483-bf21-3dc897dbe08a" => { + "id" => "0e276270-7950-4483-bf21-3dc897dbe08a", + "ipaddress" => "192.168.200.2", + "allocated" => "2014-11-26T22:32:39+0000", + "zoneid" => "0e276270-7950-4483-bf21-3dc897dbe08a", + "zonename" => "Toronto", + "issourcenat" => false, + "projectid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "project" => "TestProject", + "domainid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "domain" => "TestDomain", + "forvirtualnetwork" => true, + "isstaticnat" => false, + "issystem" => false, + "associatednetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "associatednetworkname" => "TestNetwork", + "networkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "state" => "Allocated", + "physicalnetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "tags" => [] + }}, :zones => { zone_id => { "id" => zone_id, "name" => "zone-00", @@ -788,7 +809,8 @@ module Fog "offerha" => false, "limitcpuuse" => false, "issystem" => false, - "defaultuse" => false}}, + "defaultuse" => false + }}, :accounts => { account_id => { "id" => account_id, "name" => "accountname", @@ -881,6 +903,37 @@ module Fog "storagetype" => "shared" } }, + :network_offerings => { + "cc4de87d-672d-4353-abb5-6a8a4c0abf59" => { + "id" => "cc4de87d-672d-4353-abb5-6a8a4c0abf59", + "name" => "Shared Network With Security Groups", + "displaytext" => "Shared Network With Security Groups", + "traffictype" => "Guest", + "isdefault" => true, + "specifyvlan" => true, + "conservemode" => true, + "specifyipranges" => true, + "availability" => "Optional", + "networkrate" => 200, + "state" => "Enabled", + "guestiptype" => "Shared", + "serviceofferingid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1" + } + }, + :firewall_rules => { + "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1" => { + "id"=> "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "protocol"=> "tcp", + "startport" => "443", + "endport" => "443", + "ipaddressid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "networkid"=> network_id, + "ipaddress" => "192.168.200.1", + "state" => "Active", + "cidrlist" => "255.255.255.0/24", + "tags" => [] + } + }, :egress_firewall_rules => { "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1" => { "id"=>"f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", @@ -891,6 +944,24 @@ module Fog "tags"=>[] } }, + :port_forwarding_rules => { + "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3" => { + 'id' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3", + 'privateport' => "25", + 'privateendport' => "25", + 'protocol' => "tcp", + 'publicport' => "25", + 'publicendport' => "25", + 'virtualmachineid' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3", + 'virtualmachinename' => "LoadBalancer", + 'virtualmachinedisplayname' => "LoadBalancer", + 'ipaddressid' => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + 'ipaddress' => "192.168.200.200", + 'state' => "Active", + 'cidrlist' => "", + 'tags' => [] + } + }, :os_types => { "51ef854d-279e-4e68-9059-74980fd7b29b" => { "id" => "51ef854d-279e-4e68-9059-74980fd7b29b", diff --git a/lib/fog/cloudstack/models/compute/public_ip_address.rb b/lib/fog/cloudstack/models/compute/public_ip_address.rb index 72419b5e2..19a447490 100644 --- a/lib/fog/cloudstack/models/compute/public_ip_address.rb +++ b/lib/fog/cloudstack/models/compute/public_ip_address.rb @@ -34,15 +34,15 @@ module Fog 'tags' => tags } - response = service.create_disk_offering(options) - merge_attributes(response['creatediskofferingresponse']) + response = service.associate_ip_address(options) + merge_attributes(response['associateipaddressresponse']) end def destroy requires :id response = service.disassociate_ip_address('id' => id ) - success_status = response['deletediskofferingresponse']['success'] + success_status = response['disassociateipaddressresponse']['success'] success_status == 'true' end diff --git a/lib/fog/cloudstack/requests/compute/associate_ip_address.rb b/lib/fog/cloudstack/requests/compute/associate_ip_address.rb index 7f1aa44ae..447f97db7 100644 --- a/lib/fog/cloudstack/requests/compute/associate_ip_address.rb +++ b/lib/fog/cloudstack/requests/compute/associate_ip_address.rb @@ -20,6 +20,35 @@ module Fog end end + class Mock + def associate_ip_address(*args) + public_ip_address = { + "id" => "f2f2f2f2-f2f2-f2f2-f2f2-f2f2f2f2f2", + "ipaddress" => "192.168.200.3", + "allocated" => "2014-12-22T22:32:39+0000", + "zoneid" => "0e276270-7950-4483-bf21-3dc897dbe08a", + "zonename" => "Toronto", + "issourcenat" => false, + "projectid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "project" => "TestProject", + "domainid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "domain" => "TestDomain", + "forvirtualnetwork" => true, + "isstaticnat" => false, + "issystem" => false, + "associatednetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "associatednetworkname" => "TestNetwork", + "networkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "state" => "Allocated", + "physicalnetworkid" => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + "tags" => [] + + } + self.data[:public_ip_addresses][public_ip_address_id]= public_ip_address + {'associateipaddressresponse' => public_ip_address} + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/create_firewall_rule.rb b/lib/fog/cloudstack/requests/compute/create_firewall_rule.rb index 2e890cf50..971a83c82 100644 --- a/lib/fog/cloudstack/requests/compute/create_firewall_rule.rb +++ b/lib/fog/cloudstack/requests/compute/create_firewall_rule.rb @@ -10,16 +10,38 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'createFirewallRule') + options.merge!('command' => 'createFirewallRule') else - options.merge!('command' => 'createFirewallRule', - 'ipaddressid' => args[0], + options.merge!('command' => 'createFirewallRule', + 'ipaddressid' => args[0], 'protocol' => args[1]) end request(options) end end + class Mock + def create_firewall_rule(options={}) + firewall_rule_id = Fog::Cloudstack.uuid + + firewall_rule = { + "id" => network_offering_id, + "protocol" => "tcp", + "startport" => 80, + "endport" => 80, + "ipaddressid" => "f1f1f1f1-f1f1-f1f1-f1f1f1f1f1f1", + "networkid" => "f1f1f1f1-f1f1-f1f1-f1f1f1f1f1f1", + "ipaddress" => "10.1.1.253", + "state" => "Active", + "cidrlist" => "255.255.255.0/24" + } + + self.data[:firewall_rules][firewall_rule_id] = firewall_ruleetwork_offering + + {'createfirewallruleresponse' => firewall_rule} + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/create_network_offering.rb b/lib/fog/cloudstack/requests/compute/create_network_offering.rb index 59927703b..1aace4557 100644 --- a/lib/fog/cloudstack/requests/compute/create_network_offering.rb +++ b/lib/fog/cloudstack/requests/compute/create_network_offering.rb @@ -10,19 +10,45 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'createNetworkOffering') + options.merge!('command' => 'createNetworkOffering') else - options.merge!('command' => 'createNetworkOffering', - 'traffictype' => args[0], - 'guestiptype' => args[1], - 'name' => args[2], - 'supportedservices' => args[3], + options.merge!('command' => 'createNetworkOffering', + 'traffictype' => args[0], + 'guestiptype' => args[1], + 'name' => args[2], + 'supportedservices' => args[3], 'displaytext' => args[4]) end request(options) end end + class Mock + def create_network_offering(options={}) + network_offering_id = Fog::Cloudstack.uuid + + network_offering = { + "id" => network_offering_id, + "name" => "Isolated Network for VPC", + "displaytext" => "Isolated Network for VPC", + "traffictype" => "Guest", + "isdefault" => true, + "specifyvlan" => true, + "conservemode" => true, + "specifyipranges" => false, + "availability" => "Optional", + "networkrate" => 200, + "state" => "Enabled", + "guestiptype" => "Isolated", + "serviceofferingid" => "eaec129c-f1f1-f1f1-f1f1-a379f6b2897d" + } + + self.data[:network_offerings][network_offering_id] = network_offering + + {'createnetworkofferingresponse' => network_offering} + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb b/lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb index ffc783644..f69d949f2 100644 --- a/lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb +++ b/lib/fog/cloudstack/requests/compute/create_port_forwarding_rule.rb @@ -10,19 +10,45 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'createPortForwardingRule') + options.merge!('command' => 'createPortForwardingRule') else - options.merge!('command' => 'createPortForwardingRule', - 'virtualmachineid' => args[0], - 'protocol' => args[1], - 'privateport' => args[2], - 'ipaddressid' => args[3], + options.merge!('command' => 'createPortForwardingRule', + 'virtualmachineid' => args[0], + 'protocol' => args[1], + 'privateport' => args[2], + 'ipaddressid' => args[3], 'publicport' => args[4]) end request(options) end end + class Mock + def create_port_forwarding_rule(*args) + port_forwarding_rule_id = "43192143-5828-6831-58286837474" + port_forwarding_rule = { + 'id' => port_forwarding_rule_id, + 'privateport' => "110", + 'privateendport' => "110", + 'protocol' => "tcp", + 'publicport' => "111", + 'publicendport' => "111", + 'virtualmachineid' => "8f4627c5-1fdd-4504-8a92-f61b4e9cb3e3", + 'virtualmachinename' => "Pop3LoadBalancer", + 'virtualmachinedisplayname' => "Pop3LoadBalancer", + 'ipaddressid' => "f1f1f1f1-f1f1-f1f1-f1f1-f1f1f1f1f1", + 'ipaddress' => "192.168.200.201", + 'state' => "Active", + 'cidrlist' => "", + 'tags' => [] + } + + self.data[:port_forwarding_rules][port_forwarding_rule_id]= port_forwarding_rule + {'createportforwardingruleresponse' => port_forwarding_rule} + + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/create_service_offering.rb b/lib/fog/cloudstack/requests/compute/create_service_offering.rb index a6a5d7f48..c1af066d5 100644 --- a/lib/fog/cloudstack/requests/compute/create_service_offering.rb +++ b/lib/fog/cloudstack/requests/compute/create_service_offering.rb @@ -10,16 +10,45 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'createServiceOffering') + options.merge!('command' => 'createServiceOffering') else - options.merge!('command' => 'createServiceOffering', - 'name' => args[0], + options.merge!('command' => 'createServiceOffering', + 'name' => args[0], 'displaytext' => args[1]) end request(options) end end + class Mock + + def create_service_offering(options={}) + flavour_id = Fog::Cloudstack.uuid + + flavour = { + "id" => flavour_id, + "name" => "4CPU, 4 GB RAM, High Availability", + "displaytext" => "4CPU, 4 GB RAM, High Availability", + "cpunumber" => 4, + "cpuspeed" => 2000, + "memory" => 4096, + "created" => Time.now.iso8601, + "storagetype" => "shared", + "offerha" => true, + "limitcpuuse" => false, + "isvolatile" => false, + "issytem" => false, + "defaultuse" => false, + "iscustomized" => false, + "tags" => [] + } + + self.data[:flavours][flavour_id] = flavour + + {'createserviceofferingresponse' => flavour} + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/delete_firewall_rule.rb b/lib/fog/cloudstack/requests/compute/delete_firewall_rule.rb index 1004af61d..83e5ac16c 100644 --- a/lib/fog/cloudstack/requests/compute/delete_firewall_rule.rb +++ b/lib/fog/cloudstack/requests/compute/delete_firewall_rule.rb @@ -10,15 +10,24 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'deleteFirewallRule') + options.merge!('command' => 'deleteFirewallRule') else - options.merge!('command' => 'deleteFirewallRule', + options.merge!('command' => 'deleteFirewallRule', 'id' => args[0]) end request(options) end end + class Mock + def delete_firewall_rule(options={}) + firewall_rule_id = options['id'] + data[:firewall_rules].delete(firewall_rule_id) if data[:firewall_rules][firewall_rule_id] + + { 'deletefirewallruleresponse' => { 'success' => 'true' } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/delete_network_offering.rb b/lib/fog/cloudstack/requests/compute/delete_network_offering.rb index 1db6ba899..c52e219e2 100644 --- a/lib/fog/cloudstack/requests/compute/delete_network_offering.rb +++ b/lib/fog/cloudstack/requests/compute/delete_network_offering.rb @@ -10,15 +10,24 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'deleteNetworkOffering') + options.merge!('command' => 'deleteNetworkOffering') else - options.merge!('command' => 'deleteNetworkOffering', + options.merge!('command' => 'deleteNetworkOffering', 'id' => args[0]) end request(options) end end + class Mock + def delete_network_offering(options={}) + network_offering_id = options['id'] + data[:network_offerings].delete(network_offering_id) if data[:network_offerings][network_offering_id] + + { 'deletenetworkofferingresponse' => { 'success' => 'true' } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/delete_service_offering.rb b/lib/fog/cloudstack/requests/compute/delete_service_offering.rb index 6d3c5aa53..82dd4e12b 100644 --- a/lib/fog/cloudstack/requests/compute/delete_service_offering.rb +++ b/lib/fog/cloudstack/requests/compute/delete_service_offering.rb @@ -10,15 +10,24 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'deleteServiceOffering') + options.merge!('command' => 'deleteServiceOffering') else - options.merge!('command' => 'deleteServiceOffering', + options.merge!('command' => 'deleteServiceOffering', 'id' => args[0]) end request(options) end end + class Mock + def delete_service_offering(options={}) + service_offering_id = options['id'] + data[:favours].delete(service_offering_id) if data[:flavours][service_offering_id] + + { 'deleteserviceofferingresponse' => { 'success' => 'true' } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/disassociate_ip_address.rb b/lib/fog/cloudstack/requests/compute/disassociate_ip_address.rb index 78332aa94..96244f3bf 100644 --- a/lib/fog/cloudstack/requests/compute/disassociate_ip_address.rb +++ b/lib/fog/cloudstack/requests/compute/disassociate_ip_address.rb @@ -10,15 +10,25 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'disassociateIpAddress') + options.merge!('command' => 'disassociateIpAddress') else - options.merge!('command' => 'disassociateIpAddress', + options.merge!('command' => 'disassociateIpAddress', 'id' => args[0]) end request(options) end end + class Mock + def disassociate_ip_address(*args) + public_ip_address_id = options['id'] + if self.data[:public_ip_addresses][public_ip_address_id] + self.data[:public_ip_addresses].delete(public_ip_address_id) + { "disassociateipaddressresponse" => { "success" => "true" }} + end + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb b/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb index efec76e06..f5a46305c 100644 --- a/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb +++ b/lib/fog/cloudstack/requests/compute/list_firewall_rules.rb @@ -22,6 +22,13 @@ module Fog end end + class Mock + def list_firewall_rules(*arg) + firewall_rules = self.data[:firewall_rules] + { "listfirewallrulesresponse" => { "count"=> firewall_rules.count, "firewallrule"=> firewall_rules.values } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/list_network_offerings.rb b/lib/fog/cloudstack/requests/compute/list_network_offerings.rb index 9a6101efd..e3d371ece 100644 --- a/lib/fog/cloudstack/requests/compute/list_network_offerings.rb +++ b/lib/fog/cloudstack/requests/compute/list_network_offerings.rb @@ -10,7 +10,7 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'listNetworkOfferings') + options.merge!('command' => 'listNetworkOfferings') else options.merge!('command' => 'listNetworkOfferings') end @@ -18,6 +18,13 @@ module Fog end end + class Mock + def list_network_offerings(*arg) + network_offerings = self.data[:network_offerings] + { "listnetworkofferingsresponse" => { "count"=> network_offerings.count, "networkoffering"=> network_offerings.values } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb b/lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb index 45b80c1de..7561b298a 100644 --- a/lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb +++ b/lib/fog/cloudstack/requests/compute/list_port_forwarding_rules.rb @@ -22,6 +22,18 @@ module Fog end end + class Mock + def list_port_forwarding_rules(*args) + port_forwarding_rules = self.data[:port_forwarding_rules] + { + 'listportforwardingrulesresponse' => { + 'count' => port_forwarding_rules.size, + 'portforwardingrule' => port_forwarding_rules.values + } + } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb b/lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb index ffb14f617..32fe07a85 100644 --- a/lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb +++ b/lib/fog/cloudstack/requests/compute/list_public_ip_addresses.rb @@ -22,6 +22,13 @@ module Fog end end + class Mock + def list_public_ip_addresses(*arg) + public_ip_addresses = self.data[:public_ip_addresses] + { "listpublicipaddressesresponse" => { "count"=> public_ip_addresses.count, "publicipaddress"=> public_ip_addresses.values } } + end + end + end end end diff --git a/lib/fog/cloudstack/requests/compute/list_service_offerings.rb b/lib/fog/cloudstack/requests/compute/list_service_offerings.rb index 03d45f5da..488d07763 100644 --- a/lib/fog/cloudstack/requests/compute/list_service_offerings.rb +++ b/lib/fog/cloudstack/requests/compute/list_service_offerings.rb @@ -10,35 +10,22 @@ module Fog options = {} if args[0].is_a? Hash options = args[0] - options.merge!('command' => 'listServiceOfferings') + options.merge!('command' => 'listServiceOfferings') else options.merge!('command' => 'listServiceOfferings') end request(options) end end - + class Mock def list_service_offerings(options={}) - flavors = [] - if service_offering_id = options['id'] - flavor = self.data[:flavors][service_offering_id] - raise Fog::Compute::Cloudstack::BadRequest unless flavor - flavors = [flavor] - else - flavors = self.data[:flavors].values - end + flavors = self.data[:flavors] - { - "listserviceofferingsresponse" => - { - "count" => flavors.size, - "serviceoffering"=> flavors - } - } + { "listserviceofferingsresponse" => { "count" => flavors.size, "serviceoffering"=> flavors.values}} end - end + end end end end diff --git a/tests/cloudstack/requests/firewall_rule_tests.rb b/tests/cloudstack/requests/firewall_rule_tests.rb new file mode 100644 index 000000000..ee80b8ba1 --- /dev/null +++ b/tests/cloudstack/requests/firewall_rule_tests.rb @@ -0,0 +1,29 @@ +Shindo.tests('Fog::Compute[:cloudstack] | firewall rule requests', ['cloudstack']) do + + @firewall_rules_format = { + 'listfirewallrulesresponse' => { + 'count' => Integer, + 'firewallrule' => [ + 'id' => String, + 'protocol' => String, + 'startport' => String, + 'endport' => String, + 'ipaddressid' => String, + 'networkid' => String, + 'ipaddress' => String, + 'state' => String, + 'cidrlist' => String, + 'tags' => Fog::Nullable::Array + ] + } + } + + tests('success') do + + tests('#list_firewall_rules').formats(@firewall_rules_format) do + Fog::Compute[:cloudstack].list_firewall_rules + end + + end + +end diff --git a/tests/cloudstack/requests/network_offering_tests.rb b/tests/cloudstack/requests/network_offering_tests.rb new file mode 100644 index 000000000..16e3bf6c4 --- /dev/null +++ b/tests/cloudstack/requests/network_offering_tests.rb @@ -0,0 +1,32 @@ +Shindo.tests('Fog::Compute[:cloudstack] | network offering requests', ['cloudstack']) do + + @network_offerings_format = { + 'listnetworkofferingsresponse' => { + 'count' => Integer, + 'networkoffering' => [ + 'id' => String, + 'name' => String, + 'displaytext' => String, + 'traffictype' => String, + 'isdefault' => Fog::Boolean, + 'specifyvlan' => Fog::Boolean, + 'conservemode' => Fog::Boolean, + 'specifyipranges' => Fog::Boolean, + 'availability' => String, + 'networkrate' => Integer, + 'state' => String, + 'guestiptype' => String, + 'serviceofferingid' => String, + ] + } + } + + tests('success') do + + tests('#list_network_offerings').formats(@network_offerings_format) do + Fog::Compute[:cloudstack].list_network_offerings + end + + end + +end diff --git a/tests/cloudstack/requests/port_forwarding_rule_tests.rb b/tests/cloudstack/requests/port_forwarding_rule_tests.rb new file mode 100644 index 000000000..6d4599093 --- /dev/null +++ b/tests/cloudstack/requests/port_forwarding_rule_tests.rb @@ -0,0 +1,33 @@ +Shindo.tests('Fog::Compute[:cloudstack] | port forwarding rule requests', ['cloudstack']) do + + @port_forwarding_rule_format = { + 'listportforwardingrulesresponse' => { + 'count' => Integer, + 'portforwardingrule' => [ + 'id' => String, + 'privateport' => String, + 'privateendport' => String, + 'protocol' => String, + 'publicport' => String, + 'publicendport' => String, + 'virtualmachineid' => String, + 'virtualmachinename' => String, + 'virtualmachinedisplayname' => String, + 'ipaddressid' => String, + 'ipaddress' => String, + 'state' => String, + 'cidrlist' => String, + 'tags' => Fog::Nullable::Array + ] + } + } + + tests('success') do + + tests('#list_port_forwarding_rules').formats(@port_forwarding_rule_format) do + Fog::Compute[:cloudstack].list_port_forwarding_rules('zoneid' => 1) + end + + end + +end diff --git a/tests/cloudstack/requests/public_ip_address_tests.rb b/tests/cloudstack/requests/public_ip_address_tests.rb new file mode 100644 index 000000000..574495ce3 --- /dev/null +++ b/tests/cloudstack/requests/public_ip_address_tests.rb @@ -0,0 +1,38 @@ +Shindo.tests('Fog::Compute[:cloudstack] | public ip address requests', ['cloudstack']) do + + @public_ip_addresses_format = { + 'listpublicipaddressesresponse' => { + 'count' => Integer, + 'publicipaddress' => [ + 'id' => String, + 'ipaddress' => String, + 'allocated' => String, + 'zoneid' => String, + 'zonename' => String, + 'issourcenat' => Fog::Boolean, + 'projectid' => String, + 'project' => String, + 'domainid' => String, + 'domain' => String, + 'forvirtualnetwork' => Fog::Boolean, + 'isstaticnat' => Fog::Boolean, + 'issystem' => Fog::Boolean, + 'associatednetworkid' => String, + 'associatednetworkname' => String, + 'networkid' => String, + 'state' => String, + 'physicalnetworkid' => String, + 'tags' => Fog::Nullable::Array + ] + } + } + + tests('success') do + + tests('#list_public_ip_addresses').formats(@public_ip_addresses_format) do + Fog::Compute[:cloudstack].list_public_ip_addresses + end + + end + +end diff --git a/tests/cloudstack/requests/service_offering_tests.rb b/tests/cloudstack/requests/service_offering_tests.rb index 6262ab2a1..c4808803a 100644 --- a/tests/cloudstack/requests/service_offering_tests.rb +++ b/tests/cloudstack/requests/service_offering_tests.rb @@ -4,24 +4,18 @@ Shindo.tests('Fog::Compute[:cloudstack] | service offering requests', ['cloudsta 'listserviceofferingsresponse' => { 'count' => Integer, 'serviceoffering' => [ - 'id' => Integer, + 'id' => String, + 'name' => String, + 'displaytext' => String, 'cpuspeed' => Integer, 'cpunumber' => Integer, - 'created' => String, - 'defaultuse' => Fog::Boolean, - 'displaytext' => String, - 'domain' => Fog::Nullable::String, - 'domainid' => Fog::Nullable::Integer, - 'hosttags' => Fog::Nullable::String, - 'issystem' => Fog::Boolean, - 'limitcpuuse' => Fog::Boolean, 'memory' => Integer, - 'name' => String, - 'networkrate' => Integer, - 'offerha' => Fog::Boolean, + 'created' => String, 'storagetype' => String, - 'systemvmtype' => Fog::Nullable::String, - 'tags' => Fog::Nullable::String + 'offerha' => Fog::Boolean, + 'limitcpuuse' => Fog::Boolean, + 'issystem' => Fog::Boolean, + 'defaultuse' => Fog::Boolean ] } } @@ -29,7 +23,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | service offering requests', ['cloudsta tests('success') do tests('#list_service_offerings').formats(@service_offerings_format) do - pending if Fog.mocking? Fog::Compute[:cloudstack].list_service_offerings end diff --git a/tests/cloudstack/requests/volume_tests.rb b/tests/cloudstack/requests/volume_tests.rb index faccbeafb..925e769f8 100644 --- a/tests/cloudstack/requests/volume_tests.rb +++ b/tests/cloudstack/requests/volume_tests.rb @@ -4,27 +4,27 @@ Shindo.tests('Fog::Compute[:cloudstack] | volume requests', ['cloudstack']) do 'listvolumesresponse' => { 'count' => Integer, 'volume' => [ - 'id' => Integer, + 'id' => String, 'name' => String, - 'zoneid' => Integer, + 'zoneid' => String, 'zonename' => String, 'type' => String, 'size' => Integer, 'created' => String, 'account' => String, - 'domainid' => Integer, + 'domainid' => String, 'domain' => String, 'state' => String, 'storagetype' => String, 'hypervisor' => String, - 'diskofferingid' => Fog::Nullable::Integer, + 'diskofferingid' => Fog::Nullable::String, 'diskofferingname' => Fog::Nullable::String, 'diskofferingdisplaytext' => Fog::Nullable::String, 'storage' => String, 'destroyed' => Fog::Boolean, 'isextractable' => Fog::Boolean, 'deviceid' => Fog::Nullable::Integer, - 'virtualmachineid' => Fog::Nullable::Integer, + 'virtualmachineid' => Fog::Nullable::String, 'vmname' => Fog::Nullable::String, 'vmdisplayname' => Fog::Nullable::String, 'vmstate' => Fog::Nullable::String, @@ -39,7 +39,6 @@ Shindo.tests('Fog::Compute[:cloudstack] | volume requests', ['cloudstack']) do tests('success') do tests('#list_volumes').formats(@volumes_format) do - pending if Fog.mocking? Fog::Compute[:cloudstack].list_volumes('zoneid' => 1) end