From 8a86be4093d791ec6946bf08751509f7abff6965 Mon Sep 17 00:00:00 2001 From: Alex Stephen Date: Thu, 11 Apr 2019 23:08:16 +0000 Subject: [PATCH] Generating Inspec Attributes + TF tests from single source Signed-off-by: Modular Magician --- docs/resources/google_compute_ssl_policy.md | 1 + test/integration/build/gcp-mm.tf | 5 ++--- test/integration/configuration/mm-attributes.yml | 13 +++++++------ .../verify/controls/google_compute_ssl_policies.rb | 4 ++-- .../verify/controls/google_compute_ssl_policy.rb | 8 ++++---- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/docs/resources/google_compute_ssl_policy.md b/docs/resources/google_compute_ssl_policy.md index 54043aeb9..5098cf8de 100644 --- a/docs/resources/google_compute_ssl_policy.md +++ b/docs/resources/google_compute_ssl_policy.md @@ -19,6 +19,7 @@ end describe google_compute_ssl_policy(project: 'chef-gcp-inspec', name: 'nonexistent') do it { should_not exist } end + ``` ## Properties diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 81f437f55..27535cd6b 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -137,10 +137,9 @@ 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"]}"] + custom_features = ["${var.ssl_policy["custom_features1"]}","${var.ssl_policy["custom_features2"]}"] project = "${var.gcp_project_id}" } - resource "google_pubsub_topic" "topic" { project = "${var.gcp_project_id}" name = "${var.topic["name"]}" @@ -514,4 +513,4 @@ resource "google_container_node_pool" "inspec-gcp-regional-node-pool" { region = "${var.gcp_location}" cluster = "${google_container_cluster.gcp-inspec-regional-cluster.name}" node_count = "${var.regional_node_pool["node_count"]}" -} \ No newline at end of file +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index 346ed5b9d..6b9bfe30d 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -1,9 +1,10 @@ + 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' + name: inspec-gcp-ssl-policy + min_tls_version: TLS_1_2 + profile: CUSTOM + custom_features1: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 + custom_features2: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 topic: name: 'inspec-gcp-topic' @@ -208,4 +209,4 @@ regional_node_pool: name: inspec-gcp-regional-node-pool cluster_name: inspec-gcp-regional-node-pool-cluster node_count: 1 - initial_node_count: 1 \ No newline at end of file + initial_node_count: 1 diff --git a/test/integration/verify/controls/google_compute_ssl_policies.rb b/test/integration/verify/controls/google_compute_ssl_policies.rb index c185a74cb..c88e0f6ea 100644 --- a/test/integration/verify/controls/google_compute_ssl_policies.rb +++ b/test/integration/verify/controls/google_compute_ssl_policies.rb @@ -19,8 +19,8 @@ "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" + "custom_features1": "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "custom_features2": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" }) control 'google_compute_ssl_policies-1.0' do impact 1.0 diff --git a/test/integration/verify/controls/google_compute_ssl_policy.rb b/test/integration/verify/controls/google_compute_ssl_policy.rb index af6a3b57e..88c64c8a8 100644 --- a/test/integration/verify/controls/google_compute_ssl_policy.rb +++ b/test/integration/verify/controls/google_compute_ssl_policy.rb @@ -19,8 +19,8 @@ "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" + "custom_features1": "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", + "custom_features2": "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" }) control 'google_compute_ssl_policy-1.0' do impact 1.0 @@ -30,8 +30,8 @@ it { should exist } its('min_tls_version') { should eq ssl_policy['min_tls_version'] } its('profile') { should eq ssl_policy['profile'] } - its('custom_features') { should include ssl_policy['custom_feature'] } - its('custom_features') { should include ssl_policy['custom_feature2'] } + its('custom_features') { should include ssl_policy['custom_features1'] } + its('custom_features') { should include ssl_policy['custom_features2'] } end describe google_compute_ssl_policy(project: gcp_project_id, name: 'nonexistent') do