Repository: cloudflare/cloudflare-go
Pull request #1790 (2024-04-15 18:53:49)

AUTH-6000 added options_preflight_bypass to access_applications
<!-- 
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


## Has your change been tested?

Unit tests and linking to a dev build of the tf provider

## 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/1790.txt b/.changelog/1790.txt
new file mode 100644
index 000000000..d5ac346dd
--- /dev/null
+++ b/.changelog/1790.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access_application: support options_preflight_bypass for access_application
+```
\ No newline at end of file
diff --git a/access_application.go b/access_application.go
index 8776e1859..fa426643e 100644
--- a/access_application.go
+++ b/access_application.go
@@ -53,6 +53,7 @@ type AccessApplication struct {
 	ServiceAuth401Redirect   *bool                          `json:"service_auth_401_redirect,omitempty"`
 	PathCookieAttribute      *bool                          `json:"path_cookie_attribute,omitempty"`
 	AllowAuthenticateViaWarp *bool                          `json:"allow_authenticate_via_warp,omitempty"`
+	OptionsPreflightBypass   *bool                          `json:"options_preflight_bypass,omitempty"`
 	CustomPages              []string                       `json:"custom_pages,omitempty"`
 	Tags                     []string                       `json:"tags,omitempty"`
 	AccessAppLauncherCustomization
@@ -181,6 +182,7 @@ type CreateAccessApplicationParams struct {
 	ServiceAuth401Redirect   *bool                          `json:"service_auth_401_redirect,omitempty"`
 	SessionDuration          string                         `json:"session_duration,omitempty"`
 	SkipInterstitial         *bool                          `json:"skip_interstitial,omitempty"`
+	OptionsPreflightBypass   *bool                          `json:"options_preflight_bypass,omitempty"`
 	Type                     AccessApplicationType          `json:"type,omitempty"`
 	AllowAuthenticateViaWarp *bool                          `json:"allow_authenticate_via_warp,omitempty"`
 	CustomPages              []string                       `json:"custom_pages,omitempty"`
@@ -214,6 +216,7 @@ type UpdateAccessApplicationParams struct {
 	SkipInterstitial         *bool                          `json:"skip_interstitial,omitempty"`
 	Type                     AccessApplicationType          `json:"type,omitempty"`
 	AllowAuthenticateViaWarp *bool                          `json:"allow_authenticate_via_warp,omitempty"`
+	OptionsPreflightBypass   *bool                          `json:"options_preflight_bypass,omitempty"`
 	CustomPages              []string                       `json:"custom_pages,omitempty"`
 	Tags                     []string                       `json:"tags,omitempty"`
 	AccessAppLauncherCustomization


Test patch:
diff --git a/access_application_test.go b/access_application_test.go
index c3254e8f3..c7f443381 100644
--- a/access_application_test.go
+++ b/access_application_test.go
@@ -50,7 +50,8 @@ func TestAccessApplications(t *testing.T) {
 					"path_cookie_attribute": true,
 					"custom_pages": ["480f4f69-1a28-4fdd-9240-1ed29f0ac1dc"],
 					"tags": ["engineers"],
-					"allow_authenticate_via_warp": true
+					"allow_authenticate_via_warp": true,
+					"options_preflight_bypass": false
 				}
 			],
 			"result_info": {
@@ -91,6 +92,7 @@ func TestAccessApplications(t *testing.T) {
 		Tags:                     []string{"engineers"},
 		CustomNonIdentityDenyURL: "https://blocked.com",
 		AllowAuthenticateViaWarp: BoolPtr(true),
+		OptionsPreflightBypass:   BoolPtr(false),
 	}}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/apps", handler)
@@ -143,7 +145,8 @@ func TestAccessApplication(t *testing.T) {
 				"service_auth_401_redirect": true,
 				"http_only_cookie_attribute": false,
 				"path_cookie_attribute": false,
-				"allow_authenticate_via_warp": false
+				"allow_authenticate_via_warp": false,
+				"options_preflight_bypass": false
 			}
 		}
 		`)
@@ -175,6 +178,7 @@ func TestAccessApplication(t *testing.T) {
 		PathCookieAttribute:      BoolPtr(false),
 		CustomNonIdentityDenyURL: "https://blocked.com",
 		AllowAuthenticateViaWarp: BoolPtr(false),
+		OptionsPreflightBypass:   BoolPtr(false),
 	}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/apps/480f4f69-1a28-4fdd-9240-1ed29f0ac1db", handler)
@@ -226,7 +230,8 @@ func TestCreateAccessApplications(t *testing.T) {
 				"app_launcher_visible": true,
 				"service_auth_401_redirect": true,
 				"tags": ["engineers"],
-				"allow_authenticate_via_warp": false
+				"allow_authenticate_via_warp": false,
+				"options_preflight_bypass": true
 			}
 		}
 		`)
@@ -256,6 +261,7 @@ func TestCreateAccessApplications(t *testing.T) {
 		CustomNonIdentityDenyURL: "https://blocked.com",
 		Tags:                     []string{"engineers"},
 		AllowAuthenticateViaWarp: BoolPtr(false),
+		OptionsPreflightBypass:   BoolPtr(true),
 	}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/apps", handler)
@@ -315,7 +321,8 @@ func TestUpdateAccessApplication(t *testing.T) {
 				"app_launcher_visible": true,
 				"service_auth_401_redirect": true,
 				"tags": ["engineers"],
-				"allow_authenticate_via_warp": true
+				"allow_authenticate_via_warp": true,
+				"options_preflight_bypass": true
 			}
 		}
 		`)
@@ -341,6 +348,7 @@ func TestUpdateAccessApplication(t *testing.T) {
 		Tags:                     []string{"engineers"},
 		SkipInterstitial:         BoolPtr(true),
 		AllowAuthenticateViaWarp: BoolPtr(true),
+		OptionsPreflightBypass:   BoolPtr(true),
 		CreatedAt:                &createdAt,
 		UpdatedAt:                &updatedAt,
 	}
@@ -365,6 +373,7 @@ func TestUpdateAccessApplication(t *testing.T) {
 		CustomNonIdentityDenyURL: "https://blocked.com",
 		Tags:                     []string{"engineers"},
 		AllowAuthenticateViaWarp: BoolPtr(true),
+		OptionsPreflightBypass:   BoolPtr(true),
 	}
 
 	mux.HandleFunc("/accounts/"+testAccountID+"/access/apps/480f4f69-1a28-4fdd-9240-1ed29f0ac1db", handler)
@@ -395,6 +404,7 @@ func TestUpdateAccessApplication(t *testing.T) {
 		LogoURL:                  "https://www.example.com/example.png",
 		SkipInterstitial:         BoolPtr(true),
 		CustomNonIdentityDenyURL: "https://blocked.com",
+		OptionsPreflightBypass:   BoolPtr(true),
 	})
 
 	if assert.NoError(t, err) {