Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix): Fixed drift issue within zpa_application_segment_pra resource #423

Merged
merged 3 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Changelog

## 3.1.0 (January, 17 2023)
## 3.1.1 (February, 28 2024)

### Notes

- Release date: **(January, 17 2023)**
- Release date: **(February, 28 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes

- [PR #423](https://github.com/zscaler/terraform-provider-zpa/pull/423) - Fixed drift issue within `zpa_application_segment_pra` resource

## 3.1.0 (January, 17 2024)

### Notes

- Release date: **(January, 17 2024)**
- Supported Terraform version: **v1.x**

### Enhacements
Expand Down
17 changes: 14 additions & 3 deletions docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ Track all ZPA Terraform provider's releases. New resources, features, and bug fi

---

``Last updated: v3.1.0``
``Last updated: v3.1.1``

---

## 3.1.0 (January, 17 2023) - Unreleased
## 3.1.1 (February, 28 2024)

### Notes

- Release date: **(January, 17 2023)**
- Release date: **(February, 28 2024)**
- Supported Terraform version: **v1.x**

### Bug Fixes

- [PR #423](https://github.com/zscaler/terraform-provider-zpa/pull/423) - Fixed drift issue within `zpa_application_segment_pra` resource

## 3.1.0 (January, 17 2024) - Unreleased

### Notes

- Release date: **(January, 17 2024)**
- Supported Terraform version: **v1.x**

### Enhacements
Expand Down
45 changes: 28 additions & 17 deletions zpa/data_source_zpa_posture_profile_test.go
Original file line number Diff line number Diff line change
@@ -1,42 +1,53 @@
package zpa

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

var profileNames = []string{
"CrowdStrike_ZPA_Pre-ZTA", "CrowdStrike_ZPA_ZTA_40", "CrowdStrike_ZPA_ZTA_80",
}

func TestAccDataSourcePostureProfile_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourcePostureProfileConfig_basic,
Config: testAccCheckDataSourcePostureProfile_basic(),
Check: resource.ComposeTestCheckFunc(
testAccDataSourcePostureProfileCheck("data.zpa_posture_profile.pre_zta"),
testAccDataSourcePostureProfileCheck("data.zpa_posture_profile.zta_40"),
testAccDataSourcePostureProfileCheck("data.zpa_posture_profile.zta_80"),
generatePostureProfileChecks()...,
),
},
},
})
}

func testAccDataSourcePostureProfileCheck(name string) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(name, "id"),
resource.TestCheckResourceAttrSet(name, "name"),
)
func generatePostureProfileChecks() []resource.TestCheckFunc {
var checks []resource.TestCheckFunc
for _, name := range profileNames {
resourceName := createValidResourceName(name)
checkName := fmt.Sprintf("data.zpa_posture_profile.%s", resourceName)
checks = append(checks, resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(checkName, "id"),
resource.TestCheckResourceAttrSet(checkName, "name"),
))
}
return checks
}

var testAccCheckDataSourcePostureProfileConfig_basic = `
data "zpa_posture_profile" "pre_zta" {
name = "CrowdStrike_ZPA_Pre-ZTA (zscalertwo.net)"
func testAccCheckDataSourcePostureProfile_basic() string {
var configs string
for _, name := range profileNames {
resourceName := createValidResourceName(name)
configs += fmt.Sprintf(`
data "zpa_posture_profile" "%s" {
name = "%s"
}
data "zpa_posture_profile" "zta_40" {
name = "CrowdStrike_ZPA_ZTA_40 (zscalertwo.net)"
`, resourceName, name)
}
return configs
}
data "zpa_posture_profile" "zta_80" {
name = "CrowdStrike_ZPA_ZTA_80 (zscalertwo.net)"
}`
6 changes: 0 additions & 6 deletions zpa/data_source_zpa_scim_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func TestAccDataSourceScimGroup_Basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
testAccDataSourceScimGroupCheck("data.zpa_scim_groups.engineering"),
testAccDataSourceScimGroupCheck("data.zpa_scim_groups.contractors"),
testAccDataSourceScimGroupCheck("data.zpa_scim_groups.marketing"),
testAccDataSourceScimGroupCheck("data.zpa_scim_groups.finance"),
testAccDataSourceScimGroupCheck("data.zpa_scim_groups.executives"),
),
Expand All @@ -43,11 +42,6 @@ data "zpa_scim_groups" "contractors" {
idp_name = "BD_Okta_Users"
}

data "zpa_scim_groups" "marketing" {
name = "Marketing"
idp_name = "BD_Okta_Users"
}

