@@ -4,11 +4,12 @@ import (
4
4
"testing"
5
5
6
6
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7
+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
7
8
8
9
"github.com/hashicorp/terraform-provider-google/google/acctest"
9
10
)
10
11
11
- func TestAccIAMWorkforcePoolOauthClient_basic (t *testing.T) {
12
+ func TestAccIAMWorkforcePoolOauthClient_full (t *testing.T) {
12
13
t.Parallel()
13
14
14
15
context := map[string]interface{}{
@@ -21,7 +22,7 @@ func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) {
21
22
CheckDestroy: testAccCheckIAMWorkforcePoolOauthClientDestroyProducer(t),
22
23
Steps: []resource.TestStep{
23
24
{
24
- Config: testAccIAMWorkforcePoolOauthClient_basic (context),
25
+ Config: testAccIAMWorkforcePoolOauthClient_full (context),
25
26
},
26
27
{
27
28
ResourceName: "google_iam_oauth_client.example",
@@ -30,67 +31,26 @@ func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) {
30
31
ImportStateVerifyIgnore: []string{"location", "oauth_client_id"},
31
32
},
32
33
{
33
- Config: testAccIAMWorkforcePoolOauthClient_basic_update(context),
34
+ Config: testAccIAMWorkforcePoolOauthClient_full_update(context),
35
+ ConfigPlanChecks: resource.ConfigPlanChecks{
36
+ PreApply: []plancheck.PlanCheck{
37
+ plancheck.ExpectResourceAction("google_iam_oauth_client.example", plancheck.ResourceActionUpdate),
38
+ },
39
+ },
34
40
},
35
41
{
36
42
ResourceName: "google_iam_oauth_client.example",
37
43
ImportState: true,
38
44
ImportStateVerify: true,
39
45
ImportStateVerifyIgnore: []string{"location", "oauth_client_id"},
40
46
},
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
47
{
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),
48
+ Config: testAccIAMWorkforcePoolOauthClient_full_cleanOptionalFields(context),
49
+ ConfigPlanChecks: resource.ConfigPlanChecks{
50
+ PreApply: []plancheck.PlanCheck{
51
+ plancheck.ExpectResourceAction("google_iam_oauth_client.example", plancheck.ResourceActionUpdate),
52
+ },
53
+ },
94
54
},
95
55
{
96
56
ResourceName: "google_iam_oauth_client.example",
@@ -126,10 +86,24 @@ resource "google_iam_oauth_client" "example" {
126
86
description = "Updated description"
127
87
location = "global"
128
88
disabled = true
129
- allowed_grant_types = ["AUTHORIZATION_CODE_GRANT", ]
89
+ allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"]
130
90
allowed_redirect_uris = ["https://www.update.com"]
131
91
allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform", "openid"]
132
92
client_type = "CONFIDENTIAL_CLIENT"
133
93
}
134
94
`, context)
135
95
}
96
+
97
+ func testAccIAMWorkforcePoolOauthClient_full_cleanOptionalFields(context map[string]interface{}) string {
98
+ return acctest.Nprintf(`
99
+ resource "google_iam_oauth_client" "example" {
100
+ oauth_client_id = "tf-test-example-client-id%{random_suffix}"
101
+ location = "global"
102
+ disabled = true
103
+ allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"]
104
+ allowed_redirect_uris = ["https://www.update.com"]
105
+ allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform", "openid"]
106
+ client_type = "CONFIDENTIAL_CLIENT"
107
+ }
108
+ `, context)
109
+ }
0 commit comments