@@ -26,10 +26,14 @@ func TestAccGitlabGroup_basic(t *testing.T) {
26
26
Check : resource .ComposeTestCheckFunc (
27
27
testAccCheckGitlabGroupExists ("gitlab_group.foo" , & group ),
28
28
testAccCheckGitlabGroupAttributes (& group , & testAccGitlabGroupExpectedAttributes {
29
- Name : fmt .Sprintf ("foo-name-%d" , rInt ),
30
- Path : fmt .Sprintf ("foo-path-%d" , rInt ),
31
- Description : "Terraform acceptance tests" ,
32
- LFSEnabled : true ,
29
+ Name : fmt .Sprintf ("foo-name-%d" , rInt ),
30
+ Path : fmt .Sprintf ("foo-path-%d" , rInt ),
31
+ Description : "Terraform acceptance tests" ,
32
+ LFSEnabled : true ,
33
+ Visibility : "public" , // default value
34
+ ProjectCreationLevel : "maintainer" , // default value
35
+ SubGroupCreationLevel : "owner" , // default value
36
+ TwoFactorGracePeriod : 48 , // default value
33
37
}),
34
38
),
35
39
},
@@ -39,23 +43,37 @@ func TestAccGitlabGroup_basic(t *testing.T) {
39
43
Check : resource .ComposeTestCheckFunc (
40
44
testAccCheckGitlabGroupExists ("gitlab_group.foo" , & group ),
41
45
testAccCheckGitlabGroupAttributes (& group , & testAccGitlabGroupExpectedAttributes {
42
- Name : fmt .Sprintf ("bar-name-%d" , rInt ),
43
- Path : fmt .Sprintf ("bar-path-%d" , rInt ),
44
- Description : "Terraform acceptance tests! Updated description" ,
45
- RequestAccessEnabled : true ,
46
+ Name : fmt .Sprintf ("bar-name-%d" , rInt ),
47
+ Path : fmt .Sprintf ("bar-path-%d" , rInt ),
48
+ Description : "Terraform acceptance tests! Updated description" ,
49
+ LFSEnabled : false ,
50
+ Visibility : "public" , // default value
51
+ RequestAccessEnabled : true ,
52
+ ProjectCreationLevel : "developer" ,
53
+ SubGroupCreationLevel : "maintainer" ,
54
+ RequireTwoFactorAuth : true ,
55
+ TwoFactorGracePeriod : 56 ,
56
+ AutoDevopsEnabled : true ,
57
+ EmailsDisabled : true ,
58
+ MentionsDisabled : true ,
59
+ ShareWithGroupLock : true ,
46
60
}),
47
61
),
48
62
},
49
- // Update the group to put the anem and description back
63
+ // Update the group to put the name and description back
50
64
{
51
65
Config : testAccGitlabGroupConfig (rInt ),
52
66
Check : resource .ComposeTestCheckFunc (
53
67
testAccCheckGitlabGroupExists ("gitlab_group.foo" , & group ),
54
68
testAccCheckGitlabGroupAttributes (& group , & testAccGitlabGroupExpectedAttributes {
55
- Name : fmt .Sprintf ("foo-name-%d" , rInt ),
56
- Path : fmt .Sprintf ("foo-path-%d" , rInt ),
57
- Description : "Terraform acceptance tests" ,
58
- LFSEnabled : true ,
69
+ Name : fmt .Sprintf ("foo-name-%d" , rInt ),
70
+ Path : fmt .Sprintf ("foo-path-%d" , rInt ),
71
+ Description : "Terraform acceptance tests" ,
72
+ LFSEnabled : true ,
73
+ Visibility : "public" , // default value
74
+ ProjectCreationLevel : "maintainer" , // default value
75
+ SubGroupCreationLevel : "owner" , // default value
76
+ TwoFactorGracePeriod : 48 , // default value
59
77
}),
60
78
),
61
79
},
@@ -101,11 +119,15 @@ func TestAccGitlabGroup_nested(t *testing.T) {
101
119
testAccCheckGitlabGroupExists ("gitlab_group.foo2" , & group2 ),
102
120
testAccCheckGitlabGroupExists ("gitlab_group.nested_foo" , & nestedGroup ),
103
121
testAccCheckGitlabGroupAttributes (& nestedGroup , & testAccGitlabGroupExpectedAttributes {
104
- Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
105
- Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
106
- Description : "Terraform acceptance tests" ,
107
- LFSEnabled : true ,
108
- Parent : & group ,
122
+ Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
123
+ Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
124
+ Description : "Terraform acceptance tests" ,
125
+ LFSEnabled : true ,
126
+ Visibility : "public" , // default value
127
+ ProjectCreationLevel : "maintainer" , // default value
128
+ SubGroupCreationLevel : "owner" , // default value
129
+ TwoFactorGracePeriod : 48 , // default value
130
+ Parent : & group ,
109
131
}),
110
132
),
111
133
},
@@ -116,11 +138,15 @@ func TestAccGitlabGroup_nested(t *testing.T) {
116
138
testAccCheckGitlabGroupExists ("gitlab_group.foo2" , & group2 ),
117
139
testAccCheckGitlabGroupExists ("gitlab_group.nested_foo" , & nestedGroup ),
118
140
testAccCheckGitlabGroupAttributes (& nestedGroup , & testAccGitlabGroupExpectedAttributes {
119
- Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
120
- Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
121
- Description : "Terraform acceptance tests - new parent" ,
122
- LFSEnabled : true ,
123
- Parent : & group2 ,
141
+ Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
142
+ Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
143
+ Description : "Terraform acceptance tests - new parent" ,
144
+ LFSEnabled : true ,
145
+ Visibility : "public" , // default value
146
+ ProjectCreationLevel : "maintainer" , // default value
147
+ SubGroupCreationLevel : "owner" , // default value
148
+ TwoFactorGracePeriod : 48 , // default value
149
+ Parent : & group2 ,
124
150
}),
125
151
),
126
152
},
@@ -131,10 +157,14 @@ func TestAccGitlabGroup_nested(t *testing.T) {
131
157
testAccCheckGitlabGroupExists ("gitlab_group.foo2" , & group2 ),
132
158
testAccCheckGitlabGroupExists ("gitlab_group.nested_foo" , & nestedGroup ),
133
159
testAccCheckGitlabGroupAttributes (& nestedGroup , & testAccGitlabGroupExpectedAttributes {
134
- Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
135
- Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
136
- Description : "Terraform acceptance tests - updated" ,
137
- LFSEnabled : true ,
160
+ Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
161
+ Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
162
+ Description : "Terraform acceptance tests - updated" ,
163
+ LFSEnabled : true ,
164
+ Visibility : "public" , // default value
165
+ ProjectCreationLevel : "maintainer" , // default value
166
+ SubGroupCreationLevel : "owner" , // default value
167
+ TwoFactorGracePeriod : 48 , // default value
138
168
}),
139
169
),
140
170
},
@@ -150,6 +180,10 @@ func TestAccGitlabGroup_nested(t *testing.T) {
150
180
// Path: fmt.Sprintf("nfoo-path-%d", rInt),
151
181
// Description: "Terraform acceptance tests",
152
182
// LFSEnabled: true,
183
+ // Visibility: "public", // default value
184
+ // ProjectCreationLevel: "maintainer", // default value
185
+ // SubGroupCreationLevel: "owner", // default value
186
+ // TwoFactorGracePeriod: 48, // default value
153
187
// Parent: &group,
154
188
// }),
155
189
// ),
@@ -228,12 +262,21 @@ func testAccCheckGitlabGroupExists(n string, group *gitlab.Group) resource.TestC
228
262
}
229
263
230
264
type testAccGitlabGroupExpectedAttributes struct {
231
- Name string
232
- Path string
233
- Description string
234
- Parent * gitlab.Group
235
- LFSEnabled bool
236
- RequestAccessEnabled bool
265
+ Name string
266
+ Path string
267
+ Description string
268
+ Parent * gitlab.Group
269
+ LFSEnabled bool
270
+ RequestAccessEnabled bool
271
+ Visibility gitlab.VisibilityValue
272
+ ShareWithGroupLock bool
273
+ AutoDevopsEnabled bool
274
+ EmailsDisabled bool
275
+ MentionsDisabled bool
276
+ ProjectCreationLevel gitlab.ProjectCreationLevelValue
277
+ SubGroupCreationLevel gitlab.SubGroupCreationLevelValue
278
+ RequireTwoFactorAuth bool
279
+ TwoFactorGracePeriod int
237
280
}
238
281
239
282
func testAccCheckGitlabGroupAttributes (group * gitlab.Group , want * testAccGitlabGroupExpectedAttributes ) resource.TestCheckFunc {
@@ -254,10 +297,46 @@ func testAccCheckGitlabGroupAttributes(group *gitlab.Group, want *testAccGitlabG
254
297
return fmt .Errorf ("got lfs_enabled %t; want %t" , group .LFSEnabled , want .LFSEnabled )
255
298
}
256
299
300
+ if group .Visibility != want .Visibility {
301
+ return fmt .Errorf ("got request_visibility_level: %q; want %q" , group .Visibility , want .Visibility )
302
+ }
303
+
304
+ if group .AutoDevopsEnabled != want .AutoDevopsEnabled {
305
+ return fmt .Errorf ("got request_auto_devops_enabled: %t; want %t" , group .AutoDevopsEnabled , want .AutoDevopsEnabled )
306
+ }
307
+
308
+ if group .EmailsDisabled != want .EmailsDisabled {
309
+ return fmt .Errorf ("got request_emails_disabled: %t; want %t" , group .EmailsDisabled , want .EmailsDisabled )
310
+ }
311
+
312
+ if group .MentionsDisabled != want .MentionsDisabled {
313
+ return fmt .Errorf ("got request_mentions_disabled: %t; want %t" , group .MentionsDisabled , want .MentionsDisabled )
314
+ }
315
+
257
316
if group .RequestAccessEnabled != want .RequestAccessEnabled {
258
317
return fmt .Errorf ("got request_access_enabled %t; want %t" , group .RequestAccessEnabled , want .RequestAccessEnabled )
259
318
}
260
319
320
+ if group .ProjectCreationLevel != want .ProjectCreationLevel {
321
+ return fmt .Errorf ("got project_creation_level %s; want %s" , group .ProjectCreationLevel , want .ProjectCreationLevel )
322
+ }
323
+
324
+ if group .SubGroupCreationLevel != want .SubGroupCreationLevel {
325
+ return fmt .Errorf ("got subgroup_creation_level %s; want %s" , group .SubGroupCreationLevel , want .SubGroupCreationLevel )
326
+ }
327
+
328
+ if group .RequireTwoFactorAuth != want .RequireTwoFactorAuth {
329
+ return fmt .Errorf ("got require_two_factor_authentication %t; want %t" , group .RequireTwoFactorAuth , want .RequireTwoFactorAuth )
330
+ }
331
+
332
+ if group .TwoFactorGracePeriod != want .TwoFactorGracePeriod {
333
+ return fmt .Errorf ("got two_factor_grace_period %d; want %d" , group .TwoFactorGracePeriod , want .TwoFactorGracePeriod )
334
+ }
335
+
336
+ if group .ShareWithGroupLock != want .ShareWithGroupLock {
337
+ return fmt .Errorf ("got share_with_group_lock %t; want %t" , group .ShareWithGroupLock , want .ShareWithGroupLock )
338
+ }
339
+
261
340
if want .Parent != nil {
262
341
if group .ParentID != want .Parent .ID {
263
342
return fmt .Errorf ("got parent_id %d; want %d" , group .ParentID , want .Parent .ID )
@@ -318,6 +397,14 @@ resource "gitlab_group" "foo" {
318
397
description = "Terraform acceptance tests! Updated description"
319
398
lfs_enabled = false
320
399
request_access_enabled = true
400
+ project_creation_level = "developer"
401
+ subgroup_creation_level = "maintainer"
402
+ require_two_factor_authentication = true
403
+ two_factor_grace_period = 56
404
+ auto_devops_enabled = true
405
+ emails_disabled = true
406
+ mentions_disabled = true
407
+ share_with_group_lock = true
321
408
322
409
# So that acceptance tests can be run in a gitlab organization
323
410
# with no billing
0 commit comments