From 24201fcda011ce42b7a26b24be5c21772730c2e8 Mon Sep 17 00:00:00 2001 From: Samir Anand Date: Wed, 29 Nov 2023 23:23:22 +0530 Subject: [PATCH 1/5] Automatically generated by magic modules for service: compute and resource: VpnGateway. This commit includes the following changes: - Singular Resource - Plural Resource - Documentation updates - Terraform configuration - Integration tests Signed-off-by: Samir Anand --- .../configuration/mm-attributes.yml | 15 ++- docs/resources/google_compute_vpn_gateway.md | 73 +++++++++++++ docs/resources/google_compute_vpn_gateways.md | 39 +++++++ .../compute/property/vpngateway_labels.rb | 34 ++++++ .../property/vpngateway_vpn_interfaces.rb | 48 +++++++++ libraries/google_compute_vpn_gateway.rb | 79 ++++++++++++++ libraries/google_compute_vpn_gateways.rb | 101 ++++++++++++++++++ .../controls/google_compute_vpn_gateway.rb | 55 ++++++++++ .../controls/google_compute_vpn_gateways.rb | 40 +++++++ 9 files changed, 483 insertions(+), 1 deletion(-) create mode 100644 docs/resources/google_compute_vpn_gateway.md create mode 100644 docs/resources/google_compute_vpn_gateways.md create mode 100644 libraries/google/compute/property/vpngateway_labels.rb create mode 100644 libraries/google/compute/property/vpngateway_vpn_interfaces.rb create mode 100644 libraries/google_compute_vpn_gateway.rb create mode 100644 libraries/google_compute_vpn_gateways.rb create mode 100644 test/integration/verify/controls/google_compute_vpn_gateway.rb create mode 100644 test/integration/verify/controls/google_compute_vpn_gateways.rb diff --git a/build/inspec/test/integration/configuration/mm-attributes.yml b/build/inspec/test/integration/configuration/mm-attributes.yml index eab23d3ea..ee0783a9e 100644 --- a/build/inspec/test/integration/configuration/mm-attributes.yml +++ b/build/inspec/test/integration/configuration/mm-attributes.yml @@ -882,4 +882,17 @@ tensorboard_experiment_run_time_series_resource: value_type : "value_valuetype" project_location_image_version: - parent : "value_parent" \ No newline at end of file + parent : "value_parent" +vpn_gateway: + project : "value_project" + region : "value_region" + vpn_gateway : "value_vpngateway" + kind : "value_kind" + id : "value_id" + creation_timestamp : "value_creationtimestamp" + name : "value_name" + description : "value_description" + network : "value_network" + self_link : "value_selflink" + label_fingerprint : "value_labelfingerprint" + stack_type : "value_stacktype" \ No newline at end of file diff --git a/docs/resources/google_compute_vpn_gateway.md b/docs/resources/google_compute_vpn_gateway.md new file mode 100644 index 000000000..fa153ed43 --- /dev/null +++ b/docs/resources/google_compute_vpn_gateway.md @@ -0,0 +1,73 @@ +--- +title: About the google_compute_vpn_gateway resource +platform: gcp +--- + +## Syntax +A `google_compute_vpn_gateway` is used to test a Google VpnGateway resource + +## Examples +``` +describe google_compute_vpn_gateway(project: 'chef-gcp-inspec', region: ' value_region', vpnGateway: ' ') do + it { should exist } + its('kind') { should cmp 'value_kind' } + its('id') { should cmp 'value_id' } + its('creation_timestamp') { should cmp 'value_creationtimestamp' } + its('name') { should cmp 'value_name' } + its('description') { should cmp 'value_description' } + its('region') { should cmp 'value_region' } + its('network') { should cmp 'value_network' } + its('self_link') { should cmp 'value_selflink' } + its('label_fingerprint') { should cmp 'value_labelfingerprint' } + its('stack_type') { should cmp 'value_stacktype' } + +end + +describe google_compute_vpn_gateway(project: 'chef-gcp-inspec', region: ' value_region', vpnGateway: ' ') do + it { should_not exist } +end +``` + +## Properties +Properties that can be accessed from the `google_compute_vpn_gateway` resource: + + + * `kind`: [Output Only] Type of resource. Always compute#vpnGateway for VPN gateways. + + * `id`: [Output Only] The unique identifier for the resource. This identifier is defined by the server. + + * `creation_timestamp`: [Output Only] Creation timestamp in RFC3339 text format. + + * `name`: Name of the resource. Provided by the client when the resource is created. The name must be 1-63 characters long, and comply with RFC1035. Specifically, the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase letter, and all following characters must be a dash, lowercase letter, or digit, except the last character, which cannot be a dash. + + * `description`: An optional description of this resource. Provide this property when you create the resource. + + * `region`: [Output Only] URL of the region where the VPN gateway resides. + + * `network`: URL of the network to which this VPN gateway is attached. Provided by the client when the VPN gateway is created. + + * `self_link`: [Output Only] Server-defined URL for the resource. + + * `labels`: Labels for this resource. These can only be added or modified by the setLabels method. Each label key/value pair must comply with RFC1035. Label values may be empty. + + * `additional_properties`: + + * `label_fingerprint`: A fingerprint for the labels being applied to this VpnGateway, which is essentially a hash of the labels set used for optimistic locking. The fingerprint is initially generated by Compute Engine and changes after every request to modify or update labels. You must always provide an up-to-date fingerprint hash in order to update or change labels, otherwise the request will fail with error 412 conditionNotMet. To see the latest fingerprint, make a get() request to retrieve a VpnGateway. + + * `vpn_interfaces`: The list of VPN interfaces associated with this VPN gateway. + + * `id`: [Output Only] Numeric identifier for this VPN interface associated with the VPN gateway. + + * `ip_address`: [Output Only] IP address for this VPN interface associated with the VPN gateway. The IP address could be either a regional external IP address or a regional internal IP address. The two IP addresses for a VPN gateway must be all regional external or regional internal IP addresses. There cannot be a mix of regional external IP addresses and regional internal IP addresses. For HA VPN over Cloud Interconnect, the IP addresses for both interfaces could either be regional internal IP addresses or regional external IP addresses. For regular (non HA VPN over Cloud Interconnect) HA VPN tunnels, the IP address must be a regional external IP address. + + * `interconnect_attachment`: URL of the VLAN attachment (interconnectAttachment) resource for this VPN gateway interface. When the value of this field is present, the VPN gateway is used for HA VPN over Cloud Interconnect; all egress or ingress traffic for this VPN gateway interface goes through the specified VLAN attachment resource. + + * `stack_type`: The stack type for this VPN gateway to identify the IP protocols that are enabled. Possible values are: IPV4_ONLY, IPV4_IPV6. If not specified, IPV4_ONLY will be used. + Possible values: + * IPV4_IPV6 + * IPV4_ONLY + + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/docs/resources/google_compute_vpn_gateways.md b/docs/resources/google_compute_vpn_gateways.md new file mode 100644 index 000000000..0affd25e9 --- /dev/null +++ b/docs/resources/google_compute_vpn_gateways.md @@ -0,0 +1,39 @@ +--- +title: About the google_compute_vpn_gateways resource +platform: gcp +--- + +## Syntax +A `google_compute_vpn_gateways` is used to test a Google VpnGateway resource + +## Examples +``` + describe google_compute_vpn_gateways(project: 'chef-gcp-inspec', region: ' value_region') do + it { should exist } + end +``` + +## Properties +Properties that can be accessed from the `google_compute_vpn_gateways` resource: + +See [google_compute_vpn_gateway.md](google_compute_vpn_gateway.md) for more detailed information + * `kinds`: an array of `google_compute_vpn_gateway` kind + * `ids`: an array of `google_compute_vpn_gateway` id + * `creation_timestamps`: an array of `google_compute_vpn_gateway` creation_timestamp + * `names`: an array of `google_compute_vpn_gateway` name + * `descriptions`: an array of `google_compute_vpn_gateway` description + * `regions`: an array of `google_compute_vpn_gateway` region + * `networks`: an array of `google_compute_vpn_gateway` network + * `self_links`: an array of `google_compute_vpn_gateway` self_link + * `labels`: an array of `google_compute_vpn_gateway` labels + * `label_fingerprints`: an array of `google_compute_vpn_gateway` label_fingerprint + * `vpn_interfaces`: an array of `google_compute_vpn_gateway` vpn_interfaces + * `stack_types`: an array of `google_compute_vpn_gateway` stack_type + +## Filter Criteria +This resource supports all of the above properties as filter criteria, which can be used +with `where` as a block or a method. + +## GCP Permissions + +Ensure the [Compute Engine API](https://console.cloud.google.com/apis/library/compute.googleapis.com/) is enabled for the current project. diff --git a/libraries/google/compute/property/vpngateway_labels.rb b/libraries/google/compute/property/vpngateway_labels.rb new file mode 100644 index 000000000..f28c34ae0 --- /dev/null +++ b/libraries/google/compute/property/vpngateway_labels.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Compute + module Property + class VpnGatewayLabels + attr_reader :additional_properties + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @additional_properties = args['additionalProperties'] + end + + def to_s + "#{@parent_identifier} VpnGatewayLabels" + end + end + end + end +end diff --git a/libraries/google/compute/property/vpngateway_vpn_interfaces.rb b/libraries/google/compute/property/vpngateway_vpn_interfaces.rb new file mode 100644 index 000000000..7119879e8 --- /dev/null +++ b/libraries/google/compute/property/vpngateway_vpn_interfaces.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +module GoogleInSpec + module Compute + module Property + class VpnGatewayVpnInterfaces + attr_reader :id + + attr_reader :ip_address + + attr_reader :interconnect_attachment + + def initialize(args = nil, parent_identifier = nil) + return if args.nil? + @parent_identifier = parent_identifier + @id = args['id'] + @ip_address = args['ipAddress'] + @interconnect_attachment = args['interconnectAttachment'] + end + + def to_s + "#{@parent_identifier} VpnGatewayVpnInterfaces" + end + end + + class VpnGatewayVpnInterfacesArray + def self.parse(value, parent_identifier) + return if value.nil? + return VpnGatewayVpnInterfaces.new(value, parent_identifier) unless value.is_a?(::Array) + value.map { |v| VpnGatewayVpnInterfaces.new(v, parent_identifier) } + end + end + end + end +end diff --git a/libraries/google_compute_vpn_gateway.rb b/libraries/google_compute_vpn_gateway.rb new file mode 100644 index 000000000..f9691e6f1 --- /dev/null +++ b/libraries/google_compute_vpn_gateway.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +require 'gcp_backend' +require 'google/compute/property/vpngateway_labels' +require 'google/compute/property/vpngateway_vpn_interfaces' + +# A provider to manage Compute Engine resources. +class ComputeVpnGateway < GcpResourceBase + name 'google_compute_vpn_gateway' + desc 'VpnGateway' + supports platform: 'gcp' + + attr_reader :params + attr_reader :kind + attr_reader :id + attr_reader :creation_timestamp + attr_reader :name + attr_reader :description + attr_reader :region + attr_reader :network + attr_reader :self_link + attr_reader :labels + attr_reader :label_fingerprint + attr_reader :vpn_interfaces + attr_reader :stack_type + + def initialize(params) + super(params.merge({ use_http_transport: true })) + @params = params + @fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get') + parse unless @fetched.nil? + end + + def parse + @kind = @fetched['kind'] + @id = @fetched['id'] + @creation_timestamp = @fetched['creationTimestamp'] + @name = @fetched['name'] + @description = @fetched['description'] + @region = @fetched['region'] + @network = @fetched['network'] + @self_link = @fetched['selfLink'] + @labels = GoogleInSpec::Compute::Property::VpnGatewayLabels.new(@fetched['labels'], to_s) + @label_fingerprint = @fetched['labelFingerprint'] + @vpn_interfaces = GoogleInSpec::Compute::Property::VpnGatewayVpnInterfacesArray.parse(@fetched['vpnInterfaces'], to_s) + @stack_type = @fetched['stackType'] + end + + def exists? + !@fetched.nil? + end + + def to_s + "VpnGateway #{@params[:vpnGateway]}" + end + + private + + def product_url(_ = nil) + 'https://compute.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/vpnGateways/{{vpn_gateway}}' + end +end diff --git a/libraries/google_compute_vpn_gateways.rb b/libraries/google_compute_vpn_gateways.rb new file mode 100644 index 000000000..963cc78d4 --- /dev/null +++ b/libraries/google_compute_vpn_gateways.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: false + +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- +require 'gcp_backend' +class ComputeVpnGateways < GcpResourceBase + name 'google_compute_vpn_gateways' + desc 'VpnGateway plural resource' + supports platform: 'gcp' + + attr_reader :table + + filter_table_config = FilterTable.create + + filter_table_config.add(:kinds, field: :kind) + filter_table_config.add(:ids, field: :id) + filter_table_config.add(:creation_timestamps, field: :creation_timestamp) + filter_table_config.add(:names, field: :name) + filter_table_config.add(:descriptions, field: :description) + filter_table_config.add(:regions, field: :region) + filter_table_config.add(:networks, field: :network) + filter_table_config.add(:self_links, field: :self_link) + filter_table_config.add(:labels, field: :labels) + filter_table_config.add(:label_fingerprints, field: :label_fingerprint) + filter_table_config.add(:vpn_interfaces, field: :vpn_interfaces) + filter_table_config.add(:stack_types, field: :stack_type) + + filter_table_config.connect(self, :table) + + def initialize(params = {}) + super(params.merge({ use_http_transport: true })) + @params = params + @table = fetch_wrapped_resource('vpnGateways') + end + + def fetch_wrapped_resource(wrap_path) + # fetch_resource returns an array of responses (to handle pagination) + result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get') + return if result.nil? + + # Conversion of string -> object hash to symbol -> object hash that InSpec needs + converted = [] + result.each do |response| + next if response.nil? || !response.key?(wrap_path) + response[wrap_path].each do |hash| + hash_with_symbols = {} + hash.each_key do |key| + name, value = transform(key, hash) + hash_with_symbols[name] = value + end + converted.push(hash_with_symbols) + end + end + + converted + end + + def transform(key, value) + return transformers[key].call(value) if transformers.key?(key) + + [key.to_sym, value] + end + + def transformers + { + 'kind' => ->(obj) { return :kind, obj['kind'] }, + 'id' => ->(obj) { return :id, obj['id'] }, + 'creationTimestamp' => ->(obj) { return :creation_timestamp, obj['creationTimestamp'] }, + 'name' => ->(obj) { return :name, obj['name'] }, + 'description' => ->(obj) { return :description, obj['description'] }, + 'region' => ->(obj) { return :region, obj['region'] }, + 'network' => ->(obj) { return :network, obj['network'] }, + 'selfLink' => ->(obj) { return :self_link, obj['selfLink'] }, + 'labels' => ->(obj) { return :labels, GoogleInSpec::Compute::Property::VpnGatewayLabels.new(obj['labels'], to_s) }, + 'labelFingerprint' => ->(obj) { return :label_fingerprint, obj['labelFingerprint'] }, + 'vpnInterfaces' => ->(obj) { return :vpn_interfaces, GoogleInSpec::Compute::Property::VpnGatewayVpnInterfacesArray.parse(obj['vpnInterfaces'], to_s) }, + 'stackType' => ->(obj) { return :stack_type, obj['stackType'] }, + } + end + + private + + def product_url(_ = nil) + 'https://compute.googleapis.com/compute/v1/' + end + + def resource_base_url + 'projects/{{project}}/regions/{{region}}/vpnGateways' + end +end diff --git a/test/integration/verify/controls/google_compute_vpn_gateway.rb b/test/integration/verify/controls/google_compute_vpn_gateway.rb new file mode 100644 index 000000000..aab0eb458 --- /dev/null +++ b/test/integration/verify/controls/google_compute_vpn_gateway.rb @@ -0,0 +1,55 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_compute_vpn_gateway resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + vpn_gateway = input('vpn_gateway', value: { + "project": "value_project", + "region": "value_region", + "vpn_gateway": "value_vpngateway", + "kind": "value_kind", + "id": "value_id", + "creation_timestamp": "value_creationtimestamp", + "name": "value_name", + "description": "value_description", + "network": "value_network", + "self_link": "value_selflink", + "label_fingerprint": "value_labelfingerprint", + "stack_type": "value_stacktype" +}, description: 'vpn_gateway description') +control 'google_compute_vpn_gateway-1.0' do + impact 1.0 + title 'google_compute_vpn_gateway resource test' + + describe google_compute_vpn_gateway(project: gcp_project_id, region: vpn_gateway['region'], vpnGateway: vpn_gateway['vpnGateway']) do + it { should exist } + its('kind') { should cmp vpn_gateway['kind'] } + its('id') { should cmp vpn_gateway['id'] } + its('creation_timestamp') { should cmp vpn_gateway['creation_timestamp'] } + its('name') { should cmp vpn_gateway['name'] } + its('description') { should cmp vpn_gateway['description'] } + its('region') { should cmp vpn_gateway['region'] } + its('network') { should cmp vpn_gateway['network'] } + its('self_link') { should cmp vpn_gateway['self_link'] } + its('label_fingerprint') { should cmp vpn_gateway['label_fingerprint'] } + its('stack_type') { should cmp vpn_gateway['stack_type'] } + + end + + describe google_compute_vpn_gateway(project: gcp_project_id, region: vpn_gateway['region'], vpnGateway: vpn_gateway['vpnGateway']) do + it { should_not exist } + end +end diff --git a/test/integration/verify/controls/google_compute_vpn_gateways.rb b/test/integration/verify/controls/google_compute_vpn_gateways.rb new file mode 100644 index 000000000..8f9052e0b --- /dev/null +++ b/test/integration/verify/controls/google_compute_vpn_gateways.rb @@ -0,0 +1,40 @@ +# ---------------------------------------------------------------------------- +# +# *** AUTO GENERATED CODE *** Type: MMv1 *** +# +# ---------------------------------------------------------------------------- +# +# This file is automatically generated by Magic Modules and manual +# changes will be clobbered when the file is regenerated. +# +# Please read more about how to change this file in README.md and +# CONTRIBUTING.md located at the root of this package. +# +# ---------------------------------------------------------------------------- + +title 'Test GCP google_compute_vpn_gateways resource.' + +gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') + + vpn_gateway = input('vpn_gateway', value: { + "project": "value_project", + "region": "value_region", + "vpn_gateway": "value_vpngateway", + "kind": "value_kind", + "id": "value_id", + "creation_timestamp": "value_creationtimestamp", + "name": "value_name", + "description": "value_description", + "network": "value_network", + "self_link": "value_selflink", + "label_fingerprint": "value_labelfingerprint", + "stack_type": "value_stacktype" +}, description: 'vpn_gateway description') +control 'google_compute_vpn_gateways-1.0' do + impact 1.0 + title 'google_compute_vpn_gateways resource test' + + describe google_compute_vpn_gateways(project: gcp_project_id, region: vpn_gateway['region']) do + it { should exist } + end +end From e5be6044f11fe852752849dd274aa4996431639a Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Tue, 12 Dec 2023 20:00:32 +0530 Subject: [PATCH 2/5] add terraform scripts Signed-off-by: balasubramanian-s --- libraries/google_compute_vpn_gateways.rb | 2 +- test/integration/build/gcp-mm.tf | 15 ++++++++++++++- test/integration/configuration/mm-attributes.yml | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/libraries/google_compute_vpn_gateways.rb b/libraries/google_compute_vpn_gateways.rb index 963cc78d4..3c167619a 100644 --- a/libraries/google_compute_vpn_gateways.rb +++ b/libraries/google_compute_vpn_gateways.rb @@ -41,7 +41,7 @@ class ComputeVpnGateways < GcpResourceBase def initialize(params = {}) super(params.merge({ use_http_transport: true })) @params = params - @table = fetch_wrapped_resource('vpnGateways') + @table = fetch_wrapped_resource('items') end def fetch_wrapped_resource(wrap_path) diff --git a/test/integration/build/gcp-mm.tf b/test/integration/build/gcp-mm.tf index 748179b4c..8e5b69e61 100644 --- a/test/integration/build/gcp-mm.tf +++ b/test/integration/build/gcp-mm.tf @@ -215,7 +215,9 @@ variable "spannerdatabase" { variable "scheduler_job" { type = any } - +variable "vpn_gateway" { + type = any +} resource "google_compute_ssl_policy" "custom-ssl-policy" { name = var.ssl_policy["name"] @@ -1552,3 +1554,14 @@ resource "google_vertex_ai_index" "index" { } index_update_method = "STREAM_UPDATE" } +resource "google_compute_ha_vpn_gateway" "ha_vpn_gateway" { + project = var.vpn_gateway.project + region = var.vpn_gateway.region + name = var.vpn_gateway.name + network = google_compute_network.network1.id +} +resource "google_compute_network" "network1" { + project = var.vpn_gateway.project + name = "network1" + auto_create_subnetworks = false +} diff --git a/test/integration/configuration/mm-attributes.yml b/test/integration/configuration/mm-attributes.yml index db5c85cba..91568c5d9 100644 --- a/test/integration/configuration/mm-attributes.yml +++ b/test/integration/configuration/mm-attributes.yml @@ -557,3 +557,17 @@ dlp: name: "dlp-template-inspec" location: "europe-west2" type: "Infotype" + +vpn_gateway: + project : "ppradhan" + region : "us-central1" + vpn_gateway : "4406948336461056012" + kind : "value_kind" + id : "value_id" + creation_timestamp : "value_creationtimestamp" + name : "inspec-vpn-gateway" + description : "Inspec Test HA VPN Gateway" + network : "gcp-inspec-network" + self_link : "value_selflink" + label_fingerprint : "value_labelfingerprint" + stack_type : "IPV4_ONLY" From e83799ef77c64ea6a80308584c34e842fdb4584a Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Tue, 12 Dec 2023 20:58:08 +0530 Subject: [PATCH 3/5] update attributes Signed-off-by: balasubramanian-s --- .../controls/google_compute_vpn_gateway.rb | 16 ++++++++-------- .../controls/google_compute_vpn_gateways.rb | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/integration/verify/controls/google_compute_vpn_gateway.rb b/test/integration/verify/controls/google_compute_vpn_gateway.rb index aab0eb458..54e1405bd 100644 --- a/test/integration/verify/controls/google_compute_vpn_gateway.rb +++ b/test/integration/verify/controls/google_compute_vpn_gateway.rb @@ -17,18 +17,18 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') vpn_gateway = input('vpn_gateway', value: { - "project": "value_project", - "region": "value_region", - "vpn_gateway": "value_vpngateway", + "project": "ppradhan", + "region": "us-central1", + "vpn_gateway": "2245103640699591658", "kind": "value_kind", - "id": "value_id", - "creation_timestamp": "value_creationtimestamp", - "name": "value_name", + "id": "2245103640699591658", + "creation_timestamp": "2023-12-12T05:49:57.914-08:00", + "name": "inspec-vpn-gateway", "description": "value_description", - "network": "value_network", + "network": "https://www.googleapis.com/compute/v1/projects/ppradhan/global/networks/network1", "self_link": "value_selflink", "label_fingerprint": "value_labelfingerprint", - "stack_type": "value_stacktype" + "stack_type": "IPV4_ONLY" }, description: 'vpn_gateway description') control 'google_compute_vpn_gateway-1.0' do impact 1.0 diff --git a/test/integration/verify/controls/google_compute_vpn_gateways.rb b/test/integration/verify/controls/google_compute_vpn_gateways.rb index 8f9052e0b..bc52719c0 100644 --- a/test/integration/verify/controls/google_compute_vpn_gateways.rb +++ b/test/integration/verify/controls/google_compute_vpn_gateways.rb @@ -17,18 +17,18 @@ gcp_project_id = input(:gcp_project_id, value: 'gcp_project_id', description: 'The GCP project identifier.') vpn_gateway = input('vpn_gateway', value: { - "project": "value_project", - "region": "value_region", - "vpn_gateway": "value_vpngateway", + "project": "ppradhan", + "region": "us-central1", + "vpn_gateway": "2245103640699591658", "kind": "value_kind", - "id": "value_id", - "creation_timestamp": "value_creationtimestamp", - "name": "value_name", + "id": "2245103640699591658", + "creation_timestamp": "2023-12-12T05:49:57.914-08:00", + "name": "inspec-vpn-gateway", "description": "value_description", - "network": "value_network", + "network": "https://www.googleapis.com/compute/v1/projects/ppradhan/global/networks/network1", "self_link": "value_selflink", "label_fingerprint": "value_labelfingerprint", - "stack_type": "value_stacktype" + "stack_type": "IPV4_ONLY" }, description: 'vpn_gateway description') control 'google_compute_vpn_gateways-1.0' do impact 1.0 From fb8414f5d1044106b3e1c58e76ba516857c31a97 Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Tue, 12 Dec 2023 21:02:43 +0530 Subject: [PATCH 4/5] remove duplicate file Signed-off-by: balasubramanian-s --- build/inspec/test/integration/configuration/mm-attributes.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 build/inspec/test/integration/configuration/mm-attributes.yml diff --git a/build/inspec/test/integration/configuration/mm-attributes.yml b/build/inspec/test/integration/configuration/mm-attributes.yml deleted file mode 100644 index e69de29bb..000000000 From dec22a4954c70c1b9f4aaff26dff5a98e9e55923 Mon Sep 17 00:00:00 2001 From: balasubramanian-s Date: Tue, 12 Dec 2023 21:04:54 +0530 Subject: [PATCH 5/5] fix linting issues Signed-off-by: balasubramanian-s --- libraries/google_compute_vpn_gateways.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libraries/google_compute_vpn_gateways.rb b/libraries/google_compute_vpn_gateways.rb index 3c167619a..cc49c72cf 100644 --- a/libraries/google_compute_vpn_gateways.rb +++ b/libraries/google_compute_vpn_gateways.rb @@ -74,18 +74,18 @@ def transform(key, value) def transformers { - 'kind' => ->(obj) { return :kind, obj['kind'] }, - 'id' => ->(obj) { return :id, obj['id'] }, - 'creationTimestamp' => ->(obj) { return :creation_timestamp, obj['creationTimestamp'] }, - 'name' => ->(obj) { return :name, obj['name'] }, - 'description' => ->(obj) { return :description, obj['description'] }, - 'region' => ->(obj) { return :region, obj['region'] }, - 'network' => ->(obj) { return :network, obj['network'] }, - 'selfLink' => ->(obj) { return :self_link, obj['selfLink'] }, - 'labels' => ->(obj) { return :labels, GoogleInSpec::Compute::Property::VpnGatewayLabels.new(obj['labels'], to_s) }, - 'labelFingerprint' => ->(obj) { return :label_fingerprint, obj['labelFingerprint'] }, - 'vpnInterfaces' => ->(obj) { return :vpn_interfaces, GoogleInSpec::Compute::Property::VpnGatewayVpnInterfacesArray.parse(obj['vpnInterfaces'], to_s) }, - 'stackType' => ->(obj) { return :stack_type, obj['stackType'] }, + 'kind' => ->(obj) { [:kind, obj['kind']] }, + 'id' => ->(obj) { [:id, obj['id']] }, + 'creationTimestamp' => ->(obj) { [:creation_timestamp, obj['creationTimestamp']] }, + 'name' => ->(obj) { [:name, obj['name']] }, + 'description' => ->(obj) { [:description, obj['description']] }, + 'region' => ->(obj) { [:region, obj['region']] }, + 'network' => ->(obj) { [:network, obj['network']] }, + 'selfLink' => ->(obj) { [:self_link, obj['selfLink']] }, + 'labels' => ->(obj) { [:labels, GoogleInSpec::Compute::Property::VpnGatewayLabels.new(obj['labels'], to_s)] }, + 'labelFingerprint' => ->(obj) { [:label_fingerprint, obj['labelFingerprint']] }, + 'vpnInterfaces' => ->(obj) { [:vpn_interfaces, GoogleInSpec::Compute::Property::VpnGatewayVpnInterfacesArray.parse(obj['vpnInterfaces'], to_s)] }, + 'stackType' => ->(obj) { [:stack_type, obj['stackType']] }, } end