1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/vcloud_director/requests/compute/edge_gateway_tests.rb

98 lines
3.8 KiB
Ruby
Raw Normal View History

2013-10-07 13:13:22 +01:00
Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector']) do
@service = Fog::Compute::VcloudDirector.new
@org = VcloudDirector::Compute::Helper.current_org(@service)
2013-10-07 13:13:22 +01:00
tests('Get first vDC') do
2013-10-07 13:13:22 +01:00
link = @org[:Link].detect do |l|
l[:type] == 'application/vnd.vmware.vcloud.vdc+xml'
end
@vdc_id = link[:href].split('/').last
end
tests('#get_org_vdc_gateways').data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_RECORDS_TYPE) do
2013-10-13 06:30:38 +01:00
begin
@edge_gateways = @service.get_org_vdc_gateways(@vdc_id).body
rescue Fog::Compute::VcloudDirector::Unauthorized # bug, may be localised
2013-10-13 06:30:38 +01:00
retry
end
2013-10-07 13:13:22 +01:00
@edge_gateways
end
@edge_gateways[:EdgeGatewayRecord].each do |result|
tests("each EdgeGatewayRecord").
data_matches_schema(VcloudDirector::Compute::Schema::QUERY_RESULT_EDGE_GATEWAY_RECORD_TYPE) { result }
end
2013-10-07 13:13:22 +01:00
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_configuration = @service.get_edge_gateway(@edge_gateway_id).body
end
tests('#post_configure_edge_gateway_services') do
@new_edge_gateway_configuration = {
:FirewallService =>
{
: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)
@service.process_task(response.body) unless Fog.mocking?
end
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[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule]
end
tests('#remove the firewall rule added by test').returns(nil) do
response = @service.post_configure_edge_gateway_services(@edge_gateway_id,
@edge_gateway_configuration[:Configuration][:EdgeGatewayServiceConfiguration])
@service.process_task(response.body) unless Fog.mocking?
edge_gateway = @service.get_edge_gateway(@edge_gateway_id).body
edge_gateway[:Configuration][:EdgeGatewayServiceConfiguration][:FirewallService][:FirewallRule].find { |rule| rule[:Id] == '1000' }
2013-10-07 13:13:22 +01:00
end
tests('Retrieve non-existent edge gateway').raises(Fog::Compute::VcloudDirector::Forbidden) do
2013-10-13 06:30:38 +01:00
begin
@service.get_edge_gateway('00000000-0000-0000-0000-000000000000')
rescue Fog::Compute::VcloudDirector::Unauthorized # bug, may be localised
2013-10-13 06:30:38 +01:00
retry
end
2013-10-07 13:13:22 +01:00
end
tests('Configure non-existent edge gateway').raises(Fog::Compute::VcloudDirector::Forbidden) do
begin
@service.post_configure_edge_gateway_services('00000000-0000-0000-0000-000000000000', {})
2013-10-22 09:45:54 +01:00
rescue Fog::Compute::VcloudDirector::Unauthorized # bug, may be localised
retry
end
end
end