From 26c51e0af63180aecf8e6e4a43cf65173b0f66c7 Mon Sep 17 00:00:00 2001 From: Brian Dorry Date: Mon, 9 Jan 2012 19:20:37 -0500 Subject: [PATCH] updated cloudstack tests for user level permissions, added ssh key, disk offering, service offering, os type, security group tests --- .../requests/disk_offering_tests.rb | 29 ++++++++++++++ tests/cloudstack/requests/os_type_tests.rb | 38 +++++++++++++++++++ .../requests/security_group_tests.rb | 29 ++++++++++++++ .../requests/service_offering_tests.rb | 38 +++++++++++++++++++ .../requests}/snapshot_tests.rb | 0 .../cloudstack/requests/ssh_key_pair_tests.rb | 23 +++++++++++ .../requests}/template_tests.rb | 4 +- .../requests}/virtual_machine_tests.rb | 2 +- .../requests}/volume_tests.rb | 0 .../requests}/zone_tests.rb | 17 +++++---- .../requests/cloudstack/domain_tests.rb | 26 ------------- 11 files changed, 169 insertions(+), 37 deletions(-) create mode 100644 tests/cloudstack/requests/disk_offering_tests.rb create mode 100644 tests/cloudstack/requests/os_type_tests.rb create mode 100644 tests/cloudstack/requests/security_group_tests.rb create mode 100644 tests/cloudstack/requests/service_offering_tests.rb rename tests/{compute/requests/cloudstack => cloudstack/requests}/snapshot_tests.rb (100%) create mode 100644 tests/cloudstack/requests/ssh_key_pair_tests.rb rename tests/{compute/requests/cloudstack => cloudstack/requests}/template_tests.rb (94%) rename tests/{compute/requests/cloudstack => cloudstack/requests}/virtual_machine_tests.rb (97%) rename tests/{compute/requests/cloudstack => cloudstack/requests}/volume_tests.rb (100%) rename tests/{compute/requests/cloudstack => cloudstack/requests}/zone_tests.rb (53%) delete mode 100644 tests/compute/requests/cloudstack/domain_tests.rb diff --git a/tests/cloudstack/requests/disk_offering_tests.rb b/tests/cloudstack/requests/disk_offering_tests.rb new file mode 100644 index 000000000..d9ad34bfe --- /dev/null +++ b/tests/cloudstack/requests/disk_offering_tests.rb @@ -0,0 +1,29 @@ +Shindo.tests('Fog::Compute[:cloudstack] | disk offering requests', ['cloudstack']) do + + @disk_offerings_format = { + 'listdiskofferingsresponse' => { + 'count' => Integer, + 'diskoffering' => [ + 'id' => Integer, + 'created' => String, + 'disksize' => Integer, + 'displaytext' => String, + 'domain' => Fog::Nullable::String, + 'domainid' => Fog::Nullable::Integer, + 'iscustomized' => Fog::Boolean, + 'name' => String, + 'tags' => Fog::Nullable::String + ] + } + } + + tests('success') do + + tests('#list_disk_offerings').formats(@disk_offerings_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_disk_offerings + end + + end + +end \ No newline at end of file diff --git a/tests/cloudstack/requests/os_type_tests.rb b/tests/cloudstack/requests/os_type_tests.rb new file mode 100644 index 000000000..9be49738b --- /dev/null +++ b/tests/cloudstack/requests/os_type_tests.rb @@ -0,0 +1,38 @@ +Shindo.tests('Fog::Compute[:cloudstack] | os type requests', ['cloudstack']) do + + @os_types_format = { + 'listostypesresponse' => { + 'count' => Integer, + 'ostype' => [ + 'id' => Integer, + 'description' => String, + 'oscategoryid' => Integer + ] + } + } + + @os_categories_format = { + 'listoscategoriesresponse' => { + 'count' => Integer, + 'oscategory' => [ + 'id' => Integer, + 'name' => String + ] + } + } + + tests('success') do + + tests('#list_os_types').formats(@os_types_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_os_types + end + + tests('#list_os_categories').formats(@os_categories_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_os_categories + end + + end + +end \ No newline at end of file diff --git a/tests/cloudstack/requests/security_group_tests.rb b/tests/cloudstack/requests/security_group_tests.rb new file mode 100644 index 000000000..9f8f961f2 --- /dev/null +++ b/tests/cloudstack/requests/security_group_tests.rb @@ -0,0 +1,29 @@ +Shindo.tests('Fog::Compute[:cloudstack] | security group requests', ['cloudstack']) do + + @security_groups_format = { + 'listsecuritygroupsresponse' => { + 'count' => Integer, + 'securitygroup' => [ + 'id' => Integer, + 'account' => String, + 'description' => Fog::Nullable::String, + 'domain' => String, + 'domainid' => Integer, + 'jobid' => Fog::Nullable::Integer, + 'jobstatus' => Fog::Nullable::String, + 'name' => String, + 'ingressrule' => Fog::Nullable::Array + ] + } + } + + tests('success') do + + tests('#list_security_groups').formats(@security_groups_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_security_groups + end + + end + +end \ No newline at end of file diff --git a/tests/cloudstack/requests/service_offering_tests.rb b/tests/cloudstack/requests/service_offering_tests.rb new file mode 100644 index 000000000..01360b91e --- /dev/null +++ b/tests/cloudstack/requests/service_offering_tests.rb @@ -0,0 +1,38 @@ +Shindo.tests('Fog::Compute[:cloudstack] | service offering requests', ['cloudstack']) do + + @service_offerings_format = { + 'listserviceofferingsresponse' => { + 'count' => Integer, + 'serviceoffering' => [ + 'id' => Integer, + '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, + 'storagetype' => String, + 'systemvmtype' => Fog::Nullable::String, + 'tags' => Fog::Nullable::String + ] + } + } + + tests('success') do + + tests('#list_service_offerings').formats(@service_offerings_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_service_offerings + end + + end + +end \ No newline at end of file diff --git a/tests/compute/requests/cloudstack/snapshot_tests.rb b/tests/cloudstack/requests/snapshot_tests.rb similarity index 100% rename from tests/compute/requests/cloudstack/snapshot_tests.rb rename to tests/cloudstack/requests/snapshot_tests.rb diff --git a/tests/cloudstack/requests/ssh_key_pair_tests.rb b/tests/cloudstack/requests/ssh_key_pair_tests.rb new file mode 100644 index 000000000..63e5a9dbe --- /dev/null +++ b/tests/cloudstack/requests/ssh_key_pair_tests.rb @@ -0,0 +1,23 @@ +Shindo.tests('Fog::Compute[:cloudstack] | ssh key pairs requests', ['cloudstack']) do + + @ssh_keys_format = { + 'listsshkeypairsresponse' => { + 'count' => Integer, + 'sshkeypair' => [ + 'fingerprint' => String, + 'name' => String, + 'privatekey' => Fog::Nullable::String + ] + } + } + + tests('success') do + + tests('#list_ssh_key_pairs').formats(@ssh_keys_format) do + pending if Fog.mocking? + Fog::Compute[:cloudstack].list_ssh_key_pairs + end + + end + +end \ No newline at end of file diff --git a/tests/compute/requests/cloudstack/template_tests.rb b/tests/cloudstack/requests/template_tests.rb similarity index 94% rename from tests/compute/requests/cloudstack/template_tests.rb rename to tests/cloudstack/requests/template_tests.rb index 742e8a95a..758c2b99c 100644 --- a/tests/compute/requests/cloudstack/template_tests.rb +++ b/tests/cloudstack/requests/template_tests.rb @@ -19,8 +19,8 @@ Shindo.tests('Fog::Compute[:cloudstack] | template requests', ['cloudstack']) do 'account' => String, 'zoneid' => Integer, 'zonename' => String, - 'status' => String, - 'size' => Integer, + 'status' => Fog::Nullable::String, + 'size' => Fog::Nullable::Integer, 'templatetype' => String, 'hypervisor' => String, 'domain' => String, diff --git a/tests/compute/requests/cloudstack/virtual_machine_tests.rb b/tests/cloudstack/requests/virtual_machine_tests.rb similarity index 97% rename from tests/compute/requests/cloudstack/virtual_machine_tests.rb rename to tests/cloudstack/requests/virtual_machine_tests.rb index 521f175ad..fa209e96b 100644 --- a/tests/compute/requests/cloudstack/virtual_machine_tests.rb +++ b/tests/cloudstack/requests/virtual_machine_tests.rb @@ -15,7 +15,7 @@ Shindo.tests('Fog::Compute[:cloudstack] | virtual machine requests', ['cloudstac 'haenable' => Fog::Boolean, 'zoneid' => Integer, 'zonename' => String, - 'hostid' => Integer, + 'hostid' => Fog::Nullable::String, 'hostname' => Fog::Nullable::String, 'templateid' => Integer, 'templatename' => String, diff --git a/tests/compute/requests/cloudstack/volume_tests.rb b/tests/cloudstack/requests/volume_tests.rb similarity index 100% rename from tests/compute/requests/cloudstack/volume_tests.rb rename to tests/cloudstack/requests/volume_tests.rb diff --git a/tests/compute/requests/cloudstack/zone_tests.rb b/tests/cloudstack/requests/zone_tests.rb similarity index 53% rename from tests/compute/requests/cloudstack/zone_tests.rb rename to tests/cloudstack/requests/zone_tests.rb index 8cfb82a7e..74a2e6e30 100644 --- a/tests/compute/requests/cloudstack/zone_tests.rb +++ b/tests/cloudstack/requests/zone_tests.rb @@ -6,16 +6,17 @@ Shindo.tests('Fog::Compute[:cloudstack] | zone requests', ['cloudstack']) do 'zone' => [ 'id' => Integer, 'name' => String, - 'dns1' => String, - 'dns2' => String, - 'internaldns1' => String, - 'internaldns2' => String, - 'vlan' => String, - 'guestcidraddress' => String, + 'dns1' => Fog::Nullable::String, + 'dns2' => Fog::Nullable::String, + 'internaldns1' => Fog::Nullable::String, + 'internaldns2' => Fog::Nullable::String, + 'vlan' => Fog::Nullable::String, + 'guestcidraddress' => Fog::Nullable::String, 'networktype' => String, - 'securitygroupsenabled' => [TrueClass,FalseClass], + 'securitygroupsenabled' => Fog::Nullable::Boolean, 'allocationstate' => String, - 'dhcpprovider' => String + 'dhcpprovider' => String, + 'zonetoken' => Fog::Nullable::String ] } } diff --git a/tests/compute/requests/cloudstack/domain_tests.rb b/tests/compute/requests/cloudstack/domain_tests.rb deleted file mode 100644 index 9445c0dfa..000000000 --- a/tests/compute/requests/cloudstack/domain_tests.rb +++ /dev/null @@ -1,26 +0,0 @@ -Shindo.tests('Fog::Compute[:cloudstack] | domain requests', ['cloudstack']) do - - @domains_format = { - 'listdomainsresponse' => { - 'count' => Integer, - 'domain' => [ - 'id' => Integer, - 'name' => String, - 'level' => Integer, - 'haschild' => Fog::Boolean, - 'parentdomainid' => Fog::Nullable::Integer, - 'parentdomainname' => Fog::Nullable::String - ] - } - } - - tests('success') do - - tests('#list_domains').formats(@domains_format) do - pending if Fog.mocking? - Fog::Compute[:cloudstack].list_domains - end - - end - -end \ No newline at end of file