@@ -114,6 +114,35 @@ func TestAccArgoCDProject_tokensCoexistence(t *testing.T) {
114114 })
115115}
116116
117+ func TestAccArgoCDProjectUpdateAddRole (t * testing.T ) {
118+ name := acctest .RandomWithPrefix ("test-acc" )
119+
120+ resource .Test (t , resource.TestCase {
121+ PreCheck : func () { testAccPreCheck (t ) },
122+ ProviderFactories : testAccProviders ,
123+ Steps : []resource.TestStep {
124+ {
125+ Config : testAccArgoCDProjectSimpleWithoutRole (name ),
126+ Check : resource .ComposeTestCheckFunc (
127+ resource .TestCheckResourceAttrSet (
128+ "argocd_project.simple" ,
129+ "metadata.0.uid" ,
130+ ),
131+ ),
132+ },
133+ {
134+ Config : testAccArgoCDProjectSimpleWithRole (name ),
135+ Check : resource .ComposeTestCheckFunc (
136+ resource .TestCheckResourceAttrSet (
137+ "argocd_project.simple" ,
138+ "metadata.0.uid" ,
139+ ),
140+ ),
141+ },
142+ },
143+ })
144+ }
145+
117146func testAccArgoCDProjectSimple (name string ) string {
118147 return fmt .Sprintf (`
119148resource "argocd_project" "simple" {
@@ -393,3 +422,80 @@ resource "argocd_project" "failure" {
393422}
394423 ` , name , name , name )
395424}
425+
426+ func testAccArgoCDProjectSimpleWithoutRole (name string ) string {
427+ return fmt .Sprintf (`
428+ resource "argocd_project" "simple" {
429+ metadata {
430+ name = "%s"
431+ namespace = "argocd"
432+ labels = {
433+ acceptance = "true"
434+ }
435+ annotations = {
436+ "this.is.a.really.long.nested.key" = "yes, really!"
437+ }
438+ }
439+
440+ spec {
441+ description = "simple project"
442+ source_repos = ["*"]
443+
444+ destination {
445+ name = "anothercluster"
446+ namespace = "bar"
447+ }
448+ orphaned_resources {
449+ warn = true
450+ ignore {
451+ group = "apps/v1"
452+ kind = "Deployment"
453+ name = "ignored1"
454+ }
455+ }
456+ }
457+ }
458+ ` , name )
459+ }
460+
461+ func testAccArgoCDProjectSimpleWithRole (name string ) string {
462+ return fmt .Sprintf (`
463+ resource "argocd_project" "simple" {
464+ metadata {
465+ name = "%s"
466+ namespace = "argocd"
467+ labels = {
468+ acceptance = "true"
469+ }
470+ annotations = {
471+ "this.is.a.really.long.nested.key" = "yes, really!"
472+ }
473+ }
474+
475+ spec {
476+ description = "simple project"
477+ source_repos = ["*"]
478+
479+ destination {
480+ name = "anothercluster"
481+ namespace = "bar"
482+ }
483+ orphaned_resources {
484+ warn = true
485+ ignore {
486+ group = "apps/v1"
487+ kind = "Deployment"
488+ name = "ignored1"
489+ }
490+ }
491+ role {
492+ name = "anotherrole"
493+ policies = [
494+ "p, proj:%s:anotherrole, applications, get, %s/*, allow",
495+ "p, proj:%s:anotherrole, applications, sync, %s/*, deny",
496+ ]
497+ }
498+ }
499+ }
500+ ` , name , name , name , name , name )
501+ }
0 commit comments