@@ -16,6 +16,7 @@ import (
1616 "github.com/hashicorp/terraform-plugin-framework/types"
1717 "github.com/hashicorp/terraform-plugin-testing/helper/acctest"
1818 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
19+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
1920 "k8s.io/client-go/rest"
2021 "k8s.io/client-go/tools/clientcmd"
2122 "k8s.io/client-go/util/homedir"
@@ -366,6 +367,58 @@ func TestAccArgoCDCluster_outsideDeletion(t *testing.T) {
366367 })
367368}
368369
370+ func TestAccArgoCDCluster_urlUpdate (t * testing.T ) {
371+ resource .Test (t , resource.TestCase {
372+ PreCheck : func () { testAccPreCheck (t ) },
373+ ProviderFactories : testAccProviders ,
374+ Steps : []resource.TestStep {
375+ {
376+ Config : testAccArgoCDClusterBearerToken_urlChange ("https://kubernetes.default.svc.cluster.local" ),
377+ Check : resource .ComposeTestCheckFunc (
378+ resource .TestCheckResourceAttr (
379+ "argocd_cluster.check_url_change" ,
380+ "info.0.connection_state.0.status" ,
381+ "Successful" ,
382+ ),
383+ resource .TestCheckResourceAttrSet (
384+ "argocd_cluster.check_url_change" ,
385+ "info.0.server_version" ,
386+ ),
387+ resource .TestCheckResourceAttr (
388+ "argocd_cluster.check_url_change" ,
389+ "config.0.tls_client_config.0.insecure" ,
390+ strconv .FormatBool (isInsecure ()),
391+ ),
392+ ),
393+ },
394+ {
395+ Config : testAccArgoCDClusterBearerToken_urlChange ("https://kubernetes.default" ),
396+ ConfigPlanChecks : resource.ConfigPlanChecks {
397+ PreApply : []plancheck.PlanCheck {
398+ plancheck .ExpectResourceAction ("argocd_cluster.check_url_change" , plancheck .ResourceActionReplace ),
399+ },
400+ },
401+ Check : resource .ComposeTestCheckFunc (
402+ resource .TestCheckResourceAttr (
403+ "argocd_cluster.check_url_change" ,
404+ "info.0.connection_state.0.status" ,
405+ "Successful" ,
406+ ),
407+ resource .TestCheckResourceAttrSet (
408+ "argocd_cluster.check_url_change" ,
409+ "info.0.server_version" ,
410+ ),
411+ resource .TestCheckResourceAttr (
412+ "argocd_cluster.check_url_change" ,
413+ "config.0.tls_client_config.0.insecure" ,
414+ strconv .FormatBool (isInsecure ()),
415+ ),
416+ ),
417+ },
418+ },
419+ })
420+ }
421+
369422func TestAccArgoCDCluster_namespacesErrorWhenEmpty (t * testing.T ) {
370423 name := acctest .RandString (10 )
371424
@@ -523,6 +576,17 @@ resource "argocd_cluster" "cluster_with_no_trailing_slash" {
523576}` , getConfig (), getConfig ())
524577}
525578
579+ func testAccArgoCDClusterBearerToken_urlChange (url string ) string {
580+ return fmt .Sprintf (`
581+ resource "argocd_cluster" "check_url_change" {
582+ server = "%s"
583+ config {
584+ %s
585+ }
586+ }
587+ ` , url , getConfig ())
588+ }
589+
526590func testAccArgoCDClusterMetadata_addLabels (clusterName string ) string {
527591 return fmt .Sprintf (`
528592resource "argocd_cluster" "cluster_metadata" {
0 commit comments