Skip to content

Commit

Permalink
wip: adding tests for outputs in the firewall submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
tfhartmann committed Sep 26, 2019
1 parent 2db128e commit 3dbe020
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,18 @@ suites:
controls:
- gcp
- name: local
attrs_outputs:
customized_inspec_attribute: output_network_name
customized_inspec_attribute: output_network_self_link
customized_inspec_attribute: output_subnets_ips
customized_inspec_attribute: output_routes
customized_inspec_attribute: output_subnets_flow_logs
customized_inspec_attribute: output_subnets_names
customized_inspec_attribute: output_subnets_private_access
customized_inspec_attribute: output_subnets_regions
customized_inspec_attribute: output_subnets_secondary_ranges
customized_inspec_attribute: output_svpc_host_project_id
backend: local
controls:
- gcloud
- inspec_attributes
61 changes: 61 additions & 0 deletions test/integration/submodule_firewall/controls/inspec_attributes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

project_id = attribute('project_id')
network_name = attribute('network_name')

control "inspec_attributes" do
title "Terraform Outputs"
desc "Terraform Outputs"

describe attribute("output_network_name") do
it { should eq "#{network_name}" }
end

describe attribute("output_network_self_link") do
it { should eq "https://www.googleapis.com/compute/v1/projects/#{project_id}/global/networks/#{network_name}" }
end

describe attribute("output_subnets_ips") do
it { should eq ["10.10.10.0/24", "10.10.20.0/24"] }
end

describe attribute("output_routes") do
it { should eq [] }
end

describe attribute("output_subnets_flow_logs") do
it { should eq [false, true] }
end

describe attribute("output_subnets_names") do
it { should eq ["#{network_name}-subnet-01", "#{network_name}-subnet-02"] }
end

describe attribute("output_subnets_private_access") do
it { should eq [false, true] }
end

describe attribute("output_subnets_regions") do
it { should eq ["us-west1", "us-west1"] }
end

describe attribute("output_subnets_secondary_ranges") do
it { should eq [[],[]] }
end

describe attribute("output_svpc_host_project_id") do
it { should eq "" }
end
end
22 changes: 22 additions & 0 deletions test/integration/submodule_firewall/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,25 @@ attributes:
- name: network_name
required: true
type: string
- name: output_network_name
required: true
type: string
- name: output_network_self_link
required: true
type: string
- name: output_subnets_ips
required: true
- name: output_routes
required: true
- name: output_subnets_flow_logs
required: true
- name: output_subnets_names
required: true
- name: output_subnets_private_access
required: true
- name: output_subnets_regions
required: true
- name: output_subnets_secondary_ranges
required: true
- name: output_svpc_host_project_id
required: true

0 comments on commit 3dbe020

Please sign in to comment.