|
| 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 | +) |
| 10 | + |
| 11 | +func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) { |
| 12 | + t.Parallel() |
| 13 | + |
| 14 | + context := map[string]interface{}{ |
| 15 | + "random_suffix": acctest.RandString(t, 10), |
| 16 | + } |
| 17 | + |
| 18 | + acctest.VcrTest(t, resource.TestCase{ |
| 19 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 20 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 21 | + CheckDestroy: testAccCheckIAMWorkforcePoolOauthClientDestroyProducer(t), |
| 22 | + Steps: []resource.TestStep{ |
| 23 | + { |
| 24 | + Config: testAccIAMWorkforcePoolOauthClient_basic(context), |
| 25 | + }, |
| 26 | + { |
| 27 | + ResourceName: "google_iam_oauth_client.example", |
| 28 | + ImportState: true, |
| 29 | + ImportStateVerify: true, |
| 30 | + ImportStateVerifyIgnore: []string{"location", "oauth_client_id"}, |
| 31 | + }, |
| 32 | + { |
| 33 | + Config: testAccIAMWorkforcePoolOauthClient_basic_update(context), |
| 34 | + }, |
| 35 | + { |
| 36 | + ResourceName: "google_iam_oauth_client.example", |
| 37 | + ImportState: true, |
| 38 | + ImportStateVerify: true, |
| 39 | + ImportStateVerifyIgnore: []string{"location", "oauth_client_id"}, |
| 40 | + }, |
| 41 | + }, |
| 42 | + }) |
| 43 | +} |
| 44 | + |
| 45 | +func testAccIAMWorkforcePoolOauthClient_basic(context map[string]interface{}) string { |
| 46 | + return acctest.Nprintf(` |
| 47 | +resource "google_iam_oauth_client" "example" { |
| 48 | + oauth_client_id = "tf-test-example-client-id%{random_suffix}" |
| 49 | + location = "global" |
| 50 | + allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"] |
| 51 | + allowed_redirect_uris = ["https://www.example.com"] |
| 52 | + allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform"] |
| 53 | + client_type = "CONFIDENTIAL_CLIENT" |
| 54 | +} |
| 55 | +`, context) |
| 56 | +} |
| 57 | + |
| 58 | +func testAccIAMWorkforcePoolOauthClient_basic_update(context map[string]interface{}) string { |
| 59 | + return acctest.Nprintf(` |
| 60 | +resource "google_iam_oauth_client" "example" { |
| 61 | + oauth_client_id = "tf-test-example-client-id%{random_suffix}" |
| 62 | + location = "global" |
| 63 | + allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"] |
| 64 | + allowed_redirect_uris = ["https://www.update.com"] |
| 65 | + allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform", "openid"] |
| 66 | + client_type = "CONFIDENTIAL_CLIENT" |
| 67 | +} |
| 68 | +`, context) |
| 69 | +} |
| 70 | + |
| 71 | +func TestAccIAMWorkforcePoolOauthClient_full(t *testing.T) { |
| 72 | + t.Parallel() |
| 73 | + |
| 74 | + context := map[string]interface{}{ |
| 75 | + "random_suffix": acctest.RandString(t, 10), |
| 76 | + } |
| 77 | + |
| 78 | + acctest.VcrTest(t, resource.TestCase{ |
| 79 | + PreCheck: func() { acctest.AccTestPreCheck(t) }, |
| 80 | + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), |
| 81 | + CheckDestroy: testAccCheckIAMWorkforcePoolOauthClientDestroyProducer(t), |
| 82 | + Steps: []resource.TestStep{ |
| 83 | + { |
| 84 | + Config: testAccIAMWorkforcePoolOauthClient_full(context), |
| 85 | + }, |
| 86 | + { |
| 87 | + ResourceName: "google_iam_oauth_client.example", |
| 88 | + ImportState: true, |
| 89 | + ImportStateVerify: true, |
| 90 | + ImportStateVerifyIgnore: []string{"location", "oauth_client_id"}, |
| 91 | + }, |
| 92 | + { |
| 93 | + Config: testAccIAMWorkforcePoolOauthClient_full_update(context), |
| 94 | + }, |
| 95 | + { |
| 96 | + ResourceName: "google_iam_oauth_client.example", |
| 97 | + ImportState: true, |
| 98 | + ImportStateVerify: true, |
| 99 | + ImportStateVerifyIgnore: []string{"location", "oauth_client_id"}, |
| 100 | + }, |
| 101 | + }, |
| 102 | + }) |
| 103 | +} |
| 104 | + |
| 105 | +func testAccIAMWorkforcePoolOauthClient_full(context map[string]interface{}) string { |
| 106 | + return acctest.Nprintf(` |
| 107 | +resource "google_iam_oauth_client" "example" { |
| 108 | + oauth_client_id = "tf-test-example-client-id%{random_suffix}" |
| 109 | + display_name = "Display Name of OAuth client" |
| 110 | + description = "A sample OAuth client" |
| 111 | + location = "global" |
| 112 | + disabled = false |
| 113 | + allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"] |
| 114 | + allowed_redirect_uris = ["https://www.example.com"] |
| 115 | + allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform"] |
| 116 | + client_type = "CONFIDENTIAL_CLIENT" |
| 117 | +} |
| 118 | +`, context) |
| 119 | +} |
| 120 | + |
| 121 | +func testAccIAMWorkforcePoolOauthClient_full_update(context map[string]interface{}) string { |
| 122 | + return acctest.Nprintf(` |
| 123 | +resource "google_iam_oauth_client" "example" { |
| 124 | + oauth_client_id = "tf-test-example-client-id%{random_suffix}" |
| 125 | + display_name = "Updated displayName" |
| 126 | + description = "Updated description" |
| 127 | + location = "global" |
| 128 | + disabled = true |
| 129 | + allowed_grant_types = ["AUTHORIZATION_CODE_GRANT", ] |
| 130 | + allowed_redirect_uris = ["https://www.update.com"] |
| 131 | + allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform", "openid"] |
| 132 | + client_type = "CONFIDENTIAL_CLIENT" |
| 133 | +} |
| 134 | +`, context) |
| 135 | +} |
0 commit comments