Repository: cloudflare/cloudflare-go
Pull request #1505 (2024-02-12 20:56:28)

AUTH-5858 add name id transform jsonata field to access saas applications
## Description

## 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/


github-actions[bot]: changelog detected :white_check_mark:
jacobbednarz: @khiller-cf would you mind rebasing your changes on master? looks like we had two PRs open against this same file and now it's conflicted.

Patch:
diff --git a/.changelog/1505.txt b/.changelog/1505.txt
new file mode 100644
index 000000000..4e307037a
--- /dev/null
+++ b/.changelog/1505.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access_application: add support for `name_id_transform_jsonata` in saas apps
+```
diff --git a/access_application.go b/access_application.go
index 3b5b61f54..53ab80957 100644
--- a/access_application.go
+++ b/access_application.go
@@ -114,13 +114,14 @@ 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"`
+	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"`
 
 	// OIDC saas app
 	ClientID         string   `json:"client_id,omitempty"`


Test patch:
diff --git a/access_application_test.go b/access_application_test.go
index 92cf3226f..67be75e94 100644
--- a/access_application_test.go
+++ b/access_application_test.go
@@ -678,7 +678,8 @@ func TestCreateSAMLSaasAccessApplications(t *testing.T) {
 								"name": "test3"
 							}
 						}
-					]
+					],
+					"name_id_transform_jsonata": "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')"
 				}
 			}
 		}
@@ -731,6 +732,7 @@ func TestCreateSAMLSaasAccessApplications(t *testing.T) {
 					},
 				},
 			},
+			NameIDTransformJsonata: "$substringBefore(email, '@') & '+sandbox@' & $substringAfter(email, '@')",
 		},
 		CreatedAt:                &createdAt,
 		UpdatedAt:                &updatedAt,