Skip to content

Commit

Permalink
test: add new one and amend GH Actions config
Browse files Browse the repository at this point in the history
Co-authored-by: Adam <adam.blevins@iongroup.com>
Co-authored-by: Bela <bela.sal@iongroup.com>
  • Loading branch information
3 people committed Jan 10, 2022
1 parent 34dbab5 commit 728447e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ name: Test
on:
workflow_dispatch:
push:
branches-ignore:
- 'dependabot/**'
branches:
- master

jobs:
publish:
test:
name: Test
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- uses: actions/checkout@v2
- run: ./test/run.sh
14 changes: 12 additions & 2 deletions test/infra/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ module "backend_service_routing" {
aws_account_alias = var.aws_account_alias
backend_dns = var.backend_dns

extra_listener_host_names = var.extra_listener_host_names
extra_listener_host_names = var.extra_listener_host_names
extra_listener_http_header_pairs = var.extra_listener_http_header_pairs
}

# configure provider to not try too hard talking to AWS API
Expand Down Expand Up @@ -40,6 +41,15 @@ variable "aws_account_alias" {}
variable "backend_dns" {}

variable "extra_listener_host_names" {
type = list(string)
type = list(string)
default = []
}

variable "extra_listener_http_header_pairs" {
description = "A list of HTTP headers to be included in the http header condition for the ALB listener rule"
type = list(object({
http_header_name = string,
values = set(string)
}))
default = []
}
57 changes: 57 additions & 0 deletions test/test_tf_backend_service_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,63 @@ def test_create_alb_listener_rule_extrahosts(self):
}
} """.strip() in output

def test_create_alb_listener_rule_extra_headers(self):
# When
output = check_output([
'terraform',
'plan',
'-var', 'env=live',
'-var', 'aws_account_alias=awsaccount',
'-var', 'backend_dns=testbackend.com',
'-var', 'extra_listener_http_header_pairs=[{"http_header_name":"osh_was","values":["here"]}]',
'-var-file=test/platform-config/eu-west-1.json',
'-target=module.backend_service_routing.aws_alb_listener_rule.rule',
'-no-color',
'test/infra'
]).decode('utf-8')

# Then
assert """
# module.backend_service_routing.aws_alb_listener_rule.rule will be created
+ resource "aws_alb_listener_rule" "rule" {
+ arn = (known after apply)
+ id = (known after apply)
+ listener_arn = "arn:aws:alb:eu-west-1:123456789123:alb:listener"
+ priority = 10
+ tags_all = (known after apply)
+ action {
+ order = (known after apply)
+ target_group_arn = (known after apply)
+ type = "forward"
}
+ condition {
+ host_header {
+ values = [
+ "cognito.domain.com",
]
}
}
+ condition {
+ http_header {
+ http_header_name = "osh_was"
+ values = [
+ "here",
]
}
}
+ condition {
+ path_pattern {
+ values = [
+ "*",
]
}
}
} """.strip() in output

def test_create_aws_alb_target_group(self):
# When
output = check_output([
Expand Down

0 comments on commit 728447e

Please sign in to comment.