-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add router support in InSpec (#1332)
Merged PR #1332.
- Loading branch information
1 parent
d56db0a
commit 48af196
Showing
8 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
Submodule inspec
updated
10 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
templates/inspec/examples/attributes/google_compute_router.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
gcp_project_id = attribute(:gcp_project_id, default: '<%= external_attribute('gcp_project_id') -%>', description: 'The GCP project identifier.') | ||
gcp_location = attribute(:gcp_location, default: '<%= external_attribute('gcp_location') -%>', description: 'The GCP project region.') | ||
router = attribute('router', default: <%= JSON.pretty_generate(grab_attributes['router']) -%>, description: 'Compute router description') | ||
gcp_network_name = attribute(:gcp_network_name, default: '<%= external_attribute('gcp_network_name') -%>', description: 'GCP network name') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% router = grab_attributes['router'] -%> | ||
<% gcp_network_name = "#{external_attribute('gcp_network_name', doc_generation)}" -%> | ||
describe google_compute_router(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%>) do | ||
it { should exist } | ||
its('bgp.asn') { should eq <%= doc_generation ? "'#{router['bgp_asn']}'" : "router['bgp_asn']" -%> } | ||
its('bgp.advertise_mode') { should eq <%= doc_generation ? "'#{router['bgp_advertise_mode']}'" : "router['bgp_advertise_mode']" -%> } | ||
its('bgp.advertised_groups') { should include <%= doc_generation ? "'#{router['bgp_advertised_group']}'" : "router['bgp_advertised_group']" -%> } | ||
its('bgp.advertised_ip_ranges.count') { should eq 2 } | ||
its('bgp.advertised_ip_ranges.first.range') { should eq <%= doc_generation ? "'#{router['bgp_advertised_ip_range1']}'" : "router['bgp_advertised_ip_range1']" -%> } | ||
its('bgp.advertised_ip_ranges.last.range') { should eq <%= doc_generation ? "'#{router['bgp_advertised_ip_range1']}'" : "router['bgp_advertised_ip_range2']" -%> } | ||
<% if doc_generation -%> | ||
its('network') { should match /\/<%= "#{gcp_network_name}".gsub('\'', '') -%>$/ } | ||
<% else -%> | ||
its('network') { should match /\/#{gcp_network_name}$/ } | ||
<% end -%> | ||
end | ||
|
||
describe google_compute_router(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>, name: 'nonexistent') do | ||
it { should_not exist } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%> | ||
<% gcp_location = "#{external_attribute('gcp_location', doc_generation)}" -%> | ||
<% router = grab_attributes['router'] -%> | ||
describe google_compute_routers(project: <%= gcp_project_id -%>, region: <%= gcp_location -%>) do | ||
its('names') { should include <%= doc_generation ? "'#{router['name']}'" : "router['name']" -%> } | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters