Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Inspec attribute changes
Browse files Browse the repository at this point in the history
  • Loading branch information
slevenick authored and modular-magician committed Dec 12, 2018
1 parent 10fa4f2 commit 11542aa
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
7 changes: 3 additions & 4 deletions docs/resources/google_compute_ssl_policies.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ A `google_compute_ssl_policies` is used to test a Google SslPolicy resource

## Examples
```
resource = google_compute_ssl_policies({project: 'graphite-test-sam-chef'})
describe resource do
describe google_compute_ssl_policies({project: ''}) do
it { should exist }
its('names') { should include 'inspec-gcp-ssl-policy' }
its('profiles') { should include 'CUSTOM' }
its('count') { should eq 1 }
end
resource.names.each do |policy_name|
describe google_compute_ssl_policy({project: 'graphite-test-sam-chef', name: policy_name}) do
google_compute_ssl_policies({project: ''}).names.each do |policy_name|
describe google_compute_ssl_policy({project: '', name: policy_name}) do
its('min_tls_version') { should cmp 'TLS_1_2' }
end
end
Expand Down
2 changes: 1 addition & 1 deletion docs/resources/google_compute_ssl_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A `google_compute_ssl_policy` is used to test a Google SslPolicy resource

## Examples
```
describe google_compute_ssl_policy({project: 'graphite-test-sam-chef', name: 'inspec-gcp-ssl-policy'}) do
describe google_compute_ssl_policy({project: '', name: 'inspec-gcp-ssl-policy'}) do
it { should exist }
its('min_tls_version') { should cmp 'TLS_1_2' }
its('profile') { should cmp 'CUSTOM' }
Expand Down
2 changes: 1 addition & 1 deletion libraries/google/compute/property/sslpolicy_warnings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module Google
module GoogleInSpec
module Compute
module Property
class SslPolicyWarnings
Expand Down
2 changes: 1 addition & 1 deletion libraries/google_compute_ssl_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def parse
@enabled_features = @fetched['enabledFeatures']
@custom_features = @fetched['customFeatures']
@fingerprint = @fetched['fingerprint']
@warnings = Google::Compute::Property::SslPolicyWarningsArray.parse(@fetched['warnings'])
@warnings = GoogleInSpec::Compute::Property::SslPolicyWarningsArray.parse(@fetched['warnings'])
end

def exists?
Expand Down
33 changes: 33 additions & 0 deletions test/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
variable "ssl_policy" {
type = "map"
}

resource "google_compute_ssl_policy" "custom-ssl-policy" {
name = "${var.ssl_policy["name"]}"
min_tls_version = "${var.ssl_policy["min_tls_version"]}"
profile = "${var.ssl_policy["profile"]}"
custom_features = ["${var.ssl_policy["custom_feature"]}", "${var.ssl_policy["custom_feature2"]}"]
project = "${var.gcp_project_id}"
}

resource "google_service_account" "inspecaccount" {
account_id = "inspec-account"
display_name = "InSpec Service Account"
project = "${var.gcp_project_id}"
}

resource "google_service_account_key" "inspeckey" {
service_account_id = "${google_service_account.inspecaccount.name}"
public_key_type = "TYPE_X509_PEM_FILE"
}

resource "google_project_iam_member" "inspec-iam-member" {
role = "roles/viewer"
member = "serviceAccount:${google_service_account.inspecaccount.email}"
project = "${var.gcp_project_id}"
}

resource "local_file" "file" {
content = "${base64decode(google_service_account_key.inspeckey.private_key)}"
filename = "${path.module}/inspec.json"
}
6 changes: 6 additions & 0 deletions test/integration/configuration/mm-attributes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ssl_policy:
name: 'inspec-gcp-ssl-policy'
min_tls_version: 'TLS_1_2'
profile: 'CUSTOM'
custom_feature: 'TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384'
custom_feature2: 'TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384'
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@

title 'Test GCP google_compute_ssl_policies resource.'

project_name = attribute('project_name', default: 'graphite-test-sam-chef')
project_name = attribute(:gcp_project_name, default: '')
ssl_policy = attribute('ssl_policy', default: {"name"=>"inspec-gcp-ssl-policy", "min_tls_version"=>"TLS_1_2", "profile"=>"CUSTOM", "custom_feature"=>"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "custom_feature2"=>"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"})
control 'google_compute_ssl_policies-1.0' do
impact 1.0
title 'google_compute_ssl_policies resource test'

resource = google_compute_ssl_policies({project: project_name})
describe resource do
describe google_compute_ssl_policies({project: project_name}) do
it { should exist }
its('names') { should include ssl_policy['name'] }
its('profiles') { should include ssl_policy['profile'] }
its('count') { should eq 1 }
end

resource.names.each do |policy_name|
google_compute_ssl_policies({project: project_name}).names.each do |policy_name|
describe google_compute_ssl_policy({project: project_name, name: policy_name}) do
its('min_tls_version') { should cmp ssl_policy['min_tls_version'] }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

title 'Test GCP google_compute_ssl_policy resource.'

project_name = attribute('project_name', default: 'graphite-test-sam-chef')
project_name = attribute(:gcp_project_name, default: '')
ssl_policy = attribute('ssl_policy', default: {"name"=>"inspec-gcp-ssl-policy", "min_tls_version"=>"TLS_1_2", "profile"=>"CUSTOM", "custom_feature"=>"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "custom_feature2"=>"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"})
control 'google_compute_ssl_policy-1.0' do
impact 1.0
Expand Down

0 comments on commit 11542aa

Please sign in to comment.