| 1 |
--- |
| 2 |
# tasks file for aws_api_gateway_domain |
| 3 |
|
| 4 |
- name: Run aws_api_gateway_domain module integration tests |
| 5 |
module_defaults: |
| 6 |
group/aws: |
| 7 |
access_key: "{{ aws_access_key }}" |
| 8 |
secret_key: "{{ aws_secret_key }}" |
| 9 |
session_token: "{{ security_token | default(omit) }}" |
| 10 |
region: "{{ aws_region }}" |
| 11 |
|
| 12 |
# NOTE: To make tests work set TLS ARN in defaults/main.yml to an existing and |
| 13 |
# validated TLS cert on ACM that matches given domain. |
| 14 |
|
| 15 |
block: |
| 16 |
|
| 17 |
# ==================== preparations ======================================== |
| 18 |
|
| 19 |
- name: Preperations - Create REST API Gateway on AWS API Gateway service to reference from domain tests |
| 20 |
api_gateway: |
| 21 |
swagger_file: files/api_gw_swagger.yml |
| 22 |
stage: test |
| 23 |
state: present |
| 24 |
register: api_gateway_result |
| 25 |
|
| 26 |
# ================== integration tests ========================================== |
| 27 |
|
| 28 |
- name: Create Test - API gateway custom domain setup |
| 29 |
api_gateway_domain: |
| 30 |
domain_name: "{{ api_gateway_domain_name }}" |
| 31 |
certificate_arn: "{{ api_gateway_domain_tls_arn }}" |
| 32 |
security_policy: 'TLS_1_0' |
| 33 |
endpoint_type: EDGE |
| 34 |
domain_mappings: |
| 35 |
- { rest_api_id: "{{ api_gateway_result.api_id }}", stage: test } |
| 36 |
state: present |
| 37 |
register: create_result |
| 38 |
|
| 39 |
- assert: |
| 40 |
that: |
| 41 |
- create_result.changed == True |
| 42 |
- create_result.response.domain.domain_name == api_gateway_domain_name |
| 43 |
- create_result.response.domain.distribution_domain_name is defined |
| 44 |
- create_result.response.domain.distribution_hosted_zone_id is defined |
| 45 |
- create_result.response.path_mappings is defined |
| 46 |
|
| 47 |
- name: Idempotence Test - API gateway custom domain setup |
| 48 |
api_gateway_domain: |
| 49 |
domain_name: "{{ api_gateway_domain_name }}" |
| 50 |
certificate_arn: "{{ api_gateway_domain_tls_arn }}" |
| 51 |
security_policy: 'TLS_1_0' |
| 52 |
endpoint_type: EDGE |
| 53 |
domain_mappings: |
| 54 |
- { rest_api_id: "{{ api_gateway_result.api_id }}", stage: test } |
| 55 |
state: present |
| 56 |
register: repeat_result |
| 57 |
|
| 58 |
- assert: |
| 59 |
that: |
| 60 |
- repeat_result.changed == False |
| 61 |
- repeat_result.failed == False |
| 62 |
- repeat_result.response.domain_name == api_gateway_domain_name |
| 63 |
|
| 64 |
- name: Update Test - API gateway custom domain setup, change settings |
| 65 |
api_gateway_domain: |
| 66 |
domain_name: "{{ api_gateway_domain_name }}" |
| 67 |
certificate_arn: "{{ api_gateway_domain_tls_arn }}" |
| 68 |
security_policy: 'TLS_1_2' |
| 69 |
endpoint_type: REGIONAL |
| 70 |
domain_mappings: |
| 71 |
- { base_path: v1, rest_api_id: "{{ api_gateway_result.api_id }}", stage: test } |
| 72 |
state: present |
| 73 |
register: update_result |
| 74 |
|
| 75 |
- assert: |
| 76 |
that: |
| 77 |
- update_result.changed == True |
| 78 |
- update_result.response.domain.domain_name == api_gateway_domain_name |
| 79 |
- update_result.response.domain.security_policy == 'TLS_1_2' |
| 80 |
- update_result.response.domain.endpoint_configuration.types.0 == 'REGIONAL' |
| 81 |
- update_result.response.path_mappings.0.base_path = '/v1' |
| 82 |
|
| 83 |
- name: Delete - API gateway custom domain setup deletion |
| 84 |
api_gateway_domain: |
| 85 |
domain_name: "{{ api_gateway_domain_name }}" |
| 86 |
certificate_arn: "{{ api_gateway_domain_tls_arn }}" |
| 87 |
security_policy: 'TLS_1_2' |
| 88 |
endpoint_type: REGIONAL |
| 89 |
domain_mappings: |
| 90 |
- { base_path: v1, rest_api_id: "{{ api_gateway_result.api_id }}", stage: test } |
| 91 |
state: absent |
| 92 |
register: delete_result |
| 93 |
|
| 94 |
- assert: |
| 95 |
that: |
| 96 |
- delete_result.changed == True |
| 97 |
- delete_result.response_metadata.http_status_code == 202 |
| 98 |
|
| 99 |
# ==================== cleanup ======================= |
| 100 |
|
| 101 |
always: |
| 102 |
|
| 103 |
- name: Cleanup - delete test domain setup |
| 104 |
api_gateway_domain: |
| 105 |
domain_name: "{{ api_gateway_domain_name }}" |
| 106 |
certificate_arn: "{{ api_gateway_domain_tls_arn }}" |
| 107 |
domain_mappings: [] |
| 108 |
state: absent |
| 109 |
ignore_errors: true |
| 110 |
|
| 111 |
- name: Cleanup - remove REST API Gateway on AWS API Gateway service |
| 112 |
api_gateway: |
| 113 |
api_id: "{{ api_gateway_result.api_id }}" |
| 114 |
swagger_file: files/api_gw_swagger.yml |
| 115 |
state: absent |