mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #2289 from alphagov/tests_for_edge_gateway
tests for configure edge gateways
This commit is contained in:
commit
50830be798
4 changed files with 89 additions and 15 deletions
|
@ -486,7 +486,22 @@ module Fog
|
||||||
uuid => {
|
uuid => {
|
||||||
:name => 'MockEdgeGateway',
|
:name => 'MockEdgeGateway',
|
||||||
:networks => [uplink_network_uuid, default_network_uuid],
|
:networks => [uplink_network_uuid, default_network_uuid],
|
||||||
:vdc => vdc_uuid
|
:vdc => vdc_uuid,
|
||||||
|
:Configuration => {
|
||||||
|
:GatewayBackingConfig => "compact",
|
||||||
|
:GatewayInterfaces => {
|
||||||
|
:GatewayInterface => []},
|
||||||
|
:EdgeGatewayServiceConfiguration => {
|
||||||
|
:FirewallService => {
|
||||||
|
:IsEnabled => "true",
|
||||||
|
:DefaultAction => "drop",
|
||||||
|
:LogDefaultAction => "false",
|
||||||
|
:FirewallRule => []
|
||||||
|
},
|
||||||
|
:NatService => {:IsEnabled => "true"}},
|
||||||
|
:HaEnabled => "false",
|
||||||
|
:UseDefaultRouteForDnsRelay => "false"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
:medias => {},
|
:medias => {},
|
||||||
|
|
|
@ -57,7 +57,6 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
vdc_id = edge_gateway[:vdc]
|
vdc_id = edge_gateway[:vdc]
|
||||||
|
|
||||||
body = {
|
body = {
|
||||||
:xmlns => xmlns,
|
:xmlns => xmlns,
|
||||||
:xmlns_xsi => xmlns_xsi,
|
:xmlns_xsi => xmlns_xsi,
|
||||||
|
@ -80,18 +79,8 @@ module Fog
|
||||||
{:rel => "edgeGateway:syncSyslogSettings",
|
{:rel => "edgeGateway:syncSyslogSettings",
|
||||||
:href => make_href("admin/edgeGateway/#{id}/action/syncSyslogServerSettings")}],
|
:href => make_href("admin/edgeGateway/#{id}/action/syncSyslogServerSettings")}],
|
||||||
:Description => "vCloud CI (nft00052i2)",
|
:Description => "vCloud CI (nft00052i2)",
|
||||||
:Configuration =>
|
:Configuration => edge_gateway[:Configuration].dup
|
||||||
{:GatewayBackingConfig => "compact",
|
}
|
||||||
:GatewayInterfaces =>
|
|
||||||
{:GatewayInterface => []},
|
|
||||||
:EdgeGatewayServiceConfiguration =>
|
|
||||||
{:FirewallService =>
|
|
||||||
{:IsEnabled => "true",
|
|
||||||
:DefaultAction => "drop",
|
|
||||||
:LogDefaultAction => "false"},
|
|
||||||
:NatService => {:IsEnabled => "true"}},
|
|
||||||
:HaEnabled => "false",
|
|
||||||
:UseDefaultRouteForDnsRelay => "false"}}
|
|
||||||
|
|
||||||
body[:Configuration][:GatewayInterfaces][:GatewayInterface] += edge_gateway[:networks].map do |network|
|
body[:Configuration][:GatewayInterfaces][:GatewayInterface] += edge_gateway[:networks].map do |network|
|
||||||
extras = {
|
extras = {
|
||||||
|
|
|
@ -34,6 +34,18 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
def post_configure_edge_gateway_services(id, configuration)
|
||||||
|
unless data[:edge_gateways][id]
|
||||||
|
raise Fog::Compute::VcloudDirector::Forbidden.new(
|
||||||
|
"No access to entity \"(com.vmware.vcloud.entity.edgegateway:#{id})\"."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
data[:edge_gateways][id][:Configuration][:EdgeGatewayServiceConfiguration] = configuration
|
||||||
|
Excon::Response.new(:body => {:name => 'mock_task', :href => '/10000000000000000000000000000000' })
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,57 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
@service.get_edge_gateway(@edge_gateways[:EdgeGatewayRecord].first[:href].split('/').last).body
|
@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' }
|
||||||
end
|
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
|
||||||
|
@ -36,4 +86,12 @@ Shindo.tests('Compute::VcloudDirector | edge gateway requests', ['vclouddirector
|
||||||
end
|
end
|
||||||
end
|
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', {})
|
||||||
|
rescue Fog::Compute::VcloudDirector::Unauthorized # bug, may be localised
|
||||||
|
retry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue