Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CCPA Phase 1: Cookie Sync #1135

Merged
merged 7 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions adapters/33across/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is a bit hard to read. Unified to an easier to read pattern. I originally had changes to these files, but that's been removed but I thought the refactor is nice to have.

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)
Expand Down
19 changes: 16 additions & 3 deletions adapters/adform/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions adapters/adkernel/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions adapters/adkernelAdn/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions adapters/adpone/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 14 additions & 3 deletions adapters/adtelligent/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 15 additions & 3 deletions adapters/advangelists/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions adapters/appnexus/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions adapters/audienceNetwork/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions adapters/beachfront/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 9 additions & 3 deletions adapters/brightroll/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 12 additions & 5 deletions adapters/consumable/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +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 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, _ := syncer.GetUsersyncInfo(privacy.Policies{
GDPR: gdpr.Policy{
Signal: "0",
},
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it'd be nice to not ignore the error and assert for NoError in the next line, as other adapters do? I realize that this is probably out of the scope of this PR and we may want to do it some other time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I think it's a idea to keep it uniform. Fixed.


syncer := NewConsumableSyncer(temp)

u, _ := syncer.GetUsersyncInfo("0", "")
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())
Expand Down
17 changes: 14 additions & 3 deletions adapters/conversant/usersync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 17 additions & 4 deletions adapters/datablocks/usersync_test.go
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Loading