From f6ee800b832044e7b45fa65bb8bc68d489719ccd Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Wed, 11 Dec 2019 10:23:54 -0500 Subject: [PATCH] CCPA Phase 1: Cookie Sync (#1135) --- adapters/33across/usersync_test.go | 12 +++++-- adapters/adform/usersync_test.go | 19 +++++++++-- adapters/adkernel/usersync_test.go | 18 +++++++++-- adapters/adkernelAdn/usersync_test.go | 18 +++++++++-- adapters/adpone/usersync_test.go | 12 +++++-- adapters/adtelligent/usersync_test.go | 17 ++++++++-- adapters/advangelists/usersync_test.go | 18 +++++++++-- adapters/appnexus/usersync_test.go | 12 +++++-- adapters/audienceNetwork/usersync_test.go | 12 +++++-- adapters/beachfront/usersync_test.go | 12 +++++-- adapters/brightroll/usersync_test.go | 12 +++++-- adapters/consumable/usersync_test.go | 18 ++++++++--- adapters/conversant/usersync_test.go | 17 ++++++++-- adapters/datablocks/usersync_test.go | 21 +++++++++--- adapters/emx_digital/usersync_test.go | 18 +++++++++-- adapters/engagebdr/usersync_test.go | 21 +++++++++--- adapters/eplanning/usersync_test.go | 12 +++++-- adapters/gamma/usersync_test.go | 17 ++++++++-- adapters/gamoshi/usersync_test.go | 11 +++++-- adapters/grid/usersync_test.go | 17 ++++++++-- adapters/gumgum/usersync_test.go | 18 +++++++++-- adapters/improvedigital/usersync_test.go | 17 ++++++++-- adapters/ix/usersync_test.go | 12 +++++-- adapters/lifestreet/usersync_test.go | 17 ++++++++-- adapters/lockerdome/usersync_test.go | 12 +++++-- adapters/mgid/usersync_test.go | 20 +++++++++--- adapters/openx/usersync_test.go | 12 +++++-- adapters/pubmatic/usersync_test.go | 18 +++++++++-- adapters/pulsepoint/usersync_test.go | 12 +++++-- adapters/rhythmone/usersync_test.go | 18 +++++++++-- adapters/rtbhouse/usersync_test.go | 13 ++++++-- adapters/rubicon/usersync_test.go | 17 ++++++++-- adapters/sharethrough/usersync_test.go | 20 +++++++++--- adapters/somoaudience/usersync_test.go | 12 +++++-- adapters/sonobi/usersync_test.go | 17 ++++++++-- adapters/sovrn/usersync_test.go | 17 ++++++++-- adapters/synacormedia/usersync_test.go | 15 ++++++--- adapters/syncer.go | 12 ++++--- adapters/syncer_test.go | 36 +++++++++++++++++++++ adapters/triplelift/usersync_test.go | 12 +++++-- adapters/triplelift_native/usersync_test.go | 12 +++++-- adapters/unruly/usersync_test.go | 17 ++++++++-- adapters/verizonmedia/usersync_test.go | 15 ++++++--- adapters/visx/usersync_test.go | 17 ++++++++-- adapters/vrtcal/usersync_test.go | 17 ++++++++-- adapters/yieldmo/usersync_test.go | 17 ++++++++-- endpoints/auction.go | 24 ++++++++------ endpoints/auction_test.go | 7 +++- endpoints/cookie_sync.go | 23 ++++++++++--- endpoints/openrtb2/amp_auction.go | 6 ++-- endpoints/setuid_test.go | 3 +- macros/macros.go | 1 + privacy/ccpa/ccpa.go | 8 ++--- privacy/ccpa/ccpa_test.go | 20 ++++++------ privacy/gdpr/gdpr.go | 3 +- privacy/gdpr/gdpr_test.go | 18 +++++------ usersync/usersync.go | 8 ++--- 57 files changed, 664 insertions(+), 193 deletions(-) create mode 100644 adapters/syncer_test.go diff --git a/adapters/33across/usersync_test.go b/adapters/33across/usersync_test.go index 1efb53ea8ba..f4bb28150de 100644 --- a/adapters/33across/usersync_test.go +++ b/adapters/33across/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func Test33AcrossSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://ic.tynt.com/r/d?m=xch&rt=html&ri=123&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz")) - syncer := New33AcrossSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://ic.tynt.com/r/d?m=xch&rt=html&ri=123&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := New33AcrossSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://ic.tynt.com/r/d?m=xch&rt=html&ri=123&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/adform/usersync_test.go b/adapters/adform/usersync_test.go index 815103a87d1..855506da2ed 100644 --- a/adapters/adform/usersync_test.go +++ b/adapters/adform/usersync_test.go @@ -5,12 +5,25 @@ import ( "text/template" "github.com/stretchr/testify/assert" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" ) func TestAdformSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//cm.adform.net?return_url=localhost%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewAdformSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") + syncURL := "//cm.adform.net?return_url=localhost%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdformSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//cm.adform.net?return_url=localhost%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/adkernel/usersync_test.go b/adapters/adkernel/usersync_test.go index d54322dba71..bd09c361a03 100644 --- a/adapters/adkernel/usersync_test.go +++ b/adapters/adkernel/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestAdkernelAdnSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D")) - syncer := NewAdkernelSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") + syncURL := "https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdkernelSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://sync.adkernel.com/user-sync?t=image&gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/adkernelAdn/usersync_test.go b/adapters/adkernelAdn/usersync_test.go index 3da1ed95abe..007cacce29c 100644 --- a/adapters/adkernelAdn/usersync_test.go +++ b/adapters/adkernelAdn/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestAdkernelAdnSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D")) - syncer := NewAdkernelAdnSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") + syncURL := "https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdkernelAdnSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26uid%3D%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/adpone/usersync_test.go b/adapters/adpone/usersync_test.go index ad662f14ead..87b4e9ae440 100644 --- a/adapters/adpone/usersync_test.go +++ b/adapters/adpone/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestAdponeSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://usersync.adpone.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D")) - syncer := NewadponeSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://usersync.adpone.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewadponeSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://usersync.adpone.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D%26gdpr_consent%3D%26uid%3D%7Buid%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/adtelligent/usersync_test.go b/adapters/adtelligent/usersync_test.go index ca921dff270..1cc5dfe4627 100644 --- a/adapters/adtelligent/usersync_test.go +++ b/adapters/adtelligent/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestAdtelligentSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//sync.adtelligent.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D")) - syncer := NewAdtelligentSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//sync.adtelligent.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdtelligentSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//sync.adtelligent.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7Buid%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/advangelists/usersync_test.go b/adapters/advangelists/usersync_test.go index 8880788ccf1..b97652c1c46 100644 --- a/adapters/advangelists/usersync_test.go +++ b/adapters/advangelists/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestAdvangelistsSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://nep.advangelists.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=advangelists&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&uid=$UID")) - syncer := NewAdvangelistsSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA") + syncURL := "https://nep.advangelists.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=advangelists&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&uid=$UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdvangelistsSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://nep.advangelists.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=advangelists&gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&uid=$UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/appnexus/usersync_test.go b/adapters/appnexus/usersync_test.go index 49b68f03acd..24b9eede9d6 100644 --- a/adapters/appnexus/usersync_test.go +++ b/adapters/appnexus/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestAppNexusSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ib.adnxs.com/getuid?https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewAppnexusSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//ib.adnxs.com/getuid?https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAppnexusSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//ib.adnxs.com/getuid?https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/audienceNetwork/usersync_test.go b/adapters/audienceNetwork/usersync_test.go index 843d67a09d7..c3836e4f154 100644 --- a/adapters/audienceNetwork/usersync_test.go +++ b/adapters/audienceNetwork/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestFacebookSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewFacebookSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewFacebookSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/beachfront/usersync_test.go b/adapters/beachfront/usersync_test.go index 3693bcadbc2..0b71e0f92f8 100644 --- a/adapters/beachfront/usersync_test.go +++ b/adapters/beachfront/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestBeachfrontSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("localhost")) - syncer := NewBeachfrontSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "localhost" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewBeachfrontSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "localhost", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/brightroll/usersync_test.go b/adapters/brightroll/usersync_test.go index 0bf485abdad..08104c048ac 100644 --- a/adapters/brightroll/usersync_test.go +++ b/adapters/brightroll/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestBrightrollSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("http://test-bh.ybp.yahoo.com/sync/appnexuspbs?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&url=localhost%2Fsetuid%3Fbidder%3Dbrightroll%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D")) - syncer := NewBrightrollSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "http://test-bh.ybp.yahoo.com/sync/appnexuspbs?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&url=localhost%2Fsetuid%3Fbidder%3Dbrightroll%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewBrightrollSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "http://test-bh.ybp.yahoo.com/sync/appnexuspbs?gdpr=&euconsent=&url=localhost%2Fsetuid%3Fbidder%3Dbrightroll%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/consumable/usersync_test.go b/adapters/consumable/usersync_test.go index 297a863a607..7def6be0a48 100644 --- a/adapters/consumable/usersync_test.go +++ b/adapters/consumable/usersync_test.go @@ -4,17 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestConsumableSyncer(t *testing.T) { + syncURL := "//e.serverbid.com/udb/9969/match?redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) - temp := template.Must(template.New("sync-template").Parse( - "//e.serverbid.com/udb/9969/match?redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) + syncer := NewConsumableSyncer(syncURLTemplate) + u, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) - syncer := NewConsumableSyncer(temp) - - u, _ := syncer.GetUsersyncInfo("0", "") + assert.NoError(t, err) assert.Equal(t, "//e.serverbid.com/udb/9969/match?redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D0%26gdpr_consent%3D%26uid%3D", u.URL) assert.Equal(t, "redirect", u.Type) assert.Equal(t, uint16(65535), syncer.GDPRVendorID()) diff --git a/adapters/conversant/usersync_test.go b/adapters/conversant/usersync_test.go index afbac8455f4..16affbd1d32 100644 --- a/adapters/conversant/usersync_test.go +++ b/adapters/conversant/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestConversantSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("usersync?rurl=localhost%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) - syncer := NewConversantSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "usersync?rurl=localhost%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewConversantSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "usersync?rurl=localhost%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D0%26gdpr_consent%3D%26uid%3D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/datablocks/usersync_test.go b/adapters/datablocks/usersync_test.go index f91fc94a336..9dcaf8295fa 100644 --- a/adapters/datablocks/usersync_test.go +++ b/adapters/datablocks/usersync_test.go @@ -1,15 +1,28 @@ package datablocks import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" ) func TestDatablocksSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://sync.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7Buid%7D")) - syncer := NewDatablocksSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") + syncURL := "https://sync.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7Buid%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewDatablocksSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://sync.v5prebid.datablocks.net/s2ssync?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%24%7Buid%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/emx_digital/usersync_test.go b/adapters/emx_digital/usersync_test.go index 34ec28dc2ef..d8f874c8545 100644 --- a/adapters/emx_digital/usersync_test.go +++ b/adapters/emx_digital/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestEMXDigitalSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect=localhost%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID")) - syncer := NewEMXDigitalSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA") + syncURL := "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect=localhost%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewEMXDigitalSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://cs.emxdgt.com/um?ssp=pbs&gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&redirect=localhost%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/engagebdr/usersync_test.go b/adapters/engagebdr/usersync_test.go index 1e24ff5e2fd..fbcde923f09 100644 --- a/adapters/engagebdr/usersync_test.go +++ b/adapters/engagebdr/usersync_test.go @@ -1,15 +1,28 @@ package engagebdr import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" ) func TestEngageBDRSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://match.bnmla.com/usersync/prbds2s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) - syncer := NewEngageBDRSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA") + syncURL := "https://match.bnmla.com/usersync/prbds2s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewEngageBDRSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://match.bnmla.com/usersync/prbds2s?gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D1%26gdpr_consent%3DBOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA%26uid%3D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/eplanning/usersync_test.go b/adapters/eplanning/usersync_test.go index 146f71d63d1..890832bafc3 100644 --- a/adapters/eplanning/usersync_test.go +++ b/adapters/eplanning/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestEPlanningSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3Flocalhost%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewEPlanningSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3Flocalhost%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewEPlanningSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3Flocalhost%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/gamma/usersync_test.go b/adapters/gamma/usersync_test.go index 38239f4defd..4278f9abd36 100644 --- a/adapters/gamma/usersync_test.go +++ b/adapters/gamma/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestGammaSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//hb.gammaplatform.com/sync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dgamma%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewGammaSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//hb.gammaplatform.com/sync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dgamma%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewGammaSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//hb.gammaplatform.com/sync?gdpr=0&gdpr_consent=&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dgamma%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/gamoshi/usersync_test.go b/adapters/gamoshi/usersync_test.go index 21b8bd8061d..10e23c02973 100644 --- a/adapters/gamoshi/usersync_test.go +++ b/adapters/gamoshi/usersync_test.go @@ -4,14 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestGamoshiSyncer(t *testing.T) { + syncURL := "https://rtb.gamoshi.io/pix/1707/scm?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&rurl=localhost/setuid%3Fbidder%3Dgamoshi%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Bgusr%5D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewGamoshiSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) - temp := template.Must(template.New("sync-template").Parse("https://rtb.gamoshi.io/pix/1707/scm?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&rurl=localhost/setuid%3Fbidder%3Dgamoshi%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Bgusr%5D")) - syncer := NewGamoshiSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") assert.NoError(t, err) assert.Equal(t, "https://rtb.gamoshi.io/pix/1707/scm?gdpr=&consent=&rurl=localhost/setuid%3Fbidder%3Dgamoshi%26gdpr%3D%26gdpr_consent%3D%26uid%3D%5Bgusr%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/grid/usersync_test.go b/adapters/grid/usersync_test.go index 6ce58bcb93e..9b97f605a41 100644 --- a/adapters/grid/usersync_test.go +++ b/adapters/grid/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestGridSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewGridSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewGridSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/gumgum/usersync_test.go b/adapters/gumgum/usersync_test.go index 6f5ae965de1..22c42695d38 100644 --- a/adapters/gumgum/usersync_test.go +++ b/adapters/gumgum/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestGumGumSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://rtb.gumgum.com/usync/prbds2s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) - syncer := NewGumGumSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA") + syncURL := "https://rtb.gumgum.com/usync/prbds2s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewGumGumSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://rtb.gumgum.com/usync/prbds2s?gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&r=localhost%2Fsetuid%3Fbidder%3Dgumgum%26gdpr%3D1%26gdpr_consent%3DBOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA%26uid%3D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/improvedigital/usersync_test.go b/adapters/improvedigital/usersync_test.go index 06c4ec10f83..861e4875a80 100644 --- a/adapters/improvedigital/usersync_test.go +++ b/adapters/improvedigital/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestImprovedigitalSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dimprovedigital%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BPUB_USER_ID%7D")) - syncer := NewImprovedigitalSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dimprovedigital%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BPUB_USER_ID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewImprovedigitalSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dimprovedigital%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7BPUB_USER_ID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/ix/usersync_test.go b/adapters/ix/usersync_test.go index a0c15c40cb4..10f91da1abe 100644 --- a/adapters/ix/usersync_test.go +++ b/adapters/ix/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestIxSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) - syncer := NewIxSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewIxSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3Dix%26gdpr%3D%26gdpr_consent%3D%26uid%3D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/lifestreet/usersync_test.go b/adapters/lifestreet/usersync_test.go index 138aed762e0..8fee09358e8 100644 --- a/adapters/lifestreet/usersync_test.go +++ b/adapters/lifestreet/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestLifestreetSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl=localhost%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%24visitor_cookie%24%24")) - syncer := NewLifestreetSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl=localhost%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%24visitor_cookie%24%24" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewLifestreetSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl=localhost%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24%24visitor_cookie%24%24", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/lockerdome/usersync_test.go b/adapters/lockerdome/usersync_test.go index b7466ef2836..b0307c0f215 100644 --- a/adapters/lockerdome/usersync_test.go +++ b/adapters/lockerdome/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestLockerDomeSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://lockerdome.com/usync/prebidserver?pid=&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7Buid%7D%7D")) - syncer := NewLockerDomeSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://lockerdome.com/usync/prebidserver?pid=&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7Buid%7D%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewLockerDomeSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://lockerdome.com/usync/prebidserver?pid=&gdpr=&gdpr_consent=&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D%26gdpr_consent%3D%26uid%3D%7B%7Buid%7D%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/mgid/usersync_test.go b/adapters/mgid/usersync_test.go index 7bb4d1e043b..2ce634eeac2 100644 --- a/adapters/mgid/usersync_test.go +++ b/adapters/mgid/usersync_test.go @@ -1,15 +1,27 @@ package mgid import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" ) func TestMgidSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://cm.mgid.com/m?cdsp=363893&adu=https%3A//external.com%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Bmuidn%7D")) - syncer := NewMgidSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "https://cm.mgid.com/m?cdsp=363893&adu=https%3A//external.com%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Bmuidn%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewMgidSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://cm.mgid.com/m?cdsp=363893&adu=https%3A//external.com%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7Bmuidn%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/openx/usersync_test.go b/adapters/openx/usersync_test.go index 5453fbef098..86f9bb0115e 100644 --- a/adapters/openx/usersync_test.go +++ b/adapters/openx/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestOpenxSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://rtb.openx.net/sync/prebid?r=localhost%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D")) - syncer := NewOpenxSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://rtb.openx.net/sync/prebid?r=localhost%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewOpenxSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "https://rtb.openx.net/sync/prebid?r=localhost%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/pubmatic/usersync_test.go b/adapters/pubmatic/usersync_test.go index 532eda5cfe1..ef81d223377 100644 --- a/adapters/pubmatic/usersync_test.go +++ b/adapters/pubmatic/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestPubmaticSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ads.pubmatic.com/AdServer/js/user_sync.html?predirect=localhost%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D")) - syncer := NewPubmaticSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw") + syncURL := "//ads.pubmatic.com/AdServer/js/user_sync.html?predirect=localhost%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewPubmaticSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//ads.pubmatic.com/AdServer/js/user_sync.html?predirect=localhost%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/pulsepoint/usersync_test.go b/adapters/pulsepoint/usersync_test.go index 28d310779b9..e1680fd22ba 100644 --- a/adapters/pulsepoint/usersync_test.go +++ b/adapters/pulsepoint/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestPulsepointSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//bh.contextweb.com/rtset?pid=561205&ev=1&rurl=http%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25VGUID%25%25")) - syncer := NewPulsepointSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//bh.contextweb.com/rtset?pid=561205&ev=1&rurl=http%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25VGUID%25%25" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewPulsepointSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//bh.contextweb.com/rtset?pid=561205&ev=1&rurl=http%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D%26gdpr_consent%3D%26uid%3D%25%25VGUID%25%25", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/rhythmone/usersync_test.go b/adapters/rhythmone/usersync_test.go index 0ec6d157d9c..0dcf4fbda7e 100644 --- a/adapters/rhythmone/usersync_test.go +++ b/adapters/rhythmone/usersync_test.go @@ -4,13 +4,25 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestRhythmoneSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://sync.1rx.io/usersync2/rmphb?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir=localhost%2Fsetuid%3Fbidder%3Drhythmone%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BRX_UUID%5D")) - syncer := NewRhythmoneSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("1", "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA") + syncURL := "https://sync.1rx.io/usersync2/rmphb?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir=localhost%2Fsetuid%3Fbidder%3Drhythmone%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BRX_UUID%5D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewRhythmoneSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://sync.1rx.io/usersync2/rmphb?gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&redir=localhost%2Fsetuid%3Fbidder%3Drhythmone%26gdpr%3D1%26gdpr_consent%3DBOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA%26uid%3D%5BRX_UUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/rtbhouse/usersync_test.go b/adapters/rtbhouse/usersync_test.go index d73cc3b589b..bb139f7a2e5 100644 --- a/adapters/rtbhouse/usersync_test.go +++ b/adapters/rtbhouse/usersync_test.go @@ -4,16 +4,23 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestRTBHouseSyncer(t *testing.T) { - syncURLText := "https://creativecdn.com/cm-notify?pi=prebidsrvtst&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURL := "https://creativecdn.com/cm-notify?pi=prebidsrvtst&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" syncURLTemplate := template.Must( - template.New("sync-template").Parse(syncURLText), + template.New("sync-template").Parse(syncURL), ) + syncer := NewRTBHouseSyncer(syncURLTemplate) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) assert.NoError(t, err) assert.Equal(t, "https://creativecdn.com/cm-notify?pi=prebidsrvtst&gdpr=0&gdpr_consent=", syncInfo.URL) diff --git a/adapters/rubicon/usersync_test.go b/adapters/rubicon/usersync_test.go index 072e297a249..646ebff2dc4 100644 --- a/adapters/rubicon/usersync_test.go +++ b/adapters/rubicon/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestRubiconSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://pixel.rubiconproject.com/exchange/sync.php?p=prebid&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}")) - syncer := NewRubiconSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "https://pixel.rubiconproject.com/exchange/sync.php?p=prebid&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewRubiconSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://pixel.rubiconproject.com/exchange/sync.php?p=prebid&gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/sharethrough/usersync_test.go b/adapters/sharethrough/usersync_test.go index 0cfc177f254..4802329554e 100644 --- a/adapters/sharethrough/usersync_test.go +++ b/adapters/sharethrough/usersync_test.go @@ -1,15 +1,27 @@ package sharethrough import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" ) func TestSharethroughSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://match.sharethrough.com?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}")) - syncer := NewSharethroughSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "https://match.sharethrough.com?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSharethroughSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "https://match.sharethrough.com?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/somoaudience/usersync_test.go b/adapters/somoaudience/usersync_test.go index 95ef72d892a..86460506d68 100644 --- a/adapters/somoaudience/usersync_test.go +++ b/adapters/somoaudience/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestSomoaudienceSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//publisher-east.mobileadtrading.com/usersync?ru=localhost%2Fsetuid%3Fbidder%3Dsomoaudience%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D")) - syncer := NewSomoaudienceSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//publisher-east.mobileadtrading.com/usersync?ru=localhost%2Fsetuid%3Fbidder%3Dsomoaudience%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSomoaudienceSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//publisher-east.mobileadtrading.com/usersync?ru=localhost%2Fsetuid%3Fbidder%3Dsomoaudience%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/sonobi/usersync_test.go b/adapters/sonobi/usersync_test.go index 4fc15795184..bfe5859e5d1 100644 --- a/adapters/sonobi/usersync_test.go +++ b/adapters/sonobi/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestSonobiSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//sync.go.sonobi.com/us.gif?loc=external.com%2Fsetuid%3Fbidder%3Dsonobi%26consent_string%3D{{.GDPR}}%26gdpr%3D{{.GDPRConsent}}%26uid%3D%5BUID%5D")) - syncer := NewSonobiSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//sync.go.sonobi.com/us.gif?loc=external.com%2Fsetuid%3Fbidder%3Dsonobi%26consent_string%3D{{.GDPR}}%26gdpr%3D{{.GDPRConsent}}%26uid%3D%5BUID%5D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSonobiSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//sync.go.sonobi.com/us.gif?loc=external.com%2Fsetuid%3Fbidder%3Dsonobi%26consent_string%3D0%26gdpr%3D%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/sovrn/usersync_test.go b/adapters/sovrn/usersync_test.go index 5dad5451c5e..4a4dfd9d1b9 100644 --- a/adapters/sovrn/usersync_test.go +++ b/adapters/sovrn/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestSovrnSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ap.lijit.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewSovrnSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//ap.lijit.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSovrnSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//ap.lijit.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/synacormedia/usersync_test.go b/adapters/synacormedia/usersync_test.go index 3f98fc40c8e..538efb30c73 100644 --- a/adapters/synacormedia/usersync_test.go +++ b/adapters/synacormedia/usersync_test.go @@ -1,15 +1,22 @@ package synacormedia import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/stretchr/testify/assert" ) func TestSynacormediaSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//sync.technoratimedia.com/services?srv=cs&pid=70&cb=localhost%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D")) - syncer := NewSynacorMediaSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//sync.technoratimedia.com/services?srv=cs&pid=70&cb=localhost%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSynacorMediaSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//sync.technoratimedia.com/services?srv=cs&pid=70&cb=localhost%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/syncer.go b/adapters/syncer.go index 21491b2a93e..d86e3239567 100644 --- a/adapters/syncer.go +++ b/adapters/syncer.go @@ -5,6 +5,7 @@ import ( "github.com/prebid/prebid-server/macros" "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/privacy" "github.com/prebid/prebid-server/usersync" ) @@ -41,17 +42,18 @@ const ( SyncTypeIframe SyncType = "iframe" ) -func (s *Syncer) GetUsersyncInfo(gdpr string, consent string) (*usersync.UsersyncInfo, error) { - userSyncURL, err := macros.ResolveMacros(*s.urlTemplate, macros.UserSyncTemplateParams{ - GDPR: gdpr, - GDPRConsent: consent, +func (s *Syncer) GetUsersyncInfo(privacyPolicies privacy.Policies) (*usersync.UsersyncInfo, error) { + syncURL, err := macros.ResolveMacros(*s.urlTemplate, macros.UserSyncTemplateParams{ + GDPR: privacyPolicies.GDPR.Signal, + GDPRConsent: privacyPolicies.GDPR.Consent, + USPrivacy: privacyPolicies.CCPA.Signal, }) if err != nil { return nil, err } return &usersync.UsersyncInfo{ - URL: userSyncURL, + URL: syncURL, Type: string(s.syncType), SupportCORS: false, }, err diff --git a/adapters/syncer_test.go b/adapters/syncer_test.go new file mode 100644 index 00000000000..8defd7b658a --- /dev/null +++ b/adapters/syncer_test.go @@ -0,0 +1,36 @@ +package adapters + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) + +func TestGetUsersyncInfo(t *testing.T) { + privacyPolicies := privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "A", + Consent: "B", + }, + CCPA: ccpa.Policy{ + Signal: "C", + }, + } + + syncURL := "{{.GDPR}}{{.GDPRConsent}}{{.USPrivacy}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + syncer := Syncer{ + urlTemplate: syncURLTemplate, + } + + syncInfo, err := syncer.GetUsersyncInfo(privacyPolicies) + + assert.NoError(t, err) + assert.Equal(t, "ABC", syncInfo.URL) +} diff --git a/adapters/triplelift/usersync_test.go b/adapters/triplelift/usersync_test.go index 3fe2418b2dc..b4bc845915b 100644 --- a/adapters/triplelift/usersync_test.go +++ b/adapters/triplelift/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestTripleliftSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewTripleliftSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewTripleliftSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//eb2.3lift.com/getuid?gdpr=&cmp_cs=&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/triplelift_native/usersync_test.go b/adapters/triplelift_native/usersync_test.go index 85610f61635..2fb66c2bd2a 100644 --- a/adapters/triplelift_native/usersync_test.go +++ b/adapters/triplelift_native/usersync_test.go @@ -4,13 +4,19 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) func TestTripleliftSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewTripleliftSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "//eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewTripleliftSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "//eb2.3lift.com/getuid?gdpr=&cmp_cs=&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/unruly/usersync_test.go b/adapters/unruly/usersync_test.go index b9a25b07b37..8db8f75059e 100644 --- a/adapters/unruly/usersync_test.go +++ b/adapters/unruly/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestUnrulySyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//unrulymedia.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewUnrulySyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//unrulymedia.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewUnrulySyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//unrulymedia.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) diff --git a/adapters/verizonmedia/usersync_test.go b/adapters/verizonmedia/usersync_test.go index 4643b9574eb..ad77ef0e6cb 100644 --- a/adapters/verizonmedia/usersync_test.go +++ b/adapters/verizonmedia/usersync_test.go @@ -1,15 +1,22 @@ package verizonmedia import ( - "github.com/stretchr/testify/assert" "testing" "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/stretchr/testify/assert" ) func TestVerizonMediaSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://pixel.advertising.com/ups/58207/occ?http://localhost/%2Fsetuid%3Fbidder%3Dverizonmedia%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewVerizonMediaSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncURL := "https://pixel.advertising.com/ups/58207/occ?http://localhost/%2Fsetuid%3Fbidder%3Dverizonmedia%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewVerizonMediaSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + assert.NoError(t, err) assert.Equal(t, "redirect", syncInfo.Type) assert.EqualValues(t, 25, syncer.GDPRVendorID()) diff --git a/adapters/visx/usersync_test.go b/adapters/visx/usersync_test.go index 02ca66df53d..9133c5dfcfe 100644 --- a/adapters/visx/usersync_test.go +++ b/adapters/visx/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestVisxSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dvisx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D")) - syncer := NewVisxSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dvisx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewVisxSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dvisx%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24%7BUUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/vrtcal/usersync_test.go b/adapters/vrtcal/usersync_test.go index 106c9a6ed3b..26e5838dbe3 100644 --- a/adapters/vrtcal/usersync_test.go +++ b/adapters/vrtcal/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestVrtcalSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("http://usync-prebid.vrtcal.com/s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}")) - syncer := NewVrtcalSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "http://usync-prebid.vrtcal.com/s?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewVrtcalSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "http://usync-prebid.vrtcal.com/s?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/adapters/yieldmo/usersync_test.go b/adapters/yieldmo/usersync_test.go index 0aa230e79c6..93ab907f202 100644 --- a/adapters/yieldmo/usersync_test.go +++ b/adapters/yieldmo/usersync_test.go @@ -4,13 +4,24 @@ import ( "testing" "text/template" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) func TestYieldmoSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("//ads.yieldmo.com/pbsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dyieldmo%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID")) - syncer := NewYieldmoSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("0", "") + syncURL := "//ads.yieldmo.com/pbsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dyieldmo%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewYieldmoSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + assert.NoError(t, err) assert.Equal(t, "//ads.yieldmo.com/pbsync?gdpr=0&gdpr_consent=&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dyieldmo%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) diff --git a/endpoints/auction.go b/endpoints/auction.go index 9a1d670d532..bf592e43b02 100644 --- a/endpoints/auction.go +++ b/endpoints/auction.go @@ -23,6 +23,8 @@ import ( "github.com/prebid/prebid-server/pbs" "github.com/prebid/prebid-server/pbsmetrics" pbc "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/privacy" + gdprPolicy "github.com/prebid/prebid-server/privacy/gdpr" "github.com/prebid/prebid-server/usersync" ) @@ -188,20 +190,20 @@ func (a *auction) recoverSafely(inner func(*pbs.PBSBidder, pbsmetrics.AdapterLab } } -func (a *auction) shouldUsersync(ctx context.Context, bidder openrtb_ext.BidderName, gdprApplies string, consent string) bool { - switch gdprApplies { +func (a *auction) shouldUsersync(ctx context.Context, bidder openrtb_ext.BidderName, gdprPrivacyPolicy gdprPolicy.Policy) bool { + switch gdprPrivacyPolicy.Signal { case "0": return true case "1": - if consent == "" { + if gdprPrivacyPolicy.Consent == "" { return false } fallthrough default: - if canSync, err := a.gdprPerms.HostCookiesAllowed(ctx, consent); !canSync || err != nil { + if canSync, err := a.gdprPerms.HostCookiesAllowed(ctx, gdprPrivacyPolicy.Consent); !canSync || err != nil { return false } - canSync, err := a.gdprPerms.BidderSyncAllowed(ctx, bidder, consent) + canSync, err := a.gdprPerms.BidderSyncAllowed(ctx, bidder, gdprPrivacyPolicy.Consent) return canSync && err == nil } } @@ -508,10 +510,14 @@ func (a *auction) processUserSync(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bl uid, _, _ := req.Cookie.GetUID(syncer.FamilyName()) if uid == "" { bidder.NoCookie = true - gdprApplies := req.ParseGDPR() - consent := req.ParseConsent() - if a.shouldUsersync(*ctx, openrtb_ext.BidderName(syncerCode), gdprApplies, consent) { - syncInfo, err := syncer.GetUsersyncInfo(gdprApplies, consent) + privacyPolicies := privacy.Policies{ + GDPR: gdprPolicy.Policy{ + Signal: req.ParseGDPR(), + Consent: req.ParseConsent(), + }, + } + if a.shouldUsersync(*ctx, openrtb_ext.BidderName(syncerCode), privacyPolicies.GDPR) { + syncInfo, err := syncer.GetUsersyncInfo(privacyPolicies) if err == nil { bidder.UsersyncInfo = syncInfo } else { diff --git a/endpoints/auction_test.go b/endpoints/auction_test.go index e968003a49a..df91f8ca004 100644 --- a/endpoints/auction_test.go +++ b/endpoints/auction_test.go @@ -19,6 +19,7 @@ import ( "github.com/prebid/prebid-server/pbsmetrics" metricsConf "github.com/prebid/prebid-server/pbsmetrics/config" "github.com/prebid/prebid-server/prebid_cache_client" + gdprPolicy "github.com/prebid/prebid-server/privacy/gdpr" "github.com/prebid/prebid-server/usersync/usersyncers" "github.com/spf13/viper" ) @@ -386,7 +387,11 @@ func TestShouldUsersync(t *testing.T) { }, metricsEngine: nil, } - allowSyncs := deps.shouldUsersync(context.Background(), openrtb_ext.BidderAdform, gdprApplies, consent) + privacyPolicy := gdprPolicy.Policy{ + Signal: gdprApplies, + Consent: consent, + } + allowSyncs := deps.shouldUsersync(context.Background(), openrtb_ext.BidderAdform, privacyPolicy) if allowSyncs != expectAllow { t.Errorf("Expected syncs: %t, allowed syncs: %t", expectAllow, allowSyncs) } diff --git a/endpoints/cookie_sync.go b/endpoints/cookie_sync.go index 48437008d12..475416e8ea7 100644 --- a/endpoints/cookie_sync.go +++ b/endpoints/cookie_sync.go @@ -18,6 +18,9 @@ import ( "github.com/prebid/prebid-server/gdpr" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/pbsmetrics" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + gdprPolicy "github.com/prebid/prebid-server/privacy/gdpr" "github.com/prebid/prebid-server/usersync" ) @@ -122,7 +125,16 @@ func (deps *cookieSyncDeps) Endpoint(w http.ResponseWriter, r *http.Request, _ h } for i := 0; i < len(parsedReq.Bidders); i++ { bidder := parsedReq.Bidders[i] - syncInfo, err := deps.syncers[openrtb_ext.BidderName(bidder)].GetUsersyncInfo(gdprToString(parsedReq.GDPR), parsedReq.Consent) + privacyPolicy := privacy.Policies{ + GDPR: gdprPolicy.Policy{ + Signal: gdprToString(parsedReq.GDPR), + Consent: parsedReq.Consent, + }, + CCPA: ccpa.Policy{ + Signal: parsedReq.USPrivacy, + }, + } + syncInfo, err := deps.syncers[openrtb_ext.BidderName(bidder)].GetUsersyncInfo(privacyPolicy) if err == nil { newSync := &usersync.CookieSyncBidders{ BidderCode: bidder, @@ -190,10 +202,11 @@ func cookieSyncStatus(syncCount int) string { } type cookieSyncRequest struct { - Bidders []string `json:"bidders"` - GDPR *int `json:"gdpr"` - Consent string `json:"gdpr_consent"` - Limit int `json:"limit"` + Bidders []string `json:"bidders"` + GDPR *int `json:"gdpr"` + Consent string `json:"gdpr_consent"` + USPrivacy string `json:"us_privacy"` + Limit int `json:"limit"` } func (req *cookieSyncRequest) filterExistingSyncs(valid map[openrtb_ext.BidderName]usersync.Usersyncer, cookie *usersync.PBSCookie, needSyncupForSameSite bool) { diff --git a/endpoints/openrtb2/amp_auction.go b/endpoints/openrtb2/amp_auction.go index 7328d3c1e74..6b64238f263 100644 --- a/endpoints/openrtb2/amp_auction.go +++ b/endpoints/openrtb2/amp_auction.go @@ -382,14 +382,12 @@ func (deps *endpointDeps) overrideWithParams(httpRequest *http.Request, req *ope req.Imp[0].TagID = slot } - gdprConsent := getQueryParam(httpRequest, "gdpr_consent") - ccpaValue := getQueryParam(httpRequest, "us_privacy") privacyPolicies := privacy.Policies{ GDPR: gdpr.Policy{ - Consent: gdprConsent, + Consent: getQueryParam(httpRequest, "gdpr_consent"), }, CCPA: ccpa.Policy{ - Value: ccpaValue, + Signal: getQueryParam(httpRequest, "us_privacy"), }, } diff --git a/endpoints/setuid_test.go b/endpoints/setuid_test.go index cccc6659b67..555f6173b0f 100644 --- a/endpoints/setuid_test.go +++ b/endpoints/setuid_test.go @@ -12,6 +12,7 @@ import ( "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/pbsmetrics" + "github.com/prebid/prebid-server/privacy" "github.com/prebid/prebid-server/usersync" "github.com/stretchr/testify/assert" @@ -456,7 +457,7 @@ func (s fakeSyncer) FamilyName() string { } // GetUsersyncInfo implements the Usersyncer interface with a no-op. -func (s fakeSyncer) GetUsersyncInfo(gdpr string, consent string) (*usersync.UsersyncInfo, error) { +func (s fakeSyncer) GetUsersyncInfo(privacyPolicies privacy.Policies) (*usersync.UsersyncInfo, error) { return nil, nil } diff --git a/macros/macros.go b/macros/macros.go index dd5832c35b9..9f9cfad2dcd 100644 --- a/macros/macros.go +++ b/macros/macros.go @@ -17,6 +17,7 @@ type EndpointTemplateParams struct { type UserSyncTemplateParams struct { GDPR string GDPRConsent string + USPrivacy string } // ResolveMacros resolves macros in the given template with the provided params diff --git a/privacy/ccpa/ccpa.go b/privacy/ccpa/ccpa.go index 612c1073a27..ba6ac6112c5 100644 --- a/privacy/ccpa/ccpa.go +++ b/privacy/ccpa/ccpa.go @@ -9,12 +9,12 @@ import ( // Policy represents the CCPA regulation for an OpenRTB bid request. type Policy struct { - Value string + Signal string } // Write mutates an OpenRTB bid request with the context of the CCPA policy. func (p Policy) Write(req *openrtb.BidRequest) error { - if p.Value == "" { + if p.Signal == "" { return nil } @@ -23,11 +23,11 @@ func (p Policy) Write(req *openrtb.BidRequest) error { } if req.Regs.Ext == nil { - req.Regs.Ext = json.RawMessage(`{"us_privacy":"` + p.Value + `"}`) + req.Regs.Ext = json.RawMessage(`{"us_privacy":"` + p.Signal + `"}`) return nil } var err error - req.Regs.Ext, err = jsonparser.Set(req.Regs.Ext, []byte(`"`+p.Value+`"`), "us_privacy") + req.Regs.Ext, err = jsonparser.Set(req.Regs.Ext, []byte(`"`+p.Signal+`"`), "us_privacy") return err } diff --git a/privacy/ccpa/ccpa_test.go b/privacy/ccpa/ccpa_test.go index a5b48d1467b..5847dcf0f68 100644 --- a/privacy/ccpa/ccpa_test.go +++ b/privacy/ccpa/ccpa_test.go @@ -18,43 +18,43 @@ func TestWrite(t *testing.T) { }{ { description: "Disabled", - policy: Policy{Value: ""}, + policy: Policy{Signal: ""}, request: &openrtb.BidRequest{}, expected: &openrtb.BidRequest{}, }, { description: "Enabled With Nil Request Regs Object", - policy: Policy{Value: "anyValue"}, + policy: Policy{Signal: "anySignal"}, request: &openrtb.BidRequest{}, expected: &openrtb.BidRequest{Regs: &openrtb.Regs{ - Ext: json.RawMessage(`{"us_privacy":"anyValue"}`)}}, + Ext: json.RawMessage(`{"us_privacy":"anySignal"}`)}}, }, { description: "Enabled With Nil Request Regs Ext Object", - policy: Policy{Value: "anyValue"}, + policy: Policy{Signal: "anySignal"}, request: &openrtb.BidRequest{Regs: &openrtb.Regs{}}, expected: &openrtb.BidRequest{Regs: &openrtb.Regs{ - Ext: json.RawMessage(`{"us_privacy":"anyValue"}`)}}, + Ext: json.RawMessage(`{"us_privacy":"anySignal"}`)}}, }, { description: "Enabled With Existing Request Regs Ext Object - Doesn't Overwrite", - policy: Policy{Value: "anyValue"}, + policy: Policy{Signal: "anySignal"}, request: &openrtb.BidRequest{Regs: &openrtb.Regs{ Ext: json.RawMessage(`{"existing":"any"}`)}}, expected: &openrtb.BidRequest{Regs: &openrtb.Regs{ - Ext: json.RawMessage(`{"existing":"any","us_privacy":"anyValue"}`)}}, + Ext: json.RawMessage(`{"existing":"any","us_privacy":"anySignal"}`)}}, }, { description: "Enabled With Existing Request Regs Ext Object - Overwrites", - policy: Policy{Value: "anyValue"}, + policy: Policy{Signal: "anySignal"}, request: &openrtb.BidRequest{Regs: &openrtb.Regs{ Ext: json.RawMessage(`{"existing":"any","us_privacy":"toBeOverwritten"}`)}}, expected: &openrtb.BidRequest{Regs: &openrtb.Regs{ - Ext: json.RawMessage(`{"existing":"any","us_privacy":"anyValue"}`)}}, + Ext: json.RawMessage(`{"existing":"any","us_privacy":"anySignal"}`)}}, }, { description: "Enabled With Existing Malformed Request Regs Ext Object", - policy: Policy{Value: "anyValue"}, + policy: Policy{Signal: "anySignal"}, request: &openrtb.BidRequest{Regs: &openrtb.Regs{ Ext: json.RawMessage(`malformed`)}}, expectedError: true, diff --git a/privacy/gdpr/gdpr.go b/privacy/gdpr/gdpr.go index 60d6fe8e06a..61f95ac99c6 100644 --- a/privacy/gdpr/gdpr.go +++ b/privacy/gdpr/gdpr.go @@ -7,8 +7,9 @@ import ( "github.com/mxmCherry/openrtb" ) -// Policy represents the GDPR regulation of an OpenRTB bid request. +// Policy represents the GDPR regulation for an OpenRTB bid request. type Policy struct { + Signal string Consent string } diff --git a/privacy/gdpr/gdpr_test.go b/privacy/gdpr/gdpr_test.go index 34605f079cc..80bd882dada 100644 --- a/privacy/gdpr/gdpr_test.go +++ b/privacy/gdpr/gdpr_test.go @@ -24,37 +24,37 @@ func TestWrite(t *testing.T) { }, { description: "Enabled With Nil Request User Object", - policy: Policy{Consent: "anyValue"}, + policy: Policy{Consent: "anyConsent"}, request: &openrtb.BidRequest{}, expected: &openrtb.BidRequest{User: &openrtb.User{ - Ext: json.RawMessage(`{"consent":"anyValue"}`)}}, + Ext: json.RawMessage(`{"consent":"anyConsent"}`)}}, }, { description: "Enabled With Nil Request User Ext Object", - policy: Policy{Consent: "anyValue"}, + policy: Policy{Consent: "anyConsent"}, request: &openrtb.BidRequest{User: &openrtb.User{}}, expected: &openrtb.BidRequest{User: &openrtb.User{ - Ext: json.RawMessage(`{"consent":"anyValue"}`)}}, + Ext: json.RawMessage(`{"consent":"anyConsent"}`)}}, }, { description: "Enabled With Existing Request User Ext Object - Doesn't Overwrite", - policy: Policy{Consent: "anyValue"}, + policy: Policy{Consent: "anyConsent"}, request: &openrtb.BidRequest{User: &openrtb.User{ Ext: json.RawMessage(`{"existing":"any"}`)}}, expected: &openrtb.BidRequest{User: &openrtb.User{ - Ext: json.RawMessage(`{"existing":"any","consent":"anyValue"}`)}}, + Ext: json.RawMessage(`{"existing":"any","consent":"anyConsent"}`)}}, }, { description: "Enabled With Existing Request User Ext Object - Overwrites", - policy: Policy{Consent: "anyValue"}, + policy: Policy{Consent: "anyConsent"}, request: &openrtb.BidRequest{User: &openrtb.User{ Ext: json.RawMessage(`{"existing":"any","consent":"toBeOverwritten"}`)}}, expected: &openrtb.BidRequest{User: &openrtb.User{ - Ext: json.RawMessage(`{"existing":"any","consent":"anyValue"}`)}}, + Ext: json.RawMessage(`{"existing":"any","consent":"anyConsent"}`)}}, }, { description: "Enabled With Existing Malformed Request User Ext Object", - policy: Policy{Consent: "anyValue"}, + policy: Policy{Consent: "anyConsent"}, request: &openrtb.BidRequest{User: &openrtb.User{ Ext: json.RawMessage(`malformed`)}}, expectedError: true, diff --git a/usersync/usersync.go b/usersync/usersync.go index dbf0a1f7782..2b313a021f8 100644 --- a/usersync/usersync.go +++ b/usersync/usersync.go @@ -1,14 +1,14 @@ package usersync +import "github.com/prebid/prebid-server/privacy" + type Usersyncer interface { // GetUsersyncInfo returns basic info the browser needs in order to run a user sync. // The returned UsersyncInfo object must not be mutated by callers. // - // gdpr should be 1 if GDPR is active, 0 if not, and an empty string if we're not sure. - // consent should be an empty string or a raw base64 url-encoded IAB Vendor Consent String. - // // For more information about user syncs, see http://clearcode.cc/2015/12/cookie-syncing/ - GetUsersyncInfo(gdpr string, consent string) (*UsersyncInfo, error) + GetUsersyncInfo(privacyPolicies privacy.Policies) (*UsersyncInfo, error) + // FamilyName should be the same as the `BidderName` for this Usersyncer. // This function only exists for legacy reasons. // TODO #362: when the appnexus usersyncer is consistent, delete this and use the key