diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d181c59..c253ff17 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -121,9 +121,8 @@ jobs: needs: build runs-on: ubuntu-latest if: "!github.event.pull_request.head.repo.fork" - timeout-minutes: 15 strategy: - max-parallel: 2 + max-parallel: 1 fail-fast: false matrix: terraform: @@ -176,9 +175,8 @@ jobs: needs: build runs-on: ubuntu-latest if: "!github.event.pull_request.head.repo.fork" - timeout-minutes: 15 strategy: - max-parallel: 2 + max-parallel: 1 fail-fast: false matrix: tofu: @@ -225,7 +223,7 @@ jobs: cleanup: name: Cleanup - if: "!github.event.pull_request.head.repo.fork" + if: always() needs: [tests-acceptance, tests-acceptance-opentofu] runs-on: ubuntu-latest timeout-minutes: 15 diff --git a/.github/workflows/smoketests.yml b/.github/workflows/smoketests.yml index b3edaeee..e14c52f7 100644 --- a/.github/workflows/smoketests.yml +++ b/.github/workflows/smoketests.yml @@ -40,9 +40,8 @@ jobs: name: Matrix Acceptance Tests needs: build runs-on: ubuntu-latest - timeout-minutes: 15 strategy: - max-parallel: 2 + max-parallel: 1 fail-fast: false matrix: terraform: @@ -112,10 +111,8 @@ jobs: name: OpenTofu Matrix Acceptance Tests needs: build runs-on: ubuntu-latest - if: "!github.event.pull_request.head.repo.fork" - timeout-minutes: 15 strategy: - max-parallel: 2 + max-parallel: 1 fail-fast: false matrix: tofu: diff --git a/twingate/internal/test/acctests/resource/connector-tokens_test.go b/twingate/internal/test/acctests/resource/connector-tokens_test.go index b66820e9..cc203252 100644 --- a/twingate/internal/test/acctests/resource/connector-tokens_test.go +++ b/twingate/internal/test/acctests/resource/connector-tokens_test.go @@ -12,24 +12,24 @@ import ( ) func TestAccRemoteConnectorWithTokens(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector With Tokens", func(t *testing.T) { - const terraformResourceName = "test_t1" - theResource := acctests.TerraformConnectorTokens(terraformResourceName) - remoteNetworkName := test.RandomName() + t.Parallel() - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorTokensInvalidated, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnectorTokens(terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorTokensSet(theResource), - ), - }, + const terraformResourceName = "test_t1" + theResource := acctests.TerraformConnectorTokens(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorTokensInvalidated, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnectorTokens(terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorTokensSet(theResource), + ), }, - }) + }, }) } diff --git a/twingate/internal/test/acctests/resource/connector_test.go b/twingate/internal/test/acctests/resource/connector_test.go index 933e9b20..9996c396 100644 --- a/twingate/internal/test/acctests/resource/connector_test.go +++ b/twingate/internal/test/acctests/resource/connector_test.go @@ -14,139 +14,139 @@ import ( ) func TestAccRemoteConnectorCreate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector", func(t *testing.T) { - const terraformResourceName = "test_c1" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestCheckResourceAttrSet(theResource, attr.Name), - ), - }, + t.Parallel() + + const terraformResourceName = "test_c1" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + sdk.TestCheckResourceAttrSet(theResource, attr.Name), + ), }, - }) + }, }) } func TestAccRemoteConnectorWithCustomName(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector With Custom Name", func(t *testing.T) { - const terraformResourceName = "test_c2" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - connectorName := test.RandomConnectorName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestMatchResourceAttr(theResource, attr.Name, regexp.MustCompile(connectorName)), - ), - }, + t.Parallel() + + const terraformResourceName = "test_c2" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + connectorName := test.RandomConnectorName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + sdk.TestMatchResourceAttr(theResource, attr.Name, regexp.MustCompile(connectorName)), + ), }, - }) + }, }) } func TestAccRemoteConnectorImport(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector - Import", func(t *testing.T) { - const terraformResourceName = "test_c3" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - connectorName := test.RandomConnectorName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestMatchResourceAttr(theResource, attr.Name, regexp.MustCompile(connectorName[:len(connectorName)-3]+".*")), - ), - }, - { - ResourceName: theResource, - ImportState: true, - ImportStateVerify: true, - }, + t.Parallel() + + const terraformResourceName = "test_c3" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + connectorName := test.RandomConnectorName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + sdk.TestMatchResourceAttr(theResource, attr.Name, regexp.MustCompile(connectorName[:len(connectorName)-3]+".*")), + ), }, - }) + { + ResourceName: theResource, + ImportState: true, + ImportStateVerify: true, + }, + }, }) } func TestAccRemoteConnectorNotAllowedToChangeRemoteNetworkId(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector - should fail on remote_network_id update", func(t *testing.T) { - const ( - terraformConnectorName = "test_c4" - terraformRemoteNetworkName1 = "test_c4_1" - terraformRemoteNetworkName2 = "test_c4_2" - ) - theResource := acctests.TerraformConnector(terraformConnectorName) - remoteNetworkName1 := test.RandomName() - remoteNetworkName2 := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnector(terraformRemoteNetworkName1, terraformConnectorName, remoteNetworkName1), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformRemoteNetworkName1)), - ), - }, - { - Config: terraformResourceTwingateConnector(terraformRemoteNetworkName2, terraformConnectorName, remoteNetworkName2), - ExpectError: regexp.MustCompile(resource.ErrNotAllowChangeRemoteNetworkID.Error()), - }, + t.Parallel() + + const ( + terraformConnectorName = "test_c4" + terraformRemoteNetworkName1 = "test_c4_1" + terraformRemoteNetworkName2 = "test_c4_2" + ) + theResource := acctests.TerraformConnector(terraformConnectorName) + remoteNetworkName1 := test.RandomName() + remoteNetworkName2 := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnector(terraformRemoteNetworkName1, terraformConnectorName, remoteNetworkName1), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformRemoteNetworkName1)), + ), + }, + { + Config: terraformResourceTwingateConnector(terraformRemoteNetworkName2, terraformConnectorName, remoteNetworkName2), + ExpectError: regexp.MustCompile(resource.ErrNotAllowChangeRemoteNetworkID.Error()), }, - }) + }, }) } func TestAccTwingateConnectorReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector ReCreate After Deletion", func(t *testing.T) { - const terraformResourceName = "test_c5" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - acctests.DeleteTwingateResource(theResource, resource.TwingateConnector), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - ), - }, + t.Parallel() + + const terraformResourceName = "test_c5" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + acctests.DeleteTwingateResource(theResource, resource.TwingateConnector), + ), + ExpectNonEmptyPlan: true, }, - }) + { + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + ), + }, + }, }) } @@ -196,77 +196,77 @@ func checkTwingateConnectorSetWithRemoteNetwork(connectorResource, remoteNetwork } func TestAccRemoteConnectorUpdateName(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector Update Name", func(t *testing.T) { - const terraformResourceName = "test_c6" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - connectorName := test.RandomConnectorName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestCheckResourceAttrSet(theResource, attr.Name), - ), - }, - { - Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, attr.Name, connectorName), - ), - }, + t.Parallel() + + const terraformResourceName = "test_c6" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + connectorName := test.RandomConnectorName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + sdk.TestCheckResourceAttrSet(theResource, attr.Name), + ), }, - }) + { + Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, attr.Name, connectorName), + ), + }, + }, }) } func TestAccRemoteConnectorCreateWithNotificationStatus(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Connector With Notification Status", func(t *testing.T) { - const terraformResourceName = "test_c7" - theResource := acctests.TerraformConnector(terraformResourceName) - remoteNetworkName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestCheckResourceAttrSet(theResource, attr.Name), - ), - }, - { - // expecting no changes, as by default notifications enabled - PlanOnly: true, - Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, true), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "true"), - ), - }, - { - Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, false), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"), - ), - }, - { - // expecting no changes, when user removes `status_updates_enabled` field from terraform - PlanOnly: true, - Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"), - ), - }, + t.Parallel() + + const terraformResourceName = "test_c7" + theResource := acctests.TerraformConnector(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateConnectorAndRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), + sdk.TestCheckResourceAttrSet(theResource, attr.Name), + ), }, - }) + { + // expecting no changes, as by default notifications enabled + PlanOnly: true, + Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, true), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "true"), + ), + }, + { + Config: terraformResourceTwingateConnectorWithNotificationStatus(terraformResourceName, terraformResourceName, remoteNetworkName, false), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"), + ), + }, + { + // expecting no changes, when user removes `status_updates_enabled` field from terraform + PlanOnly: true, + Config: terraformResourceTwingateConnector(terraformResourceName, terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, attr.StatusUpdatesEnabled, "false"), + ), + }, + }, }) } @@ -282,6 +282,8 @@ func terraformResourceTwingateConnectorWithNotificationStatus(terraformRemoteNet } func TestAccRemoteConnectorCreateWithNotificationStatusFalse(t *testing.T) { + t.Parallel() + const terraformResourceName = "test_c8" theResource := acctests.TerraformConnector(terraformResourceName) remoteNetworkName := test.RandomName() diff --git a/twingate/internal/test/acctests/resource/group_test.go b/twingate/internal/test/acctests/resource/group_test.go index 531b063d..d92de38b 100644 --- a/twingate/internal/test/acctests/resource/group_test.go +++ b/twingate/internal/test/acctests/resource/group_test.go @@ -18,33 +18,33 @@ var ( ) func TestAccTwingateGroupCreateUpdate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Create/Update", func(t *testing.T) { - const terraformResourceName = "test001" - theResource := acctests.TerraformGroup(terraformResourceName) - nameBefore := test.RandomName() - nameAfter := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroup(terraformResourceName, nameBefore), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), - ), - }, - { - Config: terraformResourceTwingateGroup(terraformResourceName, nameAfter), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), - ), - }, + t.Parallel() + + const terraformResourceName = "test001" + theResource := acctests.TerraformGroup(terraformResourceName) + nameBefore := test.RandomName() + nameAfter := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroup(terraformResourceName, nameBefore), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), + ), }, - }) + { + Config: terraformResourceTwingateGroup(terraformResourceName, nameAfter), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), + ), + }, + }, }) } @@ -57,107 +57,107 @@ func terraformResourceTwingateGroup(terraformResourceName, name string) string { } func TestAccTwingateGroupDeleteNonExisting(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Delete NonExisting", func(t *testing.T) { - const terraformResourceName = "test002" - theResource := acctests.TerraformGroup(terraformResourceName) - groupName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroup(terraformResourceName, groupName), - Destroy: true, - }, - { - Config: terraformResourceTwingateGroup(terraformResourceName, groupName), - ConfigPlanChecks: sdk.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), - }, + t.Parallel() + + const terraformResourceName = "test002" + theResource := acctests.TerraformGroup(terraformResourceName) + groupName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroup(terraformResourceName, groupName), + Destroy: true, + }, + { + Config: terraformResourceTwingateGroup(terraformResourceName, groupName), + ConfigPlanChecks: sdk.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), }, }, }, - }) + }, }) } func TestAccTwingateGroupReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Create After Deletion", func(t *testing.T) { - const terraformResourceName = "test003" - theResource := acctests.TerraformGroup(terraformResourceName) - groupName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroup(terraformResourceName, groupName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - acctests.DeleteTwingateResource(theResource, resource.TwingateGroup), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceTwingateGroup(terraformResourceName, groupName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - ), - }, + t.Parallel() + + const terraformResourceName = "test003" + theResource := acctests.TerraformGroup(terraformResourceName) + groupName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroup(terraformResourceName, groupName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + acctests.DeleteTwingateResource(theResource, resource.TwingateGroup), + ), + ExpectNonEmptyPlan: true, + }, + { + Config: terraformResourceTwingateGroup(terraformResourceName, groupName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + ), }, - }) + }, }) } func TestAccTwingateGroupWithSecurityPolicy(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Create/Update - With Security Policy", func(t *testing.T) { - const terraformResourceName = "test004" - theResource := acctests.TerraformGroup(terraformResourceName) - name := test.RandomName() - - securityPolicies, err := acctests.ListSecurityPolicies() - if err != nil { - t.Skip("can't run test:", err) - } - - testPolicy := securityPolicies[0] - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroup(terraformResourceName, name), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, name), - ), - }, - { - Config: terraformResourceTwingateGroupWithSecurityPolicy(terraformResourceName, name, testPolicy.ID), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, name), - sdk.TestCheckResourceAttr(theResource, attr.SecurityPolicyID, testPolicy.ID), - ), - }, - { - // expecting no changes - PlanOnly: true, - Config: terraformResourceTwingateGroup(terraformResourceName, name), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, name), - ), - }, + t.Parallel() + + const terraformResourceName = "test004" + theResource := acctests.TerraformGroup(terraformResourceName) + name := test.RandomName() + + securityPolicies, err := acctests.ListSecurityPolicies() + if err != nil { + t.Skip("can't run test:", err) + } + + testPolicy := securityPolicies[0] + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroup(terraformResourceName, name), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, name), + ), + }, + { + Config: terraformResourceTwingateGroupWithSecurityPolicy(terraformResourceName, name, testPolicy.ID), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, name), + sdk.TestCheckResourceAttr(theResource, attr.SecurityPolicyID, testPolicy.ID), + ), + }, + { + // expecting no changes + PlanOnly: true, + Config: terraformResourceTwingateGroup(terraformResourceName, name), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, name), + ), }, - }) + }, }) } @@ -171,92 +171,92 @@ func terraformResourceTwingateGroupWithSecurityPolicy(terraformResourceName, nam } func TestAccTwingateGroupUsersAuthoritativeByDefault(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Users Authoritative By Default", func(t *testing.T) { - const terraformResourceName = "test005" - theResource := acctests.TerraformGroup(terraformResourceName) - groupName := test.RandomName() - - users, userIDs := genNewUsers("u005", 3) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), - acctests.CheckGroupUsersLen(theResource, 1), - ), - }, - { - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), - Check: acctests.ComposeTestCheckFunc( - // added new user to the group though API - acctests.AddGroupUser(theResource, groupName, userIDs[1]), - acctests.WaitTestFunc(), - acctests.CheckGroupUsersLen(theResource, 2), - ), - // expecting drift - terraform going to remove unknown user - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), - acctests.CheckGroupUsersLen(theResource, 1), - ), - }, - { - // added 2 new users to the group though terraform - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), - acctests.CheckGroupUsersLen(theResource, 3), - ), - }, - { - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), - Check: acctests.ComposeTestCheckFunc( - // delete one user from the group though API - acctests.DeleteGroupUser(theResource, userIDs[2]), - acctests.WaitTestFunc(), - sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), - acctests.CheckGroupUsersLen(theResource, 2), - ), - // expecting drift - terraform going to restore deleted user - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), - acctests.CheckGroupUsersLen(theResource, 3), - ), - }, - { - // remove 2 users from the group though terraform - Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), - acctests.CheckGroupUsersLen(theResource, 1), - ), - }, - { - // expecting no drift - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], true), - PlanOnly: true, - }, - { - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:2], true), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "2"), - acctests.CheckGroupUsersLen(theResource, 2), - ), - }, + t.Parallel() + + const terraformResourceName = "test005" + theResource := acctests.TerraformGroup(terraformResourceName) + groupName := test.RandomName() + + users, userIDs := genNewUsers("u005", 3) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), + acctests.CheckGroupUsersLen(theResource, 1), + ), + }, + { + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), + Check: acctests.ComposeTestCheckFunc( + // added new user to the group though API + acctests.AddGroupUser(theResource, groupName, userIDs[1]), + acctests.WaitTestFunc(), + acctests.CheckGroupUsersLen(theResource, 2), + ), + // expecting drift - terraform going to remove unknown user + ExpectNonEmptyPlan: true, + }, + { + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), + acctests.CheckGroupUsersLen(theResource, 1), + ), + }, + { + // added 2 new users to the group though terraform + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), + acctests.CheckGroupUsersLen(theResource, 3), + ), }, - }) + { + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), + Check: acctests.ComposeTestCheckFunc( + // delete one user from the group though API + acctests.DeleteGroupUser(theResource, userIDs[2]), + acctests.WaitTestFunc(), + sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), + acctests.CheckGroupUsersLen(theResource, 2), + ), + // expecting drift - terraform going to restore deleted user + ExpectNonEmptyPlan: true, + }, + { + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:3]), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "3"), + acctests.CheckGroupUsersLen(theResource, 3), + ), + }, + { + // remove 2 users from the group though terraform + Config: terraformResourceTwingateGroupWithUsers(terraformResourceName, groupName, users, userIDs[:1]), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), + acctests.CheckGroupUsersLen(theResource, 1), + ), + }, + { + // expecting no drift + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], true), + PlanOnly: true, + }, + { + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:2], true), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "2"), + acctests.CheckGroupUsersLen(theResource, 2), + ), + }, + }, }) } @@ -284,93 +284,91 @@ func terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, } func TestAccTwingateGroupUsersNotAuthoritative(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Users Not Authoritative", func(t *testing.T) { - const terraformResourceName = "test006" - theResource := acctests.TerraformGroup(terraformResourceName) - groupName := test.RandomName() - - users, userIDs := genNewUsers("u006", 3) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), - acctests.CheckGroupUsersLen(theResource, 1), - ), - }, - { - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), - Check: acctests.ComposeTestCheckFunc( - // added new user to the group though API - acctests.AddGroupUser(theResource, groupName, userIDs[2]), - acctests.WaitTestFunc(), - acctests.CheckGroupUsersLen(theResource, 2), - ), - }, - { - // added new user to the group though terraform - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:2], false), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "2"), - acctests.CheckGroupUsersLen(theResource, 3), - ), - }, - { - // remove one user from the group though terraform - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), - Check: acctests.ComposeTestCheckFunc( - sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), - acctests.CheckGroupUsersLen(theResource, 2), - // remove one user from the group though API - acctests.DeleteGroupUser(theResource, userIDs[2]), - acctests.WaitTestFunc(), - acctests.CheckGroupUsersLen(theResource, 1), - ), - }, - { - // expecting no drift - empty plan - Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), - PlanOnly: true, - }, + t.Parallel() + + const terraformResourceName = "test006" + theResource := acctests.TerraformGroup(terraformResourceName) + groupName := test.RandomName() + + users, userIDs := genNewUsers("u006", 3) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), + acctests.CheckGroupUsersLen(theResource, 1), + ), + }, + { + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), + Check: acctests.ComposeTestCheckFunc( + // added new user to the group though API + acctests.AddGroupUser(theResource, groupName, userIDs[2]), + acctests.WaitTestFunc(), + acctests.CheckGroupUsersLen(theResource, 2), + ), + }, + { + // added new user to the group though terraform + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:2], false), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "2"), + acctests.CheckGroupUsersLen(theResource, 3), + ), + }, + { + // remove one user from the group though terraform + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), + Check: acctests.ComposeTestCheckFunc( + sdk.TestCheckResourceAttr(theResource, userIdsLen, "1"), + acctests.CheckGroupUsersLen(theResource, 2), + // remove one user from the group though API + acctests.DeleteGroupUser(theResource, userIDs[2]), + acctests.WaitTestFunc(), + acctests.CheckGroupUsersLen(theResource, 1), + ), }, - }) + { + // expecting no drift - empty plan + Config: terraformResourceTwingateGroupWithUsersAuthoritative(terraformResourceName, groupName, users, userIDs[:1], false), + PlanOnly: true, + }, + }, }) } func TestAccTwingateGroupUsersCursor(t *testing.T) { - t.Run("Test Twingate Resource : Acc Group Users Cursor", func(t *testing.T) { - acctests.SetPageLimit(1) - - const terraformResourceName = "test007" - theResource := acctests.TerraformGroup(terraformResourceName) - groupName := test.RandomName() - - users, userIDs := genNewUsers("u007", 3) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateGroupDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateGroupAndUsers(terraformResourceName, groupName, users, userIDs), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckGroupUsersLen(theResource, len(users)), - ), - }, - { - Config: terraformResourceTwingateGroupAndUsers(terraformResourceName, groupName, users, userIDs[:2]), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckGroupUsersLen(theResource, 2), - ), - }, + t.Parallel() + + const terraformResourceName = "test007" + theResource := acctests.TerraformGroup(terraformResourceName) + groupName := test.RandomName() + + users, userIDs := genNewUsers("u007", 3) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateGroupDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateGroupAndUsers(terraformResourceName, groupName, users, userIDs), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckGroupUsersLen(theResource, len(users)), + ), + }, + { + Config: terraformResourceTwingateGroupAndUsers(terraformResourceName, groupName, users, userIDs[:2]), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckGroupUsersLen(theResource, 2), + ), }, - }) + }, }) } diff --git a/twingate/internal/test/acctests/resource/remote-network_test.go b/twingate/internal/test/acctests/resource/remote-network_test.go index 09185429..60f1d037 100644 --- a/twingate/internal/test/acctests/resource/remote-network_test.go +++ b/twingate/internal/test/acctests/resource/remote-network_test.go @@ -14,27 +14,27 @@ import ( ) func TestAccTwingateRemoteNetworkCreate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Network Create", func(t *testing.T) { - const terraformResourceName = "test000" - theResource := acctests.TerraformRemoteNetwork(terraformResourceName) - networkName := test.RandomName() - networkLocation := model.LocationAzure - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: createRemoteNetworkWithLocation(terraformResourceName, networkName, networkLocation), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, networkName), - sdk.TestCheckResourceAttr(theResource, attr.Location, networkLocation), - ), - }, + t.Parallel() + + const terraformResourceName = "test000" + theResource := acctests.TerraformRemoteNetwork(terraformResourceName) + networkName := test.RandomName() + networkLocation := model.LocationAzure + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: createRemoteNetworkWithLocation(terraformResourceName, networkName, networkLocation), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, networkName), + sdk.TestCheckResourceAttr(theResource, attr.Location, networkLocation), + ), }, - }) + }, }) } @@ -48,35 +48,35 @@ func createRemoteNetworkWithLocation(terraformResourceName, name, location strin } func TestAccTwingateRemoteNetworkUpdate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Network Update", func(t *testing.T) { - const terraformResourceName = "test001" - theResource := acctests.TerraformRemoteNetwork(terraformResourceName) - nameBefore := test.RandomName() - nameAfter := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceRemoteNetwork(terraformResourceName, nameBefore), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), - sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationOther), - ), - }, - { - Config: createRemoteNetworkWithLocation(terraformResourceName, nameAfter, model.LocationAWS), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), - sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationAWS), - ), - }, + t.Parallel() + + const terraformResourceName = "test001" + theResource := acctests.TerraformRemoteNetwork(terraformResourceName) + nameBefore := test.RandomName() + nameAfter := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceRemoteNetwork(terraformResourceName, nameBefore), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), + sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationOther), + ), + }, + { + Config: createRemoteNetworkWithLocation(terraformResourceName, nameAfter, model.LocationAWS), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), + sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationAWS), + ), }, - }) + }, }) } @@ -89,91 +89,91 @@ func terraformResourceRemoteNetwork(terraformResourceName, name string) string { } func TestAccTwingateRemoteNetworkDeleteNonExisting(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Network Delete NonExisting", func(t *testing.T) { - const terraformResourceName = "test002" - theResource := acctests.TerraformRemoteNetwork(terraformResourceName) - networkName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceRemoteNetwork(terraformResourceName, networkName), - Destroy: true, - }, - { - Config: terraformResourceRemoteNetwork(terraformResourceName, networkName), - ConfigPlanChecks: sdk.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), - }, + t.Parallel() + + const terraformResourceName = "test002" + theResource := acctests.TerraformRemoteNetwork(terraformResourceName) + networkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceRemoteNetwork(terraformResourceName, networkName), + Destroy: true, + }, + { + Config: terraformResourceRemoteNetwork(terraformResourceName, networkName), + ConfigPlanChecks: sdk.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), }, }, }, - }) + }, }) } func TestAccTwingateRemoteNetworkReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Network Re Create After Deletion", func(t *testing.T) { - const terraformResourceName = "test003" - theResource := acctests.TerraformRemoteNetwork(terraformResourceName) - remoteNetworkName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceRemoteNetwork(terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - acctests.DeleteTwingateResource(theResource, resource.TwingateRemoteNetwork), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceRemoteNetwork(terraformResourceName, remoteNetworkName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - ), - }, + t.Parallel() + + const terraformResourceName = "test003" + theResource := acctests.TerraformRemoteNetwork(terraformResourceName) + remoteNetworkName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceRemoteNetwork(terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + acctests.DeleteTwingateResource(theResource, resource.TwingateRemoteNetwork), + ), + ExpectNonEmptyPlan: true, + }, + { + Config: terraformResourceRemoteNetwork(terraformResourceName, remoteNetworkName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + ), }, - }) + }, }) } func TestAccTwingateRemoteNetworkUpdateWithTheSameName(t *testing.T) { - t.Run("Test Twingate Resource : Acc Remote Network Update With The Same Name", func(t *testing.T) { - const terraformResourceName = "test004" - theResource := acctests.TerraformRemoteNetwork(terraformResourceName) - name := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceRemoteNetwork(terraformResourceName, name), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, name), - sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationOther), - ), - }, - { - Config: createRemoteNetworkWithLocation(terraformResourceName, name, model.LocationAWS), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, name), - sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationAWS), - ), - }, + t.Parallel() + + const terraformResourceName = "test004" + theResource := acctests.TerraformRemoteNetwork(terraformResourceName) + name := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateRemoteNetworkDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceRemoteNetwork(terraformResourceName, name), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, name), + sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationOther), + ), + }, + { + Config: createRemoteNetworkWithLocation(terraformResourceName, name, model.LocationAWS), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, name), + sdk.TestCheckResourceAttr(theResource, attr.Location, model.LocationAWS), + ), }, - }) + }, }) } diff --git a/twingate/internal/test/acctests/resource/resource_test.go b/twingate/internal/test/acctests/resource/resource_test.go index ec07f6ef..3c6a1e91 100644 --- a/twingate/internal/test/acctests/resource/resource_test.go +++ b/twingate/internal/test/acctests/resource/resource_test.go @@ -30,6 +30,8 @@ var ( ) func TestAccTwingateResourceCreate(t *testing.T) { + t.Parallel() + const terraformResourceName = "test1" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -55,6 +57,8 @@ func TestAccTwingateResourceCreate(t *testing.T) { } func TestAccTwingateResourceUpdateProtocols(t *testing.T) { + t.Parallel() + const terraformResourceName = "test1u" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -124,6 +128,8 @@ func createResourceWithSimpleProtocols(terraformResourceName, networkName, resou } func TestAccTwingateResourceCreateWithProtocolsAndGroups(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test2" remoteNetworkName := test.RandomName() groupName1 := test.RandomGroupName() @@ -190,6 +196,8 @@ func createResourceWithProtocolsAndGroups(networkName, groupName1, groupName2, r } func TestAccTwingateResourceFullCreationFlow(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test3" remoteNetworkName := test.RandomName() groupName := test.RandomGroupName() @@ -262,6 +270,8 @@ func resourceFullCreationFlow(networkName, groupName, resourceName string) strin } func TestAccTwingateResourceWithInvalidGroupId(t *testing.T) { + t.Parallel() + resourceName := test.RandomResourceName() networkName := test.RandomResourceName() @@ -299,6 +309,8 @@ func createResourceWithInvalidGroupId(networkName, resourceName string) string { } func TestAccTwingateResourceWithTcpDenyAllPolicy(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test5" resourceName := test.RandomResourceName() networkName := test.RandomResourceName() @@ -356,6 +368,8 @@ func createResourceWithTcpDenyAllPolicy(networkName, groupName, resourceName str } func TestAccTwingateResourceWithUdpDenyAllPolicy(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test6" remoteNetworkName := test.RandomName() groupName := test.RandomGroupName() @@ -413,6 +427,8 @@ func createResourceWithUdpDenyAllPolicy(networkName, groupName, resourceName str } func TestAccTwingateResourceWithDenyAllPolicyAndEmptyPortsList(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test7" remoteNetworkName := test.RandomName() groupName := test.RandomGroupName() @@ -473,6 +489,8 @@ func createResourceWithDenyAllPolicyAndEmptyPortsList(networkName, groupName, re } func TestAccTwingateResourceWithInvalidPortRange(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() expectedError := regexp.MustCompile("failed to parse protocols port range") @@ -546,6 +564,8 @@ func createResourceWithRestrictedPolicyAndPortRange(networkName, resourceName, p } func TestAccTwingateResourcePortReorderingCreatesNoChanges(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test9" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -612,6 +632,8 @@ func createResourceWithPortRange(networkName, resourceName, portRange string) st } func TestAccTwingateResourcePortsRepresentationChanged(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test9" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -633,6 +655,8 @@ func TestAccTwingateResourcePortsRepresentationChanged(t *testing.T) { } func TestAccTwingateResourcePortsNotChanged(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test9" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -662,6 +686,8 @@ func TestAccTwingateResourcePortsNotChanged(t *testing.T) { } func TestAccTwingateResourcePortReorderingNoChanges(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test9" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -706,6 +732,8 @@ func TestAccTwingateResourcePortReorderingNoChanges(t *testing.T) { } func TestAccTwingateResourceSetActiveStateOnUpdate(t *testing.T) { + t.Parallel() + const terraformResourceName = "test10" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -738,6 +766,8 @@ func TestAccTwingateResourceSetActiveStateOnUpdate(t *testing.T) { } func TestAccTwingateResourceReCreateAfterDeletion(t *testing.T) { + t.Parallel() + const terraformResourceName = "test10" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -767,6 +797,8 @@ func TestAccTwingateResourceReCreateAfterDeletion(t *testing.T) { } func TestAccTwingateResourceImport(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test12" remoteNetworkName := test.RandomName() groupName := test.RandomGroupName() @@ -885,6 +917,8 @@ func newTerraformGroup(resourceName, groupName string) string { } func TestAccTwingateResourceAddAccessServiceAccounts(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test15" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -942,6 +976,8 @@ func createResource15(networkName, resourceName string, terraformServiceAccount } func TestAccTwingateResourceAddAccessGroupsAndServiceAccounts(t *testing.T) { + t.Parallel() + const theResource = "twingate_resource.test16" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1101,6 +1137,7 @@ func createResource16WithoutGroups(networkName, resourceName string, groups, gro func TestAccTwingateResourceAccessServiceAccountsNotAuthoritative(t *testing.T) { t.Parallel() + const theResource = "twingate_resource.test17" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1214,6 +1251,7 @@ func createResource17(networkName, resourceName string, serviceAccounts, service func TestAccTwingateResourceAccessServiceAccountsAuthoritative(t *testing.T) { t.Parallel() + const theResource = "twingate_resource.test13" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1324,6 +1362,8 @@ func createResource13(networkName, resourceName string, serviceAccounts, service } func TestAccTwingateResourceAccessWithEmptyGroups(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1371,6 +1411,8 @@ func createResource18(networkName, resourceName string) string { } func TestAccTwingateResourceAccessWithEmptyServiceAccounts(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1418,6 +1460,8 @@ func createResource19(networkName, resourceName string) string { } func TestAccTwingateResourceAccessWithEmptyBlock(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1465,6 +1509,7 @@ func createResource20(networkName, resourceName string) string { func TestAccTwingateResourceAccessGroupsNotAuthoritative(t *testing.T) { t.Parallel() + const theResource = "twingate_resource.test22" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1578,6 +1623,7 @@ func createResource22(networkName, resourceName string, groups, groupsID []strin func TestAccTwingateResourceAccessGroupsAuthoritative(t *testing.T) { t.Parallel() + const theResource = "twingate_resource.test23" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1687,6 +1733,8 @@ func createResource23(networkName, resourceName string, groups, groupsID []strin } func TestGetResourceNameFromID(t *testing.T) { + t.Parallel() + cases := []struct { input string expected string @@ -1712,6 +1760,8 @@ func TestGetResourceNameFromID(t *testing.T) { } func TestAccTwingateCreateResourceWithFlagIsVisible(t *testing.T) { + t.Parallel() + const terraformResourceName = "test24" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -1784,6 +1834,8 @@ func createResourceWithFlagIsVisible(terraformResourceName, networkName, resourc } func TestAccTwingateCreateResourceWithFlagIsBrowserShortcutEnabled(t *testing.T) { + t.Parallel() + const terraformResourceName = "test25" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -1854,6 +1906,7 @@ func createResourceWithFlagIsBrowserShortcutEnabled(terraformResourceName, netwo func TestAccTwingateResourceGroupsAuthoritativeByDefault(t *testing.T) { t.Parallel() + const theResource = "twingate_resource.test26" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -1962,6 +2015,8 @@ func createResource26(networkName, resourceName string, groups, groupsID []strin } func TestAccTwingateResourceDoesNotSupportOldGroups(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2011,6 +2066,8 @@ func createResource28(networkName, resourceName string, groups, groupsID []strin } func TestAccTwingateResourceCreateWithAlias(t *testing.T) { + t.Parallel() + const terraformResourceName = "test29" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2049,6 +2106,8 @@ func TestAccTwingateResourceCreateWithAlias(t *testing.T) { } func TestAccTwingateResourceUpdateWithInvalidAlias(t *testing.T) { + t.Parallel() + const terraformResourceName = "test29_update_invalid" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2074,6 +2133,8 @@ func TestAccTwingateResourceUpdateWithInvalidAlias(t *testing.T) { } func TestAccTwingateResourceCreateWithInvalidAlias(t *testing.T) { + t.Parallel() + const terraformResourceName = "test29_create_invalid" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2120,7 +2181,7 @@ func createResource29WithoutAlias(terraformResourceName, networkName, resourceNa } func TestAccTwingateResourceGroupsCursor(t *testing.T) { - acctests.SetPageLimit(1) + t.Parallel() const terraformResourceName = "test27" theResource := acctests.TerraformResource(terraformResourceName) @@ -2199,6 +2260,8 @@ func createResourceWithGroupsAndServiceAccounts(name, networkName, resourceName } func TestAccTwingateResourceCreateWithPort(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2251,6 +2314,8 @@ func createResourceWithPort(networkName, resourceName, port string) string { } func TestAccTwingateResourceUpdateWithPort(t *testing.T) { + t.Parallel() + theResource := acctests.TerraformResource("test30") remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2275,6 +2340,8 @@ func TestAccTwingateResourceUpdateWithPort(t *testing.T) { } func TestAccTwingateResourceWithPortsFailsForAllowAllAndDenyAllPolicy(t *testing.T) { + t.Parallel() + const terraformResourceName = "test28" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2321,6 +2388,8 @@ func createResourceWithPorts(name, networkName, resourceName, policy string) str } func TestAccTwingateResourceWithoutPortsOkForAllowAllAndDenyAllPolicy(t *testing.T) { + t.Parallel() + const terraformResourceName = "test29" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2375,6 +2444,8 @@ func createResourceWithoutPorts(name, networkName, resourceName, policy string) } func TestAccTwingateResourceWithRestrictedPolicy(t *testing.T) { + t.Parallel() + const terraformResourceName = "test30" remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() @@ -2398,6 +2469,8 @@ func TestAccTwingateResourceWithRestrictedPolicy(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionDenyAllToRestricted(t *testing.T) { + t.Parallel() + const terraformResourceName = "test31" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2429,6 +2502,8 @@ func TestAccTwingateResourcePolicyTransitionDenyAllToRestricted(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionDenyAllToAllowAll(t *testing.T) { + t.Parallel() + const terraformResourceName = "test32" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2460,6 +2535,8 @@ func TestAccTwingateResourcePolicyTransitionDenyAllToAllowAll(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionRestrictedToDenyAll(t *testing.T) { + t.Parallel() + const terraformResourceName = "test33" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2491,6 +2568,8 @@ func TestAccTwingateResourcePolicyTransitionRestrictedToDenyAll(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionRestrictedToAllowAll(t *testing.T) { + t.Parallel() + const terraformResourceName = "test34" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2522,6 +2601,8 @@ func TestAccTwingateResourcePolicyTransitionRestrictedToAllowAll(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionRestrictedToAllowAllWithPortsShouldFail(t *testing.T) { + t.Parallel() + const terraformResourceName = "test35" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2549,6 +2630,8 @@ func TestAccTwingateResourcePolicyTransitionRestrictedToAllowAllWithPortsShouldF } func TestAccTwingateResourcePolicyTransitionAllowAllToRestricted(t *testing.T) { + t.Parallel() + const terraformResourceName = "test36" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2580,6 +2663,8 @@ func TestAccTwingateResourcePolicyTransitionAllowAllToRestricted(t *testing.T) { } func TestAccTwingateResourcePolicyTransitionAllowAllToDenyAll(t *testing.T) { + t.Parallel() + const terraformResourceName = "test37" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2611,6 +2696,8 @@ func TestAccTwingateResourcePolicyTransitionAllowAllToDenyAll(t *testing.T) { } func TestAccTwingateResourceTestCaseInsensitiveAlias(t *testing.T) { + t.Parallel() + const terraformResourceName = "test38" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2643,6 +2730,8 @@ func TestAccTwingateResourceTestCaseInsensitiveAlias(t *testing.T) { } func TestAccTwingateResourceWithBrowserOption(t *testing.T) { + t.Parallel() + const terraformResourceName = "test40" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2675,6 +2764,8 @@ func TestAccTwingateResourceWithBrowserOption(t *testing.T) { } func TestAccTwingateResourceWithBrowserOptionFailOnUpdate(t *testing.T) { + t.Parallel() + const terraformResourceName = "test41" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2708,6 +2799,8 @@ func TestAccTwingateResourceWithBrowserOptionFailOnUpdate(t *testing.T) { } func TestAccTwingateResourceWithBrowserOptionRecovered(t *testing.T) { + t.Parallel() + const terraformResourceName = "test42" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2737,6 +2830,8 @@ func TestAccTwingateResourceWithBrowserOptionRecovered(t *testing.T) { } func TestAccTwingateResourceWithBrowserOptionIP(t *testing.T) { + t.Parallel() + const terraformResourceName = "testIPWithBrowserOption" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2771,6 +2866,8 @@ func TestAccTwingateResourceWithBrowserOptionIP(t *testing.T) { } func TestAccTwingateResourceWithBrowserOptionCIDR(t *testing.T) { + t.Parallel() + const terraformResourceName = "testCIDRWithBrowserOption" theResource := acctests.TerraformResource(terraformResourceName) remoteNetworkName := test.RandomName() @@ -2857,6 +2954,8 @@ func createResourceWithoutSecurityPolicy(remoteNetwork, resource string) string } func TestAccTwingateResourceUpdateWithDefaultProtocols(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() theResource := acctests.TerraformResource(resourceName) @@ -2920,6 +3019,8 @@ func createResourceWithoutProtocols(remoteNetwork, resource string) string { } func TestAccTwingateResourceUpdatePortsFromEmptyListToNull(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() theResource := acctests.TerraformResource(resourceName) @@ -2945,6 +3046,8 @@ func TestAccTwingateResourceUpdatePortsFromEmptyListToNull(t *testing.T) { } func TestAccTwingateResourceUpdatePortsFromNullToEmptyList(t *testing.T) { + t.Parallel() + remoteNetworkName := test.RandomName() resourceName := test.RandomResourceName() theResource := acctests.TerraformResource(resourceName) diff --git a/twingate/internal/test/acctests/resource/service-account_test.go b/twingate/internal/test/acctests/resource/service-account_test.go index 5b7ed5b4..36dae3fa 100644 --- a/twingate/internal/test/acctests/resource/service-account_test.go +++ b/twingate/internal/test/acctests/resource/service-account_test.go @@ -21,91 +21,91 @@ func createServiceAccount(resourceName, serviceAccountName string) string { } func TestAccTwingateServiceAccountCreateUpdate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Account Create/Update", func(t *testing.T) { - const terraformResourceName = "test01" - theResource := acctests.TerraformServiceAccount(terraformResourceName) - nameBefore := test.RandomName() - nameAfter := test.RandomName() + t.Parallel() - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceAccount(terraformResourceName, nameBefore), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), - ), - }, - { - Config: createServiceAccount(terraformResourceName, nameAfter), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), - ), - }, + const terraformResourceName = "test01" + theResource := acctests.TerraformServiceAccount(terraformResourceName) + nameBefore := test.RandomName() + nameAfter := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceAccount(terraformResourceName, nameBefore), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameBefore), + ), }, - }) + { + Config: createServiceAccount(terraformResourceName, nameAfter), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Name, nameAfter), + ), + }, + }, }) } func TestAccTwingateServiceAccountDeleteNonExisting(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Account Delete NonExisting", func(t *testing.T) { - const terraformResourceName = "test02" - theResource := acctests.TerraformServiceAccount(terraformResourceName) - name := test.RandomName() + t.Parallel() - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceAccount(terraformResourceName, name), - Destroy: true, - }, - { - Config: createServiceAccount(terraformResourceName, name), - ConfigPlanChecks: sdk.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), - }, + const terraformResourceName = "test02" + theResource := acctests.TerraformServiceAccount(terraformResourceName) + name := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceAccount(terraformResourceName, name), + Destroy: true, + }, + { + Config: createServiceAccount(terraformResourceName, name), + ConfigPlanChecks: sdk.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), }, }, }, - }) + }, }) } func TestAccTwingateServiceAccountReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Account Create After Deletion", func(t *testing.T) { - const terraformResourceName = "test03" - theResource := acctests.TerraformServiceAccount(terraformResourceName) - name := test.RandomName() + t.Parallel() - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceAccount(terraformResourceName, name), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - acctests.DeleteTwingateResource(theResource, resource.TwingateServiceAccount), - acctests.WaitTestFunc(), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: createServiceAccount(terraformResourceName, name), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - ), - }, + const terraformResourceName = "test03" + theResource := acctests.TerraformServiceAccount(terraformResourceName) + name := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceAccount(terraformResourceName, name), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + acctests.DeleteTwingateResource(theResource, resource.TwingateServiceAccount), + acctests.WaitTestFunc(), + ), + ExpectNonEmptyPlan: true, + }, + { + Config: createServiceAccount(terraformResourceName, name), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + ), }, - }) + }, }) } diff --git a/twingate/internal/test/acctests/resource/service-key_test.go b/twingate/internal/test/acctests/resource/service-key_test.go index 9f676e2a..95a75768 100644 --- a/twingate/internal/test/acctests/resource/service-key_test.go +++ b/twingate/internal/test/acctests/resource/service-key_test.go @@ -58,347 +58,347 @@ func nonEmptyValue(value string) error { } func TestAccTwingateServiceKeyCreateUpdate(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Create/Update", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), + }, + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyCreateUpdateWithName(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Create/Update With Name", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - beforeName := test.RandomName() - afterName := test.RandomName() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKeyWithName(terraformResourceName, serviceAccountName, beforeName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttr(serviceKey, attr.Name, beforeName), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, - { - Config: createServiceKeyWithName(terraformResourceName, serviceAccountName, afterName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttr(serviceKey, attr.Name, afterName), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - acctests.WaitTestFunc(), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + beforeName := test.RandomName() + afterName := test.RandomName() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKeyWithName(terraformResourceName, serviceAccountName, beforeName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttr(serviceKey, attr.Name, beforeName), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), + }, + { + Config: createServiceKeyWithName(terraformResourceName, serviceAccountName, afterName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttr(serviceKey, attr.Name, afterName), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + acctests.WaitTestFunc(), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyWontReCreateAfterInactive(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Won't ReCreate After Inactive", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - resourceID := new(string) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - acctests.GetTwingateResourceID(serviceKey, &resourceID), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - acctests.RevokeTwingateServiceKey(serviceKey), - acctests.WaitTestFunc(), - acctests.CheckTwingateServiceKeyStatus(serviceKey, model.StatusRevoked), - ), - }, - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttr(serviceKey, attr.IsActive, "false"), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { - if *resourceID == "" { - return errors.New("failed to fetch resource id") - } - - if value != *resourceID { - return errors.New("resource was re-created") - } - - return nil - }), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + resourceID := new(string) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + acctests.GetTwingateResourceID(serviceKey, &resourceID), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + acctests.RevokeTwingateServiceKey(serviceKey), + acctests.WaitTestFunc(), + acctests.CheckTwingateServiceKeyStatus(serviceKey, model.StatusRevoked), + ), + }, + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttr(serviceKey, attr.IsActive, "false"), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { + if *resourceID == "" { + return errors.New("failed to fetch resource id") + } + + if value != *resourceID { + return errors.New("resource was re-created") + } + + return nil + }), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyDelete(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Delete", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Destroy: true, - }, - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - ConfigPlanChecks: sdk.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction(serviceKey, plancheck.ResourceActionCreate), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Destroy: true, + }, + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + ConfigPlanChecks: sdk.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(serviceKey, plancheck.ResourceActionCreate), }, }, }, - }) + }, }) } func TestAccTwingateServiceKeyReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key ReCreate After Delete", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - acctests.RevokeTwingateServiceKey(serviceKey), - acctests.DeleteTwingateResource(serviceKey, resource.TwingateServiceAccountKey), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: createServiceKey(terraformResourceName, serviceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + acctests.RevokeTwingateServiceKey(serviceKey), + acctests.DeleteTwingateResource(serviceKey, resource.TwingateServiceAccountKey), + ), + ExpectNonEmptyPlan: true, + }, + { + Config: createServiceKey(terraformResourceName, serviceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyCreateWithInvalidExpiration(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Create With Invalid Expiration", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, -1), - ExpectError: regexp.MustCompile(resource.ErrInvalidExpirationTime.Error()), - }, - { - Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 366), - ExpectError: regexp.MustCompile(resource.ErrInvalidExpirationTime.Error()), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, -1), + ExpectError: regexp.MustCompile(resource.ErrInvalidExpirationTime.Error()), + }, + { + Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 366), + ExpectError: regexp.MustCompile(resource.ErrInvalidExpirationTime.Error()), }, - }) + }, }) } func TestAccTwingateServiceKeyCreateWithExpiration(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key Create With Expiration", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 365), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttr(serviceKey, attr.IsActive, "true"), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceAccount := acctests.TerraformServiceAccount(terraformResourceName) + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 365), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttr(serviceKey, attr.IsActive, "true"), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyReCreateAfterChangingExpirationTime(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key ReCreate After Changing Expiration Time", func(t *testing.T) { - serviceAccountName := test.RandomName() - terraformResourceName := test.TerraformRandName("test_key") - serviceKey := acctests.TerraformServiceKey(terraformResourceName) - - resourceID := new(string) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 1), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - acctests.GetTwingateResourceID(serviceKey, &resourceID), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - ), - }, - { - Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 2), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { - if *resourceID == "" { - return errors.New("failed to fetch resource id") - } - - if value == *resourceID { - return errors.New("resource was not re-created") - } - - return nil - }), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + terraformResourceName := test.TerraformRandName("test_key") + serviceKey := acctests.TerraformServiceKey(terraformResourceName) + + resourceID := new(string) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 1), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + acctests.GetTwingateResourceID(serviceKey, &resourceID), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + ), + }, + { + Config: createServiceKeyWithExpiration(terraformResourceName, serviceAccountName, 2), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { + if *resourceID == "" { + return errors.New("failed to fetch resource id") + } + + if value == *resourceID { + return errors.New("resource was not re-created") + } + + return nil + }), + ), }, - }) + }, }) } func TestAccTwingateServiceKeyAndServiceAccountLifecycle(t *testing.T) { - t.Run("Test Twingate Resource : Acc Service Key and Service Account Lifecycle", func(t *testing.T) { - serviceAccountName := test.RandomName() - serviceAccountNameV2 := test.RandomName() - terraformServiceAccountName := test.TerraformRandName("test_acc") - terraformServiceAccountNameV2 := test.TerraformRandName("test_acc_v2") - terraformServiceAccountKeyName := test.TerraformRandName("test_key") - serviceAccount := acctests.TerraformServiceAccount(terraformServiceAccountName) - serviceAccountV2 := acctests.TerraformServiceAccount(terraformServiceAccountNameV2) - serviceKey := acctests.TerraformServiceKey(terraformServiceAccountKeyName) - - serviceKeyResourceID := new(string) - serviceAccountResourceID := new(string) - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, - Steps: []sdk.TestStep{ - { - Config: createServiceKeyV1(terraformServiceAccountName, serviceAccountName, terraformServiceAccountNameV2, serviceAccountNameV2, terraformServiceAccountKeyName, terraformServiceAccountName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccount), - sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - acctests.GetTwingateResourceID(serviceKey, &serviceKeyResourceID), - acctests.GetTwingateResourceID(serviceKey, &serviceAccountResourceID), - ), - }, - { - Config: createServiceKeyV1(terraformServiceAccountName, serviceAccountName, terraformServiceAccountNameV2, serviceAccountNameV2, terraformServiceAccountKeyName, terraformServiceAccountNameV2), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(serviceAccountV2), - sdk.TestCheckResourceAttr(serviceAccountV2, attr.Name, serviceAccountNameV2), - acctests.CheckTwingateResourceExists(serviceKey), - sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), - - // test resources were re-created - sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { - if *serviceKeyResourceID == "" { - return errors.New("failed to fetch service_key resource id") - } - - if value == *serviceKeyResourceID { - return errors.New("service_key resource was not re-created") - } - - return nil - }), - - sdk.TestCheckResourceAttrWith(serviceAccountV2, attr.ID, func(value string) error { - if *serviceAccountResourceID == "" { - return errors.New("failed to fetch service_account resource id") - } - - if value == *serviceAccountResourceID { - return errors.New("service_account resource was not re-created") - } - - return nil - }), - ), - }, + t.Parallel() + + serviceAccountName := test.RandomName() + serviceAccountNameV2 := test.RandomName() + terraformServiceAccountName := test.TerraformRandName("test_acc") + terraformServiceAccountNameV2 := test.TerraformRandName("test_acc_v2") + terraformServiceAccountKeyName := test.TerraformRandName("test_key") + serviceAccount := acctests.TerraformServiceAccount(terraformServiceAccountName) + serviceAccountV2 := acctests.TerraformServiceAccount(terraformServiceAccountNameV2) + serviceKey := acctests.TerraformServiceKey(terraformServiceAccountKeyName) + + serviceKeyResourceID := new(string) + serviceAccountResourceID := new(string) + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateServiceAccountDestroy, + Steps: []sdk.TestStep{ + { + Config: createServiceKeyV1(terraformServiceAccountName, serviceAccountName, terraformServiceAccountNameV2, serviceAccountNameV2, terraformServiceAccountKeyName, terraformServiceAccountName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccount), + sdk.TestCheckResourceAttr(serviceAccount, attr.Name, serviceAccountName), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + acctests.GetTwingateResourceID(serviceKey, &serviceKeyResourceID), + acctests.GetTwingateResourceID(serviceKey, &serviceAccountResourceID), + ), + }, + { + Config: createServiceKeyV1(terraformServiceAccountName, serviceAccountName, terraformServiceAccountNameV2, serviceAccountNameV2, terraformServiceAccountKeyName, terraformServiceAccountNameV2), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(serviceAccountV2), + sdk.TestCheckResourceAttr(serviceAccountV2, attr.Name, serviceAccountNameV2), + acctests.CheckTwingateResourceExists(serviceKey), + sdk.TestCheckResourceAttrWith(serviceKey, attr.Token, nonEmptyValue), + + // test resources were re-created + sdk.TestCheckResourceAttrWith(serviceKey, attr.ID, func(value string) error { + if *serviceKeyResourceID == "" { + return errors.New("failed to fetch service_key resource id") + } + + if value == *serviceKeyResourceID { + return errors.New("service_key resource was not re-created") + } + + return nil + }), + + sdk.TestCheckResourceAttrWith(serviceAccountV2, attr.ID, func(value string) error { + if *serviceAccountResourceID == "" { + return errors.New("failed to fetch service_account resource id") + } + + if value == *serviceAccountResourceID { + return errors.New("service_account resource was not re-created") + } + + return nil + }), + ), }, - }) + }, }) } diff --git a/twingate/internal/test/acctests/resource/user_test.go b/twingate/internal/test/acctests/resource/user_test.go index 46864d47..74f1ee42 100644 --- a/twingate/internal/test/acctests/resource/user_test.go +++ b/twingate/internal/test/acctests/resource/user_test.go @@ -15,55 +15,55 @@ import ( ) func TestAccTwingateUserCreateUpdate(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Create/Update", func(t *testing.T) { - const terraformResourceName = "test001" - theResource := acctests.TerraformUser(terraformResourceName) - email := test.RandomEmail() - firstName := test.RandomName() - lastName := test.RandomName() - role := model.UserRoleSupport - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUser(terraformResourceName, email), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - ), - }, - { - Config: terraformResourceTwingateUserWithFirstName(terraformResourceName, email, firstName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), - ), - }, - { - Config: terraformResourceTwingateUserWithLastName(terraformResourceName, email, lastName), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), - sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), - ), - }, - { - Config: terraformResourceTwingateUserWithRole(terraformResourceName, email, role), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), - sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), - sdk.TestCheckResourceAttr(theResource, attr.Role, role), - ), - }, + t.Parallel() + + const terraformResourceName = "test001" + theResource := acctests.TerraformUser(terraformResourceName) + email := test.RandomEmail() + firstName := test.RandomName() + lastName := test.RandomName() + role := model.UserRoleSupport + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUser(terraformResourceName, email), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + ), + }, + { + Config: terraformResourceTwingateUserWithFirstName(terraformResourceName, email, firstName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), + ), + }, + { + Config: terraformResourceTwingateUserWithLastName(terraformResourceName, email, lastName), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), + sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), + ), }, - }) + { + Config: terraformResourceTwingateUserWithRole(terraformResourceName, email, role), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), + sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), + sdk.TestCheckResourceAttr(theResource, attr.Role, role), + ), + }, + }, }) } @@ -107,31 +107,31 @@ func terraformResourceTwingateUserWithRole(terraformResourceName, email, role st } func TestAccTwingateUserFullCreate(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Full Create", func(t *testing.T) { - const terraformResourceName = "test002" - theResource := acctests.TerraformUser(terraformResourceName) - email := test.RandomEmail() - firstName := test.RandomName() - lastName := test.RandomName() - role := test.RandomUserRole() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUserFull(terraformResourceName, email, firstName, lastName, role), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), - sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), - sdk.TestCheckResourceAttr(theResource, attr.Role, role), - ), - }, + t.Parallel() + + const terraformResourceName = "test002" + theResource := acctests.TerraformUser(terraformResourceName) + email := test.RandomEmail() + firstName := test.RandomName() + lastName := test.RandomName() + role := test.RandomUserRole() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUserFull(terraformResourceName, email, firstName, lastName, role), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + sdk.TestCheckResourceAttr(theResource, attr.FirstName, firstName), + sdk.TestCheckResourceAttr(theResource, attr.LastName, lastName), + sdk.TestCheckResourceAttr(theResource, attr.Role, role), + ), }, - }) + }, }) } @@ -148,60 +148,60 @@ func terraformResourceTwingateUserFull(terraformResourceName, email, firstName, } func TestAccTwingateUserReCreation(t *testing.T) { - t.Run("Test Twingate Resource : Acc User ReCreation", func(t *testing.T) { - const terraformResourceName = "test003" - theResource := acctests.TerraformUser(terraformResourceName) - email1 := test.RandomEmail() - email2 := test.RandomEmail() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUser(terraformResourceName, email1), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email1), - ), - }, - { - Config: terraformResourceTwingateUser(terraformResourceName, email2), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email2), - ), - }, + t.Parallel() + + const terraformResourceName = "test003" + theResource := acctests.TerraformUser(terraformResourceName) + email1 := test.RandomEmail() + email2 := test.RandomEmail() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUser(terraformResourceName, email1), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email1), + ), + }, + { + Config: terraformResourceTwingateUser(terraformResourceName, email2), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email2), + ), }, - }) + }, }) } func TestAccTwingateUserUpdateState(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Update State", func(t *testing.T) { - const terraformResourceName = "test004" - theResource := acctests.TerraformUser(terraformResourceName) - email := test.RandomEmail() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUser(terraformResourceName, email), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - sdk.TestCheckResourceAttr(theResource, attr.Email, email), - ), - }, - { - Config: terraformResourceTwingateUserDisabled(terraformResourceName, email), - ExpectError: regexp.MustCompile(`User in PENDING state`), - }, + t.Parallel() + + const terraformResourceName = "test004" + theResource := acctests.TerraformUser(terraformResourceName) + email := test.RandomEmail() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUser(terraformResourceName, email), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + sdk.TestCheckResourceAttr(theResource, attr.Email, email), + ), + }, + { + Config: terraformResourceTwingateUserDisabled(terraformResourceName, email), + ExpectError: regexp.MustCompile(`User in PENDING state`), }, - }) + }, }) } @@ -216,96 +216,96 @@ func terraformResourceTwingateUserDisabled(terraformResourceName, email string) } func TestAccTwingateUserDelete(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Delete", func(t *testing.T) { - const terraformResourceName = "test005" - theResource := acctests.TerraformUser(terraformResourceName) - userEmail := test.RandomEmail() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUser(terraformResourceName, userEmail), - Destroy: true, - }, - { - Config: terraformResourceTwingateUser(terraformResourceName, userEmail), - ConfigPlanChecks: sdk.ConfigPlanChecks{ - PreApply: []plancheck.PlanCheck{ - plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), - }, + t.Parallel() + + const terraformResourceName = "test005" + theResource := acctests.TerraformUser(terraformResourceName) + userEmail := test.RandomEmail() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUser(terraformResourceName, userEmail), + Destroy: true, + }, + { + Config: terraformResourceTwingateUser(terraformResourceName, userEmail), + ConfigPlanChecks: sdk.ConfigPlanChecks{ + PreApply: []plancheck.PlanCheck{ + plancheck.ExpectResourceAction(theResource, plancheck.ResourceActionCreate), }, }, }, - }) + }, }) } func TestAccTwingateUserReCreateAfterDeletion(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Create After Deletion", func(t *testing.T) { - const terraformResourceName = "test006" - theResource := acctests.TerraformUser(terraformResourceName) - email := test.RandomEmail() - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUser(terraformResourceName, email), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - acctests.DeleteTwingateResource(theResource, resource.TwingateUser), - ), - ExpectNonEmptyPlan: true, - }, - { - Config: terraformResourceTwingateUser(terraformResourceName, email), - Check: acctests.ComposeTestCheckFunc( - acctests.CheckTwingateResourceExists(theResource), - ), - }, + t.Parallel() + + const terraformResourceName = "test006" + theResource := acctests.TerraformUser(terraformResourceName) + email := test.RandomEmail() + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUser(terraformResourceName, email), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + acctests.DeleteTwingateResource(theResource, resource.TwingateUser), + ), + ExpectNonEmptyPlan: true, + }, + { + Config: terraformResourceTwingateUser(terraformResourceName, email), + Check: acctests.ComposeTestCheckFunc( + acctests.CheckTwingateResourceExists(theResource), + ), }, - }) + }, }) } func TestAccTwingateUserCreateWithUnknownRole(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Create With Unknown Role", func(t *testing.T) { - const terraformResourceName = "test007" - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUserWithRole(terraformResourceName, test.RandomEmail(), "UnknownRole"), - ExpectError: regexp.MustCompile(`Attribute role value must be one of`), - }, + t.Parallel() + + const terraformResourceName = "test007" + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUserWithRole(terraformResourceName, test.RandomEmail(), "UnknownRole"), + ExpectError: regexp.MustCompile(`Attribute role value must be one of`), }, - }) + }, }) } func TestAccTwingateUserCreateWithoutEmail(t *testing.T) { - t.Run("Test Twingate Resource : Acc User Create Without Email", func(t *testing.T) { - const terraformResourceName = "test008" - - sdk.Test(t, sdk.TestCase{ - ProtoV6ProviderFactories: acctests.ProviderFactories, - PreCheck: func() { acctests.PreCheck(t) }, - CheckDestroy: acctests.CheckTwingateUserDestroy, - Steps: []sdk.TestStep{ - { - Config: terraformResourceTwingateUserWithoutEmail(terraformResourceName), - ExpectError: regexp.MustCompile("Error: Missing required argument"), - }, + t.Parallel() + + const terraformResourceName = "test008" + + sdk.Test(t, sdk.TestCase{ + ProtoV6ProviderFactories: acctests.ProviderFactories, + PreCheck: func() { acctests.PreCheck(t) }, + CheckDestroy: acctests.CheckTwingateUserDestroy, + Steps: []sdk.TestStep{ + { + Config: terraformResourceTwingateUserWithoutEmail(terraformResourceName), + ExpectError: regexp.MustCompile("Error: Missing required argument"), }, - }) + }, }) }