From 4cb7151a89973f9d86e4acde67e1addfdba0b660 Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Wed, 9 Oct 2024 19:16:16 +0530 Subject: [PATCH] Updated test cases and added terraform scripts Signed-off-by: balasubramanian-s --- README.md | 1 + docs/resources/google_data_fusion_instance.md | 43 +++++++++---------- .../resources/google_data_fusion_instances.md | 2 +- libraries/google_data_fusion_instance.rb | 4 +- libraries/google_data_fusion_instances.rb | 2 +- test/integration/build/gcp-mm.tf | 10 +++++ .../configuration/mm-attributes.yml | 5 +++ .../controls/google_data_fusion_instance.rb | 38 ++++++++-------- .../controls/google_data_fusion_instances.rb | 26 +++++++---- 9 files changed, 79 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 86d56db9..ae9e214f 100644 --- a/README.md +++ b/README.md @@ -292,6 +292,7 @@ The following resources are available in the InSpec GCP Profile | [google_container_cluster](docs/resources/google_container_cluster.md) | [google_container_clusters](docs/resources/google_container_clusters.md) | | [google_container_node_pool](docs/resources/google_container_node_pool.md) | [google_container_node_pools](docs/resources/google_container_node_pools.md) | | [google_container_server_config](docs/resources/google_container_server_config.md) | No Plural Resource | +| [google_data_fusion_instance](docs/resources/google_data_fusion_instance.md) | [google_data_fusion_instances](docs/resources/google_data_fusion_instances.md) | | [google_dataflow_project_location_job](docs/resources/google_dataflow_project_location_job.md) | [google_dataflow_project_location_jobs](docs/resources/google_dataflow_project_location_jobs.md) | | [google_dataproc_autoscaling_policy](docs/resources/google_dataproc_autoscaling_policy.md) | [google_dataproc_autoscaling_policies](docs/resources/google_dataproc_autoscaling_policies.md) | | [google_dataproc_cluster](docs/resources/google_dataproc_cluster.md) | [google_dataproc_clusters](docs/resources/google_dataproc_clusters.md) | diff --git a/docs/resources/google_data_fusion_instance.md b/docs/resources/google_data_fusion_instance.md index 45c4982f..b1f9d524 100644 --- a/docs/resources/google_data_fusion_instance.md +++ b/docs/resources/google_data_fusion_instance.md @@ -23,28 +23,27 @@ A `google_data_fusion_instance` is used to test a Google Instance resource ## Examples ``` -describe google_data_fusion_instance(name: ' inspec-instance') do +describe google_data_fusion_instance(name: 'projects/*/locations/*/instances/inspec-instance') do it { should exist } its('name') { should cmp 'inspec-instance' } - its('description') { should cmp '' } - its('type') { should cmp '' } - its('create_time') { should cmp '' } - its('update_time') { should cmp '' } - its('state') { should cmp '' } - its('state_message') { should cmp '' } - its('service_endpoint') { should cmp '' } - its('zone') { should cmp '' } - its('version') { should cmp '' } - its('service_account') { should cmp '' } - its('display_name') { should cmp '' } - its('api_endpoint') { should cmp '' } - its('gcs_bucket') { should cmp '' } - its('p4service_account') { should cmp '' } - its('tenant_project_id') { should cmp '' } - its('dataproc_service_account') { should cmp '' } - its('workforce_identity_service_endpoint') { should cmp '' } - its('patch_revision') { should cmp '' } - + its('description') { should cmp 'value_description' } + its('type') { should cmp 'value_type' } + its('create_time') { should cmp 'value_create_time' } + its('update_time') { should cmp 'value_update_time' } + its('state') { should cmp 'value_state' } + its('state_message') { should cmp 'value_state_message' } + its('service_endpoint') { should cmp 'value_service_endpoint' } + its('zone') { should cmp 'value_zone' } + its('version') { should cmp 'value_version' } + its('service_account') { should cmp 'value_service_account' } + its('display_name') { should cmp 'value_display_name' } + its('api_endpoint') { should cmp 'value_api_endpoint' } + its('gcs_bucket') { should cmp 'value_gcs_bucket' } + its('p4service_account') { should cmp 'value_p4service_account' } + its('tenant_project_id') { should cmp 'value_tenant_project_id' } + its('dataproc_service_account') { should cmp 'value_dataproc_service_account' } + its('workforce_identity_service_endpoint') { should cmp 'value_workforce_identity_service_endpoint' } + its('patch_revision') { should cmp 'value_patch_revision' } end describe google_data_fusion_instance(name: "does_not_exit") do @@ -98,11 +97,11 @@ Properties that can be accessed from the `google_data_fusion_instance` resource: * `labels`: The resource labels for instance to use to annotate any related underlying resources such as Compute Engine VMs. The character '=' is not allowed to be used within the labels. - * `additional_properties`: + * `additional_properties`: * `options`: Map of additional options used to configure the behavior of Data Fusion instance. - * `additional_properties`: + * `additional_properties`: * `create_time`: Output only. The time the instance was created. diff --git a/docs/resources/google_data_fusion_instances.md b/docs/resources/google_data_fusion_instances.md index 586ce8b1..1027b56c 100644 --- a/docs/resources/google_data_fusion_instances.md +++ b/docs/resources/google_data_fusion_instances.md @@ -23,7 +23,7 @@ A `google_data_fusion_instances` is used to test a Google Instance resource ## Examples ``` - describe google_data_fusion_instances(parent: ' ') do + describe google_data_fusion_instances(parent: 'projects/*/locations/*') do it { should exist } end ``` diff --git a/libraries/google_data_fusion_instance.rb b/libraries/google_data_fusion_instance.rb index def1864d..7d4fb62c 100644 --- a/libraries/google_data_fusion_instance.rb +++ b/libraries/google_data_fusion_instance.rb @@ -121,7 +121,7 @@ def exists? end def to_s - "Instance #{@params[:]}" + "Instance #{@params[:name]}" end private @@ -131,6 +131,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+name}}' + '{{name}}' end end diff --git a/libraries/google_data_fusion_instances.rb b/libraries/google_data_fusion_instances.rb index 9e1a8a0f..d0d28656 100644 --- a/libraries/google_data_fusion_instances.rb +++ b/libraries/google_data_fusion_instances.rb @@ -142,6 +142,6 @@ def product_url(_ = nil) end def resource_base_url - '{{+parent}}/instances' + '{{parent}}/instances' end end diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 0c3e237b..385a181d 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -263,6 +263,9 @@ variable "dataproc_metastore_service" { variable "dataproc_metastore_federation" { type = any } +variable "data_fusion_instance" { + type = any +} resource "google_compute_ssl_policy" "custom-ssl-policy" { name = var.ssl_policy["name"] @@ -2218,3 +2221,10 @@ resource "google_dataproc_metastore_federation" "inspec-federation" { metastore_type = var.dataproc_metastore_service.metastore_type } } + +resource "google_data_fusion_instance" "data_fusion_instance" { + project = var.gcp_project_id + name = var.data_fusion_instance.name + region = var.data_fusion_instance.location + type = var.data_fusion_instance.type +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index 960b4963..538260f1 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -740,3 +740,8 @@ apigee_instance_attachment: description: "InSpec Apigee Instances" parent : "organizations/ppradhan" api_proxy_type : "PROGRAMMABLE" + +data_fusion_instance: + name: "inspec-instance" + location: "us-central1" + type: "DEVELOPER" diff --git a/test/integration/verify/controls/google_data_fusion_instance.rb b/test/integration/verify/controls/google_data_fusion_instance.rb index a0e0ff38..be0259e9 100644 --- a/test/integration/verify/controls/google_data_fusion_instance.rb +++ b/test/integration/verify/controls/google_data_fusion_instance.rb @@ -17,14 +17,22 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') instance = input('instance', value: { - "name": "inspec-instance", - "machine_type": "n1-standard-1", - "tag_1": "foo", - "tag_2": "bar", - "metadata_key": "123", - "metadata_value": "asdf", - "sa_scope": "https://www.googleapis.com/auth/compute.readonly", - "startup_script": "echo hi > /test.txt" + "name": "projects/ppradhan/locations/us-central1/instances/inspec-instance", + "parent": "projects/ppradhan/locations/us-central1", + "type": "DEVELOPER", + "state": "ACTIVE", + "create_time": "2024-10-09T12:34:49.544484250Z", + "update_time": "2024-10-09T12:53:56.928042766Z", + "version": "6.10.1", + "service_account": "cloud-datafusion-management-sa@b0ed40f9567706323-tp.iam.gserviceaccount.com", + "p4_service_account": "service-165434197229@gcp-sa-datafusion.iam.gserviceaccount.com", + "serviceEndpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.googleusercontent.com", + "zone": "us-central1-c", + "api_endpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.googleusercontent.com/api", + "gcs_bucket": "gs://df-1770363587862806578-7atlcp4ghmi67nkzaizbbqaaaa", + "tenant_project_id": "b0ed40f9567706323-tp", + "workforce_identity_service_endpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.byoid.googleusercontent.com.", + "patch_revision": "6.10.1.1" }, description: 'instance description') control 'google_data_fusion_instance-1.0' do impact 1.0 @@ -38,20 +46,16 @@ its('create_time') { should cmp instance['create_time'] } its('update_time') { should cmp instance['update_time'] } its('state') { should cmp instance['state'] } - its('state_message') { should cmp instance['state_message'] } - its('service_endpoint') { should cmp instance['service_endpoint'] } - its('zone') { should cmp instance['zone'] } - its('version') { should cmp instance['version'] } its('service_account') { should cmp instance['service_account'] } - its('display_name') { should cmp instance['display_name'] } - its('api_endpoint') { should cmp instance['api_endpoint'] } - its('gcs_bucket') { should cmp instance['gcs_bucket'] } - its('p4service_account') { should cmp instance['p4service_account'] } + its('p4_service_account') { should cmp instance['p4_service_account'] } its('tenant_project_id') { should cmp instance['tenant_project_id'] } its('dataproc_service_account') { should cmp instance['dataproc_service_account'] } its('workforce_identity_service_endpoint') { should cmp instance['workforce_identity_service_endpoint'] } its('patch_revision') { should cmp instance['patch_revision'] } - + its('tenant_project_id') { should cmp instance['tenant_project_id'] } + its('api_endpoint') { should cmp instance['api_endpoint'] } + its('gcs_bucket') { should cmp instance['gcs_bucket'] } + its('zone') { should cmp instance['zone'] } end describe google_data_fusion_instance(name: "does_not_exit") do diff --git a/test/integration/verify/controls/google_data_fusion_instances.rb b/test/integration/verify/controls/google_data_fusion_instances.rb index 4222388a..a03bd75c 100644 --- a/test/integration/verify/controls/google_data_fusion_instances.rb +++ b/test/integration/verify/controls/google_data_fusion_instances.rb @@ -17,20 +17,28 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') instance = input('instance', value: { - "name": "inspec-instance", - "machine_type": "n1-standard-1", - "tag_1": "foo", - "tag_2": "bar", - "metadata_key": "123", - "metadata_value": "asdf", - "sa_scope": "https://www.googleapis.com/auth/compute.readonly", - "startup_script": "echo hi > /test.txt" + "name": "projects/ppradhan/locations/us-central1/instances/inspec-instance", + "parent": "projects/ppradhan/locations/us-central1", + "type": "DEVELOPER", + "state": "ACTIVE", + "create_time": "2024-10-09T12:34:49.544484250Z", + "update_time": "2024-10-09T12:53:56.928042766Z", + "version": "6.10.1", + "service_account": "cloud-datafusion-management-sa@b0ed40f9567706323-tp.iam.gserviceaccount.com", + "p4_service_account": "service-165434197229@gcp-sa-datafusion.iam.gserviceaccount.com", + "serviceEndpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.googleusercontent.com", + "zone": "us-central1-c", + "api_endpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.googleusercontent.com/api", + "gcs_bucket": "gs://df-1770363587862806578-7atlcp4ghmi67nkzaizbbqaaaa", + "tenant_project_id": "b0ed40f9567706323-tp", + "workforce_identity_service_endpoint": "https://inspec-instance-ppradhan-dot-usc1.datafusion.byoid.googleusercontent.com.", + "patch_revision": "6.10.1.1" }, description: 'instance description') control 'google_data_fusion_instances-1.0' do impact 1.0 title 'google_data_fusion_instances resource test' - describe google_data_fusion_instances(parent: instance['parent']) do + describe google_data_fusion_instances(parent: instance['parent']) do it { should exist } end end