Skip to content

Commit

Permalink
Add support for multiple root schain nodes (prebid#1374)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsardo authored and sachin-pubmatic committed Aug 2, 2021
1 parent f342d50 commit 4ce313b
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions endpoints/openrtb2/auction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,53 @@ func TestGetAccountID(t *testing.T) {
}
}

func TestSChainInvalid(t *testing.T) {
deps := &endpointDeps{
&nobidExchange{},
newParamsValidator(t),
&mockStoredReqFetcher{},
empty_fetcher.EmptyFetcher{},
empty_fetcher.EmptyFetcher{},
&config.Configuration{},
pbsmetrics.NewMetrics(metrics.NewRegistry(), openrtb_ext.BidderList(), config.DisabledMetrics{}),
analyticsConf.NewPBSAnalytics(&config.Analytics{}),
map[string]string{},
false,
[]byte{},
openrtb_ext.BidderMap,
nil,
nil,
hardcodedResponseIPValidator{response: true},
}

ui := uint64(1)
req := openrtb.BidRequest{
ID: "someID",
Imp: []openrtb.Imp{
{
ID: "imp-ID",
Banner: &openrtb.Banner{
W: &ui,
H: &ui,
},
Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`),
},
},
Site: &openrtb.Site{
ID: "myID",
},
Regs: &openrtb.Regs{
Ext: json.RawMessage(`{"us_privacy":"abcd"}`),
},
Ext: json.RawMessage(`{"prebid":{"schains":[{"bidders":["appnexus"],"schain":{"complete":1,"nodes":[{"asi":"directseller1.com","sid":"00001","rid":"BidRequest1","hp":1}],"ver":"1.0"}}, {"bidders":["appnexus"],"schain":{"complete":1,"nodes":[{"asi":"directseller2.com","sid":"00002","rid":"BidRequest2","hp":1}],"ver":"1.0"}}]}}`),
}

errL := deps.validateRequest(&req)

expectedError := fmt.Errorf("request.ext.prebid.schains contains multiple schains for bidder appnexus; it must contain no more than one per bidder.")
assert.ElementsMatch(t, errL, []error{expectedError})
}

func TestSanitizeRequest(t *testing.T) {
testCases := []struct {
description string
Expand Down

0 comments on commit 4ce313b

Please sign in to comment.