# ----------------------------------------------------------------------------
#
#     ***     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_sql_ssl_cert resource.'

gcp_project_id = attribute(:gcp_project_id, default: 'gcp_project_id', description: 'The GCP project identifier.')
sql_connect = attribute('sql_connect', default: {
  "region": "us-central1",
  "database_version": "POSTGRES_13",
  "backend_type": "SECOND_GEN",
  "cert_serial_number": 0,
  "common_name": "C=US,O=Google\\, Inc,CN=Google Cloud SQL Server CA,dnQualifier=68c79386-b63e-4998-8254-ba59729cdf78",
  "sha1_fingerprint": "80c5c611c0a591db967c7dda3467e23127288fed",
  "instance": "test-pg"
}, description: 'Sql connect settings about a Cloud SQL instance')

control 'google_sql_ssl_cert-1.0' do
  impact 1.0
  title 'google_sql_ssl_cert resource test'

  describe google_sql_ssl_cert(project: gcp_project_id, instance: sql_connect['instance'], sha1_fingerprint:  sql_connect['sha1_fingerprint']) do
    it { should exist }
    its('instance') { should eq sql_connect['instance'] }
    its('common_name') { should eq sql_connect['common_name'] }
    its('sha1_fingerprint') { should eq sql_connect['sha1_fingerprint'] }
  end

  describe google_sql_ssl_cert(project: gcp_project_id, instance: 'nonexistent', sha1_fingerprint:  sql_connect['sha1_fingerprint']) do
    it { should_not exist }
  end
end