data "zpa_scim_groups" "finance" {
name = "Finance"
idp_name = "BD_Okta_Users"
Expand Down
41 changes: 30 additions & 11 deletions zpa/data_source_zpa_trusted_network_test.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,53 @@
package zpa

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

var networkNames = []string{
"BD-TrustedNetwork01", "BD-TrustedNetwork02", "BD-TrustedNetwork03", "BD Trusted Network 01",
}

func TestAccDataSourceTrustedNetwork_Basic(t *testing.T) {
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckDataSourceTrustedNetworkConfig_basic,
Config: testAccCheckDataSourceTrustedNetwork_basic(),
Check: resource.ComposeTestCheckFunc(
testAccDataSourceTrustedNetworkCheck("data.zpa_trusted_network.trusted_network03"),
generateTrustedNetworkChecks()...,
),
},
},
})
}

func testAccDataSourceTrustedNetworkCheck(name string) resource.TestCheckFunc {
return resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(name, "id"),
resource.TestCheckResourceAttrSet(name, "name"),
)
func generateTrustedNetworkChecks() []resource.TestCheckFunc {
var checks []resource.TestCheckFunc
for _, name := range networkNames {
resourceName := createValidResourceName(name)
checkName := fmt.Sprintf("data.zpa_trusted_network.%s", resourceName)
checks = append(checks, resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrSet(checkName, "id"),
resource.TestCheckResourceAttrSet(checkName, "name"),
))
}
return checks
}

var testAccCheckDataSourceTrustedNetworkConfig_basic = `
data "zpa_trusted_network" "trusted_network03" {
name = "BD-TrustedNetwork03 (zscalertwo.net)"
}`
func testAccCheckDataSourceTrustedNetwork_basic() string {
var configs string
for _, name := range networkNames {
resourceName := createValidResourceName(name)
configs += fmt.Sprintf(`
data "zpa_trusted_network" "%s" {
name = "%s"
}
`, resourceName, name)
}
return configs
}
2 changes: 1 addition & 1 deletion zpa/resource_zpa_lss_config_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ resource "%s" "%s" {
operator = "OR"
operands {
object_type = "CLIENT_TYPE"
values = ["zpn_client_type_exporter", "zpn_client_type_ip_anchoring", "zpn_client_type_zapp", "zpn_client_type_edge_connector", "zpn_client_type_machine_tunnel", "zpn_client_type_browser_isolation", "zpn_client_type_slogger", "zpn_client_type_zapp_partner", "zpn_client_type_branch_connector"]
values = ["zpn_client_type_exporter", "zpn_client_type_ip_anchoring", "zpn_client_type_zapp", "zpn_client_type_edge_connector", "zpn_client_type_machine_tunnel", "zpn_client_type_browser_isolation", "zpn_client_type_slogger", "zpn_client_type_branch_connector"]
}
}
conditions {
Expand Down
6 changes: 3 additions & 3 deletions zpa/resource_zpa_policy_access_rule_reorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func hasDuplicates(orders map[string]int) (int, []string, bool) {
return 0, nil, false
}

func getRules(d *schema.ResourceData, zClient *Client) (*RulesOrders, error) {
func getRules(d *schema.ResourceData) (*RulesOrders, error) {
policyType := d.Get("policy_type").(string)
orders := RulesOrders{
PolicyType: policyType,
Expand All @@ -116,7 +116,7 @@ func getRules(d *schema.ResourceData, zClient *Client) (*RulesOrders, error) {

func resourcePolicyAccessReorderRead(d *schema.ResourceData, m interface{}) error {
zClient := m.(*Client)
rulesOrders, err := getRules(d, zClient)
rulesOrders, err := getRules(d)
if err != nil {
return err
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func resourcePolicyAccessReorderUpdate(d *schema.ResourceData, m interface{}) er
// Convert the interface to a client instance.
zClient := m.(*Client)
// Fetch and sort the rule orders from the provided data.
rules, err := getRules(d, zClient)
rules, err := getRules(d)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions zpa/resource_zpa_provisioning_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ resource "%s" "%s" {
// resource variables
resourcetype.ZPAProvisioningKey,
generatedName,
generatedName,
name,
provisioningKeyType,
strconv.FormatBool(variable.ProvisioningKeyEnabled),
usage,
Expand Down Expand Up @@ -301,7 +301,7 @@ func serviceEdgeGroupProvisioningKeyResourceHCL(generatedName, name, serviceEdge
// resource variables
resourcetype.ZPAProvisioningKey,
generatedName,
generatedName,
name,
provisioningKeyType,
strconv.FormatBool(variable.ProvisioningKeyEnabled),
usage,
Expand Down