Skip to content

Commit

Permalink
Add some integration tests for aws_service_ip_ranges (#473)
Browse files Browse the repository at this point in the history
Add some integration tests for aws_service_ip_ranges

SUMMARY
Add some integration tests for aws_service_ip_ranges
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
aws_service_ip_ranges
ADDITIONAL INFORMATION
Initial tests to support #430

Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
  • Loading branch information
tremble authored Aug 27, 2021
1 parent fd402ab commit 997a0ef
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cloud/aws
103 changes: 103 additions & 0 deletions tests/integration/targets/lookup_aws_service_ip_ranges/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
- name: lookup range with no arguments
set_fact:
no_params: "{{ lookup('amazon.aws.aws_service_ip_ranges') }}"

- name: assert that we're returned a single string
assert:
that:
- no_params is defined
- no_params is string

- name: lookup range with wantlist
set_fact:
want_list: "{{ lookup('amazon.aws.aws_service_ip_ranges', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- want_list is defined
- want_list is iterable
- want_list is not string
- want_list | length > 1
- want_list[0] | ansible.netcommon.ipv4

- name: lookup range with service
set_fact:
s3_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='S3', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- s3_ips is defined
- s3_ips is iterable
- s3_ips is not string
- s3_ips | length > 1
- s3_ips[0] | ansible.netcommon.ipv4

- name: lookup range with a different service
set_fact:
route53_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', service='ROUTE53_HEALTHCHECKS', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- route53_ips is defined
- route53_ips is iterable
- route53_ips is not string
- route53_ips | length > 1
- route53_ips[0] | ansible.netcommon.ipv4

- name: assert that service IPs don't overlap
assert:
that:
- route53_ips | intersect(s3_ips) | length == 0

- name: lookup range with region
set_fact:
us_east_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- us_east_1_ips is defined
- us_east_1_ips is iterable
- us_east_1_ips is not string
- us_east_1_ips | length > 1
- us_east_1_ips[0] | ansible.netcommon.ipv4

- name: lookup range with a different region
set_fact:
eu_central_1_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='eu-central-1', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- eu_central_1_ips is defined
- eu_central_1_ips is iterable
- eu_central_1_ips is not string
- eu_central_1_ips | length > 1
- eu_central_1_ips[0] | ansible.netcommon.ipv4

- name: assert that regional IPs don't overlap
assert:
that:
- eu_central_1_ips | intersect(us_east_1_ips) | length == 0

- name: lookup range with service and region
set_fact:
s3_us_ips: "{{ lookup('amazon.aws.aws_service_ip_ranges', region='us-east-1', service='S3', wantlist=True) }}"

- name: assert that we're returned a list
assert:
that:
- s3_us_ips is defined
- s3_us_ips is iterable
- s3_us_ips is not string
- s3_us_ips | length > 1
- s3_us_ips[0] | ansible.netcommon.ipv4

- name: assert that the regional service IPs are a subset of the regional IPs and service IPs.
assert:
that:
- ( s3_us_ips | intersect(us_east_1_ips) | length ) == ( s3_us_ips | length )
- ( s3_us_ips | intersect(s3_ips) | length ) == ( s3_us_ips | length )

0 comments on commit 997a0ef

Please sign in to comment.