Skip to content

Commit

Permalink
Updated test cases and added terraform scripts
Browse files Browse the repository at this point in the history
Signed-off-by: balasubramanian-s <[email protected]>
  • Loading branch information
balasubramanian-s committed Oct 9, 2024
1 parent 476ea64 commit 4cb7151
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 52 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
43 changes: 21 additions & 22 deletions docs/resources/google_data_fusion_instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/resources/google_data_fusion_instances.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
4 changes: 2 additions & 2 deletions libraries/google_data_fusion_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def exists?
end

def to_s
"Instance #{@params[:]}"
"Instance #{@params[:name]}"
end

private
Expand All @@ -131,6 +131,6 @@ def product_url(_ = nil)
end

def resource_base_url
'{{+name}}'
'{{name}}'
end
end
2 changes: 1 addition & 1 deletion libraries/google_data_fusion_instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,6 @@ def product_url(_ = nil)
end

def resource_base_url
'{{+parent}}/instances'
'{{parent}}/instances'
end
end
10 changes: 10 additions & 0 deletions test/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
}
5 changes: 5 additions & 0 deletions test/integration/configuration/mm-attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
38 changes: 21 additions & 17 deletions test/integration/verify/controls/google_data_fusion_instance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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
Expand All @@ -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
Expand Down
26 changes: 17 additions & 9 deletions test/integration/verify/controls/google_data_fusion_instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
"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

0 comments on commit 4cb7151

Please sign in to comment.