lib/brightbox-cli/vendor/fog/tests/aws/models/elb/model_tests.rb in brightbox-cli-0.17.1 vs lib/brightbox-cli/vendor/fog/tests/aws/models/elb/model_tests.rb in brightbox-cli-0.17.2

- old
+ new

@@ -1,6 +1,7 @@ Shindo.tests('AWS::ELB | models', ['aws', 'elb']) do + require 'fog' @availability_zones = Fog::Compute[:aws].describe_availability_zones('state' => 'available').body['availabilityZoneInfo'].collect{ |az| az['zoneName'] } @key_name = 'fog-test-model' tests('success') do tests('load_balancers') do @@ -11,19 +12,21 @@ tests('listeners') do tests("default attributes") do listener = Fog::AWS[:elb].listeners.new tests('instance_port is 80').returns(80) { listener.instance_port } + tests('instance_protocol is HTTP').returns('HTTP') { listener.instance_protocol } tests('lb_port is 80').returns(80) { listener.lb_port } tests('protocol is HTTP').returns('HTTP') { listener.protocol } tests('policy_names is empty').returns([]) { listener.policy_names } end tests("specifying attributes") do - attributes = {:instance_port => 2000, :lb_port => 2001, :protocol => 'SSL', :policy_names => ['fake'] } + attributes = {:instance_port => 2000, :instance_protocol => 'SSL', :lb_port => 2001, :protocol => 'SSL', :policy_names => ['fake'] } listener = Fog::AWS[:elb].listeners.new(attributes) tests('instance_port is 2000').returns(2000) { listener.instance_port } + tests('instance_protocol is SSL').returns('SSL') { listener.instance_protocol } tests('lb_port is 2001').returns(2001) { listener.lb_port } tests('protocol is SSL').returns('SSL') { listener.protocol } tests('policy_names is [ fake ]').returns(['fake']) { listener.policy_names } end end @@ -60,28 +63,29 @@ 'LoadBalancerPort' => 2030, 'InstancePort' => 2030, 'Protocol' => 'HTTP' }, 'PolicyNames' => [] }, { 'Listener' => { - 'LoadBalancerPort' => 443, 'InstancePort' => 443, 'Protocol' => 'HTTPS', + 'LoadBalancerPort' => 443, 'InstancePort' => 443, 'Protocol' => 'HTTPS', 'InstanceProtocol' => 'HTTPS', 'SSLCertificateId' => @certificate['Arn'] }, 'PolicyNames' => [] }] elb3 = Fog::AWS[:elb].load_balancers.create(:id => "#{elb_id}-3", 'ListenerDescriptions' => listeners, :availability_zones => @availability_zones) tests('there are 2 listeners').returns(2) { elb3.listeners.count } tests('instance_port is 2030').returns(2030) { elb3.listeners.first.instance_port } tests('lb_port is 2030').returns(2030) { elb3.listeners.first.lb_port } tests('protocol is HTTP').returns('HTTP') { elb3.listeners.first.protocol } tests('protocol is HTTPS').returns('HTTPS') { elb3.listeners.last.protocol } + tests('instance_protocol is HTTPS').returns('HTTPS') { elb3.listeners.last.instance_protocol } elb3.destroy end tests('with invalid Server Cert ARN').raises(Fog::AWS::IAM::NotFound) do listeners = [{ 'Listener' => { - 'LoadBalancerPort' => 443, 'InstancePort' => 80, 'Protocol' => 'HTTPS', "SSLCertificateId" => "fakecert"} + 'LoadBalancerPort' => 443, 'InstancePort' => 80, 'Protocol' => 'HTTPS', 'InstanceProtocol' => 'HTTPS', "SSLCertificateId" => "fakecert"} }] Fog::AWS[:elb].load_balancers.create(:id => "#{elb_id}-4", "ListenerDescriptions" => listeners, :availability_zones => @availability_zones) end end @@ -176,20 +180,20 @@ tests('listeners') do tests('default') do returns(1) { elb.listeners.size } listener = elb.listeners.first - returns([80,80,'HTTP', []]) { [listener.instance_port, listener.lb_port, listener.protocol, listener.policy_names] } + returns([80,80,'HTTP','HTTP', []]) { [listener.instance_port, listener.lb_port, listener.protocol, listener.instance_protocol, listener.policy_names] } end tests('#get') do returns(80) { elb.listeners.get(80).lb_port } end tests('create') do - new_listener = { 'InstancePort' => 443, 'LoadBalancerPort' => 443, 'Protocol' => 'TCP'} - elb.listeners.create(:instance_port => 443, :lb_port => 443, :protocol => 'TCP') + new_listener = { 'InstancePort' => 443, 'LoadBalancerPort' => 443, 'Protocol' => 'TCP', 'InstanceProtocol' => 'TCP'} + elb.listeners.create(:instance_port => 443, :lb_port => 443, :protocol => 'TCP', :instance_protocol => 'TCP') returns(2) { elb.listeners.size } returns(443) { elb.listeners.get(443).lb_port } end tests('destroy') do @@ -240,9 +244,14 @@ end tests('a malformed policy') do raises(ArgumentError) { elb.policies.create(:id => 'foo', :cookie_stickiness => 'invalid stickiness') } end + end + + tests('setting a new ssl certificate id') do + elb.listeners.create(:instance_port => 443, :lb_port => 443, :protocol => 'HTTPS', :instance_protocol => 'HTTPS', :ssl_id => @certificate['Arn']) + elb.set_listener_ssl_certificate(443, @certificate['Arn']) end tests('destroy') do elb.destroy end