mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud_director] test should fail fast, and use a clearly test id and description
This commit is contained in:
parent
6477089348
commit
96a428e465
1 changed files with 48 additions and 44 deletions
|
@ -1,5 +1,36 @@
|
||||||
Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector']) do
|
Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector']) do
|
||||||
|
|
||||||
|
FIREWALL_RULE_ID = '9999'
|
||||||
|
|
||||||
|
@new_edge_gateway_configuration = {
|
||||||
|
:FirewallService =>
|
||||||
|
{
|
||||||
|
:IsEnabled => "true",
|
||||||
|
:DefaultAction => "allow",
|
||||||
|
:LogDefaultAction => "false",
|
||||||
|
:FirewallRule => [
|
||||||
|
{
|
||||||
|
:IsEnabled => "false",
|
||||||
|
:MatchOnTranslate => "false",
|
||||||
|
:Id => FIREWALL_RULE_ID,
|
||||||
|
:Policy => "drop",
|
||||||
|
:Description => "generated from edge_gateway_tests",
|
||||||
|
:Protocols => {
|
||||||
|
:Tcp => "true"
|
||||||
|
},
|
||||||
|
:Port => "3412",
|
||||||
|
:DestinationPortRange => "3412",
|
||||||
|
:DestinationIp => "internal",
|
||||||
|
:SourcePort => "3412",
|
||||||
|
:SourceIp => "internal",
|
||||||
|
:SourcePortRange => "3412",
|
||||||
|
:EnableLogging => "false"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@service = Fog::Compute::VcloudDirector.new
|
@service = Fog::Compute::VcloudDirector.new
|
||||||
@org = VcloudDirector::Compute::Helper.current_org(@service)
|
@org = VcloudDirector::Compute::Helper.current_org(@service)
|
||||||
|
|
||||||
|
@ -26,57 +57,30 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
|
||||||
|
|
||||||
tests('#get_edge_gateway').data_matches_schema(VcloudDirector::Compute::Schema::GATEWAY_TYPE) do
|
tests('#get_edge_gateway').data_matches_schema(VcloudDirector::Compute::Schema::GATEWAY_TYPE) do
|
||||||
@edge_gateway_id = @edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last
|
@edge_gateway_id = @edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last
|
||||||
@edge_gateway_configuration = @service.get_edge_gateway(@edge_gateway_id).body
|
@orginal_gateway_conf = @service.get_edge_gateway(@edge_gateway_id).body
|
||||||
end
|
end
|
||||||
|
|
||||||
tests('#post_configure_edge_gateway_services') do
|
tests('#configure_edge_gateway_services') do
|
||||||
@new_edge_gateway_configuration = {
|
|
||||||
:FirewallService =>
|
rule = @orginal_gateway_conf[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule].find { |rule| rule[:Id] == FIREWALL_RULE_ID }
|
||||||
{
|
raise('fail fast if our test firewall rule already exists - its likely left over from a broken test run') if rule
|
||||||
:IsEnabled => "true",
|
|
||||||
:DefaultAction => "allow",
|
|
||||||
:LogDefaultAction => "false",
|
|
||||||
:FirewallRule => [
|
|
||||||
{
|
|
||||||
:IsEnabled => "false",
|
|
||||||
:MatchOnTranslate => "false",
|
|
||||||
:Id => "1000",
|
|
||||||
:Policy => "drop",
|
|
||||||
:Description => "description",
|
|
||||||
:Protocols => {
|
|
||||||
:Tcp => "true"
|
|
||||||
},
|
|
||||||
:Port => "3412",
|
|
||||||
:DestinationPortRange => "3412",
|
|
||||||
:DestinationIp => "internal",
|
|
||||||
:SourcePort => "3412",
|
|
||||||
:SourceIp => "internal",
|
|
||||||
:SourcePortRange => "3412",
|
|
||||||
:EnableLogging => "false"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response = @service.post_configure_edge_gateway_services(@edge_gateway_id, @new_edge_gateway_configuration)
|
response = @service.post_configure_edge_gateway_services(@edge_gateway_id, @new_edge_gateway_configuration)
|
||||||
@service.process_task(response.body) unless Fog.mocking?
|
@service.process_task(response.body) unless Fog.mocking?
|
||||||
end
|
|
||||||
|
|
||||||
tests('#check for new firewall rule').returns(@new_edge_gateway_configuration[:FirewallService][:FirewallRule]) do
|
tests('#check for new firewall rule').returns(@new_edge_gateway_configuration[:FirewallService][:FirewallRule]) do
|
||||||
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
|
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
|
||||||
|
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule]
|
||||||
|
end
|
||||||
|
|
||||||
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule]
|
tests('#remove the firewall rule added by test').returns(nil) do
|
||||||
end
|
response = @service.post_configure_edge_gateway_services(@edge_gateway_id,
|
||||||
|
@orginal_gateway_conf[:Configuration][:EdgeGatewayServiceConfiguration])
|
||||||
tests('#remove the firewall rule added by test').returns(nil) do
|
@service.process_task(response.body) unless Fog.mocking?
|
||||||
response = @service.post_configure_edge_gateway_services(@edge_gateway_id,
|
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
|
||||||
@edge_gateway_configuration[:Configuration][:EdgeGatewayServiceConfiguration])
|
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule].find { |rule| rule[:Id] == FIREWALL_RULE_ID }
|
||||||
|
end
|
||||||
@service.process_task(response.body) unless Fog.mocking?
|
end
|
||||||
|
|
||||||
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
|
|
||||||
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule].find { |rule| rule[:Id] == '1000' }
|
|
||||||
end
|
|
||||||
|
|
||||||
tests('Retrieve non-existent edge gateway').raises(Fog::Compute::VcloudDirector::Forbidden) do
|
tests('Retrieve non-existent edge gateway').raises(Fog::Compute::VcloudDirector::Forbidden) do
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue