1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #1384 from brightbox/firewall_request_tests

[Brightbox] Adds firewall request tests
This commit is contained in:
Paul Thornthwaite 2012-12-17 06:59:50 -08:00
commit 10c94fbf40
3 changed files with 109 additions and 30 deletions

View file

@ -0,0 +1,33 @@
Shindo.tests('Fog::Compute[:brightbox] | firewall policy requests', ['brightbox']) do
tests('success') do
pending if Fog.mocking?
create_options = {
:name => "Fog test policy A"
}
tests("#create_firewall_policy(#{create_options.inspect})") do
result = Fog::Compute[:brightbox].create_firewall_policy(create_options)
@firewall_policy_id = result["id"]
formats(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, false) { result }
end
tests("#list_firewall_policies()") do
formats(Brightbox::Compute::Formats::Collection::FIREWALL_POLICIES, false) do
Fog::Compute[:brightbox].list_firewall_policies
end
end
tests("#get_firewall_policy('#{@firewall_policy_id}')") do
formats(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, false) do
Fog::Compute[:brightbox].get_firewall_policy(@firewall_policy_id)
end
end
tests("#destroy_firewall_policy('#{@firewall_policy_id}')") do
result = Fog::Compute[:brightbox].destroy_firewall_policy(@firewall_policy_id)
formats(Brightbox::Compute::Formats::Full::FIREWALL_POLICY, false) { result }
end
end
end

View file

@ -0,0 +1,43 @@
Shindo.tests('Fog::Compute[:brightbox] | firewall rule requests', ['brightbox']) do
tests('success') do
pending if Fog.mocking?
unless Fog.mocking?
policy = Fog::Compute[:brightbox].firewall_policies.create
end
create_options = {
:firewall_policy => policy.id,
:destination => "127.0.0.1"
}
tests("#create_firewall_rule(#{create_options.inspect})") do
result = Fog::Compute[:brightbox].create_firewall_rule(create_options)
@firewall_rule_id = result["id"]
formats(Brightbox::Compute::Formats::Full::FIREWALL_RULE, false) { result }
end
tests("#get_firewall_rule('#{@firewall_rule_id}')") do
formats(Brightbox::Compute::Formats::Full::FIREWALL_RULE, false) do
Fog::Compute[:brightbox].get_firewall_rule(@firewall_rule_id)
end
end
update_options = {:source => nil, :destination => "127.0.0.1"}
tests("#update_firewall_rule('#{@firewall_rule_id}', #{update_options.inspect})") do
formats(Brightbox::Compute::Formats::Full::FIREWALL_RULE, false) do
Fog::Compute[:brightbox].update_firewall_rule(@firewall_rule_id, update_options)
end
end
tests("#destroy_firewall_rule('#{@firewall_rule_id}')") do
result = Fog::Compute[:brightbox].destroy_firewall_rule(@firewall_rule_id)
formats(Brightbox::Compute::Formats::Full::FIREWALL_RULE, false) { result }
end
unless Fog.mocking?
policy.destroy
end
end
end

View file

@ -133,7 +133,7 @@ class Brightbox
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"name" => Fog::Nullable::String,
"default" => Fog::Boolean,
"created_at" => String,
"description" => Fog::Nullable::String
@ -143,11 +143,12 @@ class Brightbox
"id" => String,
"resource_type" => String,
"url" => String,
"created_at" => String,
"source" => Fog::Nullable::String,
"source_port" => Fog::Nullable::String,
"destination" => Fog::Nullable::String,
"destination_port" => Fog::Nullable::String,
"protocol" => String,
"protocol" => Fog::Nullable::String,
"icmp_type_name" => Fog::Nullable::String,
"description" => Fog::Nullable::String
}
@ -307,25 +308,12 @@ class Brightbox
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"name" => Fog::Nullable::String,
"description" => Fog::Nullable::String,
"default" => Fog::Boolean,
"server_group" => Brightbox::Compute::Formats::Nested::SERVER_GROUP,
"rules" => [Brightbox::Compute::Formats::Nested::FIREWALL_RULE]
}
FIREWALL_RULE = {
"id" => String,
"resource_type" => String,
"url" => String,
"source" => String,
"source_port" => String,
"destination" => String,
"destination_port" => String,
"protocol" => String,
"icmp_type_name" => String,
"description" => Fog::Nullable::String,
"firewall_policy" => Brightbox::Compute::Formats::Nested::FIREWALL_POLICY
"created_at" => String,
"server_group" => Fog::Brightbox::Nullable::ServerGroup,
"rules" => [Brightbox::Compute::Formats::Nested::FIREWALL_RULE]
}
IMAGE = {
@ -514,26 +502,42 @@ class Brightbox
"id" => String,
"resource_type" => String,
"url" => String,
"name" => String,
"name" => Fog::Nullable::String,
"description" => Fog::Nullable::String,
"default" => Fog::Boolean,
"server_group" => Brightbox::Compute::Formats::Nested::SERVER_GROUP,
"rules" => [Brightbox::Compute::Formats::Nested::FIREWALL_RULE]
"created_at" => String,
"server_group" => Fog::Brightbox::Nullable::ServerGroup,
"rules" => [Brightbox::Compute::Formats::Nested::FIREWALL_RULE]
}
FIREWALL_RULE = {
"id" => String,
"resource_type" => String,
"url" => String,
"source" => String,
"source_port" => String,
"destination" => String,
"destination_port" => String,
"protocol" => String,
"icmp_type_name" => String,
"description" => Fog::Nullable::String
"created_at" => String,
"source" => Fog::Nullable::String,
"source_port" => Fog::Nullable::String,
"destination" => Fog::Nullable::String,
"destination_port" => Fog::Nullable::String,
"protocol" => Fog::Nullable::String,
"icmp_type_name" => Fog::Nullable::String,
"description" => Fog::Nullable::String,
"firewall_policy" => Brightbox::Compute::Formats::Nested::FIREWALL_POLICY
}
#FIREWALL_RULE = {
#"id" => String,
#"resource_type" => String,
#"url" => String,
#"source" => String,
#"source_port" => String,
#"destination" => String,
#"destination_port" => String,
#"protocol" => String,
#"icmp_type_name" => String,
#"description" => Fog::Nullable::String
#}
IMAGE = {
"name" => String,
"created_at" => String,
@ -666,7 +670,6 @@ class Brightbox
CLOUD_IPS = [Brightbox::Compute::Formats::Collected::CLOUD_IP]
IMAGES = [Brightbox::Compute::Formats::Collected::IMAGE]
FIREWALL_POLICIES = [Brightbox::Compute::Formats::Collected::FIREWALL_POLICY]
FIREWALL_RULES = [Brightbox::Compute::Formats::Collected::FIREWALL_RULE]
LOAD_BALANCERS = [Brightbox::Compute::Formats::Collected::LOAD_BALANCER]
SERVERS = [Brightbox::Compute::Formats::Collected::SERVER]
SERVER_GROUPS = [Brightbox::Compute::Formats::Collected::SERVER_GROUP]