-
Notifications
You must be signed in to change notification settings - Fork 758
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
update cookie sync endpoint to be case insensitive #3103
Changes from 5 commits
e8802d0
c7685f9
526ce55
88209d7
176b887
c124abb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
package usersync | ||
|
||
import ( | ||
"github.com/prebid/prebid-server/openrtb_ext" | ||
"strings" | ||
) | ||
|
||
// Chooser determines which syncers are eligible for a given request. | ||
type Chooser interface { | ||
// Choose considers bidders to sync, filters the bidders, and returns the result of the | ||
|
@@ -15,9 +20,10 @@ func NewChooser(bidderSyncerLookup map[string]Syncer) Chooser { | |
} | ||
|
||
return standardChooser{ | ||
bidderSyncerLookup: bidderSyncerLookup, | ||
biddersAvailable: bidders, | ||
bidderChooser: standardBidderChooser{shuffler: randomShuffler{}}, | ||
bidderSyncerLookup: bidderSyncerLookup, | ||
biddersAvailable: bidders, | ||
bidderChooser: standardBidderChooser{shuffler: randomShuffler{}}, | ||
normalizeValidBidderName: openrtb_ext.NormalizeBidderName, | ||
} | ||
} | ||
|
||
|
@@ -100,9 +106,10 @@ type Privacy interface { | |
|
||
// standardChooser implements the user syncer algorithm per official Prebid specification. | ||
type standardChooser struct { | ||
bidderSyncerLookup map[string]Syncer | ||
biddersAvailable []string | ||
bidderChooser bidderChooser | ||
bidderSyncerLookup map[string]Syncer | ||
biddersAvailable []string | ||
bidderChooser bidderChooser | ||
normalizeValidBidderName func(name string) (openrtb_ext.BidderName, bool) | ||
} | ||
|
||
// Choose randomly selects user syncers which are permitted by the user's privacy settings and | ||
|
@@ -136,7 +143,12 @@ func (c standardChooser) Choose(request Request, cookie *Cookie) Result { | |
} | ||
|
||
func (c standardChooser) evaluate(bidder string, syncersSeen map[string]struct{}, syncTypeFilter SyncTypeFilter, privacy Privacy, cookie *Cookie) (Syncer, BidderEvaluation) { | ||
syncer, exists := c.bidderSyncerLookup[bidder] | ||
bidderNormalized, exists := c.normalizeValidBidderName(bidder) | ||
if !exists { | ||
return nil, BidderEvaluation{Status: StatusUnknownBidder, Bidder: bidder} | ||
} | ||
|
||
syncer, exists := c.bidderSyncerLookup[bidderNormalized.String()] | ||
if !exists { | ||
return nil, BidderEvaluation{Status: StatusUnknownBidder, Bidder: bidder} | ||
} | ||
|
@@ -147,7 +159,7 @@ func (c standardChooser) evaluate(bidder string, syncersSeen map[string]struct{} | |
} | ||
syncersSeen[syncer.Key()] = struct{}{} | ||
|
||
if !syncer.SupportsType(syncTypeFilter.ForBidder(bidder)) { | ||
if !syncer.SupportsType(syncTypeFilter.ForBidder(strings.ToLower(bidder))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't this line also use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We cannot use normalised bidder name here and the reason is there is biddersLookup map that is created in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, but when I subbed in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @AlexBVolcy It is because test cases are setup that way. If you setup a test case where you use |
||
return nil, BidderEvaluation{Status: StatusTypeNotSupported, Bidder: bidder, SyncerKey: syncer.Key()} | ||
} | ||
|
||
|
@@ -160,11 +172,11 @@ func (c standardChooser) evaluate(bidder string, syncersSeen map[string]struct{} | |
return nil, BidderEvaluation{Status: StatusBlockedByPrivacy, Bidder: bidder, SyncerKey: syncer.Key()} | ||
} | ||
|
||
if !privacy.GDPRAllowsBidderSync(bidder) { | ||
if !privacy.GDPRAllowsBidderSync(bidderNormalized.String()) { | ||
return nil, BidderEvaluation{Status: StatusBlockedByGDPR, Bidder: bidder, SyncerKey: syncer.Key()} | ||
} | ||
|
||
if !privacy.CCPAAllowsBidderSync(bidder) { | ||
if !privacy.CCPAAllowsBidderSync(bidderNormalized.String()) { | ||
return nil, BidderEvaluation{Status: StatusBlockedByCCPA, Bidder: bidder, SyncerKey: syncer.Key()} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own understanding, why was this changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we mocked
normalizedBidderNamesLookup
field in standardChooser - apparently, go changes the address of the struct by copying the values to a new struct. Hence, the address are different however the values are same and that is what the assert statement is doing.