Skip to content

Commit

Permalink
add acceptance tests for string value page rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacob Fowler committed Dec 6, 2024
1 parent 7de025c commit 7433537
Show file tree
Hide file tree
Showing 4 changed files with 445 additions and 34 deletions.
32 changes: 32 additions & 0 deletions internal/services/page_rule/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,29 @@ type PageRuleActionsModel struct {
AlwaysUseHTTPS types.Bool `tfsdk:"always_use_https" json:"always_use_https,optional"`
AutomaticHTTPSRewrites types.String `tfsdk:"automatic_https_rewrites" json:"automatic_https_rewrites,optional"`
BrowserCheck types.String `tfsdk:"browser_check" json:"browser_check,optional"`
BypassCacheOnCookie types.String `tfsdk:"bypass_cache_on_cookie" json:"bypass_cache_on_cookie,optional"`
CacheByDeviceType types.String `tfsdk:"cache_by_device_type" json:"cache_by_device_type,optional"`
CacheDeceptionArmor types.String `tfsdk:"cache_deception_armor" json:"cache_deception_armor,optional"`
CacheLevel types.String `tfsdk:"cache_level" json:"cache_level,optional"`
CacheOnCookie types.String `tfsdk:"cache_on_cookie" json:"cache_on_cookie,optional"`
DisableApps types.Bool `tfsdk:"disable_apps" json:"disable_apps,optional"`
DisablePerformance types.Bool `tfsdk:"disable_performance" json:"disable_performance,optional"`
DisableSecurity types.Bool `tfsdk:"disable_security" json:"disable_security,optional"`
DisableZaraz types.Bool `tfsdk:"disable_zaraz" json:"disable_zaraz,optional"`
EmailObfuscation types.String `tfsdk:"email_obfuscation" json:"email_obfuscation,optional"`
ExplicitCacheControl types.String `tfsdk:"explicit_cache_control" json:"explicit_cache_control,optional"`
HostHeaderOverride types.String `tfsdk:"host_header_override" json:"host_header_override,optional"`
IPGeolocation types.String `tfsdk:"ip_geolocation" json:"ip_geolocation,optional"`
Mirage types.String `tfsdk:"mirage" json:"mirage,optional"`
OpportunisticEncryption types.String `tfsdk:"opportunistic_encryption" json:"opportunistic_encryption,optional"`
OriginErrorPagePassThru types.String `tfsdk:"origin_error_page_pass_thru" json:"origin_error_page_pass_thru,optional"`
Polish types.String `tfsdk:"polish" json:"polish,optional"`
ResolveOverride types.String `tfsdk:"resolve_override" json:"resolve_override,optional"`
RespectStrongEtag types.String `tfsdk:"respect_strong_etag" json:"respect_strong_etag,optional"`
ResponseBuffering types.String `tfsdk:"response_buffering" json:"response_buffering,optional"`
RocketLoader types.String `tfsdk:"rocket_loader" json:"rocket_loader,optional"`
SSL types.String `tfsdk:"ssl" json:"ssl,optional"`
SecurityLevel types.String `tfsdk:"security_level" json:"security_level,optional"`
SortQueryStringForCache types.String `tfsdk:"sort_query_string_for_cache" json:"sort_query_string_for_cache,optional"`
TrueClientIPHeader types.String `tfsdk:"true_client_ip_header" json:"true_client_ip_header,optional"`
WAF types.String `tfsdk:"waf" json:"waf,optional"`
Expand All @@ -98,12 +106,21 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if !m.BrowserCheck.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDBrowserCheck, "value": m.BrowserCheck.ValueString()})
}
if !m.BypassCacheOnCookie.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDBypassCacheOnCookie, "value": m.BypassCacheOnCookie.ValueString()})
}
if !m.CacheByDeviceType.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheByDeviceType, "value": m.CacheByDeviceType.ValueString()})
}
if !m.CacheDeceptionArmor.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheDeceptionArmor, "value": m.CacheDeceptionArmor.ValueString()})
}
if !m.CacheLevel.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheLevel, "value": m.CacheLevel.ValueString()})
}
if !m.CacheOnCookie.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDCacheOnCookie, "value": m.CacheOnCookie.ValueString()})
}
if m.DisableApps.ValueBool() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDDisableApps, "value": m.DisableApps.ValueBool()})
}
Expand All @@ -122,6 +139,9 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if !m.ExplicitCacheControl.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDExplicitCacheControl, "value": m.ExplicitCacheControl.ValueString()})
}
if !m.HostHeaderOverride.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDHostHeaderOverride, "value": m.HostHeaderOverride.ValueString()})
}
if !m.IPGeolocation.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDIPGeolocation, "value": m.IPGeolocation.ValueString()})
}
Expand All @@ -134,6 +154,12 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if !m.OriginErrorPagePassThru.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDOriginErrorPagePassThru, "value": m.OriginErrorPagePassThru.ValueString()})
}
if !m.Polish.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDPolish, "value": m.Polish.ValueString()})
}
if !m.ResolveOverride.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDResolveOverride, "value": m.ResolveOverride.ValueString()})
}
if !m.RespectStrongEtag.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDRespectStrongEtag, "value": m.RespectStrongEtag.ValueString()})
}
Expand All @@ -143,9 +169,15 @@ func (m *PageRuleActionsModel) Encode() (encoded []map[string]any, err error) {
if !m.RocketLoader.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDRocketLoader, "value": m.RocketLoader.ValueString()})
}
if !m.SecurityLevel.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDSecurityLevel, "value": m.SecurityLevel.ValueString()})
}
if !m.SortQueryStringForCache.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDSortQueryStringForCache, "value": m.SortQueryStringForCache.ValueString()})
}
if !m.SSL.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDSSL, "value": m.SSL.ValueString()})
}
if !m.TrueClientIPHeader.IsNull() {
encoded = append(encoded, map[string]any{"id": pagerules.PageRuleActionsIDTrueClientIPHeader, "value": m.TrueClientIPHeader.ValueString()})
}
Expand Down
Loading

0 comments on commit 7433537

Please sign in to comment.