Skip to content

Commit

Permalink
Add test for key types, fix service account keys resource (GoogleClou…
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored and Nathan Klish committed May 18, 2020
1 parent c4ff65c commit 46dabdc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions products/iam/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ objects:
- !ruby/object:Api::Resource
name: 'ServiceAccountKey'
base_url: projects/{{project}}/serviceAccounts/{{service_account}}/keys
collection_url_key: 'keys'
description: |
A service account in the Identity and Access Management API.
parameters:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% gcp_project_id = "#{external_attribute('gcp_project_id', doc_generation)}" -%>
<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%>
google_service_account_keys(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com").key_names.each do |sa_key_name|
describe google_service_account_key(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com", name: sa_key_name) do
describe google_service_account_key(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com", name: sa_key_name.split('/').last) do
it { should exist }
its('key_type') { should_not cmp 'USER_MANAGED' }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<% gcp_service_account_display_name = "#{external_attribute('gcp_service_account_display_name', doc_generation)}" -%>
describe google_service_account_keys(project: <%= gcp_project_id -%>, service_account: "<%= doc_generation ? "display-name" : "\#{gcp_service_account_display_name}" -%>@<%= doc_generation ? "project-id" : "\#{gcp_project_id}" -%>.iam.gserviceaccount.com") do
its('count') { should be <= 1000 }
its('key_types') { should_not include 'USER_MANAGED' }
end
5 changes: 5 additions & 0 deletions templates/inspec/tests/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,11 @@ resource "google_service_account" "spanner_service_account" {
display_name = "${var.gcp_service_account_display_name}-sp"
}

resource "google_service_account_key" "userkey" {
service_account_id = google_service_account.spanner_service_account.name
public_key_type = "TYPE_X509_PEM_FILE"
}

resource "google_spanner_instance" "spanner_instance" {
project = var.gcp_project_id
config = var.spannerinstance["config"]
Expand Down

0 comments on commit 46dabdc

Please sign in to comment.