diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 404873f6..4579cceb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,8 +126,8 @@ jobs: fail-fast: false matrix: terraform: - - '1.4.*' - - '1.5.*' + - '1.6.*' + - '1.7.*' - 'latest' steps: diff --git a/.github/workflows/smoketests.yml b/.github/workflows/smoketests.yml index ff053b92..63c26ad5 100644 --- a/.github/workflows/smoketests.yml +++ b/.github/workflows/smoketests.yml @@ -6,6 +6,7 @@ permissions: read-all on: schedule: - cron: "0 */3 * * *" + workflow_dispatch: {} jobs: build: diff --git a/go.mod b/go.mod index 59005d4f..a15d2ab1 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 github.com/hashicorp/terraform-plugin-go v0.21.0 github.com/hashicorp/terraform-plugin-testing v1.6.0 - github.com/hasura/go-graphql-client v0.11.0 + github.com/hasura/go-graphql-client v0.12.0 github.com/iancoleman/strcase v0.3.0 github.com/jarcoal/httpmock v1.3.1 github.com/mattn/goveralls v0.0.12 diff --git a/go.sum b/go.sum index 76c3e66e..9c4a2c57 100644 --- a/go.sum +++ b/go.sum @@ -83,12 +83,6 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= -github.com/graph-gophers/graphql-go v1.5.0 h1:fDqblo50TEpD0LY7RXk/LFVYEVqo3+tXMNMPSVXA1yc= -github.com/graph-gophers/graphql-go v1.5.0/go.mod h1:YtmJZDLbF1YYNrlNAuiO5zAStUWc3XZT07iGsVqe1Os= -github.com/graph-gophers/graphql-transport-ws v0.0.2 h1:DbmSkbIGzj8SvHei6n8Mh9eLQin8PtA8xY9eCzjRpvo= -github.com/graph-gophers/graphql-transport-ws v0.0.2/go.mod h1:5BVKvFzOd2BalVIBFfnfmHjpJi/MZ5rOj8G55mXvZ8g= github.com/hashicorp/cli v1.1.6 h1:CMOV+/LJfL1tXCOKrgAX0uRKnzjj/mpmqNXloRSy2K8= github.com/hashicorp/cli v1.1.6/go.mod h1:MPon5QYlgjjo0BSoAiN0ESeT5fRzDjVRp+uioJ0piz4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -146,8 +140,8 @@ github.com/hashicorp/terraform-svchost v0.1.1 h1:EZZimZ1GxdqFRinZ1tpJwVxxt49xc/S github.com/hashicorp/terraform-svchost v0.1.1/go.mod h1:mNsjQfZyf/Jhz35v6/0LWcv26+X7JPS+buii2c9/ctc= github.com/hashicorp/yamux v0.1.1 h1:yrQxtgseBDrq9Y652vSRDvsKCJKOUD+GzTS4Y0Y8pvE= github.com/hashicorp/yamux v0.1.1/go.mod h1:CtWFDAQgb7dxtzFs4tWbplKIe2jSi3+5vKbgIO0SLnQ= -github.com/hasura/go-graphql-client v0.11.0 h1:EFEkpMZlkq5gLZj9oiI6TnHCOHV1oErxOroMc5qUHQI= -github.com/hasura/go-graphql-client v0.11.0/go.mod h1:eNNnmHAp6NgwKZ4xRbZEfywxr07qk34Y0QhbPsYIfhw= +github.com/hasura/go-graphql-client v0.12.0 h1:mVVPIP87sVFXaPIBL07AhTjOEvgXnNSIHJ3qKcWUFkQ= +github.com/hasura/go-graphql-client v0.12.0/go.mod h1:F4N4kR6vY8amio3gEu3tjSZr8GPOXJr3zj72DKixfLE= github.com/huandu/xstrings v1.3.3 h1:/Gcsuc1x8JVbJ9/rlye4xZnVAbEkGauT8lbebqcQws4= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= diff --git a/twingate/internal/test/acctests/datasource/connectors_test.go b/twingate/internal/test/acctests/datasource/connectors_test.go index 2e923147..82a9b63f 100644 --- a/twingate/internal/test/acctests/datasource/connectors_test.go +++ b/twingate/internal/test/acctests/datasource/connectors_test.go @@ -262,8 +262,6 @@ func TestAccDatasourceTwingateConnectorsFilterBySuffix(t *testing.T) { t.Parallel() connectorName := test.RandomConnectorName() - prefix := test.Prefix() - suffix := connectorName[len(prefix):] resourceName := test.RandomResourceName() theDatasource := "data.twingate_connectors." + resourceName @@ -273,7 +271,7 @@ func TestAccDatasourceTwingateConnectorsFilterBySuffix(t *testing.T) { CheckDestroy: acctests.CheckTwingateResourceDestroy, Steps: []resource.TestStep{ { - Config: testDatasourceTwingateConnectorsFilter(resourceName, test.RandomName(), connectorName, attr.FilterBySuffix, suffix), + Config: testDatasourceTwingateConnectorsFilter(resourceName, test.RandomName(), connectorName, attr.FilterBySuffix, connectorName), Check: acctests.ComposeTestCheckFunc( resource.TestCheckResourceAttr(theDatasource, connectorsLen, "1"), resource.TestCheckResourceAttr(theDatasource, connectorNamePath, connectorName), diff --git a/twingate/internal/test/acctests/datasource/service-accounts_test.go b/twingate/internal/test/acctests/datasource/service-accounts_test.go index fe42bfd1..6fa142d7 100644 --- a/twingate/internal/test/acctests/datasource/service-accounts_test.go +++ b/twingate/internal/test/acctests/datasource/service-accounts_test.go @@ -283,7 +283,7 @@ func TestAccDatasourceTwingateServicesFilterByPrefix(t *testing.T) { theDatasource = "data.twingate_service_accounts.out" ) - prefix := test.Prefix("orange") + prefix := test.Prefix("orange") + acctest.RandString(5) name := acctest.RandomWithPrefix(prefix) config := []terraformServiceConfig{ { @@ -291,7 +291,7 @@ func TestAccDatasourceTwingateServicesFilterByPrefix(t *testing.T) { terraformResourceName: test.TerraformRandName(terraformResourceName), }, { - serviceName: test.Prefix("lemon"), + serviceName: test.Prefix("lemon") + acctest.RandString(5), terraformResourceName: test.TerraformRandName(terraformResourceName), }, } diff --git a/twingate/internal/test/acctests/datasource/users_test.go b/twingate/internal/test/acctests/datasource/users_test.go index 6b09d9cc..96ebad91 100644 --- a/twingate/internal/test/acctests/datasource/users_test.go +++ b/twingate/internal/test/acctests/datasource/users_test.go @@ -16,13 +16,13 @@ import ( func TestAccDatasourceTwingateUsers_basic(t *testing.T) { t.Run("Test Twingate Datasource : Acc Users Basic", func(t *testing.T) { - acctests.SetPageLimit(1) - users, err := acctests.GetTestUsers() if err != nil && !errors.Is(err, acctests.ErrResourceNotFound) { t.Skip("can't run test:", err) } + acctests.SetPageLimit(len(users)/3 + 1) + resource.Test(t, resource.TestCase{ ProtoV6ProviderFactories: acctests.ProviderFactories, PreCheck: func() { acctests.PreCheck(t) }, diff --git a/twingate/internal/test/acctests/resource/connector_test.go b/twingate/internal/test/acctests/resource/connector_test.go index 83d3bc91..b0ebcd1a 100644 --- a/twingate/internal/test/acctests/resource/connector_test.go +++ b/twingate/internal/test/acctests/resource/connector_test.go @@ -13,8 +13,6 @@ import ( "github.com/hashicorp/terraform-plugin-testing/terraform" ) -var testRegexp = regexp.MustCompile(test.Prefix() + ".*") - func TestAccRemoteConnectorCreate(t *testing.T) { t.Run("Test Twingate Resource : Acc Remote Connector", func(t *testing.T) { const terraformResourceName = "test_c1" @@ -78,7 +76,7 @@ func TestAccRemoteConnectorImport(t *testing.T) { Config: terraformResourceTwingateConnectorWithName(terraformResourceName, remoteNetworkName, connectorName), Check: acctests.ComposeTestCheckFunc( checkTwingateConnectorSetWithRemoteNetwork(theResource, acctests.TerraformRemoteNetwork(terraformResourceName)), - sdk.TestMatchResourceAttr(theResource, attr.Name, testRegexp), + sdk.TestMatchResourceAttr(theResource, attr.Name, regexp.MustCompile(connectorName[:len(connectorName)-3]+".*")), ), }, { diff --git a/twingate/internal/test/helper.go b/twingate/internal/test/helper.go index b6b5aa13..7a00ac9d 100644 --- a/twingate/internal/test/helper.go +++ b/twingate/internal/test/helper.go @@ -1,6 +1,7 @@ package test import ( + "crypto/sha256" "fmt" "os" "strings" @@ -17,10 +18,10 @@ const ( func RandomConnectorName() string { const maxLength = 30 - name := Prefix(acctest.RandString(maxLength)) - if len(name) > maxLength { - name = name[:maxLength] - } + // hash using only for text compression + hash := fmt.Sprintf("%x", sha256.Sum224([]byte(Prefix()))) + name := fmt.Sprintf("%s-%s-", prefixName, hash[:15]) + name += acctest.RandString(maxLength - len(name)) return name }