Repository: cloudflare/cloudflare-go
Pull request #1562 (2024-03-14 15:15:13)

AUTH-5974 added saml_attribute_transform_jsonata for saas apps
<!-- 
Provide a general summary of your changes in the title above. You should
remove this overview, any sections and any section descriptions you
don't need below before submitting. There isn't a strict requirement to
use this template if you can structure your description and still cover
these points. 
-->

## Description

This change adds support for saml_attribute_transform_jsonata in access saas applications
## Has your change been tested?

Unit tests

## Screenshots (if appropriate):

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [x] I have updated the documentation accordingly.
- [x] I have added tests to cover my changes.
- [x] All new and existing tests passed.
- [x] This change is using publicly documented in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) 
      and relies on stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/



Patch:
diff --git a/.changelog/1562.txt b/.changelog/1562.txt
new file mode 100644
index 000000000..e135f681d
--- /dev/null
+++ b/.changelog/1562.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access_application: add support for `saml_attribute_transform_jsonata` in saas apps
+```
diff --git a/access_application.go b/access_application.go
index 53ab80957..8776e1859 100644
--- a/access_application.go
+++ b/access_application.go
@@ -114,14 +114,15 @@ type SaasApplication struct {
 	AuthType  string     `json:"auth_type,omitempty"`
 
 	// SAML saas app
-	ConsumerServiceUrl     string                `json:"consumer_service_url,omitempty"`
-	SPEntityID             string                `json:"sp_entity_id,omitempty"`
-	IDPEntityID            string                `json:"idp_entity_id,omitempty"`
-	NameIDFormat           string                `json:"name_id_format,omitempty"`
-	SSOEndpoint            string                `json:"sso_endpoint,omitempty"`
-	DefaultRelayState      string                `json:"default_relay_state,omitempty"`
-	CustomAttributes       []SAMLAttributeConfig `json:"custom_attributes,omitempty"`
-	NameIDTransformJsonata string                `json:"name_id_transform_jsonata,omitempty"`
+	ConsumerServiceUrl            string                `json:"consumer_service_url,omitempty"`
+	SPEntityID                    string                `json:"sp_entity_id,omitempty"`
+	IDPEntityID                   string                `json:"idp_entity_id,omitempty"`
+	NameIDFormat                  string                `json:"name_id_format,omitempty"`
+	SSOEndpoint                   string                `json:"sso_endpoint,omitempty"`
+	DefaultRelayState             string                `json:"default_relay_state,omitempty"`
+	CustomAttributes              []SAMLAttributeConfig `json:"custom_attributes,omitempty"`
+	NameIDTransformJsonata        string                `json:"name_id_transform_jsonata,omitempty"`
+	SamlAttributeTransformJsonata string                `json:"saml_attribute_transform_jsonata"`
 
 	// OIDC saas app
 	ClientID         string   `json:"client_id,omitempty"`


Test patch:
diff --git a/access_application_test.go b/access_application_test.go
index 67be75e94..c3254e8f3 100644
--- a/access_application_test.go
+++ b/access_application_test.go
@@ -679,7 +679,8 @@ func TestCreateSAMLSaasAccessApplications(t *testing.T) {
 							}
 						}
 					],
-					"name_id_transform_jsonata": "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"
+					"name_id_transform_jsonata": "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')",
+					"saml_attribute_transform_jsonata": "$ ~>| groups | {'group_name': name} |"
 				}
 			}
 		}
@@ -732,7 +733,8 @@ func TestCreateSAMLSaasAccessApplications(t *testing.T) {
 					},
 				},
 			},
-			NameIDTransformJsonata: "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')",
+			NameIDTransformJsonata:        "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')",
+			SamlAttributeTransformJsonata: "$ ~>| groups | {'group_name': name} |",
 		},
 		CreatedAt:                &createdAt,
 		UpdatedAt:                &updatedAt,