Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elb_application_lb: test a rule based on http-header #347

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,27 +159,43 @@
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Rules:
- Conditions:
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'User-Agent'
Values: ['*Trident/7:0*rv:*']
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'X-Something'
Values: ['foobar']
Priority: '1'
Actions:
- Type: fixed-response
FixedResponseConfig:
StatusCode: "200"
ContentType: "text/html"
MessageBody: "<b>Hello World!</b>"
- Conditions:
- Field: path-pattern
Values:
- "/forward-path/*"
Priority: 1
Priority: 2
Actions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
- Conditions:
- Field: path-pattern
Values:
- "/redirect-path/*"
Priority: 2
Priority: 3
Actions:
- Type: redirect
RedirectConfig: "{{ RedirectActionConfig }}"
- Conditions:
- Field: path-pattern
Values:
- "/fixed-response-path/"
Priority: 3
Priority: 4
Actions:
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Expand All @@ -189,13 +205,15 @@
that:
- alb.changed
- alb.listeners|length == 1
- alb.listeners[0].rules|length == 4 ## defaultactions is included as a rule
- alb.listeners[0].rules|length == 5 ## defaultactions is included as a rule
- alb.listeners[0].rules[0].actions|length == 1
- alb.listeners[0].rules[0].actions[0].type == "forward"
- alb.listeners[0].rules[0].actions[0].type == "fixed-response"
- alb.listeners[0].rules[1].actions|length == 1
- alb.listeners[0].rules[1].actions[0].type == "redirect"
- alb.listeners[0].rules[1].actions[0].type == "forward"
- alb.listeners[0].rules[2].actions|length == 1
- alb.listeners[0].rules[2].actions[0].type == "fixed-response"
- alb.listeners[0].rules[2].actions[0].type == "redirect"
- alb.listeners[0].rules[3].actions|length == 1
- alb.listeners[0].rules[3].actions[0].type == "fixed-response"

- name: test idempotence multiple non-default rules
elb_application_lb:
Expand All @@ -210,27 +228,43 @@
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Rules:
- Conditions:
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'User-Agent'
Values: ['*Trident/7:0*rv:*']
- Field: http-header
HttpHeaderConfig:
HttpHeaderName: 'X-Something'
Values: ['foobar']
Priority: '1'
Actions:
- Type: fixed-response
FixedResponseConfig:
StatusCode: "200"
ContentType: "text/html"
MessageBody: "<b>Hello World!</b>"
- Conditions:
- Field: path-pattern
Values:
- "/forward-path/*"
Priority: 1
Priority: 2
Actions:
- Type: forward
TargetGroupName: "{{ tg_name }}"
- Conditions:
- Field: path-pattern
Values:
- "/redirect-path/*"
Priority: 2
Priority: 3
Actions:
- Type: redirect
RedirectConfig: "{{ RedirectActionConfig }}"
- Conditions:
- Field: path-pattern
Values:
- "/fixed-response-path/"
Priority: 3
Priority: 4
Actions:
- Type: fixed-response
FixedResponseConfig: "{{ FixedResponseActionConfig }}"
Expand All @@ -240,13 +274,15 @@
that:
- not alb.changed
- alb.listeners|length == 1
- alb.listeners[0].rules|length == 4 ## defaultactions is included as a rule
- alb.listeners[0].rules|length == 5 ## defaultactions is included as a rule
- alb.listeners[0].rules[0].actions|length == 1
- alb.listeners[0].rules[0].actions[0].type == "forward"
- alb.listeners[0].rules[0].actions[0].type == "fixed-response"
- alb.listeners[0].rules[1].actions|length == 1
- alb.listeners[0].rules[1].actions[0].type == "redirect"
- alb.listeners[0].rules[1].actions[0].type == "forward"
- alb.listeners[0].rules[2].actions|length == 1
- alb.listeners[0].rules[2].actions[0].type == "fixed-response"
- alb.listeners[0].rules[2].actions[0].type == "redirect"
- alb.listeners[0].rules[3].actions|length == 1
- alb.listeners[0].rules[3].actions[0].type == "fixed-response"


# - name: test creating ALB with a default listener with multiple actions
Expand Down