2018-02-08 01:12:02 +00:00
|
|
|
fixtures = {}
|
|
|
|
[
|
2018-02-26 21:37:36 +00:00
|
|
|
'subnet_01_id',
|
|
|
|
'subnet_vpc_id',
|
2018-02-08 01:12:02 +00:00
|
|
|
].each do |fixture_name|
|
2019-06-10 21:41:23 +00:00
|
|
|
fixtures[fixture_name] = input(
|
2018-02-08 01:12:02 +00:00
|
|
|
fixture_name,
|
|
|
|
default: "default.#{fixture_name}",
|
|
|
|
description: 'See ../build/ec2.tf',
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-02-08 04:23:05 +00:00
|
|
|
control "aws_subnets recall" do
|
|
|
|
all_subnets = aws_subnets
|
2018-02-08 01:12:02 +00:00
|
|
|
|
|
|
|
# You should be able to get a specific subnet given its id
|
2018-02-26 21:37:36 +00:00
|
|
|
describe all_subnets.where(subnet_id: fixtures['subnet_01_id']) do
|
2018-02-08 01:12:02 +00:00
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
|
|
|
|
# You should be able to get subnets given a vpc_id
|
2018-02-26 21:37:36 +00:00
|
|
|
describe all_subnets.where(vpc_id: fixtures['subnet_vpc_id']) do
|
2018-02-08 01:12:02 +00:00
|
|
|
it { should exist }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe all_subnets.where(vpc_id: 'vpc-00000000') do
|
|
|
|
it { should_not exist }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe all_subnets.where(subnet_id: 'subnet-00000000') do
|
|
|
|
it { should_not exist }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-26 21:37:36 +00:00
|
|
|
control "aws_subnets properties by subnet id" do
|
2018-02-08 01:12:02 +00:00
|
|
|
# you should be able to test the cidr_block of a subnet
|
2018-02-26 21:37:36 +00:00
|
|
|
describe aws_subnets.where(subnet_id: fixtures['subnet_01_id']) do
|
2018-09-10 18:38:57 +00:00
|
|
|
its('cidr_blocks') { should include '172.31.48.0/28' }
|
2018-02-08 01:12:02 +00:00
|
|
|
its('states') { should_not include 'pending' }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-26 21:37:36 +00:00
|
|
|
control "aws_subnets properties by vpc_id" do
|
2018-02-08 01:12:02 +00:00
|
|
|
# you should be able to test the cidr_block of a subnet
|
2018-02-26 21:37:36 +00:00
|
|
|
describe aws_subnets.where(vpc_id: fixtures['subnet_vpc_id']) do
|
2018-09-10 18:38:57 +00:00
|
|
|
its('cidr_blocks') { should include '172.31.48.0/28' }
|
2018-02-08 01:12:02 +00:00
|
|
|
its('states') { should include 'available' }
|
|
|
|
end
|
|
|
|
end
|