@@ -32,7 +32,7 @@ func TestAccGitlabProjectAccessToken_basic(t *testing.T) {
32
32
}),
33
33
),
34
34
},
35
- // Update the pipeline trigger to change the parameters
35
+ // Update the Project Access Token to change the parameters
36
36
{
37
37
Config : testAccGitlabProjectAccessTokenUpdateConfig (rInt ),
38
38
Check : resource .ComposeTestCheckFunc (
@@ -44,7 +44,20 @@ func TestAccGitlabProjectAccessToken_basic(t *testing.T) {
44
44
}),
45
45
),
46
46
},
47
- // Update the pipeline trigger to get back to initial settings
47
+ // Add a CICD variable with Project Access Token value
48
+ {
49
+ Config : testAccGitlabProjectAccessTokenUpdateConfigWithCICDvar (rInt ),
50
+ Check : resource .ComposeTestCheckFunc (
51
+ testAccCheckGitlabProjectAccessTokenExists ("gitlab_project_access_token.bar" , & pat ),
52
+ testAccCheckGitlabProjectVariableExists (testAccProvider .Meta ().(* gitlab.Client ), "gitlab_project_variable.var" ),
53
+ testAccCheckGitlabProjectAccessTokenAttributes (& pat , & testAccGitlabProjectAccessTokenExpectedAttributes {
54
+ name : "my new project token" ,
55
+ scopes : map [string ]bool {"read_repository" : false , "api" : true , "write_repository" : false , "read_api" : false },
56
+ expiresAt : "2022-05-01" ,
57
+ }),
58
+ ),
59
+ },
60
+ //Restore Project Access Token initial parameters
48
61
{
49
62
Config : testAccGitlabProjectAccessTokenConfig (rInt ),
50
63
Check : resource .ComposeTestCheckFunc (
@@ -202,3 +215,31 @@ resource "gitlab_project_access_token" "bar" {
202
215
}
203
216
` , rInt )
204
217
}
218
+
219
+ func testAccGitlabProjectAccessTokenUpdateConfigWithCICDvar (rInt int ) string {
220
+ return fmt .Sprintf (`
221
+ resource "gitlab_project" "foo" {
222
+ name = "foo-%d"
223
+ description = "Terraform acceptance tests"
224
+
225
+ # So that acceptance tests can be run in a gitlab organization
226
+ # with no billing
227
+ visibility_level = "public"
228
+ }
229
+
230
+ resource "gitlab_project_access_token" "bar" {
231
+ name = "my new project token"
232
+ project = gitlab_project.foo.id
233
+ expires_at = "2022-05-01"
234
+ scopes = ["api"]
235
+ }
236
+
237
+
238
+ resource "gitlab_project_variable" "var" {
239
+ project = gitlab_project.foo.id
240
+ key = "my_proj_access_token"
241
+ value = gitlab_project_access_token.bar.token
242
+ }
243
+
244
+ ` , rInt )
245
+ }
0 commit comments