@@ -27,52 +27,89 @@ func TestAccGitlabUser_basic(t *testing.T) {
27
27
Check : resource .ComposeTestCheckFunc (
28
28
testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
29
29
testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
30
- Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
31
- Password : fmt .Sprintf ("test%dtt" , rInt ),
32
- Username : fmt .Sprintf ("listest%d" , rInt ),
33
- Name : fmt .Sprintf ("foo %d" , rInt ),
34
- ProjectsLimit : 0 ,
35
- Admin : false ,
36
- CanCreateGroup : false ,
37
- SkipConfirmation : true ,
38
- External : false ,
30
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
31
+ Username : fmt .Sprintf ("listest%d" , rInt ),
32
+ Name : fmt .Sprintf ("foo %d" , rInt ),
33
+ ProjectsLimit : 0 ,
34
+ Admin : false ,
35
+ CanCreateGroup : false ,
36
+ External : false ,
39
37
}),
40
38
),
41
39
},
40
+ {
41
+ ResourceName : "gitlab_user.foo" ,
42
+ ImportState : true ,
43
+ ImportStateVerify : true ,
44
+ ImportStateVerifyIgnore : []string {
45
+ "password" ,
46
+ "skip_confirmation" ,
47
+ },
48
+ },
42
49
// Update the user to change the name, email, projects_limit and more
43
50
{
44
51
Config : testAccGitlabUserUpdateConfig (rInt ),
45
52
Check : resource .ComposeTestCheckFunc (
46
53
testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
47
54
testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
48
- Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
49
- Password : fmt .Sprintf ("test%dtt" , rInt ),
50
- Username : fmt .Sprintf ("listest%d" , rInt ),
51
- Name : fmt .Sprintf ("bar %d" , rInt ),
52
- ProjectsLimit : 10 ,
53
- Admin : true ,
54
- CanCreateGroup : true ,
55
- SkipConfirmation : false ,
56
- External : false ,
57
- Note : fmt .Sprintf ("note%d" , rInt ),
55
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
56
+ Username : fmt .Sprintf ("listest%d" , rInt ),
57
+ Name : fmt .Sprintf ("bar %d" , rInt ),
58
+ ProjectsLimit : 10 ,
59
+ Admin : true ,
60
+ CanCreateGroup : true ,
61
+ External : false ,
62
+ Note : fmt .Sprintf ("note%d" , rInt ),
58
63
}),
59
64
),
60
65
},
66
+ {
67
+ ResourceName : "gitlab_user.foo" ,
68
+ ImportState : true ,
69
+ ImportStateVerify : true ,
70
+ ImportStateVerifyIgnore : []string {
71
+ "password" ,
72
+ "skip_confirmation" ,
73
+ },
74
+ },
61
75
// Update the user to put the name back
62
76
{
63
77
Config : testAccGitlabUserConfig (rInt ),
64
78
Check : resource .ComposeTestCheckFunc (
65
79
testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
66
80
testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
67
- Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
68
- Password : fmt .Sprintf ("test%dtt" , rInt ),
69
- Username : fmt .Sprintf ("listest%d" , rInt ),
70
- Name : fmt .Sprintf ("foo %d" , rInt ),
71
- ProjectsLimit : 0 ,
72
- Admin : false ,
73
- CanCreateGroup : false ,
74
- SkipConfirmation : false ,
75
- External : false ,
81
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
82
+ Username : fmt .Sprintf ("listest%d" , rInt ),
83
+ Name : fmt .Sprintf ("foo %d" , rInt ),
84
+ ProjectsLimit : 0 ,
85
+ Admin : false ,
86
+ CanCreateGroup : false ,
87
+ External : false ,
88
+ }),
89
+ ),
90
+ },
91
+ {
92
+ ResourceName : "gitlab_user.foo" ,
93
+ ImportState : true ,
94
+ ImportStateVerify : true ,
95
+ ImportStateVerifyIgnore : []string {
96
+ "password" ,
97
+ "skip_confirmation" ,
98
+ },
99
+ },
100
+ // Update the user to disable skip confirmation
101
+ {
102
+ Config : testAccGitlabUserUpdateConfigNoSkipConfirmation (rInt ),
103
+ Check : resource .ComposeTestCheckFunc (
104
+ testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
105
+ testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
106
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
107
+ Username : fmt .Sprintf ("listest%d" , rInt ),
108
+ Name : fmt .Sprintf ("foo %d" , rInt ),
109
+ ProjectsLimit : 0 ,
110
+ Admin : false ,
111
+ CanCreateGroup : false ,
112
+ External : false ,
76
113
}),
77
114
),
78
115
},
@@ -82,6 +119,32 @@ func TestAccGitlabUser_basic(t *testing.T) {
82
119
ImportStateVerify : true ,
83
120
ImportStateVerifyIgnore : []string {
84
121
"password" ,
122
+ "skip_confirmation" ,
123
+ },
124
+ },
125
+ // Update the user to initial config
126
+ {
127
+ Config : testAccGitlabUserConfig (rInt ),
128
+ Check : resource .ComposeTestCheckFunc (
129
+ testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
130
+ testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
131
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
132
+ Username : fmt .Sprintf ("listest%d" , rInt ),
133
+ Name : fmt .Sprintf ("foo %d" , rInt ),
134
+ ProjectsLimit : 0 ,
135
+ Admin : false ,
136
+ CanCreateGroup : false ,
137
+ External : false ,
138
+ }),
139
+ ),
140
+ },
141
+ {
142
+ ResourceName : "gitlab_user.foo" ,
143
+ ImportState : true ,
144
+ ImportStateVerify : true ,
145
+ ImportStateVerifyIgnore : []string {
146
+ "password" ,
147
+ "skip_confirmation" ,
85
148
},
86
149
},
87
150
},
@@ -107,6 +170,16 @@ func TestAccGitlabUser_password_reset(t *testing.T) {
107
170
Config : testAccGitlabUserConfigPasswordReset (rInt ),
108
171
Check : testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
109
172
},
173
+ {
174
+ ResourceName : "gitlab_user.foo" ,
175
+ ImportState : true ,
176
+ ImportStateVerify : true ,
177
+ ImportStateVerifyIgnore : []string {
178
+ "password" ,
179
+ "reset_password" ,
180
+ "skip_confirmation" ,
181
+ },
182
+ },
110
183
},
111
184
})
112
185
}
@@ -136,16 +209,14 @@ func testAccCheckGitlabUserExists(n string, user *gitlab.User) resource.TestChec
136
209
}
137
210
138
211
type testAccGitlabUserExpectedAttributes struct {
139
- Email string
140
- Password string
141
- Username string
142
- Name string
143
- ProjectsLimit int
144
- Admin bool
145
- CanCreateGroup bool
146
- SkipConfirmation bool
147
- External bool
148
- Note string
212
+ Email string
213
+ Username string
214
+ Name string
215
+ ProjectsLimit int
216
+ Admin bool
217
+ CanCreateGroup bool
218
+ External bool
219
+ Note string
149
220
}
150
221
151
222
func testAccCheckGitlabUserAttributes (user * gitlab.User , want * testAccGitlabUserExpectedAttributes ) resource.TestCheckFunc {
@@ -241,6 +312,22 @@ resource "gitlab_user" "foo" {
241
312
` , rInt , rInt , rInt , rInt , rInt )
242
313
}
243
314
315
+ func testAccGitlabUserUpdateConfigNoSkipConfirmation (rInt int ) string {
316
+ return fmt .Sprintf (`
317
+ resource "gitlab_user" "foo" {
318
+ name = "foo %d"
319
+ username = "listest%d"
320
+ password = "test%dtt"
321
+ email = "listest%[email protected] "
322
+ is_admin = false
323
+ projects_limit = 0
324
+ can_create_group = false
325
+ is_external = false
326
+ skip_confirmation = false
327
+ }
328
+ ` , rInt , rInt , rInt , rInt )
329
+ }
330
+
244
331
func testAccGitlabUserConfigPasswordReset (rInt int ) string {
245
332
return fmt .Sprintf (`
246
333
resource "gitlab_user" "foo" {
0 commit comments