Skip to content

Commit

Permalink
Merge pull request #224 from zscaler/zpa-#224-redirection-policy
Browse files Browse the repository at this point in the history
feat: Added support to zpa policy access redirection
  • Loading branch information
willguibr authored Feb 13, 2024
2 parents 9296d4e + 94d3daf commit 04f5b6e
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 23 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

# 2.3.9 (February 12, 2024)

## Notes
- Golang: **v1.19**

### Fixes

- [PR #224](https://github.com/zscaler/zscaler-sdk-go/pull/224) - Added support to ZPA Policy Access Redirection resource.
- **NOTE** This feature is in limited availability. Contact Zscaler Support to enable this feature for your organization.

# 2.3.8 (January 31, 2024)

## Notes
Expand Down
10 changes: 10 additions & 0 deletions docs/guides/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ Track all Zscaler SDK GO releases. New resources, features, and bug fixes will b

---

# 2.3.9 (February 12, 2024)

## Notes
- Golang: **v1.19**

### Fixes

- [PR #224](https://github.com/zscaler/zscaler-sdk-go/pull/224) - Added support to ZPA Policy Access Redirection resource.
- **NOTE** This feature is in limited availability. Contact Zscaler Support to enable this feature for your organization.

# 2.3.8 (January 31, 2024)

## Notes
Expand Down
1 change: 1 addition & 0 deletions zpa/services/browseraccess/zpa_browser_access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func TestApplicationSegment(t *testing.T) {
if retrievedResource.Name != updateName {
t.Errorf("Expected retrieved resource name '%s', but got '%s'", updateName, createdResource.Name)
}

// Test resources retrieval
resources, _, err := service.GetAll()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions zpa/services/policysetcontroller/policysetcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type PolicyRule struct {
Conditions []Conditions `json:"conditions"`
AppServerGroups []AppServerGroups `json:"appServerGroups"`
AppConnectorGroups []AppConnectorGroups `json:"appConnectorGroups"`
ServiceEdgeGroups []ServiceEdgeGroups `json:"serviceEdgeGroups"`
}

type Conditions struct {
Expand Down Expand Up @@ -97,6 +98,10 @@ type AppConnectorGroups struct {
ID string `json:"id,omitempty"`
}

type ServiceEdgeGroups struct {
ID string `json:"id,omitempty"`
}

type Count struct {
Count string `json:"count"`
}
Expand Down
37 changes: 24 additions & 13 deletions zpa/services/scimattributeheader/zpa_scim_attribute_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ func TestSCIMAttributeHeader(t *testing.T) {
t.Fatalf("Expected status code %d, got %d", http.StatusOK, resp.StatusCode)
}

// If attribute list is empty, skip the subsequent logic
// Instead of failing the test, log a message and return successfully if no groups are found.
if len(scimAttribute) == 0 {
t.Log("No SCIM Attribute Header found, skipping further tests.")
return
t.Logf("No SCIM Attribute Header found, skipping further tests.")
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

// Use the first SCIM attribute headers's name from the list for testing
Expand All @@ -93,9 +93,11 @@ func TestResponseFormatValidation(t *testing.T) {
t.Errorf("Error getting SCIM Attribute Header: %v", err)
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(groups) == 0 {
t.Errorf("No SCIM Attribute Header found")
return
t.Logf("No SCIM Attribute Header found")
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

// Validate each group
Expand Down Expand Up @@ -139,10 +141,14 @@ func TestEmptyResponse(t *testing.T) {
t.Errorf("Error getting SCIM Attribute Header: %v", err)
return
}
if groups == nil {
t.Errorf("Received nil response for SCIM Attribute Header")
return

// Simplified check for an empty response
if len(groups) == 0 {
t.Logf("Received an empty response for SCIM Attribute Header for IdP ID: %s. This may be expected if no SCIM groups are configured.", testIdpId)
} else {
t.Logf("Received response for SCIM Attribute Header for IdP ID: %s with %d groups.", testIdpId, len(groups))
}

}

func TestGetSCIMAttributeHeaderByID(t *testing.T) {
Expand All @@ -161,9 +167,10 @@ func TestGetSCIMAttributeHeaderByID(t *testing.T) {
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(attributes) == 0 {
t.Errorf("No SCIM Attribute Header found")
return
t.Logf("No SCIM Attribute Header found")
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

specificID := attributes[0].ID
Expand Down Expand Up @@ -192,8 +199,11 @@ func TestSCIMAttributeHeaderGetValues(t *testing.T) {
if err != nil {
t.Fatalf("Error getting all SCIM Attribute Header: %v", err)
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(attributes) == 0 {
t.Fatalf("No SCIM Attribute Header found")
t.Logf("No SCIM Attribute Header found")
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

// Use the ID of the first attribute for GetValues
Expand Down Expand Up @@ -225,9 +235,10 @@ func TestAllFieldsOfSCIMAttributeHeaders(t *testing.T) {
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(attributes) == 0 {
t.Errorf("No SCIM Attribute Header found")
return
t.Logf("No SCIM Attribute Header found")
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

specificID := attributes[0].ID
Expand Down
25 changes: 15 additions & 10 deletions zpa/services/scimgroup/zpa_scim_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ func TestSCIMGroupGetByNameWithSort(t *testing.T) {
t.Fatalf("Error retrieving SCIM groups: %v", err)
}
if len(scimGroups) == 0 {
t.Fatalf("No SCIM groups found to test with")
t.Skipf("No SCIM groups found to test with for IDP ID: %s", testIdpId)
}

// Check if we have enough groups for the test, otherwise return an error
if len(scimGroups) < 100 {
t.Fatalf("Not enough SCIM groups available for testing. Required: 50, Found: %d", len(scimGroups))
t.Fatalf("Not enough SCIM groups available for testing. Required: 100, Found: %d", len(scimGroups))
}

// Randomly pick a group name from the first 50 groups
rand.Seed(time.Now().UnixNano())
randomIndex := rand.Intn(500)
randomIndex := rand.Intn(50) // Adjusted to ensure it picks within the available range
testScimName := scimGroups[randomIndex].Name

// Test with both DESC and ASC sort orders
Expand Down Expand Up @@ -169,9 +169,11 @@ func TestResponseFormatValidation(t *testing.T) {
t.Errorf("Error getting scim group: %v", err)
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(groups) == 0 {
t.Errorf("No scim group found")
return
t.Logf("No SCIM Group found for tenant ID: %s. This is not necessarily an error, depending on tenant configuration.", testIdpId)
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

// Validate each group
Expand Down Expand Up @@ -236,19 +238,21 @@ func TestGetSCIMGroupByID(t *testing.T) {
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(groups) == 0 {
t.Errorf("No SCIM Group found")
return
t.Logf("No SCIM Group found for tenant ID: %s. This is not necessarily an error, depending on tenant configuration.", testIdpId)
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

// Proceed with the test if there are groups.
specificID := groups[0].ID
group, _, err := service.Get(strconv.FormatInt(specificID, 10))
if err != nil {
t.Errorf("Error getting SCIM Group by ID: %v", err)
return
}
if group.ID != specificID {
t.Errorf("Mismatch in group ID: expected '%d', got %d", specificID, group.ID)
t.Errorf("Mismatch in group ID: expected '%d', got '%d'", specificID, group.ID)
return
}
}
Expand All @@ -268,9 +272,10 @@ func TestAllFieldsOfSCIMGroups(t *testing.T) {
return
}

// Instead of failing the test, log a message and return successfully if no groups are found.
if len(groups) == 0 {
t.Errorf("No SCIM Group found")
return
t.Logf("No SCIM Group found for tenant ID: %s. This is not necessarily an error, depending on tenant configuration.", testIdpId)
return // Return successfully since the absence of SCIM Groups is not considered a failure condition.
}

specificID := groups[0].ID
Expand Down
4 changes: 4 additions & 0 deletions zpa/services/serviceedgegroup/zpa_service_edge_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ type ServiceEdgeGroup struct {
VersionProfileID string `json:"versionProfileId,omitempty"`
VersionProfileName string `json:"versionProfileName,omitempty"`
VersionProfileVisibilityScope string `json:"versionProfileVisibilityScope,omitempty"`
ObjectType string `json:"objectType,omitempty"`
ScopeName string `json:"scopeName,omitempty"`
RestrictedEntity bool `json:"restrictedEntity,omitempty"`
AltCloud string `json:"altCloud,omitempty"`
MicroTenantID string `json:"microtenantId,omitempty"`
MicroTenantName string `json:"microtenantName,omitempty"`
}
Expand Down

0 comments on commit 04f5b6e

Please sign in to comment.