Skip to content

Commit 5662a5b

Browse files
authored
Fix minor edit suggestions for IAM OAuth Client resource (#13258)
1 parent 71072a9 commit 5662a5b

File tree

5 files changed

+37
-96
lines changed

5 files changed

+37
-96
lines changed

mmv1/products/iamworkforcepool/OauthClient.yaml

+5-10
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,13 @@ timeouts:
3434
update_minutes: 20
3535
delete_minutes: 20
3636
custom_code:
37-
constants: "templates/terraform/constants/iam_oauth_client.go.tmpl"
3837
decoder: "templates/terraform/decoders/treat_deleted_state_as_gone.go.tmpl"
3938
test_check_destroy: "templates/terraform/custom_check_destroy/iam_oauth_client.go.tmpl"
4039
post_create: "templates/terraform/post_create/sleep.go.tmpl"
4140
post_update: "templates/terraform/post_create/sleep.go.tmpl"
4241
post_delete: "templates/terraform/post_create/sleep.go.tmpl"
4342
exclude_sweeper: true
4443
examples:
45-
- name: "iam_oauth_client_basic"
46-
primary_resource_id: "example"
47-
vars:
48-
oauth_client_id: "example-client-id"
4944
- name: "iam_oauth_client_full"
5045
primary_resource_id: "example"
5146
vars:
@@ -98,7 +93,7 @@ properties:
9893
- name: state
9994
type: String
10095
description: |-
101-
Output only. The state of the OauthClient.
96+
The state of the OauthClient.
10297
Possible values:
10398
STATE_UNSPECIFIED
10499
ACTIVE
@@ -107,7 +102,7 @@ properties:
107102
- name: disabled
108103
type: Boolean
109104
description: |-
110-
Optional. Whether the OauthClient is disabled. You cannot use a disabled OAuth
105+
Whether the OauthClient is disabled. You cannot use a disabled OAuth
111106
client.
112107
- name: clientId
113108
type: String
@@ -116,13 +111,13 @@ properties:
116111
- name: displayName
117112
type: String
118113
description: |-
119-
Optional. A user-specified display name of the OauthClient.
114+
A user-specified display name of the OauthClient.
120115
121116
Cannot exceed 32 characters.
122117
- name: description
123118
type: String
124119
description: |-
125-
Optional. A user-specified description of the OauthClient.
120+
A user-specified description of the OauthClient.
126121
127122
Cannot exceed 256 characters.
128123
- name: allowedGrantTypes
@@ -134,7 +129,7 @@ properties:
134129
- name: expireTime
135130
type: String
136131
description: |-
137-
Output only. Time after which the OauthClient will be permanently purged and cannot
132+
Time after which the OauthClient will be permanently purged and cannot
138133
be recovered.
139134
output: true
140135
- name: clientType

mmv1/templates/terraform/constants/iam_oauth_client.go.tmpl

-20
This file was deleted.

mmv1/templates/terraform/custom_check_destroy/iam_oauth_client.go.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
config := acctest.GoogleProviderConfig(t)
22

3-
url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{"{{"}}IAMWorkforcePoolBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/locations/global/oauthClients/{{"{{"}}oauth_client_id{{"}}"}}")
3+
url, err := tpgresource.ReplaceVarsForTest(config, rs, "{{"{{"}}IAMWorkforcePoolBasePath{{"}}"}}projects/{{"{{"}}project{{"}}"}}/locations/{{"{{"}}location{{"}}"}}/oauthClients/{{"{{"}}oauth_client_id{{"}}"}}")
44
if err != nil {
55
return err
66
}
@@ -19,4 +19,4 @@ if v := res["state"]; v == "DELETED" {
1919
return nil
2020
}
2121

22-
return fmt.Errorf("IAMOAuthCLient still exists at %s", url)
22+
return fmt.Errorf("IAMOAuthClient still exists at %s", url)

mmv1/templates/terraform/examples/iam_oauth_client_basic.tf.tmpl

-8
This file was deleted.

mmv1/third_party/terraform/services/iamworkforcepool/resource_iam_oauth_client_test.go.tmpl

+30-56
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ import (
44
"testing"
55

66
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
7+
"github.com/hashicorp/terraform-plugin-testing/plancheck"
78

89
"github.com/hashicorp/terraform-provider-google/google/acctest"
910
)
1011

11-
func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) {
12+
func TestAccIAMWorkforcePoolOauthClient_full(t *testing.T) {
1213
t.Parallel()
1314

1415
context := map[string]interface{}{
@@ -21,7 +22,7 @@ func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) {
2122
CheckDestroy: testAccCheckIAMWorkforcePoolOauthClientDestroyProducer(t),
2223
Steps: []resource.TestStep{
2324
{
24-
Config: testAccIAMWorkforcePoolOauthClient_basic(context),
25+
Config: testAccIAMWorkforcePoolOauthClient_full(context),
2526
},
2627
{
2728
ResourceName: "google_iam_oauth_client.example",
@@ -30,67 +31,26 @@ func TestAccIAMWorkforcePoolOauthClient_basic(t *testing.T) {
3031
ImportStateVerifyIgnore: []string{"location", "oauth_client_id"},
3132
},
3233
{
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+
},
3440
},
3541
{
3642
ResourceName: "google_iam_oauth_client.example",
3743
ImportState: true,
3844
ImportStateVerify: true,
3945
ImportStateVerifyIgnore: []string{"location", "oauth_client_id"},
4046
},
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-
},
8647
{
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+
},
9454
},
9555
{
9656
ResourceName: "google_iam_oauth_client.example",
@@ -126,10 +86,24 @@ resource "google_iam_oauth_client" "example" {
12686
description = "Updated description"
12787
location = "global"
12888
disabled = true
129-
allowed_grant_types = ["AUTHORIZATION_CODE_GRANT", ]
89+
allowed_grant_types = ["AUTHORIZATION_CODE_GRANT"]
13090
allowed_redirect_uris = ["https://www.update.com"]
13191
allowed_scopes = ["https://www.googleapis.com/auth/cloud-platform", "openid"]
13292
client_type = "CONFIDENTIAL_CLIENT"
13393
}
13494
`, context)
13595
}
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

Comments
 (0)