require 'spec_helper' require 'vcloud_network_configurator' describe "happy path for lb configurations" do before :each do WebMock.disable_net_connect! WebMock.reset! session_url = "https://super%40org-name: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_lb_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", "-r", "spec/integration/test_data/rules_dir/common_lb.rb,spec/integration/test_data/rules_dir/preview/lb.rb", "-i", "spec/integration/test_data/rules_dir/preview/interfaces.yaml", "-o", "org-name", "-c", "lb", "https://www.vcloud.eggplant.com"] configurator = VcloudNetworkConfigurator.new(args) configurator.execute.should be_true end end def configure_task_xml %q{} end def configure_lb_xml %q{ false Frontend pool true HTTP ROUND_ROBIN 80 HTTP / 2 3 5 15 true HTTPS ROUND_ROBIN 443 SSL / 2 3 5 15 false TCP ROUND_ROBIN TCP 2 3 5 15 20.2.0.1 1 HTTP 80 HTTPS 443 TCP 20.3.0.2 1 HTTP 80 HTTPS 443 TCP false true VDC-1 20.1.0.2 true HTTP 80 true HTTPS 443 false TCP false Frontend pool } end