From b322af08c65fc7f8498cb2c8294fdbda22e57123 Mon Sep 17 00:00:00 2001 From: Stuart Paterson Date: Mon, 30 Jul 2018 14:04:57 +0100 Subject: [PATCH] Update the google_project version as per #39. Also udpate the associated test to explicitly cover both project_id and project_number cases. Signed-off-by: Stuart Paterson --- docs/resources/google_project.md | 13 +++++++++++-- test/integration/verify/controls/gcp_project.rb | 6 ++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/resources/google_project.md b/docs/resources/google_project.md index e9a384019..250a4c6c2 100644 --- a/docs/resources/google_project.md +++ b/docs/resources/google_project.md @@ -5,17 +5,26 @@ platform: gcp # google\_project -Use the `google_project` InSpec audit resource to test properties of a GCP project. +Use the `google_project` InSpec audit resource to test properties of a GCP project.
## Syntax -A `google_project` resource block declares the tests for a single GCP project by name. +Google projects have a name, ID and number as described [here](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects). + +A `google_project` resource block declares the tests for a single GCP project identified by `project_id` or `project_number`: describe google_project(project: 'chef-inspec-gcp') do it { should exist } its('name') { should eq 'chef-inspec-gcp' } + its('project_number') { should eq 12345678 } + end + + describe google_project(project: 12345678) do + it { should exist } + its('name') { should eq 'chef-inspec-gcp' } + its('project_number') { should eq 12345678 } end
diff --git a/test/integration/verify/controls/gcp_project.rb b/test/integration/verify/controls/gcp_project.rb index c59716429..d76a97d3c 100644 --- a/test/integration/verify/controls/gcp_project.rb +++ b/test/integration/verify/controls/gcp_project.rb @@ -16,4 +16,10 @@ its('lifecycle_state') { should eq "ACTIVE" } end + describe google_project(project: gcp_project_number.to_i) do + it { should exist } + its('name') { should eq gcp_project_name } + its('project_number') { should eq gcp_project_number.to_i } + its('lifecycle_state') { should eq "ACTIVE" } + end end