Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for key types, fix service account keys resource #3452

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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