fix(cef): allow no-third-party cookie policy
- commit
- 9904d0fd33572092b6d9a5dfb4bfd0af31689f78
- author
- brice · · 2026-04-11 16:37 UTC
- parent
- a363a97
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
3 files · +24 -1
M internal/bootstrap/engine_test.go +9 -0
| @@ -33,3 +33,12 @@ func TestBuildEngine_CEF_ReturnsErrorForUnsupportedCookiePolicy(t *testing.T) { | |||
| 33 | 33 | _, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()}) | |
| 34 | 34 | require.ErrorIs(t, err, cef.ErrCookiePolicyUnsupported) | |
| 35 | 35 | } | |
| 36 | + | ||
| 37 | + | func TestBuildEngine_CEF_AllowsNoThirdPartyCookiePolicy(t *testing.T) { | |
| 38 | + | cfg := config.DefaultConfig() | |
| 39 | + | cfg.Engine.Type = "cef" | |
| 40 | + | cfg.Engine.CookiePolicy = config.CookiePolicyNoThirdParty | |
| 41 | + | cfg.Engine.CEF.CEFDir = t.TempDir() | |
| 42 | + | _, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()}) | |
| 43 | + | require.NotErrorIs(t, err, cef.ErrCookiePolicyUnsupported) | |
| 44 | + | } | |
| @@ -33,3 +33,12 @@ func TestBuildEngine_CEF_ReturnsErrorForUnsupportedCookiePolicy(t *testing.T) { | |||||
| 33 | _, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()}) | 33 | _, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()}) | ||
| 34 | require.ErrorIs(t, err, cef.ErrCookiePolicyUnsupported) | 34 | require.ErrorIs(t, err, cef.ErrCookiePolicyUnsupported) | ||
| 35 | } | 35 | } | ||
| 36 | + | ||||
| 37 | + | func TestBuildEngine_CEF_AllowsNoThirdPartyCookiePolicy(t *testing.T) { | |||
| 38 | + | cfg := config.DefaultConfig() | |||
| 39 | + | cfg.Engine.Type = "cef" | |||
| 40 | + | cfg.Engine.CookiePolicy = config.CookiePolicyNoThirdParty | |||
| 41 | + | cfg.Engine.CEF.CEFDir = t.TempDir() | |||
| 42 | + | _, err := BuildEngine(EngineInput{Config: cfg, Ctx: context.Background()}) | |||
| 43 | + | require.NotErrorIs(t, err, cef.ErrCookiePolicyUnsupported) | |||
| 44 | + | } | |||
M internal/infrastructure/cef/engine_init.go +9 -1
| @@ -98,7 +98,15 @@ func resolvedStateRoot(opts port.EngineOptions) string { | |||
| 98 | 98 | ||
| 99 | 99 | // prepareCEFSettings builds purecef.Settings from the engine config. | |
| 100 | 100 | func prepareCEFSettings(opts port.EngineOptions, cfg RuntimeConfig, logger *zerolog.Logger) (purecef.Settings, error) { | |
| 101 | - | if opts.CookiePolicy != "" && opts.CookiePolicy != port.CookiePolicyAlways { | |
| 101 | + | switch opts.CookiePolicy { | |
| 102 | + | case "", port.CookiePolicyAlways: | |
| 103 | + | case port.CookiePolicyNoThirdParty: | |
| 104 | + | logger.Warn(). | |
| 105 | + | Str("cookie_policy", string(opts.CookiePolicy)). | |
| 106 | + | Msg("cef: no_third_party cookie policy is currently treated as always") | |
| 107 | + | case port.CookiePolicyNever: | |
| 108 | + | return purecef.Settings{}, fmt.Errorf("%w: %s", ErrCookiePolicyUnsupported, opts.CookiePolicy) | |
| 109 | + | default: | |
| 102 | 110 | return purecef.Settings{}, fmt.Errorf("%w: %s", ErrCookiePolicyUnsupported, opts.CookiePolicy) | |
| 103 | 111 | } | |
| 104 | 112 | ||
| @@ -98,7 +98,15 @@ func resolvedStateRoot(opts port.EngineOptions) string { | |||||
| 98 | 98 | ||||
| 99 | // prepareCEFSettings builds purecef.Settings from the engine config. | 99 | // prepareCEFSettings builds purecef.Settings from the engine config. | ||
| 100 | func prepareCEFSettings(opts port.EngineOptions, cfg RuntimeConfig, logger *zerolog.Logger) (purecef.Settings, error) { | 100 | func prepareCEFSettings(opts port.EngineOptions, cfg RuntimeConfig, logger *zerolog.Logger) (purecef.Settings, error) { | ||
| 101 | - | if opts.CookiePolicy != "" && opts.CookiePolicy != port.CookiePolicyAlways { | 101 | + | switch opts.CookiePolicy { |
| 102 | + | case "", port.CookiePolicyAlways: | |||
| 103 | + | case port.CookiePolicyNoThirdParty: | |||
| 104 | + | logger.Warn(). | |||
| 105 | + | Str("cookie_policy", string(opts.CookiePolicy)). | |||
| 106 | + | Msg("cef: no_third_party cookie policy is currently treated as always") | |||
| 107 | + | case port.CookiePolicyNever: | |||
| 108 | + | return purecef.Settings{}, fmt.Errorf("%w: %s", ErrCookiePolicyUnsupported, opts.CookiePolicy) | |||
| 109 | + | default: | |||
| 102 | return purecef.Settings{}, fmt.Errorf("%w: %s", ErrCookiePolicyUnsupported, opts.CookiePolicy) | 110 | return purecef.Settings{}, fmt.Errorf("%w: %s", ErrCookiePolicyUnsupported, opts.CookiePolicy) | ||
| 103 | } | 111 | } | ||
| 104 | 112 | ||||
M internal/infrastructure/cef/engine_init_test.go +6 -0
| @@ -35,6 +35,12 @@ func TestPrepareCEFSettings_RejectsNonDefaultCookiePolicy(t *testing.T) { | |||
| 35 | 35 | require.ErrorIs(t, err, ErrCookiePolicyUnsupported) | |
| 36 | 36 | } | |
| 37 | 37 | ||
| 38 | + | func TestPrepareCEFSettings_AllowsNoThirdPartyCookiePolicy(t *testing.T) { | |
| 39 | + | logger := zerolog.Nop() | |
| 40 | + | _, err := prepareCEFSettings(port.EngineOptions{CookiePolicy: port.CookiePolicyNoThirdParty}, RuntimeConfig{}, &logger) | |
| 41 | + | require.NoError(t, err) | |
| 42 | + | } | |
| 43 | + | ||
| 38 | 44 | func TestPrepareCEFInitTraceFile_DisabledByDefault(t *testing.T) { | |
| 39 | 45 | t.Setenv(puregoCEFInitTraceEnvVar, "") | |
| 40 | 46 | ||
| @@ -35,6 +35,12 @@ func TestPrepareCEFSettings_RejectsNonDefaultCookiePolicy(t *testing.T) { | |||||
| 35 | require.ErrorIs(t, err, ErrCookiePolicyUnsupported) | 35 | require.ErrorIs(t, err, ErrCookiePolicyUnsupported) | ||
| 36 | } | 36 | } | ||
| 37 | 37 | ||||
| 38 | + | func TestPrepareCEFSettings_AllowsNoThirdPartyCookiePolicy(t *testing.T) { | |||
| 39 | + | logger := zerolog.Nop() | |||
| 40 | + | _, err := prepareCEFSettings(port.EngineOptions{CookiePolicy: port.CookiePolicyNoThirdParty}, RuntimeConfig{}, &logger) | |||
| 41 | + | require.NoError(t, err) | |||
| 42 | + | } | |||
| 43 | + | ||||
| 38 | func TestPrepareCEFInitTraceFile_DisabledByDefault(t *testing.T) { | 44 | func TestPrepareCEFInitTraceFile_DisabledByDefault(t *testing.T) { | ||
| 39 | t.Setenv(puregoCEFInitTraceEnvVar, "") | 45 | t.Setenv(puregoCEFInitTraceEnvVar, "") | ||
| 40 | 46 | ||||