require 'spec_helper'
require 'vcloud_network_configurator'
describe "happy path for nat configurations" do
before :each do
WebMock.disable_net_connect!
WebMock.reset!
session_url = "https://super%40preview:man@www.vcloud.eggplant.com/sessions"
edge_gateway_configure_url = "https://www.vcloud.eggplant.com/admin/edgeGateway/123321/action/configureServices"
task_url = "https://www.vcloud.eggplant.com/api/tasks/10"
stub_request(:post, session_url).
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby'}).
to_return(:status => 200,
:body => File.read('spec/integration/test_data/happy_path_auth_response.xml'),
:headers => { 'x-vcloud-authorization' => '123321'})
stub_request(:post, edge_gateway_configure_url).
with(:body => configure_nat_xml,
:headers => { 'Accept'=>'application/*+xml;version=5.1',
'Content-Type'=>'application/vnd.vmware.admin.edgeGatewayServiceConfiguration+xml',
'User-Agent'=>'Ruby',
'X-Vcloud-Authorization'=>'123321' }).
to_return(:status => 202, :body => configure_task_xml)
stub_request(:get, task_url).
with(:headers => {'Accept'=>'application/*+xml;version=5.1', 'User-Agent'=>'Ruby', 'X-Vcloud-Authorization'=>'123321'}).
to_return(:status => 200, :body => configure_task_xml, :headers => {})
end
it "should configure edgegateway successfully" do
args = ["-u", "super", "-p", "man", "-U", "123321", "-d",
"spec/integration/test_data/rules_dir", "-e", "preview",
"-c", "nat", "https://www.vcloud.eggplant.com"]
configurator = VcloudNetworkConfigurator.new(args)
configurator.execute.should be_true
end
end
def configure_task_xml
%q{}
end
def configure_nat_xml
%q{
true
SNAT
true
65538
internal-ip
external-ip
DNAT
true
65539
external-ip
22
internal-ip
22
tcp
}
end