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

Adapter Name Case Insensitive: ext.prebid.multibid #3217

Merged
merged 8 commits into from
Oct 18, 2023

Conversation

guscarreon
Copy link
Contributor

Normalization was done in buildMultiBidMap(prebid *openrtb_ext.ExtRequestPrebid) inside file exchange/exchange.go. Let me know your thoughts.

Copy link
Contributor

@AlexBVolcy AlexBVolcy left a comment

Choose a reason for hiding this comment

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

Looks good, just left comments regarding tests

Comment on lines +5790 to +5798
desc: "Lowercase prebid.MultiBid.Bidder is found in the BidderName list, entry is mapped",
inPrebid: &openrtb_ext.ExtRequestPrebid{
MultiBid: []*openrtb_ext.ExtMultiBid{
{Bidder: "appnexus"},
},
},
expected: map[string]openrtb_ext.ExtMultiBid{
"appnexus": {Bidder: "appnexus"},
},
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add another test case just like this, except the Bidder is capitalized: (i.e APPNEXUS)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -5750,3 +5750,182 @@ func TestSetSeatNonBid(t *testing.T) {
})
}
}

func TestBuildMultiBidMap(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you also a JSON test in /exchangetest similar to multi-bids.json, where we can test the case insensitivity there as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! That extra test revealed another spot where case insensitivity was needed inside function buildRequestExtMultiBid(). Added exchange/exchangetest/multi-bids-mixed-case.json.

Comment on lines 5927 to 5928
multiBidMap := buildMultiBidMap(tc.inPrebid)
assert.Equal(t, tc.expected, multiBidMap, tc.desc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add t.Run

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -2259,8 +2259,13 @@ func TestTimeoutComputation(t *testing.T) {
func TestExchangeJSON(t *testing.T) {
if specFiles, err := os.ReadDir("./exchangetest"); err == nil {
for _, specFile := range specFiles {
if !strings.HasSuffix(specFile.Name(), ".json") {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added so vim's .swp files wouldn't error. Can remove if you want

@@ -467,12 +467,12 @@ func buildRequestExtMultiBid(adapter string, reqMultiBid []*openrtb_ext.ExtMulti
adapterMultiBid := make([]*openrtb_ext.ExtMultiBid, 0)
for _, multiBid := range reqMultiBid {
if multiBid.Bidder != "" {
if multiBid.Bidder == adapter || isBidderInExtAlternateBidderCodes(adapter, multiBid.Bidder, adapterABC) {
if strings.ToLower(multiBid.Bidder) == adapter || isBidderInExtAlternateBidderCodes(adapter, strings.ToLower(multiBid.Bidder), adapterABC) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we use openrtb_ext.NormalizeBidderName() here, exchange/exchangetest/multi-bids-with-extra-bids.json fails. Whether or not the expectations in said test are correct we can leave for a future discussion.

Copy link
Contributor

@VeronikaSolovei9 VeronikaSolovei9 left a comment

Choose a reason for hiding this comment

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

LGTM

@SyntaxNode SyntaxNode merged commit bde7bcf into master Oct 18, 2023
3 checks passed
@SyntaxNode SyntaxNode deleted the caseInsensitiveBuildMultiBidMap branch November 17, 2023 22:13
svamiftah pushed a commit to sovrn/prebid-server that referenced this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants