@@ -34,6 +34,33 @@ func TestAccGitlabUser_basic(t *testing.T) {
34
34
Admin : false ,
35
35
CanCreateGroup : false ,
36
36
External : false ,
37
+ State : "active" ,
38
+ }),
39
+ ),
40
+ },
41
+ {
42
+ ResourceName : "gitlab_user.foo" ,
43
+ ImportState : true ,
44
+ ImportStateVerify : true ,
45
+ ImportStateVerifyIgnore : []string {
46
+ "password" ,
47
+ "skip_confirmation" ,
48
+ },
49
+ },
50
+ // Create a user with blocked state
51
+ {
52
+ Config : testAccGitlabUserConfigBlocked (rInt ),
53
+ Check : resource .ComposeTestCheckFunc (
54
+ testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
55
+ testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
56
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
57
+ Username : fmt .Sprintf ("listest%d" , rInt ),
58
+ Name : fmt .Sprintf ("foo %d" , rInt ),
59
+ ProjectsLimit : 0 ,
60
+ Admin : false ,
61
+ CanCreateGroup : false ,
62
+ External : false ,
63
+ State : "blocked" ,
37
64
}),
38
65
),
39
66
},
@@ -60,6 +87,34 @@ func TestAccGitlabUser_basic(t *testing.T) {
60
87
CanCreateGroup : true ,
61
88
External : false ,
62
89
Note : fmt .Sprintf ("note%d" , rInt ),
90
+ State : "active" ,
91
+ }),
92
+ ),
93
+ },
94
+ {
95
+ ResourceName : "gitlab_user.foo" ,
96
+ ImportState : true ,
97
+ ImportStateVerify : true ,
98
+ ImportStateVerifyIgnore : []string {
99
+ "password" ,
100
+ "skip_confirmation" ,
101
+ },
102
+ },
103
+ // Update the user to change the state to blocked
104
+ {
105
+ Config : testAccGitlabUserUpdateConfigBlocked (rInt ),
106
+ Check : resource .ComposeTestCheckFunc (
107
+ testAccCheckGitlabUserExists ("gitlab_user.foo" , & user ),
108
+ testAccCheckGitlabUserAttributes (& user , & testAccGitlabUserExpectedAttributes {
109
+ Email :
fmt .
Sprintf (
"listest%[email protected] " ,
rInt ),
110
+ Username : fmt .Sprintf ("listest%d" , rInt ),
111
+ Name : fmt .Sprintf ("bar %d" , rInt ),
112
+ ProjectsLimit : 10 ,
113
+ Admin : true ,
114
+ CanCreateGroup : true ,
115
+ External : false ,
116
+ Note : fmt .Sprintf ("note%d" , rInt ),
117
+ State : "blocked" ,
63
118
}),
64
119
),
65
120
},
@@ -85,6 +140,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
85
140
Admin : false ,
86
141
CanCreateGroup : false ,
87
142
External : false ,
143
+ State : "active" ,
88
144
}),
89
145
),
90
146
},
@@ -110,6 +166,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
110
166
Admin : false ,
111
167
CanCreateGroup : false ,
112
168
External : false ,
169
+ State : "active" ,
113
170
}),
114
171
),
115
172
},
@@ -135,6 +192,7 @@ func TestAccGitlabUser_basic(t *testing.T) {
135
192
Admin : false ,
136
193
CanCreateGroup : false ,
137
194
External : false ,
195
+ State : "active" ,
138
196
}),
139
197
),
140
198
},
@@ -215,6 +273,7 @@ type testAccGitlabUserExpectedAttributes struct {
215
273
CanCreateGroup bool
216
274
External bool
217
275
Note string
276
+ State string
218
277
}
219
278
220
279
func testAccCheckGitlabUserAttributes (user * gitlab.User , want * testAccGitlabUserExpectedAttributes ) resource.TestCheckFunc {
@@ -251,6 +310,10 @@ func testAccCheckGitlabUserAttributes(user *gitlab.User, want *testAccGitlabUser
251
310
return fmt .Errorf ("got projects_limit %d; want %d" , user .ProjectsLimit , want .ProjectsLimit )
252
311
}
253
312
313
+ if user .State != want .State {
314
+ return fmt .Errorf ("got state %q; want %q" , user .State , want .State )
315
+ }
316
+
254
317
return nil
255
318
}
256
319
}
@@ -292,6 +355,22 @@ resource "gitlab_user" "foo" {
292
355
` , rInt , rInt , rInt , rInt )
293
356
}
294
357
358
+ func testAccGitlabUserConfigBlocked (rInt int ) string {
359
+ return fmt .Sprintf (`
360
+ resource "gitlab_user" "foo" {
361
+ name = "foo %d"
362
+ username = "listest%d"
363
+ password = "test%dtt"
364
+ email = "listest%[email protected] "
365
+ is_admin = false
366
+ projects_limit = 0
367
+ can_create_group = false
368
+ is_external = false
369
+ state = "blocked"
370
+ }
371
+ ` , rInt , rInt , rInt , rInt )
372
+ }
373
+
295
374
func testAccGitlabUserUpdateConfig (rInt int ) string {
296
375
return fmt .Sprintf (`
297
376
resource "gitlab_user" "foo" {
@@ -308,6 +387,23 @@ resource "gitlab_user" "foo" {
308
387
` , rInt , rInt , rInt , rInt , rInt )
309
388
}
310
389
390
+ func testAccGitlabUserUpdateConfigBlocked (rInt int ) string {
391
+ return fmt .Sprintf (`
392
+ resource "gitlab_user" "foo" {
393
+ name = "bar %d"
394
+ username = "listest%d"
395
+ password = "test%dtt"
396
+ email = "listest%[email protected] "
397
+ is_admin = true
398
+ projects_limit = 10
399
+ can_create_group = true
400
+ is_external = false
401
+ note = "note%d"
402
+ state = "blocked"
403
+ }
404
+ ` , rInt , rInt , rInt , rInt , rInt )
405
+ }
406
+
311
407
func testAccGitlabUserUpdateConfigNoSkipConfirmation (rInt int ) string {
312
408
return fmt .Sprintf (`
313
409
resource "gitlab_user" "foo" {
0 commit comments