Skip to content

Commit

Permalink
Adding update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnarayanan committed Dec 13, 2024
1 parent 3593a30 commit 24c628c
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 8 deletions.
5 changes: 4 additions & 1 deletion mmv1/products/developerconnect/Connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ examples:
primary_resource_id: 'my-connection'
primary_resource_name: 'fmt.Sprintf("tf-test-connection%s", context["random_suffix"])'
vars:
connection_name: 'tf-test-connection'
connection_name: 'tf-test-connection'
- name: 'developer_connect_connection_github_doc'
exclude_test: true
- name: 'developer_connect_connection_github_enterprise'
Expand Down Expand Up @@ -189,6 +189,7 @@ properties:
Optional. This checksum is computed by the server based on the value of other
fields, and may be sent on update and delete requests to ensure the
client has an up-to-date value before proceeding.
output: true
- name: uid
type: String
description: Output only. A system-assigned unique identifier for a the GitRepositoryLink.
Expand Down Expand Up @@ -300,11 +301,13 @@ properties:
description: |-
Output only. Message of what the user should do next to continue the installation.
Empty string if the installation is already complete.
output: true
- name: actionUri
type: String
description: |-
Output only. Link to follow for next action. Empty string if the installation is already
complete.
output: true
- name: stage
type: String
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGithubUpdate(t
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -66,6 +66,12 @@ func testAccDeveloperConnectConnection_GithubUpdate(context map[string]interface
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

crypto_key_config {
key_reference = "projects/devconnect-terraform-creds/locations/us-central1/keyRings/tf-keyring/cryptoKeys/tf-crypto-key"
}

github_config {
github_app = "DEVELOPER_CONNECT"
Expand Down Expand Up @@ -98,7 +104,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGithubEnterpris
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels", "ssl_ca_certificate"},
ImportStateVerifyIgnore: []string{"connection_id", "labels", "terraform_labels"},
},
{
Config: testAccDeveloperConnectConnection_GithubEnterpriseUpdate(context),
Expand All @@ -107,7 +113,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGithubEnterpris
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels", "ssl_ca_certificate"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -136,6 +142,12 @@ func testAccDeveloperConnectConnection_GithubEnterpriseUpdate(context map[string
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

crypto_key_config {
key_reference = "projects/devconnect-terraform-creds/locations/us-central1/keyRings/tf-keyring/cryptoKeys/tf-crypto-key"
}

github_enterprise_config {
host_uri = "https://ghe.proctor-staging-test.com"
Expand All @@ -149,6 +161,54 @@ resource "google_developer_connect_connection" "my-connection" {
}


func TestAccDeveloperConnectConnection_GhePrivConnection(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccDeveloperConnectConnection_GhePrivConnection(context),
},
{
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
}


func testAccDeveloperConnectConnection_GhePrivConnection(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

github_enterprise_config {
host_uri = "https://ghe.proctor-private-ca.com"

ssl_ca_certificate = "-----BEGIN CERTIFICATE-----\nMIIEXTCCA0WgAwIBAgIUANaBCc9j/xdKJHU0sgmv6yE2WCIwDQYJKoZIhvcNAQEL\nBQAwLDEUMBIGA1UEChMLUHJvY3RvciBFbmcxFDASBgNVBAMTC1Byb2N0b3ItZW5n\nMB4XDTIxMDcxNTIwMDcwMloXDTIyMDcxNTIwMDcwMVowADCCASIwDQYJKoZIhvcN\nAQEBBQADggEPADCCAQoCggEBAMVel7I88DkhwW445BNPBZvJNTV1AreHdz4um4U1\nop2+4L7JeNrUs5SRc0fzeOyOmA9ZzTDu9hBC7zj/sVNUy6cIQGCj32sr5SCAEIat\nnFZlzmVqJPT4J5NAaE37KO5347myTJEBrvpq8az4CtvX0yUzPK0gbUmaSaztVi4o\ndbJLKyv575xCLC/Hu6fIHBDH19eG1Ath9VpuAOkttRRoxu2VqijJZrGqaS+0o+OX\nrLi5HMtZbZjgQB4mc1g3ZDKX/gynxr+CDNaqNOqxuog33Tl5OcOk9DrR3MInaE7F\nyQFuH9mzF64AqOoTf7Tr/eAIz5XVt8K51nk+fSybEfKVwtMCAwEAAaOCAaEwggGd\nMA4GA1UdDwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdDgQWBBQU/9dYyqMz\nv9rOMwPZcoIRMDAQCjAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz5TAVRmyFfDCB\njQYIKwYBBQUHAQEEgYAwfjB8BggrBgEFBQcwAoZwaHR0cDovL3ByaXZhdGVjYS1j\nb250ZW50LTYxYWEyYzA5LTAwMDAtMjJjMi05ZjYyLWQ0ZjU0N2Y4MDIwMC5zdG9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nO1Yxj/jPSZ67Kdeoy0lEwvc2hL5FQGhIjLMR0mzOyN4fk/DZiA/4tAVi7hJyqpUC\n71JSwp7MwXL1b26CSE1MhcoCqA/E4iZxfJfF/ef4lhmC24UEmu8FEbldoy+6OysB\nRu7dGDwicW5F9h7eSkpGAsCRdJHh65iUx/IH0C4Ux2UZRDZdj6wVbuVu9tb938xF\nyRuVClONoLSn/lwdzeV7hQmBSm8qmfgbNPbYRaNLz3hOpsT+27aDQp2/pxue8hFJ\nd7We3+Lr5O4IL45PBwhVEAiFZqde6d4qViNEB2qTAgMBAAGjYzBhMA4GA1UdDwEB\n/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTkQGTiCkLCmv/Awxdz\n5TAVRmyFfDAfBgNVHSMEGDAWgBTkQGTiCkLCmv/Awxdz5TAVRmyFfDANBgkqhkiG\n9w0BAQsFAAOCAQEAfy5BJsWdx0oWWi7SFg9MbryWjBVPJl93UqACgG0Cgh813O/x\nlDZQhGO/ZFVhHz/WgooE/HgVNoVJTubKLLzz+zCkOB0wa3GMqJDyFjhFmUtd/3VM\nZh0ZQ+JWYsAiZW4VITj5xEn/d/B3xCFWGC1vhvhptEJ8Fo2cE1yM2pzk08NqFWoY\n4FaH0sbxWgyCKwTmtcYDbnx4FYuddryGCIxbYizqUK1dr4DGKeHonhm/d234Ew3x\n3vIBPoHMOfBec/coP1xAf5o+F+MRMO/sQ3tTGgyOH18lwsHo9SmXCrmOwVQPKrEw\nm+A+5TjXLmenyaBhqXa0vkAZYJhWdROhWC0VTA==\n-----END CERTIFICATE-----\n"

service_directory_config {
service = "projects/devconnect-terraform-creds/locations/us-central1/namespaces/my-namespace/services/terraform-github"
}
}

}
`, context)
}


func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabUpdate(t *testing.T) {
t.Parallel()

Expand All @@ -167,7 +227,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabUpdate(t
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
{
Config: testAccDeveloperConnectConnection_GitlabUpdate(context),
Expand All @@ -176,7 +236,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabUpdate(t
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -210,6 +270,12 @@ func testAccDeveloperConnectConnection_GitlabUpdate(context map[string]interface
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

crypto_key_config {
key_reference = "projects/devconnect-terraform-creds/locations/us-central1/keyRings/tf-keyring/cryptoKeys/tf-crypto-key"
}

gitlab_config {
webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-webhook/versions/latest"
Expand All @@ -226,6 +292,64 @@ resource "google_developer_connect_connection" "my-connection" {
`, context)
}

func TestAccDeveloperConnectConnection_GlePrivConnection(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccDeveloperConnectConnection_GlePrivConnection(context),
},
{
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
}


func testAccDeveloperConnectConnection_GlePrivConnection(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

gitlab_enterprise_config {
host_uri = "https://gle-us.gle-us-private.com"

webhook_secret_secret_version = "projects/devconnect-terraform-creds/secrets/gitlab-enterprise-webhook/versions/latest"

read_authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/gle-private-read-token/versions/latest"
}

authorizer_credential {
user_token_secret_version = "projects/devconnect-terraform-creds/secrets/gle-private-api/versions/latest"
}

ssl_ca_certificate = "-----BEGIN CERTIFICATE-----\nMIIFbjCCA1agAwIBAgIUH+nsWsqagMW9Ld8E9J71yPLPpD8wDQYJKoZIhvcNAQEL\nBQAwJDEiMCAGA1UEAwwZZ2xlLXVzLmdsZS11cy1wcml2YXRlLmNvbTAeFw0yNDEw\nMzExNjQzMjBaFw0zNDEwMjkxNjQzMjBaMCQxIjAgBgNVBAMMGWdsZS11cy5nbGUt\ndXMtcHJpdmF0ZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDL\n+dUU8MHo+Eskx4SSnI1thRIiljgsyJSzSOplaD4lqahFnrG0cB0ovKpyRL4A+0wM\nzVW7W1Pfi8DiEOxxfNo7pEj+0zrzJHHqnzW9kApIlRmO1TBBJ7i9HaVamJ1Od01b\n2WI/pnKFEvNfLQSDQBulhkHZ2McyauDhb1DxefKnVX8ac6qhxtc4IzrezIQuJ18N\nDPtNLUDD4rtU4mIX4lx1yBIplrgypAo1HDbJOwW8OR76MtjAY7ek3K6UCyduQtwy\nmfZ23b3Eg69W10HVMVTy6m5NaGKi/TWy2MJ71hKUQ1+tWIPH5SL7FzYPKL4XXw5W\np61LhIiBAd2tgD41b2cQxhUbVifc1qHtnwNz/tE77M9ySH37rEUIlExzr3D3JV+f\nXjXEXUr9as8GRnS5zhD/opKe7wKbwpYMHhylK1h6XH/sBO7dBajf5xCvpZZBDzrK\nkpTqwHspT7p40WF9d8odjEk/xZKn5LdcDG2I+4U7SVS5e8ud41HUQxJwQx56lKfh\n2WB+zs7nS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ml+5/pt+tBhtVzHA6vMxn18IYaNpuTwSxi/+M10K\nRjw=\n-----END CERTIFICATE-----\n"


service_directory_config {
service = "projects/devconnect-terraform-creds/locations/us-central1/namespaces/my-namespace/services/terraform-gle"
}
}

}
`, context)
}


func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabEnterpriseUpdate(t *testing.T) {
t.Parallel()
Expand All @@ -245,7 +369,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabEnterpris
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
{
Config: testAccDeveloperConnectConnection_GitlabEnterpriseUpdate(context),
Expand All @@ -254,7 +378,7 @@ func TestAccDeveloperConnectConnection_developerConnectConnectionGitlabEnterpris
ResourceName: "google_developer_connect_connection.my-connection",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"annotations", "connection_id", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"connection_id", "location", "terraform_labels"},
},
},
})
Expand Down Expand Up @@ -290,6 +414,12 @@ func testAccDeveloperConnectConnection_GitlabEnterpriseUpdate(context map[string
resource "google_developer_connect_connection" "my-connection" {
location = "us-central1"
connection_id = "tf-test-tf-test-connection%{random_suffix}"
annotations = {}
labels = {}

crypto_key_config {
key_reference = "projects/devconnect-terraform-creds/locations/us-central1/keyRings/tf-keyring/cryptoKeys/tf-crypto-key"
}

gitlab_enterprise_config {
host_uri = "https://gle-us-central1.gcb-test.com"
Expand Down

0 comments on commit 24c628c

Please sign in to comment.