Skip to content

Commit

Permalink
Enforce GDPR privacy if there's an error parsing consent
Browse files Browse the repository at this point in the history
  • Loading branch information
bsardo committed Jan 7, 2021
1 parent 601a746 commit 6e9c31e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
12 changes: 7 additions & 5 deletions exchange/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ func cleanOpenRTBRequests(ctx context.Context,
if gdprEnforced {
var publisherID = req.LegacyLabels.PubID
_, geo, id, err := gDPR.PersonalInfoAllowed(ctx, bidderRequest.BidderCoreName, publisherID, gdprSignal, consent)
privacyEnforcement.GDPRGeo = !geo && err == nil
privacyEnforcement.GDPRID = !id && err == nil
} else {
privacyEnforcement.GDPRGeo = false
privacyEnforcement.GDPRID = false
if err == nil {
privacyEnforcement.GDPRGeo = !geo
privacyEnforcement.GDPRID = !id
} else {
privacyEnforcement.GDPRGeo = true
privacyEnforcement.GDPRID = true
}
}

privacyEnforcement.Apply(bidderRequest.BidRequest)
Expand Down
21 changes: 18 additions & 3 deletions exchange/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import (
//
// It only allows appnexus for GDPR consent
type permissionsMock struct {
personalInfoAllowed bool
personalInfoAllowed bool
personalInfoAllowedError error
}

func (p *permissionsMock) HostCookiesAllowed(ctx context.Context, consent string) (bool, error) {
Expand All @@ -32,7 +33,7 @@ func (p *permissionsMock) BidderSyncAllowed(ctx context.Context, bidder openrtb_
}

func (p *permissionsMock) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdpr gdpr.Signal, consent string) (bool, bool, bool, error) {
return p.personalInfoAllowed, p.personalInfoAllowed, p.personalInfoAllowed, nil
return p.personalInfoAllowed, p.personalInfoAllowed, p.personalInfoAllowed, p.personalInfoAllowedError
}

func assertReq(t *testing.T, bidderRequests []BidderRequest,
Expand Down Expand Up @@ -1054,6 +1055,7 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) {
gdpr string
gdprConsent string
gdprScrub bool
permissionsError error
userSyncIfAmbiguous bool
expectPrivacyLabels metrics.PrivacyLabels
}{
Expand Down Expand Up @@ -1179,6 +1181,19 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) {
GDPRTCFVersion: "",
},
},
{
description: "Not Enforce - error while checking if personal info is allowed",
gdprAccountEnabled: nil,
gdprHostEnabled: true,
gdpr: "1",
gdprConsent: "BONV8oqONXwgmADACHENAO7pqzAAppY",
gdprScrub: true,
permissionsError: errors.New("Some error"),
expectPrivacyLabels: metrics.PrivacyLabels{
GDPREnforced: true,
GDPRTCFVersion: metrics.TCFVersionV1,
},
},
}

for _, test := range testCases {
Expand Down Expand Up @@ -1214,7 +1229,7 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) {
context.Background(),
auctionReq,
nil,
&permissionsMock{personalInfoAllowed: !test.gdprScrub},
&permissionsMock{personalInfoAllowed: !test.gdprScrub, personalInfoAllowedError: test.permissionsError},
test.userSyncIfAmbiguous,
privacyConfig)
result := results[0]
Expand Down

0 comments on commit 6e9c31e

Please sign in to comment.