diff --git a/lib/fog/aws/parsers/elbv2/describe_listeners.rb b/lib/fog/aws/parsers/elbv2/describe_listeners.rb
index 523941ab4..72672f541 100644
--- a/lib/fog/aws/parsers/elbv2/describe_listeners.rb
+++ b/lib/fog/aws/parsers/elbv2/describe_listeners.rb
@@ -7,6 +7,7 @@ module Fog
reset_listener
@default_action = {}
@certificate = {}
+ @redirect_config = {}
@results = { 'Listeners' => [] }
@response = { 'DescribeListenersResult' => {}, 'ResponseMetadata' => {} }
end
@@ -26,38 +27,47 @@ module Fog
end
def end_element(name)
- case name
- when 'member'
- if @in_default_actions
+ if @in_default_actions
+ case name
+ when 'member'
@listener['DefaultActions'] << @default_action
@default_action = {}
- elsif @in_certificates
- @listener['Certificates'] << @certificate
- @certificate = {}
- else
- @results['Listeners'] << @listener
- reset_listener
+ when 'Type', 'TargetGroupArn'
+ @default_action[name] = value
+ when 'Path', 'Protocol', 'Port', 'Query', 'Host', 'StatusCode'
+ @redirect_config[name] = value
+ when 'RedirectConfig'
+ @default_action[name] = @redirect_config
+ @redirect_config = {}
+ when 'DefaultActions'
+ @in_default_actions = false
end
- when 'LoadBalancerArn', 'Protocol', 'Port', 'ListenerArn'
- @listener[name] = value
- when 'Type', 'TargetGroupArn'
- @default_action[name] = value
- when 'CertificateArn'
- @certificate[name] = value
+ else
+ case name
+ when 'member'
+ if @in_certificates
+ @listener['Certificates'] << @certificate
+ @certificate = {}
+ else
+ @results['Listeners'] << @listener
+ reset_listener
+ end
+ when 'LoadBalancerArn', 'Protocol', 'Port', 'ListenerArn'
+ @listener[name] = value
+ when 'CertificateArn'
+ @certificate[name] = value
+ when 'Certificates'
+ @in_certificates = false
- when 'DefaultActions'
- @in_default_actions = false
- when 'Certificates'
- @in_certificates = false
+ when 'RequestId'
+ @response['ResponseMetadata'][name] = value
- when 'RequestId'
- @response['ResponseMetadata'][name] = value
+ when 'NextMarker'
+ @results['NextMarker'] = value
- when 'NextMarker'
- @results['NextMarker'] = value
-
- when 'DescribeListenersResponse'
- @response['DescribeListenersResult'] = @results
+ when 'DescribeListenersResponse'
+ @response['DescribeListenersResult'] = @results
+ end
end
end
end
diff --git a/tests/parsers/elbv2/describe_listeners_tests.rb b/tests/parsers/elbv2/describe_listeners_tests.rb
index 4d7063cae..52d741c43 100644
--- a/tests/parsers/elbv2/describe_listeners_tests.rb
+++ b/tests/parsers/elbv2/describe_listeners_tests.rb
@@ -14,6 +14,15 @@ DESCRIBE_LISTENERS_RESULT = <<-EOF
forward
arn:aws:elasticloadbalancing:us-west-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067
+
+ HTTPS
+ 443
+ \#{path}
+ \#{query}
+ \#{host}
+ HTTP_301
+ redirect
+
diff --git a/tests/requests/elbv2/helper.rb b/tests/requests/elbv2/helper.rb
index bf1165c76..4eb4c78f9 100644
--- a/tests/requests/elbv2/helper.rb
+++ b/tests/requests/elbv2/helper.rb
@@ -30,12 +30,18 @@ class AWS
'CreateLoadBalancerResult' => {'LoadBalancers' => [LOAD_BALANCER], 'NextMarker' => Fog::Nullable::String}
})
+ LISTENER_DEFAULT_ACTIONS = [{
+ "Type" => String,
+ "TargetGroupArn" => String,
+ "RedirectConfig" => Fog::Nullable::Hash
+ }]
+
LISTENER = {
"LoadBalancerArn" => String,
"Protocol" => String,
"Port" => String,
"ListenerArn" => String,
- "DefaultActions" => [{"Type" => String, "TargetGroupArn" => String}],
+ "DefaultActions" => LISTENER_DEFAULT_ACTIONS,
"Certificates" => [{"CertificateArn" => String}]
}