Skip to content

Commit 1d98254

Browse files
author
WeiMengXS
committed
fix: cr
1 parent 69f5987 commit 1d98254

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

tencentcloud/resource_tc_cam_mfa_flag.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ Provides a resource to create a cam mfa_flag
44
Example Usage
55
66
```hcl
7+
data "tencentcloud_user_info" "info"{}
8+
79
resource "tencentcloud_cam_mfa_flag" "mfa_flag" {
8-
op_uin = 20003xxxxxxx
10+
op_uin = data.tencentcloud_user_info.info.uin
911
login_flag {
10-
phone = 0
11-
stoken = 1
12-
wechat = 0
13-
12+
phone = 0
13+
stoken = 1
14+
wechat = 0
1415
}
1516
action_flag {
16-
phone = 0
17-
stoken = 1
18-
wechat = 0
17+
phone = 0
18+
stoken = 1
19+
wechat = 0
1920
}
2021
}
22+
2123
```
2224
2325
Import

tencentcloud/resource_tc_cam_mfa_flag_test.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ func TestAccTencentCloudCamMfaFlagResource_basic(t *testing.T) {
2929
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "action_flag.0.wechat", "0"),
3030
),
3131
},
32+
{
33+
Config: testAccCamMfaFlagUpdate,
34+
Check: resource.ComposeTestCheckFunc(
35+
resource.TestCheckResourceAttrSet("tencentcloud_cam_mfa_flag.mfa_flag", "id"),
36+
resource.TestCheckResourceAttrSet("tencentcloud_cam_mfa_flag.mfa_flag", "login_flag.#"),
37+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "login_flag.0.phone", "0"),
38+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "login_flag.0.stoken", "0"),
39+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "login_flag.0.wechat", "0"),
40+
41+
resource.TestCheckResourceAttrSet("tencentcloud_cam_mfa_flag.mfa_flag", "action_flag.#"),
42+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "action_flag.0.phone", "0"),
43+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "action_flag.0.stoken", "0"),
44+
resource.TestCheckResourceAttr("tencentcloud_cam_mfa_flag.mfa_flag", "action_flag.0.wechat", "0"),
45+
),
46+
},
3247
},
3348
})
3449
}
@@ -39,14 +54,32 @@ data "tencentcloud_user_info" "info"{}
3954
resource "tencentcloud_cam_mfa_flag" "mfa_flag" {
4055
op_uin = data.tencentcloud_user_info.info.uin
4156
login_flag {
42-
phone = 0
43-
stoken = 1
44-
wechat = 0
57+
phone = 0
58+
stoken = 1
59+
wechat = 0
60+
}
61+
action_flag {
62+
phone = 0
63+
stoken = 1
64+
wechat = 0
65+
}
66+
}
67+
68+
`
69+
const testAccCamMfaFlagUpdate = `
70+
data "tencentcloud_user_info" "info"{}
71+
72+
resource "tencentcloud_cam_mfa_flag" "mfa_flag" {
73+
op_uin = data.tencentcloud_user_info.info.uin
74+
login_flag {
75+
phone = 0
76+
stoken = 0
77+
wechat = 0
4578
}
4679
action_flag {
47-
phone = 0
48-
stoken = 1
49-
wechat = 0
80+
phone = 0
81+
stoken = 0
82+
wechat = 0
5083
}
5184
}
5285

tencentcloud/service_tencentcloud_cam.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ func (me *CamService) DescribeCamMfaFlagById(ctx context.Context) (loginFlag *ca
13761376
}
13771377
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
13781378

1379-
if response.Response.ActionFlag == nil && response.Response.LoginFlag == nil {
1379+
if response == nil || response.Response == nil || response.Response.ActionFlag == nil && response.Response.LoginFlag == nil {
13801380
return
13811381
}
13821382

0 commit comments

Comments
 (0)