Derive consent mode from geolocation, not banner config
The consent mode is now determined dynamically by the visitor's country and its applicable regulation. The configured consent_mode column is dropped from cookie_banners and added to cookie_consent_records to persist the geo-derived mode at consent-recording time. When no regulation matches, the default is OPT_OUT. Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -34,7 +34,6 @@ func TestSnapshotsEqual(t *testing.T) {
|
||||
PrivacyPolicyURL: &policy,
|
||||
CookiePolicyURL: "https://example.com/cookies",
|
||||
ConsentExpiryDays: 180,
|
||||
ConsentMode: "OPT_IN",
|
||||
DefaultLanguage: "en",
|
||||
Categories: []coredata.CookieBannerVersionSnapshotCategory{
|
||||
{
|
||||
@@ -248,7 +247,6 @@ func TestBuildSnapshot_RankInvariant(t *testing.T) {
|
||||
ID: bannerID,
|
||||
CookiePolicyURL: "https://example.com/cookies",
|
||||
ConsentExpiryDays: 365,
|
||||
ConsentMode: coredata.CookieConsentModeOptIn,
|
||||
DefaultLanguage: "en",
|
||||
}
|
||||
|
||||
@@ -298,14 +296,15 @@ func TestRemapTextsForConsentMode(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("no regulation clears reject and customize", func(t *testing.T) {
|
||||
t.Run("opt in mode keeps all buttons", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
texts := baseTexts()
|
||||
remapTextsForConsentMode(texts, ConsentModeOptIn, RegulationNone)
|
||||
remapTextsForConsentMode(texts, ConsentModeOptIn)
|
||||
|
||||
assert.Empty(t, texts["button_reject_all"])
|
||||
assert.Empty(t, texts["button_customize"])
|
||||
assert.Equal(t, "Accept All", texts["button_accept_all"])
|
||||
assert.Equal(t, "Reject All", texts["button_reject_all"])
|
||||
assert.Equal(t, "Customize", texts["button_customize"])
|
||||
})
|
||||
|
||||
t.Run("opt out mode maps opt out to reject and clears customize", func(t *testing.T) {
|
||||
@@ -313,7 +312,7 @@ func TestRemapTextsForConsentMode(t *testing.T) {
|
||||
|
||||
texts := baseTexts()
|
||||
texts["button_opt_out"] = "Do Not Sell"
|
||||
remapTextsForConsentMode(texts, ConsentModeOptOut, RegulationCCPA)
|
||||
remapTextsForConsentMode(texts, ConsentModeOptOut)
|
||||
|
||||
assert.Equal(t, "Do Not Sell", texts["button_reject_all"])
|
||||
assert.Empty(t, texts["button_customize"])
|
||||
|
||||
Reference in New Issue
Block a user