diff --git a/.github/workflows/zia-test.yml b/.github/workflows/zia-test.yml index 98e05f01..f27311e7 100644 --- a/.github/workflows/zia-test.yml +++ b/.github/workflows/zia-test.yml @@ -93,7 +93,6 @@ jobs: environment: - ZIA_ZSCLOUD - ZIA_ZS0 - - ZIA_ZS2 - ZIA_ZS3 environment: ${{ matrix.environment }} steps: @@ -224,3 +223,72 @@ jobs: ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }} needs: - zia-zsbeta-tests + + zia-zscalertwo-test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + goVersion: ["1.20"] + environment: + - ZIA_ZS2 + environment: ${{ matrix.environment }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.goVersion }} + + - name: Set Go env + run: | + echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV + echo "$(go env GOPATH)/bin" >> $GITHUB_PATH + + - name: Setup Go Tools + run: make tools + + - name: Download Go Dependencies + run: | + go mod tidy && go mod vendor + + - name: Setup Go Tools + run: make tools + + - name: Check Formatting + run: make fmtcheck + + - name: Vet Code + run: make vet + + - name: Lint Code + run: make lint + + - name: Check Build + run: make build + + - name: Run tests with retry on Ubuntu + uses: nick-fields/retry@v3 + with: + max_attempts: 3 + timeout_minutes: 60 # Adjust as needed + command: | + make sweep + make test:integration:zscalertwo + make sweep + env: + ZIA_USERNAME: ${{ secrets.ZIA_USERNAME }} + ZIA_PASSWORD: ${{ secrets.ZIA_PASSWORD }} + ZIA_API_KEY: ${{ secrets.ZIA_API_KEY }} + ZIA_CLOUD: ${{ secrets.ZIA_CLOUD }} + ZIA_SANDBOX_TOKEN: ${{ secrets.ZIA_SANDBOX_TOKEN }} + ZPA_CLIENT_ID: ${{ secrets.ZPA_CLIENT_ID }} + ZPA_CLIENT_SECRET: ${{ secrets.ZPA_CLIENT_SECRET }} + ZPA_CUSTOMER_ID: ${{ secrets.ZPA_CUSTOMER_ID }} + ZPA_CLOUD: ${{ secrets.ZPA_CLOUD }} + TF_ACC: ${{ secrets.TF_ACC }} + ZIA_ACC_TEST_FORCE_SWEEPERS: ${{ secrets.ZIA_ACC_TEST_FORCE_SWEEPERS }} + needs: + - zia-zsbeta-tests diff --git a/GNUmakefile b/GNUmakefile index 92c049ed..e844bddd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -115,6 +115,77 @@ test\:integration\:zscalerone: @echo "Running integration tests for ZscalerOne..." @TF_ACC=1 go test -v -cover ./zia -timeout 120m -run ^$(integration_tests)$$ +# Default set of integration tests to run for ZscalerOne +ZS2_INTEGRATION_TESTS?=\ + TestAccDataSourceActivationStatus_Basic \ + TestAccDataSourceAdminRoles_Basic \ + TestAccDataSourceAdminUsers_Basic \ + TestAccDataSourceFWApplicationServicesGroupLite_Basic \ + TestAccDataSourceFWApplicationServicesLite_Basic \ + TestAccDataSourceAuthSettingsUrls_Basic \ + TestAccDataSourceCBIProfile_Basic \ + TestAccDataSourceDeviceGroups_Basic \ + TestAccDataSourceDLPDictionaries_Basic \ + TestAccDataSourceDLPEngines_Basic \ + TestAccDataSourceDLPICAPServers_Basic \ + TestAccDataSourceDLPIncidentReceiverServers_Basic \ + TestAccDataSourceDLPNotificationTemplates_Basic \ + TestAccDataSourceDlpWebRules_Basic \ + TestAccDataSourceFWIPDestinationGroups_Basic \ + TestAccDataSourceFWIPSourceGroups_Basic \ + TestAccDataSourceFWNetworkApplicationGroups_Basic \ + TestAccDataSourceFWNetworkServiceGroups_Basic \ + TestAccResourceFWNetworkServicesBasic \ + TestAccDataSourceFWTimeWindow_Basic \ + TestAccDataSourceLocationGroup_Basic \ + TestAccDataSourceLocationLite_Basic \ + TestAccDataSourceLocationManagement_Basic \ + TestAccDataSourceRuleLabels_Basic \ + TestResourceSandboxSettings_basic \ + TestAccDataSourceTrafficGreInternalIPRangeList_Basic \ + TestAccDataSourceTrafficForwardingStaticIP_Basic \ + TestAccDataSourceTrafficForwardingVPNCredentials_Basic \ + TestAccDataSourceTrafficForwardingGreTunnels_Basic \ + TestAccDataSourceURLCategories_Basic \ + TestAccDataSourceURLFilteringRules_Basic \ + TestAccDataSourceDepartmentManagement_Basic \ + TestAccDataSourceGroupManagement_Basic \ + TestAccDataSourceUserManagement_Basic \ + TestAccResourceAdminUsersBasic \ + TestAccResourceAuthSettingsUrls_basic \ + TestAccResourceDLPDictionariesBasic \ + TestAccResourceDLPEnginesBasic \ + TestAccResourceDLPNotificationTemplatesBasic \ + TestAccResourceDlpWebRules_Basic \ + TestAccResourceFWIPDestinationGroupsBasic \ + TestAccResourceFWIPSourceGroupsBasic \ + TestAccResourceFWNetworkApplicationGroupsBasic \ + TestAccResourceFWNetworkServiceGroupsBasic \ + TestAccResourceFWNetworkServicesBasic \ + TestAccResourceLocationManagementBasic \ + TestAccResourceRuleLabelsBasic \ + TestAccZiaSandboxFileSubmission_basic \ + TestResourceSandboxSettings_basic \ + TestAccResourceSecurityPolicySettings_basic \ + TestAccResourceTrafficForwardingStaticIPBasic \ + TestAccResourceTrafficForwardingVPNCredentialsBasic \ + TestAccResourceTrafficForwardingGRETunnelBasic \ + TestAccResourceURLCategoriesBasic \ + TestAccResourceURLFilteringRulesBasic \ + TestAccResourceUserManagementBasic + +ifeq ($(strip $(ZS_INTEGRATION_TESTS)),) + ZS_INTEGRATION_TESTS = $(ZS2_INTEGRATION_TESTS) +endif + +space := $(subst ,, ) +integration_zs2_tests := $(subst $(space),\|,$(ZS_INTEGRATION_TESTS)) + +# Target to run integration tests for ZscalerTwo +test\:integration\:zscalertwo: + @echo "Running integration tests for ZscalerTwo..." + @TF_ACC=1 go test -v -cover ./zia -timeout 120m -run ^$(integration_zs2_tests)$$ + build13: GOOS=$(shell go env GOOS) build13: GOARCH=$(shell go env GOARCH) ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... diff --git a/go.mod b/go.mod index 9635842e..198958fb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/hashicorp/go-hclog v1.6.2 github.com/hashicorp/terraform-plugin-sdk v1.17.2 github.com/hashicorp/terraform-plugin-sdk/v2 v2.32.0 - github.com/zscaler/zscaler-sdk-go/v2 v2.3.8 + github.com/zscaler/zscaler-sdk-go/v2 v2.3.9 ) require ( diff --git a/go.sum b/go.sum index dc55cbce..19b9d351 100644 --- a/go.sum +++ b/go.sum @@ -368,8 +368,8 @@ github.com/zclconf/go-cty v1.14.2 h1:kTG7lqmBou0Zkx35r6HJHUQTvaRPr5bIAf3AoHS0izI github.com/zclconf/go-cty v1.14.2/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zclconf/go-cty-yaml v1.0.2/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= -github.com/zscaler/zscaler-sdk-go/v2 v2.3.8 h1:ajdAHp0SSbY5BahC2EfQo/812v2QwpKaDjsnwtYSbAM= -github.com/zscaler/zscaler-sdk-go/v2 v2.3.8/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg= +github.com/zscaler/zscaler-sdk-go/v2 v2.3.9 h1:7EcMIOKJqHABJonOdQEE/i4zjmGnZtxvr4O5woPJy9w= +github.com/zscaler/zscaler-sdk-go/v2 v2.3.9/go.mod h1:v8TLsPbVlQ3kAvGs8sIWsuhSAVggLbowiyDzaGYPWKg= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/zia/data_source_zia_traffic_forwarding_gre_tunnels_test.go b/zia/data_source_zia_traffic_forwarding_gre_tunnels_test.go index fba80612..efca6121 100644 --- a/zia/data_source_zia_traffic_forwarding_gre_tunnels_test.go +++ b/zia/data_source_zia_traffic_forwarding_gre_tunnels_test.go @@ -28,10 +28,12 @@ func TestAccDataSourceTrafficForwardingGreTunnels_Basic(t *testing.T) { Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "id", resourceTypeAndName, "id"), + resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "source_ip", resourceTypeAndName, "source_ip"), resource.TestCheckResourceAttrPair(dataSourceTypeAndName, "comment", resourceTypeAndName, "comment"), resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)), resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)), ), + ExpectNonEmptyPlan: true, }, }, }) diff --git a/zia/resource_zia_traffic_forwarding_gre_tunnels_test.go b/zia/resource_zia_traffic_forwarding_gre_tunnels_test.go index 9f5044f2..52e752b6 100644 --- a/zia/resource_zia_traffic_forwarding_gre_tunnels_test.go +++ b/zia/resource_zia_traffic_forwarding_gre_tunnels_test.go @@ -34,10 +34,11 @@ func TestAccResourceTrafficForwardingGRETunnelBasic(t *testing.T) { Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered), Check: resource.ComposeTestCheckFunc( testAccCheckTrafficForwardingGRETunnelExists(resourceTypeAndName, &gretunnel), - resource.TestCheckResourceAttr(resourceTypeAndName, "comment", "TestAcc Created with Terraform"), + resource.TestCheckResourceAttr(resourceTypeAndName, "comment", generatedName), resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)), resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)), ), + ExpectNonEmptyPlan: true, }, // update @@ -45,10 +46,11 @@ func TestAccResourceTrafficForwardingGRETunnelBasic(t *testing.T) { Config: testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName, variable.GRETunnelWithinCountry, variable.GRETunnelIPUnnumbered), Check: resource.ComposeTestCheckFunc( testAccCheckTrafficForwardingGRETunnelExists(resourceTypeAndName, &gretunnel), - resource.TestCheckResourceAttr(resourceTypeAndName, "comment", "TestAcc Created with Terraform"), + resource.TestCheckResourceAttr(resourceTypeAndName, "comment", generatedName), resource.TestCheckResourceAttr(resourceTypeAndName, "within_country", strconv.FormatBool(variable.GRETunnelWithinCountry)), resource.TestCheckResourceAttr(resourceTypeAndName, "ip_unnumbered", strconv.FormatBool(variable.GRETunnelIPUnnumbered)), ), + ExpectNonEmptyPlan: true, }, }, }) @@ -112,10 +114,10 @@ func testAccCheckTrafficForwardingGRETunnelExists(resource string, rule *gretunn func testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, generatedName, staticIPResourceHCL, staticIPTypeAndName string, withinCountry, ipUnnumbered bool) string { return fmt.Sprintf(` - // gre tunnel resource + // static ip resource %s - // static ip resource + // gre tunnel resource %s data "%s" "%s" { @@ -134,11 +136,12 @@ func testAccCheckTrafficForwardingGRETunnelConfigure(resourceTypeAndName, genera } func getTrafficForwardingGRETunnel_HCL(generatedName, staticIPTypeAndName string, withinCountry, ipUnnumbered bool) string { + return fmt.Sprintf(` resource "%s" "%s" { source_ip = "${%s.ip_address}" - comment = "TestAcc Created with Terraform" + comment = "%s" country_code = "CA" within_country = "%s" ip_unnumbered = "%s" @@ -148,6 +151,7 @@ resource "%s" "%s" { resourcetype.TrafficForwardingGRETunnel, generatedName, staticIPTypeAndName, + generatedName, strconv.FormatBool(withinCountry), strconv.FormatBool(ipUnnumbered), )