From 6b20110f763bbc53fcae09fa00ceda3bab8398f4 Mon Sep 17 00:00:00 2001 From: Veronika Solovei Date: Thu, 18 Jul 2019 12:29:06 -0700 Subject: [PATCH] Added pass through of BCat and BAdv from Video req to openRTB request (#964) --- endpoints/openrtb2/video_auction.go | 8 +++++ endpoints/openrtb2/video_auction_test.go | 37 ++++++++++++++++++++++++ openrtb_ext/bid_request_video.go | 17 +++++++++++ 3 files changed, 62 insertions(+) diff --git a/endpoints/openrtb2/video_auction.go b/endpoints/openrtb2/video_auction.go index e706ce9ea64..077f84d2a24 100644 --- a/endpoints/openrtb2/video_auction.go +++ b/endpoints/openrtb2/video_auction.go @@ -467,6 +467,14 @@ func mergeData(videoRequest *openrtb_ext.BidRequestVideo, bidRequest *openrtb.Bi } } + if len(videoRequest.BCat) != 0 { + bidRequest.BCat = videoRequest.BCat + } + + if len(videoRequest.BAdv) != 0 { + bidRequest.BAdv = videoRequest.BAdv + } + bidExt, err := createBidExtension(videoRequest) if err != nil { return err diff --git a/endpoints/openrtb2/video_auction_test.go b/endpoints/openrtb2/video_auction_test.go index 198a06fbf90..8f25cce2d91 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -487,6 +487,43 @@ func TestVideoBuildVideoResponseNoBids(t *testing.T) { assert.Len(t, bidRespVideo.AdPods, 0, "AdPods length should be 0") } +func TestMergeOpenRTBToVideoRequest(t *testing.T) { + var bidReq = &openrtb.BidRequest{} + var videoReq = &openrtb_ext.BidRequestVideo{} + + videoReq.App = openrtb.App{ + Domain: "test.com", + Bundle: "test.bundle", + } + + videoReq.Site = openrtb.Site{ + Page: "site.com/index", + } + + var dnt int8 = 4 + var lmt int8 = 5 + videoReq.Device = openrtb.Device{ + DNT: &dnt, + Lmt: &lmt, + } + + videoReq.BCat = []string{"test1", "test2"} + videoReq.BAdv = []string{"test3", "test4"} + + mergeData(videoReq, bidReq) + + assert.Equal(t, videoReq.BCat, bidReq.BCat, "BCat is incorrect") + assert.Equal(t, videoReq.BAdv, bidReq.BAdv, "BAdv is incorrect") + + assert.Equal(t, videoReq.App.Domain, bidReq.App.Domain, "App.Domain is incorrect") + assert.Equal(t, videoReq.App.Bundle, bidReq.App.Bundle, "App.Bundle is incorrect") + + assert.Equal(t, videoReq.Device.Lmt, bidReq.Device.Lmt, "Device.Lmt is incorrect") + assert.Equal(t, videoReq.Device.DNT, bidReq.Device.DNT, "Device.DNT is incorrect") + + assert.Equal(t, videoReq.Site.Page, bidReq.Site.Page, "Device.Site.Page is incorrect") +} + func mockDeps(t *testing.T, ex *mockExchangeVideo) *endpointDeps { theMetrics := pbsmetrics.NewMetrics(metrics.NewRegistry(), openrtb_ext.BidderList()) edep := &endpointDeps{ diff --git a/openrtb_ext/bid_request_video.go b/openrtb_ext/bid_request_video.go index 1a6948ebf60..97404d40ba3 100644 --- a/openrtb_ext/bid_request_video.go +++ b/openrtb_ext/bid_request_video.go @@ -111,6 +111,23 @@ type BidRequestVideo struct { // be received including Internet latency to avoid timeout. This // value supersedes any a priori guidance from the exchange. TMax int64 `json:"tmax,omitempty"` + + // Attribute: + // bcat + // Type: + // string array + // Description: + // Blocked advertiser categories using the IAB content + // categories. Refer to List 5.1. + BCat []string `json:"bcat,omitempty"` + + // Attribute: + // badv + // Type: + // string array + // Description: + // Block list of advertisers by their domains (e.g., “ford.com”). + BAdv []string `json:"badv,omitempty"` } type PodConfig struct {