|
| 1 | +package iamworkforcepool_test |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-testing/helper/resource" |
| 7 | + |
| 8 | + "github.com/hashicorp/terraform-provider-google/google/acctest" |
| 9 | + "github.com/hashicorp/terraform-provider-google/google/envvar" |
| 10 | +) |
| 11 | + |
| 12 | +func TestAccIAMWorkforcePoolWorkforcePoolProviderScimTenant_update(t *testing.T) { |
| 13 | + t.Parallel() |
| 14 | + |
| 15 | + context := map[string]interface{}{ |
| 16 | + "org_id": envvar.GetTestOrgFromEnv(t), |
| 17 | + "random_suffix": acctest.RandString(t, 10), |
| 18 | + } |
| 19 | + |
| 20 | + acctest.VcrTest(t, resource.TestCase{ |
| 21 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 22 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 23 | + CheckDestroy: testAccCheckIAMWorkforcePoolWorkforcePoolProviderScimTenantDestroyProducer(t), |
| 24 | + Steps: []resource.TestStep{ |
| 25 | + { |
| 26 | + Config: testAccIAMWorkforcePoolWorkforcePoolProviderScimTenant_full(context), |
| 27 | + }, |
| 28 | + { |
| 29 | + ResourceName: "google_iam_workforce_pool_provider_scim_tenant.scim_tenant", |
| 30 | + ImportState: true, |
| 31 | + ImportStateVerify: true, |
| 32 | + ImportStateVerifyIgnore: []string{"state"}, |
| 33 | + }, |
| 34 | + { |
| 35 | + Config: testAccIAMWorkforcePoolWorkforcePoolProviderScimTenant_update(context), |
| 36 | + }, |
| 37 | + { |
| 38 | + ResourceName: "google_iam_workforce_pool_provider_scim_tenant.scim_tenant", |
| 39 | + ImportState: true, |
| 40 | + ImportStateVerify: true, |
| 41 | + ImportStateVerifyIgnore: []string{"state"}, |
| 42 | + }, |
| 43 | + }, |
| 44 | + }) |
| 45 | +} |
| 46 | + |
| 47 | +func testAccIAMWorkforcePoolWorkforcePoolProviderScimTenant_full(context map[string]interface{}) string { |
| 48 | + return acctest.Nprintf(` |
| 49 | +resource "google_iam_workforce_pool" "pool" { |
| 50 | + workforce_pool_id = "tf-test-example-pool%{random_suffix}" |
| 51 | + parent = "organizations/%{org_id}" |
| 52 | + location = "global" |
| 53 | +} |
| 54 | +
|
| 55 | +resource "google_iam_workforce_pool_provider" "provider" { |
| 56 | + workforce_pool_id = google_iam_workforce_pool.pool.workforce_pool_id |
| 57 | + location = "global" |
| 58 | + provider_id = "tf-test-provider-%{random_suffix}" |
| 59 | + attribute_mapping = { |
| 60 | + "google.subject" = "assertion.sub" |
| 61 | + } |
| 62 | + oidc { |
| 63 | + issuer_uri = "https://accounts.thirdparty.com" |
| 64 | + client_id = "client-id" |
| 65 | + client_secret { |
| 66 | + value { |
| 67 | + plain_text = "client-secret" |
| 68 | + } |
| 69 | + } |
| 70 | + web_sso_config { |
| 71 | + response_type = "CODE" |
| 72 | + assertion_claims_behavior = "MERGE_USER_INFO_OVER_ID_TOKEN_CLAIMS" |
| 73 | + additional_scopes = ["groups", "roles"] |
| 74 | + } |
| 75 | + } |
| 76 | + display_name = "Display name" |
| 77 | + description = "A sample OIDC workforce pool provider." |
| 78 | + disabled = false |
| 79 | + attribute_condition = "true" |
| 80 | +} |
| 81 | +
|
| 82 | +resource "google_iam_workforce_pool_provider_scim_tenant" "scim_tenant" { |
| 83 | + location = "global" |
| 84 | + workforce_pool_id = google_iam_workforce_pool.pool.workforce_pool_id |
| 85 | + provider_id = google_iam_workforce_pool_provider.provider.provider_id |
| 86 | + scim_tenant_id = "example-scim-tenant" |
| 87 | + display_name = "Example SCIM Tenant" |
| 88 | + description = "A basic SCIM tenant for IAM Workforce Pool Provider" |
| 89 | + # state is output only, not settable |
| 90 | +} |
| 91 | +
|
| 92 | +`, context) |
| 93 | +} |
| 94 | + |
| 95 | +func testAccIAMWorkforcePoolWorkforcePoolProviderScimTenant_update(context map[string]interface{}) string { |
| 96 | + return acctest.Nprintf(` |
| 97 | +resource "google_iam_workforce_pool" "pool" { |
| 98 | + workforce_pool_id = "tf-test-example-pool%{random_suffix}" |
| 99 | + parent = "organizations/%{org_id}" |
| 100 | + location = "global" |
| 101 | +} |
| 102 | +
|
| 103 | +resource "google_iam_workforce_pool_provider" "provider" { |
| 104 | + workforce_pool_id = google_iam_workforce_pool.pool.workforce_pool_id |
| 105 | + location = "global" |
| 106 | + provider_id = "tf-test-provider-%{random_suffix}" |
| 107 | + attribute_mapping = { |
| 108 | + "google.subject" = "assertion.sub" |
| 109 | + } |
| 110 | + oidc { |
| 111 | + issuer_uri = "https://accounts.thirdparty.com" |
| 112 | + client_id = "client-id" |
| 113 | + client_secret { |
| 114 | + value { |
| 115 | + plain_text = "client-secret" |
| 116 | + } |
| 117 | + } |
| 118 | + web_sso_config { |
| 119 | + response_type = "CODE" |
| 120 | + assertion_claims_behavior = "MERGE_USER_INFO_OVER_ID_TOKEN_CLAIMS" |
| 121 | + additional_scopes = ["groups", "roles"] |
| 122 | + } |
| 123 | + } |
| 124 | + display_name = "Display name" |
| 125 | + description = "A sample OIDC workforce pool provider." |
| 126 | + disabled = false |
| 127 | + attribute_condition = "true" |
| 128 | +} |
| 129 | +
|
| 130 | +resource "google_iam_workforce_pool_provider_scim_tenant" "scim_tenant" { |
| 131 | + location = "global" |
| 132 | + workforce_pool_id = google_iam_workforce_pool.pool.workforce_pool_id |
| 133 | + provider_id = google_iam_workforce_pool_provider.provider.provider_id |
| 134 | + scim_tenant_id = "example-scim-tenant" |
| 135 | + display_name = "Example SCIM Tenant - Updated" |
| 136 | + description = "A basic SCIM tenant for IAM Workforce Pool Provider - Updated" |
| 137 | + # state is output only, not settable |
| 138 | +} |
| 139 | +`, context) |
| 140 | +} |
0 commit comments