From a098d7c32cc85b40dc061460ab9bb9994cbbea98 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 06:53:20 -0500 Subject: [PATCH 01/42] adding DMX main file --- adapters/dmx/dmx.go | 248 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 248 insertions(+) create mode 100644 adapters/dmx/dmx.go diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go new file mode 100644 index 00000000000..64f03c01932 --- /dev/null +++ b/adapters/dmx/dmx.go @@ -0,0 +1,248 @@ +package dmx + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "net/http" + "sort" +) + +type DmxAdapter struct { + endpoint string + publisherId string +} + +func New(text string) error { + return &errorString{text} +} + +// errorString is a trivial implementation of error. +type errorString struct { + s string +} + +func (e *errorString) Error() string { + return e.s +} + +func NewDmxBidder(endpoint string, publisher_id string) *DmxAdapter { + return &DmxAdapter{endpoint: endpoint, publisherId: publisher_id} +} + +type dmxBidder struct { + Bidder dmxExt `json:"bidder"` +} + +type dmxUser struct { + User *openrtb.User `json:"user"` +} + +type dmxExt struct { + PublisherId string `json:"publisher_id,omitempty"` +} + +type dmxBanner struct { + Banner *openrtb.Banner `json:"banner"` +} + +type dmxSize struct { + W uint64 + H uint64 + S uint64 +} + +type DmxSize []dmxSize + +func (a DmxSize) Len() int { + return len(a) +} + +func (a DmxSize) Swap(i, j int) { + a[i], a[j] = a[j], a[i] +} + +func (a DmxSize) Less(i, j int) bool { + return a[i].S > a[j].S +} + +func Remove(toBeRemove []openrtb.Format, a DmxSize) (dmx DmxSize) { + for _, value := range toBeRemove { + for _, dmxValue := range a { + if dmxValue.H == value.H && dmxValue.W == value.W { + //fmt.Println("true") + dmx = append(dmx, dmxValue) + } + } + } + return +} + +var CheckTopSizes = []dmxSize{ + {300, 250, 100}, + {728, 90, 95}, + {320, 50, 90}, + {160, 600, 88}, + {300, 600, 85}, + {300, 50, 80}, + {970, 250, 75}, + {970, 90, 70}, +} + +func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { + var dmxImp dmxBidder + var imps []openrtb.Imp + //var userParams *dmxUser + if err := json.Unmarshal(request.Imp[0].Ext, &dmxImp); err != nil { + errs = append(errs, err) + } + + //fmt.Println(request.User) + if request.User != nil { + if request.User.BuyerUID != "" { + request.User.ID = request.User.BuyerUID + + } + } + + for _, inst := range request.Imp { + var banner openrtb.Banner + var ins openrtb.Imp + //for _, insbanner := range inst.Banner.Format { + banner = openrtb.Banner{ + W: &inst.Banner.Format[0].W, + H: &inst.Banner.Format[0].H, + Format: inst.Banner.Format, + } + nSize := Remove(inst.Banner.Format, CheckTopSizes) + sort.Sort(DmxSize(nSize)) + if inst.Banner.Format[0].W != 0 { + banner.W = &nSize[0].W + } + if inst.Banner.Format[0].H != 0 { + banner.H = &nSize[0].H + } + + var intVal int8 + intVal = 1 + ins = openrtb.Imp{ + ID: inst.ID, + Banner: &banner, + Ext: inst.Ext, + Secure: &intVal, + } + imps = append(imps, ins) + + } + + request.Imp = imps + + if dmxImp.Bidder.PublisherId != "" { + request.Site.Publisher = &openrtb.Publisher{ID: dmxImp.Bidder.PublisherId} + } else { + if request.Site.Publisher != nil { + request.Site.Publisher.ID = adapter.publisherId + } + } + + if request.App != nil { + request.Site = nil + request.App.Publisher = &openrtb.Publisher{ID: dmxImp.Bidder.PublisherId} + } + + + oJson, _ := json.Marshal(request) + headers := http.Header{} + headers.Add("Content-Type", "Application/json;charset=utf-8") + reqBidder := &adapters.RequestData{ + Method: "POST", + Uri: adapter.endpoint, //adapter.endpoint, + Body: oJson, + Headers: headers, + } + + + if request.User == nil { + if request.App == nil { + return nil, []error{errors.New("no user Id only app send request")} + } + } + + reqsBidder = append(reqsBidder, reqBidder) + return +} + +func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + var errs []error + + if http.StatusNoContent == response.StatusCode { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("No content to be return"), + }} + } + + if http.StatusBadRequest == response.StatusCode { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Bad formated request"), + }} + } + + if http.StatusOK != response.StatusCode { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Something is really wrong"), + }} + } + + var bidResp openrtb.BidResponse + + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(5) + + for _, sb := range bidResp.SeatBid { + for i := range sb.Bid { + bidType, err := getMediaTypeForImp(sb.Bid[i].ImpID, request.Imp) + if err != nil { + errs = append(errs, err) + } else { + b := &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: bidType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + } + return bidResponse, errs + + return nil, errs +} + +func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { + mediaType := openrtb_ext.BidTypeBanner + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner == nil && imp.Video != nil { + mediaType = openrtb_ext.BidTypeVideo + } + return mediaType, nil + } + } + + // This shouldnt happen. Lets handle it just incase by returning an error. + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), + } +} + + +func getCookieInfo(request *pbs.PBSRequest) { + +} \ No newline at end of file From 255d38420af89d3ba29c117d68db0a5400e47459 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 06:54:51 -0500 Subject: [PATCH 02/42] adding user sync for dmx --- adapters/dmx/usersync.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 adapters/dmx/usersync.go diff --git a/adapters/dmx/usersync.go b/adapters/dmx/usersync.go new file mode 100644 index 00000000000..98e56234fa6 --- /dev/null +++ b/adapters/dmx/usersync.go @@ -0,0 +1,12 @@ +package dmx + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewDmxSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("dmx", 144, temp, adapters.SyncTypeRedirect) +} From c78cdcc2f627b821e2f131163f899e886e9343b7 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:01:21 -0500 Subject: [PATCH 03/42] adding dmx in the adapter map --- exchange/adapter_map.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 395b4a5d845..24d3b93b0f0 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -21,6 +21,7 @@ import ( "github.com/prebid/prebid-server/adapters/consumable" "github.com/prebid/prebid-server/adapters/conversant" "github.com/prebid/prebid-server/adapters/datablocks" + "github.com/prebid/prebid-server/adapters/dmx" "github.com/prebid/prebid-server/adapters/emx_digital" "github.com/prebid/prebid-server/adapters/engagebdr" "github.com/prebid/prebid-server/adapters/eplanning" @@ -73,6 +74,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderBrightroll: brightroll.NewBrightrollBidder(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].Endpoint), openrtb_ext.BidderConsumable: consumable.NewConsumableBidder(cfg.Adapters[string(openrtb_ext.BidderConsumable)].Endpoint), openrtb_ext.BidderDatablocks: datablocks.NewDatablocksBidder(cfg.Adapters[string(openrtb_ext.BidderDatablocks)].Endpoint), + openrtb_ext.BidderDmx: dmx.NewDmxBidder(cfg.Adapters[string(openrtb_ext.BidderDmx)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderDmx)].PublisherId), openrtb_ext.BidderEngageBDR: engagebdr.NewEngageBDRBidder(client, cfg.Adapters[string(openrtb_ext.BidderEngageBDR)].Endpoint), openrtb_ext.BidderEmxDigital: emx_digital.NewEmxDigitalBidder(cfg.Adapters[string(openrtb_ext.BidderEmxDigital)].Endpoint), openrtb_ext.BidderEPlanning: eplanning.NewEPlanningBidder(client, cfg.Adapters[string(openrtb_ext.BidderEPlanning)].Endpoint), From 436f3a5cf93b24669b9b292418031d175d9cc232 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:04:52 -0500 Subject: [PATCH 04/42] mapping in struct Adapter 'publisherId' --- config/config.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/config.go b/config/config.go index 0c3d36df631..2b1d1e8c555 100644 --- a/config/config.go +++ b/config/config.go @@ -233,6 +233,9 @@ type Adapter struct { PlatformID string `mapstructure:"platform_id"` AppID string `mapstructure:"app_id"` AppSecret string `mapstructure:"app_secret"` + + // needed for district m DMX + PublisherId string `mapstructure:"publisher_id"` } // validateAdapterEndpoint makes sure that an adapter has a valid endpoint From 49bcf69f58a1b3914c0f15f9ecd676e835a1b102 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:09:12 -0500 Subject: [PATCH 05/42] adding config in syncer.go --- usersync/usersyncers/syncer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/usersync/usersyncers/syncer.go b/usersync/usersyncers/syncer.go index 7a43fe831b2..0a9b0cd03d7 100644 --- a/usersync/usersyncers/syncer.go +++ b/usersync/usersyncers/syncer.go @@ -19,6 +19,7 @@ import ( "github.com/prebid/prebid-server/adapters/consumable" "github.com/prebid/prebid-server/adapters/conversant" "github.com/prebid/prebid-server/adapters/datablocks" + "github.com/prebid/prebid-server/adapters/dmx" "github.com/prebid/prebid-server/adapters/emx_digital" "github.com/prebid/prebid-server/adapters/engagebdr" "github.com/prebid/prebid-server/adapters/eplanning" @@ -73,6 +74,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderConsumable, consumable.NewConsumableSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderConversant, conversant.NewConversantSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderDatablocks, datablocks.NewDatablocksSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderDmx, dmx.NewDmxSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderEmxDigital, emx_digital.NewEMXDigitalSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderEPlanning, eplanning.NewEPlanningSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderFacebook, audienceNetwork.NewFacebookSyncer) From 419bfc676be42b0ad0be92c9440db1c8cf652700 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:13:00 -0500 Subject: [PATCH 06/42] set config endpoint for dmx --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 2b1d1e8c555..27980183a4b 100644 --- a/config/config.go +++ b/config/config.go @@ -653,7 +653,7 @@ func SetupViper(v *viper.Viper, filename string) { // for them and specify all the parameters they need for them to work correctly. v.SetDefault("adapters.audiencenetwork.disabled", true) v.SetDefault("adapters.rubicon.disabled", true) - + v.SetDefault("adapters.dmx.endpoint", "https://dmx.districtm.io/b/v2") v.SetDefault("adapters.adtelligent.endpoint", "http://hb.adtelligent.com/auction") v.SetDefault("adapters.adform.endpoint", "http://adx.adform.net/adx") v.SetDefault("adapters.appnexus.endpoint", "http://ib.adnxs.com/openrtb2") // Docs: https://wiki.appnexus.com/display/supply/Incoming+Bid+Request+from+SSPs From f04450fe1fac4ba6f94c366e3b5b27d2d066e759 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:17:04 -0500 Subject: [PATCH 07/42] set default usersync url template --- config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/config/config.go b/config/config.go index 27980183a4b..96921441497 100644 --- a/config/config.go +++ b/config/config.go @@ -489,6 +489,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConsumable, "https://e.serverbid.com/udb/9969/match?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConversant, "https://prebid-match.dotomi.com/prebid/match?rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDatablocks, "https://search.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://cdn.districtm.io/ids/?sellerid="+cfg.Adapters[string(openrtb_ext.BidderDmx)].PublisherId+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3F"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") // openrtb_ext.BidderFacebook doesn't have a good default. From b3e6fbc5d453f369481853a0224a5f78b9c0d527 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:21:09 -0500 Subject: [PATCH 08/42] adding dmx to bidder.go --- openrtb_ext/bidders.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index f7f5497658a..4e993dd4bd4 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -33,6 +33,7 @@ const ( BidderConsumable BidderName = "consumable" BidderConversant BidderName = "conversant" BidderDatablocks BidderName = "datablocks" + BidderDmx BidderName = "dmx" BidderEmxDigital BidderName = "emx_digital" BidderEPlanning BidderName = "eplanning" BidderFacebook BidderName = "audienceNetwork" @@ -84,6 +85,7 @@ var BidderMap = map[string]BidderName{ "consumable": BidderConsumable, "conversant": BidderConversant, "datablocks": BidderDatablocks, + "dmx": BidderDmx, "emx_digital": BidderEmxDigital, "eplanning": BidderEPlanning, "gamma": BidderGamma, From 0f4e542842742361cd029d8e91541838f03aab39 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 07:22:47 -0500 Subject: [PATCH 09/42] adding user sync test --- adapters/dmx/usersync_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 adapters/dmx/usersync_test.go diff --git a/adapters/dmx/usersync_test.go b/adapters/dmx/usersync_test.go new file mode 100644 index 00000000000..f594e887774 --- /dev/null +++ b/adapters/dmx/usersync_test.go @@ -0,0 +1,19 @@ +package dmx + +import ( + "testing" + "text/template" + + "github.com/stretchr/testify/assert" +) + +func TestDmxSyncer(t *testing.T) { + temp := template.Must(template.New("sync-template").Parse("https://cdn.districtm.io/ids/?sellerid=10007")) + syncer := NewDmxSyncer(temp) + syncInfo, err := syncer.GetUsersyncInfo("", "") + assert.NoError(t, err) + assert.Equal(t, "https://cdn.districtm.io/ids/?sellerid=10007", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.EqualValues(t, 144, syncer.GDPRVendorID()) + assert.Equal(t, false, syncInfo.SupportCORS) +} From 08f108d28b8eed1b25cc8874d605bcc78e8f44d2 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 08:56:57 -0500 Subject: [PATCH 10/42] adding json bidder params --- static/bidder-params/dmx.json | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 static/bidder-params/dmx.json diff --git a/static/bidder-params/dmx.json b/static/bidder-params/dmx.json new file mode 100644 index 00000000000..4c0df65e3d4 --- /dev/null +++ b/static/bidder-params/dmx.json @@ -0,0 +1,22 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "District M DMX Adapter Params", + "description": "A schema which validates params accepted by the DMX adapter", + "type": "object", + "properties": { + "memberid" : { + "type": "string", + "description": "Represent boost MemberId from districtm UI" + }, + "tagid": { + "type": "string", + "description": "Represent the placement ID, this value is optional" + }, + "bidfloor": { + "type": "string", + "description": "The minimum price acceptable for a bid" + } + }, + + "required": ["memberid"] +} \ No newline at end of file From afb976815b8768562c08f8f0194e59d6179d800e Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 09:06:02 -0500 Subject: [PATCH 11/42] adding yaml file --- static/bidder-info/dmx.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 static/bidder-info/dmx.yaml diff --git a/static/bidder-info/dmx.yaml b/static/bidder-info/dmx.yaml new file mode 100644 index 00000000000..ae51473751d --- /dev/null +++ b/static/bidder-info/dmx.yaml @@ -0,0 +1,6 @@ +maintainer: + email: "steve.alliance@gmail.com" +capabilities: + site: + mediaTypes: + - banner \ No newline at end of file From bd7738007ecc1c2d1477b4d64026c217d4e73cb4 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 09:16:43 -0500 Subject: [PATCH 12/42] remove fmt.Println --- adapters/dmx/dmx.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 64f03c01932..438011ca790 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -155,7 +155,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte request.App.Publisher = &openrtb.Publisher{ID: dmxImp.Bidder.PublisherId} } - oJson, _ := json.Marshal(request) headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") @@ -166,7 +165,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte Headers: headers, } - if request.User == nil { if request.App == nil { return nil, []error{errors.New("no user Id only app send request")} @@ -242,7 +240,6 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, } } - func getCookieInfo(request *pbs.PBSRequest) { -} \ No newline at end of file +} From 8e27b0bd1c7cf7dfbfe240d90f46ebcc91eccac6 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 09:26:13 -0500 Subject: [PATCH 13/42] adding media types app banner --- static/bidder-info/dmx.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/bidder-info/dmx.yaml b/static/bidder-info/dmx.yaml index ae51473751d..e97027bf45d 100644 --- a/static/bidder-info/dmx.yaml +++ b/static/bidder-info/dmx.yaml @@ -3,4 +3,7 @@ maintainer: capabilities: site: mediaTypes: - - banner \ No newline at end of file + - banner + app: + mediaTypes: + - banner From 63b61d28cac811ba57d0752d948031f6e66da2cc Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 2 Mar 2020 09:38:59 -0500 Subject: [PATCH 14/42] adding DMX into sync test --- usersync/usersyncers/syncer_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 1c4b3b07675..81fb560ccf5 100644 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -27,6 +27,7 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderConsumable): syncConfig, string(openrtb_ext.BidderConversant): syncConfig, string(openrtb_ext.BidderDatablocks): syncConfig, + string(openrtb_ext.BidderDmx): syncConfig, string(openrtb_ext.BidderEmxDigital): syncConfig, string(openrtb_ext.BidderEPlanning): syncConfig, string(openrtb_ext.BidderGrid): syncConfig, From 572cc9657c88c093e4815ef2c45a74aacd4f57c4 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 23 Mar 2020 09:33:47 -0400 Subject: [PATCH 15/42] update correction required plus unit test --- adapters/dmx/dmx.go | 231 ++++++++--------- adapters/dmx/dmx_test.go | 452 ++++++++++++++++++++++++++++++++++ adapters/dmx/usersync_test.go | 4 +- 3 files changed, 574 insertions(+), 113 deletions(-) create mode 100644 adapters/dmx/dmx_test.go diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 438011ca790..2f0090c5244 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -8,9 +8,7 @@ import ( "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" - "github.com/prebid/prebid-server/pbs" "net/http" - "sort" ) type DmxAdapter struct { @@ -18,143 +16,111 @@ type DmxAdapter struct { publisherId string } -func New(text string) error { - return &errorString{text} -} - -// errorString is a trivial implementation of error. -type errorString struct { - s string -} - -func (e *errorString) Error() string { - return e.s -} func NewDmxBidder(endpoint string, publisher_id string) *DmxAdapter { return &DmxAdapter{endpoint: endpoint, publisherId: publisher_id} } -type dmxBidder struct { - Bidder dmxExt `json:"bidder"` -} - -type dmxUser struct { - User *openrtb.User `json:"user"` -} - type dmxExt struct { - PublisherId string `json:"publisher_id,omitempty"` + Bidder dmxParams `json:"bidder"` } -type dmxBanner struct { - Banner *openrtb.Banner `json:"banner"` +type dmxParams struct { + TagId string `json:"tagid,omitempty"` + DmxId string `json:"dmxid,omitempty"` + MemberId string `json:"memberid,omitempty"` + PublisherId string `json:"publisher_id"` } -type dmxSize struct { - W uint64 - H uint64 - S uint64 -} -type DmxSize []dmxSize +func ReturnPubId(str1, str2 string) string { + if str1 != "" { + return str1 + } + if str2 != "" { + return str2 + } + return "" -func (a DmxSize) Len() int { - return len(a) } -func (a DmxSize) Swap(i, j int) { - a[i], a[j] = a[j], a[i] -} +func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { + var dmxBidderStaticInfo dmxExt + var imps []openrtb.Imp + var rootExtInfo dmxExt + var publisherId string + if len(request.Imp) < 1 { + errs = append(errs, errors.New("imp is empty no auction possible")) + return nil, errs + } -func (a DmxSize) Less(i, j int) bool { - return a[i].S > a[j].S -} + if len(request.Imp) >= 1 { + err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) + if err != nil { + errs = append(errs, err) + } else { + publisherId = ReturnPubId(rootExtInfo.Bidder.PublisherId, rootExtInfo.Bidder.MemberId) -func Remove(toBeRemove []openrtb.Format, a DmxSize) (dmx DmxSize) { - for _, value := range toBeRemove { - for _, dmxValue := range a { - if dmxValue.H == value.H && dmxValue.W == value.W { - //fmt.Println("true") - dmx = append(dmx, dmxValue) - } } } - return -} - -var CheckTopSizes = []dmxSize{ - {300, 250, 100}, - {728, 90, 95}, - {320, 50, 90}, - {160, 600, 88}, - {300, 600, 85}, - {300, 50, 80}, - {970, 250, 75}, - {970, 90, 70}, -} - -func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { - var dmxImp dmxBidder - var imps []openrtb.Imp - //var userParams *dmxUser - if err := json.Unmarshal(request.Imp[0].Ext, &dmxImp); err != nil { + if err := json.Unmarshal(request.Ext, &dmxBidderStaticInfo); err != nil { errs = append(errs, err) } - //fmt.Println(request.User) - if request.User != nil { - if request.User.BuyerUID != "" { - request.User.ID = request.User.BuyerUID - + if dmxBidderStaticInfo.Bidder.PublisherId != "" && publisherId == "" { + request.Site.Publisher = &openrtb.Publisher{ID: dmxBidderStaticInfo.Bidder.PublisherId} + } else { + if request.Site.Publisher != nil { + request.Site.Publisher.ID = adapter.publisherId } } + if request.App != nil { + request.Site = nil + request.App.Publisher = &openrtb.Publisher{ID: publisherId} + } + if request.Site != nil { + + request.Site.Publisher.ID = publisherId + } + for _, inst := range request.Imp { var banner openrtb.Banner var ins openrtb.Imp - //for _, insbanner := range inst.Banner.Format { - banner = openrtb.Banner{ - W: &inst.Banner.Format[0].W, - H: &inst.Banner.Format[0].H, - Format: inst.Banner.Format, - } - nSize := Remove(inst.Banner.Format, CheckTopSizes) - sort.Sort(DmxSize(nSize)) - if inst.Banner.Format[0].W != 0 { - banner.W = &nSize[0].W - } - if inst.Banner.Format[0].H != 0 { - banner.H = &nSize[0].H - } - var intVal int8 - intVal = 1 - ins = openrtb.Imp{ - ID: inst.ID, - Banner: &banner, - Ext: inst.Ext, - Secure: &intVal, - } - imps = append(imps, ins) + if len(inst.Banner.Format) != 0 { + banner = openrtb.Banner{ + W: &inst.Banner.Format[0].W, + H: &inst.Banner.Format[0].H, + Format: inst.Banner.Format, + } - } + var intVal int8 + intVal = 1 + var params dmxExt - request.Imp = imps + source := (*json.RawMessage)(&inst.Ext) + if err := json.Unmarshal(*source, ¶ms); err != nil { + errs = append(errs, err) + } + if params.Bidder.PublisherId == "" && params.Bidder.MemberId == "" { + var failedParams dmxParams + if err := json.Unmarshal(inst.Ext, &failedParams); err != nil { + errs = append(errs, err) + return nil, errs + } + imps = fetchFailedParams(failedParams, inst, ins,imps, banner, intVal) + } else { + imps = fetchParams(params, inst, ins,imps, banner, intVal) + } - if dmxImp.Bidder.PublisherId != "" { - request.Site.Publisher = &openrtb.Publisher{ID: dmxImp.Bidder.PublisherId} - } else { - if request.Site.Publisher != nil { - request.Site.Publisher.ID = adapter.publisherId } - } - if request.App != nil { - request.Site = nil - request.App.Publisher = &openrtb.Publisher{ID: dmxImp.Bidder.PublisherId} } + request.Imp = imps + + oJson, _ := json.Marshal(request) headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") @@ -167,7 +133,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte if request.User == nil { if request.App == nil { - return nil, []error{errors.New("no user Id only app send request")} + return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} } } @@ -220,7 +186,54 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } return bidResponse, errs - return nil, errs +} + +func fetchFailedParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp,imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { + if params.TagId != "" { + ins = openrtb.Imp{ + ID: inst.ID, + TagID: params.TagId, + Banner: &banner, + Ext: inst.Ext, + Secure: &intVal, + } + } + + if params.DmxId != "" { + ins = openrtb.Imp{ + ID: inst.ID, + TagID: params.DmxId, + Banner: &banner, + Ext: inst.Ext, + Secure: &intVal, + } + } + imps = append(imps, ins) + return imps +} + +func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp,imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { + if params.Bidder.TagId != "" { + ins = openrtb.Imp{ + ID: inst.ID, + TagID: params.Bidder.TagId, + Banner: &banner, + Ext: inst.Ext, + Secure: &intVal, + } + } + + if params.Bidder.DmxId != "" { + ins = openrtb.Imp{ + ID: inst.ID, + TagID: params.Bidder.DmxId, + Banner: &banner, + Ext: inst.Ext, + Secure: &intVal, + } + } + imps = append(imps, ins) + return imps } func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { @@ -238,8 +251,4 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), } -} - -func getCookieInfo(request *pbs.PBSRequest) { - -} +} \ No newline at end of file diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go new file mode 100644 index 00000000000..392c85c46ac --- /dev/null +++ b/adapters/dmx/dmx_test.go @@ -0,0 +1,452 @@ +package dmx + +import ( + "encoding/json" + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/adapterstest" + "testing" +) + +package dmx + +import ( + "encoding/json" + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" +) + +var ( + bidRequest string +) + +func TestFetchParams(t *testing.T){ + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + var arrImp []openrtb.Imp + var imps = fetchParams( + dmxExt{ Bidder: dmxParams{ + TagId: "222", + PublisherId: "5555", + } }, + openrtb.Imp{ID: "32"}, + openrtb.Imp{ID: "32"}, + arrImp, + openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + {W: 300, H: 250}, + }}, + 1) + var imps2 = fetchParams( + dmxExt{ Bidder: dmxParams{ + DmxId: "222", + MemberId: "5555", + } }, + openrtb.Imp{ID: "32"}, + openrtb.Imp{ID: "32"}, + arrImp, + openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + {W: 300, H: 250}, + }}, + 1) + if len(imps) == 0 { + t.Errorf("should increment the length by one") + } + + if len(imps2) == 0 { + t.Errorf("should increment the length by one") + } + +} +func TestJsonSamples(t *testing.T) { + adapterstest.RunJSONBidderTest(t, "dmxtest", new(DmxAdapter)) +} + + +func TestMakeRequestsOtherPlacement(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"tagid\": \"1007\", \"placement_id\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + ID: "1234", + } + + actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if actualAdapterRequests != nil { + t.Errorf("request should be nil") + } + if len(err) == 0 { + t.Errorf("We should have at least one Error") + } + +} + +func TestMakeRequestsInvalid(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + ID: "1234", + } + + actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if actualAdapterRequests != nil { + t.Errorf("request should be nil") + } + if len(err) == 0 { + t.Errorf("We should have at least one Error") + } + +} + +func TestMakeRequestsNoImp(t *testing.T){ + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"},}, + ID: "1234", + } + actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if actualAdapterRequests != nil { + t.Errorf("request should be nil") + } + if len(err) == 0 { + t.Errorf("We should have at least one Error") + } +} + +func TestMakeRequestsApp(t *testing.T){ + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"},}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if len(actualAdapterRequests) != 1 { + t.Errorf("openrtb type should be an Array when it's an App") + } + var the_body openrtb.BidRequest + if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { + t.Errorf("failed to read bid request") + } + + if the_body.App == nil { + t.Errorf("app property should be populated") + } + +} + +func TestMakeRequestsNoUser(t *testing.T){ + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if actualAdapterRequests != nil { + t.Errorf("openrtb type should be empty") + } + + +} + +func TestMakeRequests(t *testing.T) { + //server := httptest.NewServer(http.HandlerFunc(DummyDmxServer)) + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + imp2 := openrtb.Imp{ + ID: "imp2", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + imp3 := openrtb.Imp{ + ID: "imp3", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1, imp2, imp3}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{ID: "districtmID"}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if len(actualAdapterRequests) != 1 { + t.Errorf("should have 1 request") + } + var the_body openrtb.BidRequest + if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { + t.Errorf("failed to read bid request") + } + + if len(the_body.Imp) != 3 { + t.Errorf("must have 3 bids") + } + +} + +func TestMakeBidsNoContent(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{ID: "districtmID"}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + _, err204 := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 204}) + + if err204 == nil { + t.Errorf("Was expecting error") + } + + _, err400 := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 400}) + + if err400 == nil { + t.Errorf("Was expecting error") + } + + _, err500 := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 500}) + + if err500 == nil { + t.Errorf("Was expecting error") + } + + bidResponse := &adapters.ResponseData{ + StatusCode: 200, + Body: []byte(`{ + "id": "JdSgvXjee0UZ", + "seatbid": [ + { + "bid": [ + { + "id": "16-40dbf1ef_0gKywr9JnzPAW4bE-1", + "impid": "imp1", + "price": 2.3456, + "adm": "", + "nurl": "dmxnotificationurlhere", + "adomain": [ + "brand.com", + "advertiser.net" + ], + "cid": "12345", + "crid": "232303", + "cat": [ + "IAB20-3" + ], + "attr": [ + 2 + ], + "w": 300, + "h": 600, + "language": "en" + } + ], + "seat": "10001" + } + ], + "cur": "USD" +}`), + } + + bidResponseNoMatch := &adapters.ResponseData{ + StatusCode: 200, + Body: []byte(`{ + "id": "JdSgvXjee0UZ", + "seatbid": [ + { + "bid": [ + { + "id": "16-40dbf1ef_0gKywr9JnzPAW4bE-1", + "impid": "djvnsvns", + "price": 2.3456, + "adm": "", + "nurl": "dmxnotificationurlhere", + "adomain": [ + "brand.com", + "advertiser.net" + ], + "cid": "12345", + "crid": "232303", + "cat": [ + "IAB20-3" + ], + "attr": [ + 2 + ], + "w": 300, + "h": 600, + "language": "en" + } + ], + "seat": "10001" + } + ], + "cur": "USD" +}`), + } + + bids, _ := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], bidResponse) + if bids == nil { + t.Errorf("ads not parse") + } + bidsNoMatching, _ := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], bidResponseNoMatch) + if bidsNoMatching == nil { + t.Errorf("ads not parse") + } + +} + diff --git a/adapters/dmx/usersync_test.go b/adapters/dmx/usersync_test.go index f594e887774..60a9c510ee1 100644 --- a/adapters/dmx/usersync_test.go +++ b/adapters/dmx/usersync_test.go @@ -8,11 +8,11 @@ import ( ) func TestDmxSyncer(t *testing.T) { - temp := template.Must(template.New("sync-template").Parse("https://cdn.districtm.io/ids/?sellerid=10007")) + temp := template.Must(template.New("sync-template").Parse("https://dmx.districtm.io/s/v1/img/s/10007")) syncer := NewDmxSyncer(temp) syncInfo, err := syncer.GetUsersyncInfo("", "") assert.NoError(t, err) - assert.Equal(t, "https://cdn.districtm.io/ids/?sellerid=10007", syncInfo.URL) + assert.Equal(t, "https://dmx.districtm.io/s/v1/img/s/10007", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) assert.EqualValues(t, 144, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) From 8bc4bd236a33b6d3e7ab14baa72390c0b259ce1a Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Tue, 24 Mar 2020 09:54:42 -0400 Subject: [PATCH 16/42] run gofmt on dmx --- adapters/dmx/dmx.go | 19 +++++------ adapters/dmx/dmx_test.go | 71 ++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 58 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 2f0090c5244..22ea758779f 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -16,7 +16,6 @@ type DmxAdapter struct { publisherId string } - func NewDmxBidder(endpoint string, publisher_id string) *DmxAdapter { return &DmxAdapter{endpoint: endpoint, publisherId: publisher_id} } @@ -26,13 +25,12 @@ type dmxExt struct { } type dmxParams struct { - TagId string `json:"tagid,omitempty"` - DmxId string `json:"dmxid,omitempty"` - MemberId string `json:"memberid,omitempty"` + TagId string `json:"tagid,omitempty"` + DmxId string `json:"dmxid,omitempty"` + MemberId string `json:"memberid,omitempty"` PublisherId string `json:"publisher_id"` } - func ReturnPubId(str1, str2 string) string { if str1 != "" { return str1 @@ -109,9 +107,9 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte errs = append(errs, err) return nil, errs } - imps = fetchFailedParams(failedParams, inst, ins,imps, banner, intVal) + imps = fetchFailedParams(failedParams, inst, ins, imps, banner, intVal) } else { - imps = fetchParams(params, inst, ins,imps, banner, intVal) + imps = fetchParams(params, inst, ins, imps, banner, intVal) } } @@ -120,7 +118,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte request.Imp = imps - oJson, _ := json.Marshal(request) headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") @@ -188,7 +185,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } -func fetchFailedParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp,imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { +func fetchFailedParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { if params.TagId != "" { ins = openrtb.Imp{ ID: inst.ID, @@ -212,7 +209,7 @@ func fetchFailedParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp,imps return imps } -func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp,imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { +func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { if params.Bidder.TagId != "" { ins = openrtb.Imp{ ID: inst.ID, @@ -251,4 +248,4 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, return "", &errortypes.BadInput{ Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), } -} \ No newline at end of file +} diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 392c85c46ac..54f481178d6 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -1,15 +1,5 @@ package dmx -import ( - "encoding/json" - "github.com/mxmCherry/openrtb" - "github.com/prebid/prebid-server/adapters" - "github.com/prebid/prebid-server/adapters/adapterstest" - "testing" -) - -package dmx - import ( "encoding/json" "github.com/mxmCherry/openrtb" @@ -23,16 +13,16 @@ var ( bidRequest string ) -func TestFetchParams(t *testing.T){ +func TestFetchParams(t *testing.T) { var w, h int = 300, 250 var width, height uint64 = uint64(w), uint64(h) var arrImp []openrtb.Imp var imps = fetchParams( - dmxExt{ Bidder: dmxParams{ - TagId: "222", + dmxExt{Bidder: dmxParams{ + TagId: "222", PublisherId: "5555", - } }, + }}, openrtb.Imp{ID: "32"}, openrtb.Imp{ID: "32"}, arrImp, @@ -41,10 +31,10 @@ func TestFetchParams(t *testing.T){ }}, 1) var imps2 = fetchParams( - dmxExt{ Bidder: dmxParams{ - DmxId: "222", + dmxExt{Bidder: dmxParams{ + DmxId: "222", MemberId: "5555", - } }, + }}, openrtb.Imp{ID: "32"}, openrtb.Imp{ID: "32"}, arrImp, @@ -65,7 +55,6 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "dmxtest", new(DmxAdapter)) } - func TestMakeRequestsOtherPlacement(t *testing.T) { var w, h int = 300, 250 @@ -73,7 +62,7 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"tagid\": \"1007\", \"placement_id\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -81,7 +70,6 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} inputRequest := openrtb.BidRequest{ @@ -111,7 +99,7 @@ func TestMakeRequestsInvalid(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -119,7 +107,6 @@ func TestMakeRequestsInvalid(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} inputRequest := openrtb.BidRequest{ @@ -142,7 +129,7 @@ func TestMakeRequestsInvalid(t *testing.T) { } -func TestMakeRequestsNoImp(t *testing.T){ +func TestMakeRequestsNoImp(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") inputRequest := openrtb.BidRequest{ Imp: []openrtb.Imp{}, @@ -151,8 +138,8 @@ func TestMakeRequestsNoImp(t *testing.T){ ID: "10007", }, }, - App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"},}, - ID: "1234", + App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, + ID: "1234", } actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) @@ -164,14 +151,14 @@ func TestMakeRequestsNoImp(t *testing.T){ } } -func TestMakeRequestsApp(t *testing.T){ +func TestMakeRequestsApp(t *testing.T) { var w, h int = 300, 250 var width, height uint64 = uint64(w), uint64(h) adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -179,7 +166,6 @@ func TestMakeRequestsApp(t *testing.T){ Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} inputRequest := openrtb.BidRequest{ @@ -189,8 +175,8 @@ func TestMakeRequestsApp(t *testing.T){ ID: "10007", }, }, - App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"},}, - ID: "1234", + App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, + ID: "1234", } actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) @@ -209,14 +195,14 @@ func TestMakeRequestsApp(t *testing.T){ } -func TestMakeRequestsNoUser(t *testing.T){ +func TestMakeRequestsNoUser(t *testing.T) { var w, h int = 300, 250 var width, height uint64 = uint64(w), uint64(h) adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -224,7 +210,6 @@ func TestMakeRequestsNoUser(t *testing.T){ Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} inputRequest := openrtb.BidRequest{ @@ -243,7 +228,6 @@ func TestMakeRequestsNoUser(t *testing.T){ t.Errorf("openrtb type should be empty") } - } func TestMakeRequests(t *testing.T) { @@ -254,7 +238,7 @@ func TestMakeRequests(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -262,10 +246,9 @@ func TestMakeRequests(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} imp2 := openrtb.Imp{ - ID: "imp2", + ID: "imp2", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -273,10 +256,9 @@ func TestMakeRequests(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} imp3 := openrtb.Imp{ - ID: "imp3", + ID: "imp3", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -284,11 +266,8 @@ func TestMakeRequests(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} - - inputRequest := openrtb.BidRequest{ Imp: []openrtb.Imp{imp1, imp2, imp3}, Site: &openrtb.Site{ @@ -297,7 +276,7 @@ func TestMakeRequests(t *testing.T) { }, }, User: &openrtb.User{ID: "districtmID"}, - ID: "1234", + ID: "1234", } actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) @@ -323,7 +302,7 @@ func TestMakeBidsNoContent(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") imp1 := openrtb.Imp{ - ID: "imp1", + ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), Banner: &openrtb.Banner{ W: &width, @@ -331,7 +310,6 @@ func TestMakeBidsNoContent(t *testing.T) { Format: []openrtb.Format{ {W: 300, H: 250}, }, - }} inputRequest := openrtb.BidRequest{ @@ -342,7 +320,7 @@ func TestMakeBidsNoContent(t *testing.T) { }, }, User: &openrtb.User{ID: "districtmID"}, - ID: "1234", + ID: "1234", } actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) @@ -449,4 +427,3 @@ func TestMakeBidsNoContent(t *testing.T) { } } - From 4e4115361059516a706e51059cf383c3d4b43765 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 6 Apr 2020 07:19:02 -0400 Subject: [PATCH 17/42] update sellerid support in params --- adapters/dmx/dmx.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 22ea758779f..f50a2ea0271 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -28,7 +28,8 @@ type dmxParams struct { TagId string `json:"tagid,omitempty"` DmxId string `json:"dmxid,omitempty"` MemberId string `json:"memberid,omitempty"` - PublisherId string `json:"publisher_id"` + PublisherId string `json:"publisher_id,omitempty"` + SellerId string `json:"seller_id,omitempty"` } func ReturnPubId(str1, str2 string) string { @@ -47,6 +48,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte var imps []openrtb.Imp var rootExtInfo dmxExt var publisherId string + var sellerId string if len(request.Imp) < 1 { errs = append(errs, errors.New("imp is empty no auction possible")) return nil, errs @@ -58,7 +60,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte errs = append(errs, err) } else { publisherId = ReturnPubId(rootExtInfo.Bidder.PublisherId, rootExtInfo.Bidder.MemberId) - + sellerId = rootExtInfo.Bidder.SellerId } } if err := json.Unmarshal(request.Ext, &dmxBidderStaticInfo); err != nil { @@ -78,8 +80,11 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte request.App.Publisher = &openrtb.Publisher{ID: publisherId} } if request.Site != nil { - - request.Site.Publisher.ID = publisherId + if request.Site.Publisher == nil { + request.Site.Publisher = &openrtb.Publisher{ID: publisherId} + } else { + request.Site.Publisher.ID = publisherId + } } for _, inst := range request.Imp { @@ -123,7 +128,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte headers.Add("Content-Type", "Application/json;charset=utf-8") reqBidder := &adapters.RequestData{ Method: "POST", - Uri: adapter.endpoint, //adapter.endpoint, + Uri: adapter.endpoint + addParams(sellerId), //adapter.endpoint, Body: oJson, Headers: headers, } @@ -233,6 +238,13 @@ func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrt return imps } +func addParams(str string) string { + if str != "" { + return "?sellerid=" + str + } + return "" +} + func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { From a00c90c141db9fd93c1b9083e9325e0771f9cecb Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 6 Apr 2020 07:21:27 -0400 Subject: [PATCH 18/42] change setup key form publisherId to sellerId --- config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 96921441497..f31a506df5e 100644 --- a/config/config.go +++ b/config/config.go @@ -235,7 +235,7 @@ type Adapter struct { AppSecret string `mapstructure:"app_secret"` // needed for district m DMX - PublisherId string `mapstructure:"publisher_id"` + SellerID string `mapstructure:"seller_id"` } // validateAdapterEndpoint makes sure that an adapter has a valid endpoint @@ -489,7 +489,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConsumable, "https://e.serverbid.com/udb/9969/match?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConversant, "https://prebid-match.dotomi.com/prebid/match?rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDatablocks, "https://search.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://cdn.districtm.io/ids/?sellerid="+cfg.Adapters[string(openrtb_ext.BidderDmx)].PublisherId+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/"+cfg.Adapters[string(openrtb_ext.BidderDmx)].SellerID+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3F"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") // openrtb_ext.BidderFacebook doesn't have a good default. From 9e4693dd7b9c7460dd6cb806dd9dd06b41119e78 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 15 Apr 2020 11:48:45 -0400 Subject: [PATCH 19/42] update bidder info to main districtm mailbox --- static/bidder-info/dmx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/bidder-info/dmx.yaml b/static/bidder-info/dmx.yaml index e97027bf45d..acc054ff427 100644 --- a/static/bidder-info/dmx.yaml +++ b/static/bidder-info/dmx.yaml @@ -1,5 +1,5 @@ maintainer: - email: "steve.alliance@gmail.com" + email: "steve@districtm.net" capabilities: site: mediaTypes: From b53697a26e500885acccab5b6697b171a6dededa Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 15 Apr 2020 11:49:38 -0400 Subject: [PATCH 20/42] run gofmt on bidders.go --- openrtb_ext/bidders.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 4e993dd4bd4..9446628a3a0 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -85,7 +85,7 @@ var BidderMap = map[string]BidderName{ "consumable": BidderConsumable, "conversant": BidderConversant, "datablocks": BidderDatablocks, - "dmx": BidderDmx, + "dmx": BidderDmx, "emx_digital": BidderEmxDigital, "eplanning": BidderEPlanning, "gamma": BidderGamma, From b6530cb9611fe35c7c7227f2305aa2cd0df4354e Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 15 Apr 2020 11:51:44 -0400 Subject: [PATCH 21/42] update unit test to reflect change on main dmx.go --- adapters/dmx/dmx_test.go | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 54f481178d6..4a377102a77 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -129,27 +129,7 @@ func TestMakeRequestsInvalid(t *testing.T) { } -func TestMakeRequestsNoImp(t *testing.T) { - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ - ID: "10007", - }, - }, - App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, - ID: "1234", - } - actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) - if actualAdapterRequests != nil { - t.Errorf("request should be nil") - } - if len(err) == 0 { - t.Errorf("We should have at least one Error") - } -} func TestMakeRequestsApp(t *testing.T) { var w, h int = 300, 250 @@ -327,8 +307,8 @@ func TestMakeBidsNoContent(t *testing.T) { _, err204 := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 204}) - if err204 == nil { - t.Errorf("Was expecting error") + if err204 != nil { + t.Errorf("Was expecting nil") } _, err400 := adapter.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 400}) From 311e106240e4028da6712ff876cd98c4b35e3bd0 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 15 Apr 2020 12:06:34 -0400 Subject: [PATCH 22/42] remove config setting inside config.go | run fmt --- config/config.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/config/config.go b/config/config.go index f31a506df5e..8d08af6374a 100644 --- a/config/config.go +++ b/config/config.go @@ -233,9 +233,6 @@ type Adapter struct { PlatformID string `mapstructure:"platform_id"` AppID string `mapstructure:"app_id"` AppSecret string `mapstructure:"app_secret"` - - // needed for district m DMX - SellerID string `mapstructure:"seller_id"` } // validateAdapterEndpoint makes sure that an adapter has a valid endpoint From aa1dd6e1781a929f25fbd3df971293cfd7088faf Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 15 Apr 2020 13:31:25 -0400 Subject: [PATCH 23/42] syncer_test.go update --- usersync/usersyncers/syncer_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 81fb560ccf5..a0a7f872075 100644 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -27,7 +27,7 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderConsumable): syncConfig, string(openrtb_ext.BidderConversant): syncConfig, string(openrtb_ext.BidderDatablocks): syncConfig, - string(openrtb_ext.BidderDmx): syncConfig, + string(openrtb_ext.BidderDmx): syncConfig, string(openrtb_ext.BidderEmxDigital): syncConfig, string(openrtb_ext.BidderEPlanning): syncConfig, string(openrtb_ext.BidderGrid): syncConfig, From 465ab83e2d5fa9eed210ad4e153b6268aea41abf Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Thu, 16 Apr 2020 02:35:44 -0400 Subject: [PATCH 24/42] add test to confirm that site doesn't generate a panic in go --- adapters/dmx/dmx_test.go | 54 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 4a377102a77..45ff9265153 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -60,7 +60,7 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"tagid\": \"1007\", \"placement_id\": \"123456\"}"), @@ -97,7 +97,7 @@ func TestMakeRequestsInvalid(t *testing.T) { var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), @@ -130,13 +130,55 @@ func TestMakeRequestsInvalid(t *testing.T) { } +func TestMakeRequestNoSite(t *testing.T){ + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if len(actualAdapterRequests) != 1 { + t.Errorf("openrtb type should be an Array when it's an App") + } + var the_body openrtb.BidRequest + if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { + t.Errorf("failed to read bid request") + } + + if the_body.App == nil { + t.Errorf("app property should be populated") + } + + if the_body.App.Publisher.ID == "" { + t.Errorf("Missing publisher ID must be in") + } +} + func TestMakeRequestsApp(t *testing.T) { var w, h int = 300, 250 var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), @@ -180,7 +222,7 @@ func TestMakeRequestsNoUser(t *testing.T) { var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), @@ -216,7 +258,7 @@ func TestMakeRequests(t *testing.T) { var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), @@ -280,7 +322,7 @@ func TestMakeBidsNoContent(t *testing.T) { var width, height uint64 = uint64(w), uint64(h) - adapter := NewDmxBidder("https://dmx.districtm.io/b/v2", "10007") + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), From f9065873f09dd1b497f366ba1328d05f737500ca Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Thu, 16 Apr 2020 02:37:47 -0400 Subject: [PATCH 25/42] update request from last review (PR) --- adapters/dmx/dmx.go | 74 +++++++++++++++++++--------------------- adapters/dmx/dmx_test.go | 4 +-- 2 files changed, 36 insertions(+), 42 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index f50a2ea0271..6c06a49e1e2 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -9,6 +9,7 @@ import ( "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" "net/http" + "net/url" ) type DmxAdapter struct { @@ -16,8 +17,8 @@ type DmxAdapter struct { publisherId string } -func NewDmxBidder(endpoint string, publisher_id string) *DmxAdapter { - return &DmxAdapter{endpoint: endpoint, publisherId: publisher_id} +func NewDmxBidder(endpoint string) *DmxAdapter { + return &DmxAdapter{endpoint: endpoint} } type dmxExt struct { @@ -32,15 +33,11 @@ type dmxParams struct { SellerId string `json:"seller_id,omitempty"` } -func ReturnPubId(str1, str2 string) string { +func UserSellerOrPubId(str1, str2 string) string { if str1 != "" { return str1 } - if str2 != "" { - return str2 - } - return "" - + return str2 } func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { @@ -49,17 +46,15 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte var rootExtInfo dmxExt var publisherId string var sellerId string - if len(request.Imp) < 1 { - errs = append(errs, errors.New("imp is empty no auction possible")) - return nil, errs - } + + var dmxReq = request if len(request.Imp) >= 1 { err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) if err != nil { errs = append(errs, err) } else { - publisherId = ReturnPubId(rootExtInfo.Bidder.PublisherId, rootExtInfo.Bidder.MemberId) + publisherId = UserSellerOrPubId(rootExtInfo.Bidder.PublisherId, rootExtInfo.Bidder.MemberId) sellerId = rootExtInfo.Bidder.SellerId } } @@ -68,22 +63,22 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } if dmxBidderStaticInfo.Bidder.PublisherId != "" && publisherId == "" { - request.Site.Publisher = &openrtb.Publisher{ID: dmxBidderStaticInfo.Bidder.PublisherId} - } else { - if request.Site.Publisher != nil { - request.Site.Publisher.ID = adapter.publisherId - } + publisherId = dmxBidderStaticInfo.Bidder.PublisherId } - if request.App != nil { - request.Site = nil - request.App.Publisher = &openrtb.Publisher{ID: publisherId} + if dmxReq.App != nil { + dmxReq.Site = nil + dmxReq.App.Publisher.ID = publisherId } - if request.Site != nil { - if request.Site.Publisher == nil { - request.Site.Publisher = &openrtb.Publisher{ID: publisherId} + if dmxReq.Site != nil { + if dmxReq.Site.Publisher == nil { + dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} } else { - request.Site.Publisher.ID = publisherId + if dmxReq.Site.Publisher != nil { + dmxReq.Site.Publisher.ID = adapter.publisherId + } else { + dmxReq.Site.Publisher.ID = publisherId + } } } @@ -98,8 +93,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte Format: inst.Banner.Format, } - var intVal int8 - intVal = 1 + const intVal int8 = 1 var params dmxExt source := (*json.RawMessage)(&inst.Ext) @@ -112,7 +106,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte errs = append(errs, err) return nil, errs } - imps = fetchFailedParams(failedParams, inst, ins, imps, banner, intVal) + imps = fetchAlternativeParams(failedParams, inst, ins, imps, banner, intVal) } else { imps = fetchParams(params, inst, ins, imps, banner, intVal) } @@ -121,9 +115,13 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } - request.Imp = imps + dmxReq.Imp = imps + + oJson, err := json.Marshal(request) - oJson, _ := json.Marshal(request) + if err != nil { + errs = append(errs, err) + } headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") reqBidder := &adapters.RequestData{ @@ -133,8 +131,8 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte Headers: headers, } - if request.User == nil { - if request.App == nil { + if dmxReq.User == nil { + if dmxReq.App == nil { return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} } } @@ -147,20 +145,18 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest var errs []error if http.StatusNoContent == response.StatusCode { - return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("No content to be return"), - }} + return nil, nil } if http.StatusBadRequest == response.StatusCode { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Bad formated request"), + Message: fmt.Sprintf("Unexpected status code 400"), }} } if http.StatusOK != response.StatusCode { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Something is really wrong"), + Message: fmt.Sprintf("Unexpected response no status code"), }} } @@ -190,7 +186,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } -func fetchFailedParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { +func fetchAlternativeParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { if params.TagId != "" { ins = openrtb.Imp{ ID: inst.ID, @@ -240,7 +236,7 @@ func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrt func addParams(str string) string { if str != "" { - return "?sellerid=" + str + return "?sellerid=" + url.QueryEscape(str) } return "" } diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 45ff9265153..25beb0a9b09 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -129,8 +129,7 @@ func TestMakeRequestsInvalid(t *testing.T) { } - -func TestMakeRequestNoSite(t *testing.T){ +func TestMakeRequestNoSite(t *testing.T) { var w, h int = 300, 250 var width, height uint64 = uint64(w), uint64(h) @@ -172,7 +171,6 @@ func TestMakeRequestNoSite(t *testing.T){ } } - func TestMakeRequestsApp(t *testing.T) { var w, h int = 300, 250 From 31d3f0b2526b7f759d701b115d08c4e9a26e6622 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 20 Apr 2020 16:05:12 -0400 Subject: [PATCH 26/42] update dmx.yaml file for video support --- static/bidder-info/dmx.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/static/bidder-info/dmx.yaml b/static/bidder-info/dmx.yaml index acc054ff427..d6e54178db4 100644 --- a/static/bidder-info/dmx.yaml +++ b/static/bidder-info/dmx.yaml @@ -4,6 +4,8 @@ capabilities: site: mediaTypes: - banner + - video app: mediaTypes: - banner + - video From 5f0339e276646c40e79237440cad17a00e1ea4f1 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Tue, 21 Apr 2020 12:42:30 -0400 Subject: [PATCH 27/42] update support for video + testing at 88% coverage --- adapters/dmx/dmx.go | 78 ++++++++++++++++++------ adapters/dmx/dmx_test.go | 127 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 186 insertions(+), 19 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 6c06a49e1e2..f639404fb07 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" "net/http" "net/url" + "strings" ) type DmxAdapter struct { @@ -83,19 +84,37 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } for _, inst := range request.Imp { - var banner openrtb.Banner + var banner *openrtb.Banner + var video *openrtb.Video var ins openrtb.Imp + if inst.Banner != nil { + if len(inst.Banner.Format) != 0 { + banner = inst.Banner + const intVal int8 = 1 + var params dmxExt + + source := (*json.RawMessage)(&inst.Ext) + if err := json.Unmarshal(*source, ¶ms); err != nil { + errs = append(errs, err) + } + if params.Bidder.PublisherId == "" && params.Bidder.MemberId == "" { + var failedParams dmxParams + if err := json.Unmarshal(inst.Ext, &failedParams); err != nil { + errs = append(errs, err) + return nil, errs + } + imps = fetchAlternativeParams(failedParams, inst, ins, imps, banner, nil, intVal) + } else { + imps = fetchParams(params, inst, ins, imps, banner, nil, intVal) + } - if len(inst.Banner.Format) != 0 { - banner = openrtb.Banner{ - W: &inst.Banner.Format[0].W, - H: &inst.Banner.Format[0].H, - Format: inst.Banner.Format, } + } - const intVal int8 = 1 + if inst.Video != nil { + video = inst.Video var params dmxExt - + const intVal int8 = 1 source := (*json.RawMessage)(&inst.Ext) if err := json.Unmarshal(*source, ¶ms); err != nil { errs = append(errs, err) @@ -106,9 +125,9 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte errs = append(errs, err) return nil, errs } - imps = fetchAlternativeParams(failedParams, inst, ins, imps, banner, intVal) + imps = fetchAlternativeParams(failedParams, inst, ins, imps, nil, video, intVal) } else { - imps = fetchParams(params, inst, ins, imps, banner, intVal) + imps = fetchParams(params, inst, ins, imps, nil, video, intVal) } } @@ -117,11 +136,13 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte dmxReq.Imp = imps - oJson, err := json.Marshal(request) + oJson, err := json.Marshal(dmxReq) if err != nil { errs = append(errs, err) } + //dmxReq.User = &openrtb.User{ID: "msfnkafbhsbfdahmbahfsafasfdas"} + headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") reqBidder := &adapters.RequestData{ @@ -178,6 +199,9 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest Bid: &sb.Bid[i], BidType: bidType, } + if b.BidType == openrtb_ext.BidTypeVideo { + b.Bid.AdM = videoImpInsertion(b.Bid) + } bidResponse.Bids = append(bidResponse.Bids, b) } } @@ -186,12 +210,11 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } -func fetchAlternativeParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { +func fetchAlternativeParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner *openrtb.Banner, video *openrtb.Video, intVal int8) []openrtb.Imp { if params.TagId != "" { ins = openrtb.Imp{ ID: inst.ID, TagID: params.TagId, - Banner: &banner, Ext: inst.Ext, Secure: &intVal, } @@ -201,21 +224,26 @@ func fetchAlternativeParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, ins = openrtb.Imp{ ID: inst.ID, TagID: params.DmxId, - Banner: &banner, Ext: inst.Ext, Secure: &intVal, } } + if banner != nil { + ins.Banner = banner + } + + if video != nil { + ins.Video = video + } imps = append(imps, ins) return imps } -func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner openrtb.Banner, intVal int8) []openrtb.Imp { +func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner *openrtb.Banner, video *openrtb.Video, intVal int8) []openrtb.Imp { if params.Bidder.TagId != "" { ins = openrtb.Imp{ ID: inst.ID, TagID: params.Bidder.TagId, - Banner: &banner, Ext: inst.Ext, Secure: &intVal, } @@ -225,11 +253,17 @@ func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrt ins = openrtb.Imp{ ID: inst.ID, TagID: params.Bidder.DmxId, - Banner: &banner, Ext: inst.Ext, Secure: &intVal, } } + if banner != nil { + ins.Banner = banner + } + + if video != nil { + ins.Video = video + } imps = append(imps, ins) return imps } @@ -257,3 +291,13 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), } } + +func videoImpInsertion(bid *openrtb.Bid) string { + adm := bid.AdM + nurl := bid.NURL + search := "" + imp := "" + wrapped_nurl := fmt.Sprintf(imp, nurl) + results := strings.Replace(adm, search, wrapped_nurl, 1) + return results +} diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 25beb0a9b09..832c8bccb5a 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -2,8 +2,10 @@ package dmx import ( "encoding/json" + "fmt" "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" + "strings" "testing" "github.com/prebid/prebid-server/adapters/adapterstest" @@ -26,9 +28,10 @@ func TestFetchParams(t *testing.T) { openrtb.Imp{ID: "32"}, openrtb.Imp{ID: "32"}, arrImp, - openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + &openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ {W: 300, H: 250}, }}, + nil, 1) var imps2 = fetchParams( dmxExt{Bidder: dmxParams{ @@ -38,9 +41,10 @@ func TestFetchParams(t *testing.T) { openrtb.Imp{ID: "32"}, openrtb.Imp{ID: "32"}, arrImp, - openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + &openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ {W: 300, H: 250}, }}, + nil, 1) if len(imps) == 0 { t.Errorf("should increment the length by one") @@ -83,6 +87,7 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { } actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + fmt.Println(actualAdapterRequests, err) if actualAdapterRequests != nil { t.Errorf("request should be nil") } @@ -315,6 +320,47 @@ func TestMakeRequests(t *testing.T) { } +func TestMakeBidVideo(t *testing.T) { + var w, h int = 640, 480 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Video: &openrtb.Video{ + W: width, + H: height, + MIMEs: []string{"video/mp4"}, + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{ID: "districtmID"}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + + if len(actualAdapterRequests) != 1 { + t.Errorf("should have 1 request") + } + var the_body openrtb.BidRequest + if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { + t.Errorf("failed to read bid request") + } + + if len(the_body.Imp) != 1 { + t.Errorf("must have 3 bids") + } +} + func TestMakeBidsNoContent(t *testing.T) { var w, h int = 300, 250 @@ -447,3 +493,80 @@ func TestMakeBidsNoContent(t *testing.T) { } } + +func TestVideoImpInsertion(t *testing.T) { + var bidResp openrtb.BidResponse + var bid openrtb.Bid + payload := []byte(`{ + "id": "some-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "video1", + "impid": "video1", + "price": 5.01, + "nurl": "https://demo.arripiblik.com/359585167267151", + "adm": "BidSwitch", + "crid": "76575664756", + "dealid": "dmx-deal-hp-24", + "w": 640, + "h": 480, + "ext": { + "prebid": { + "type": "video" + } + } + }, + { + "id": "some-impression-id", + "impid": "some-impression-id", + "price": 5.01, + "adm": "", + "crid": "1346943998", + "dealid": "dmx-deal-hp-24", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + { + "id": "some-impression-id2", + "impid": "some-impression-id2", + "price": 5.01, + "adm": "", + "crid": "1424798162", + "dealid": "dmx-deal-hp-24", + "w": 728, + "h": 90, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "dmx" + } + ] +}`) + + err := json.Unmarshal(payload, &bidResp) + if err != nil { + t.Errorf("Payload is invalid") + } + fmt.Println(bidResp) + bid = openrtb.Bid(bidResp.SeatBid[0].Bid[0]) + data := videoImpInsertion(&bid) + fmt.Println(data) + + find := strings.Index(data, "demo.arripiblik.com") + + if find == -1 { + t.Errorf("String was not found") + } + +} From 3dcb2dc79a15a62bb05f1eb32c13ca43ab03d68d Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 22 Apr 2020 11:12:56 -0400 Subject: [PATCH 28/42] update code based on last comment --- adapters/dmx/dmx.go | 133 +++++++++++++-------------------------- adapters/dmx/dmx_test.go | 41 ++++++------ 2 files changed, 62 insertions(+), 112 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index f639404fb07..27033e185a8 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -14,8 +14,7 @@ import ( ) type DmxAdapter struct { - endpoint string - publisherId string + endpoint string } func NewDmxBidder(endpoint string) *DmxAdapter { @@ -42,13 +41,13 @@ func UserSellerOrPubId(str1, str2 string) string { } func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { - var dmxBidderStaticInfo dmxExt var imps []openrtb.Imp var rootExtInfo dmxExt var publisherId string var sellerId string var dmxReq = request + //dmxReq.User = &openrtb.User{ID: "fnakfnakubakufbnalinalifnali"} if len(request.Imp) >= 1 { err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) @@ -59,77 +58,56 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte sellerId = rootExtInfo.Bidder.SellerId } } - if err := json.Unmarshal(request.Ext, &dmxBidderStaticInfo); err != nil { - errs = append(errs, err) - } - - if dmxBidderStaticInfo.Bidder.PublisherId != "" && publisherId == "" { - publisherId = dmxBidderStaticInfo.Bidder.PublisherId - } if dmxReq.App != nil { dmxReq.Site = nil - dmxReq.App.Publisher.ID = publisherId + if dmxReq.App.Publisher != nil { + dmxReq.App.Publisher.ID = publisherId + } else { + dmxReq.App.Publisher = &openrtb.Publisher{ID: publisherId} + } } if dmxReq.Site != nil { if dmxReq.Site.Publisher == nil { dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} - } else { - if dmxReq.Site.Publisher != nil { - dmxReq.Site.Publisher.ID = adapter.publisherId - } else { - dmxReq.Site.Publisher.ID = publisherId - } + } + } + if dmxReq.User == nil { + if dmxReq.App == nil { + return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} } } - for _, inst := range request.Imp { + for _, inst := range dmxReq.Imp { var banner *openrtb.Banner var video *openrtb.Video var ins openrtb.Imp - if inst.Banner != nil { - if len(inst.Banner.Format) != 0 { - banner = inst.Banner - const intVal int8 = 1 - var params dmxExt - - source := (*json.RawMessage)(&inst.Ext) - if err := json.Unmarshal(*source, ¶ms); err != nil { - errs = append(errs, err) - } - if params.Bidder.PublisherId == "" && params.Bidder.MemberId == "" { - var failedParams dmxParams - if err := json.Unmarshal(inst.Ext, &failedParams); err != nil { - errs = append(errs, err) - return nil, errs + var params dmxExt + const intVal int8 = 1 + source := (*json.RawMessage)(&inst.Ext) + if err := json.Unmarshal(*source, ¶ms); err != nil { + errs = append(errs, err) + } + if isDmxParams(params.Bidder) { + if inst.Banner != nil { + if len(inst.Banner.Format) != 0 { + banner = inst.Banner + if params.Bidder.PublisherId != "" || params.Bidder.MemberId != "" { + imps = fetchParams(params, inst, ins, imps, banner, nil, intVal) + } else { + return nil, []error{errors.New("Missing Params for auction to be send")} } - imps = fetchAlternativeParams(failedParams, inst, ins, imps, banner, nil, intVal) - } else { - imps = fetchParams(params, inst, ins, imps, banner, nil, intVal) } - } - } - if inst.Video != nil { - video = inst.Video - var params dmxExt - const intVal int8 = 1 - source := (*json.RawMessage)(&inst.Ext) - if err := json.Unmarshal(*source, ¶ms); err != nil { - errs = append(errs, err) - } - if params.Bidder.PublisherId == "" && params.Bidder.MemberId == "" { - var failedParams dmxParams - if err := json.Unmarshal(inst.Ext, &failedParams); err != nil { - errs = append(errs, err) - return nil, errs + if inst.Video != nil { + video = inst.Video + if params.Bidder.PublisherId != "" || params.Bidder.MemberId != "" { + imps = fetchParams(params, inst, ins, imps, nil, video, intVal) + } else { + return nil, []error{errors.New("Missing Params for auction to be send")} } - imps = fetchAlternativeParams(failedParams, inst, ins, imps, nil, video, intVal) - } else { - imps = fetchParams(params, inst, ins, imps, nil, video, intVal) } - } } @@ -140,6 +118,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte if err != nil { errs = append(errs, err) + return nil, errs } //dmxReq.User = &openrtb.User{ID: "msfnkafbhsbfdahmbahfsafasfdas"} @@ -152,12 +131,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte Headers: headers, } - if dmxReq.User == nil { - if dmxReq.App == nil { - return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} - } - } - reqsBidder = append(reqsBidder, reqBidder) return } @@ -210,35 +183,6 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } -func fetchAlternativeParams(params dmxParams, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner *openrtb.Banner, video *openrtb.Video, intVal int8) []openrtb.Imp { - if params.TagId != "" { - ins = openrtb.Imp{ - ID: inst.ID, - TagID: params.TagId, - Ext: inst.Ext, - Secure: &intVal, - } - } - - if params.DmxId != "" { - ins = openrtb.Imp{ - ID: inst.ID, - TagID: params.DmxId, - Ext: inst.Ext, - Secure: &intVal, - } - } - if banner != nil { - ins.Banner = banner - } - - if video != nil { - ins.Video = video - } - imps = append(imps, ins) - return imps -} - func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner *openrtb.Banner, video *openrtb.Video, intVal int8) []openrtb.Imp { if params.Bidder.TagId != "" { ins = openrtb.Imp{ @@ -301,3 +245,12 @@ func videoImpInsertion(bid *openrtb.Bid) string { results := strings.Replace(adm, search, wrapped_nurl, 1) return results } + +func isDmxParams(t interface{}) bool { + switch t.(type) { + case dmxParams: + return true + default: + return false + } +} \ No newline at end of file diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 832c8bccb5a..29bbfccc561 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -2,7 +2,6 @@ package dmx import ( "encoding/json" - "fmt" "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "strings" @@ -67,7 +66,7 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"tagid\": \"1007\", \"placement_id\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -77,7 +76,8 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { }} inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, + User: &openrtb.User{ID: "bscakucbkasucbkasunscancasuin"}, + Imp: []openrtb.Imp{imp1}, Site: &openrtb.Site{ Publisher: &openrtb.Publisher{ ID: "10007", @@ -87,12 +87,12 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { } actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) - fmt.Println(actualAdapterRequests, err) - if actualAdapterRequests != nil { + + if actualAdapterRequests == nil { t.Errorf("request should be nil") } - if len(err) == 0 { - t.Errorf("We should have at least one Error") + if len(err) != 0 { + t.Errorf("We should have no error") } } @@ -105,7 +105,7 @@ func TestMakeRequestsInvalid(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -125,11 +125,12 @@ func TestMakeRequestsInvalid(t *testing.T) { } actualAdapterRequests, err := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) - if actualAdapterRequests != nil { + + if len(actualAdapterRequests) != 0 { t.Errorf("request should be nil") } if len(err) == 0 { - t.Errorf("We should have at least one Error") + t.Errorf("We should have no error") } } @@ -184,7 +185,7 @@ func TestMakeRequestsApp(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -228,7 +229,7 @@ func TestMakeRequestsNoUser(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -264,7 +265,7 @@ func TestMakeRequests(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -274,7 +275,7 @@ func TestMakeRequests(t *testing.T) { }} imp2 := openrtb.Imp{ ID: "imp2", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -284,7 +285,7 @@ func TestMakeRequests(t *testing.T) { }} imp3 := openrtb.Imp{ ID: "imp3", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -328,7 +329,7 @@ func TestMakeBidVideo(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Video: &openrtb.Video{ W: width, H: height, @@ -357,7 +358,7 @@ func TestMakeBidVideo(t *testing.T) { } if len(the_body.Imp) != 1 { - t.Errorf("must have 3 bids") + t.Errorf("must have 1 bids") } } @@ -369,7 +370,7 @@ func TestMakeBidsNoContent(t *testing.T) { adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") imp1 := openrtb.Imp{ ID: "imp1", - Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\"}"), + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), Banner: &openrtb.Banner{ W: &width, H: &height, @@ -558,13 +559,9 @@ func TestVideoImpInsertion(t *testing.T) { if err != nil { t.Errorf("Payload is invalid") } - fmt.Println(bidResp) bid = openrtb.Bid(bidResp.SeatBid[0].Bid[0]) data := videoImpInsertion(&bid) - fmt.Println(data) - find := strings.Index(data, "demo.arripiblik.com") - if find == -1 { t.Errorf("String was not found") } From 30c595d832e86a2155c2b6ef6ed2141e9d6af240 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 22 Apr 2020 11:19:23 -0400 Subject: [PATCH 29/42] update idsync endpoint --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 8d08af6374a..15f0137a6a6 100644 --- a/config/config.go +++ b/config/config.go @@ -486,7 +486,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConsumable, "https://e.serverbid.com/udb/9969/match?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConversant, "https://prebid-match.dotomi.com/prebid/match?rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDatablocks, "https://search.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/"+cfg.Adapters[string(openrtb_ext.BidderDmx)].SellerID+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/10007?r="+url.QueryEscape(externalURL)+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3F"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") // openrtb_ext.BidderFacebook doesn't have a good default. From 409caec3b133c23c980737c9141c0c03419ee8bc Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 22 Apr 2020 11:29:01 -0400 Subject: [PATCH 30/42] update fetchparams to append nothing when tagid || dmxid is empty --- adapters/dmx/dmx.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 27033e185a8..dd30999f34b 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -208,6 +208,10 @@ func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrt if video != nil { ins.Video = video } + + if ins.TagID == "" { + return imps + } imps = append(imps, ins) return imps } From f655384eb20bfbfb85b419f0efc7e7768a2d4d47 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Thu, 23 Apr 2020 09:45:20 -0400 Subject: [PATCH 31/42] Eids and Digitrust validation --- adapters/dmx/dmx.go | 49 +++++++++-- adapters/dmx/dmx_test.go | 181 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 224 insertions(+), 6 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index dd30999f34b..956f89a8a3d 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -40,14 +40,38 @@ func UserSellerOrPubId(str1, str2 string) string { return str2 } +type dmxUserExt struct { + Eids []dmxEids `json:"eids,omitempty"` + Digitrust dmxDigitrust `json:"digitrust,omitempty"` +} +type dmxEids struct { + Source string `json:"source,omitempty"` + Uids []struct { + ID string `json:"id,omitempty"` + Ext json.RawMessage + } `json:"uids,omitempty"` +} + +type dmxDigitrust struct { + ID string `json:"id,omitempty"` + Keyv int `json:"keyv,omitempty"` +} + func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { var imps []openrtb.Imp var rootExtInfo dmxExt var publisherId string var sellerId string + var user_ext dmxUserExt + var hasId []bool var dmxReq = request - //dmxReq.User = &openrtb.User{ID: "fnakfnakubakufbnalinalifnali"} + + if dmxReq.User == nil { + if dmxReq.App == nil { + return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} + } + } if len(request.Imp) >= 1 { err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) @@ -61,6 +85,9 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte if dmxReq.App != nil { dmxReq.Site = nil + if dmxReq.App.ID != "" { + hasId = append(hasId, true) + } if dmxReq.App.Publisher != nil { dmxReq.App.Publisher.ID = publisherId } else { @@ -72,12 +99,23 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} } } - if dmxReq.User == nil { - if dmxReq.App == nil { - return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} + if dmxReq.User != nil { + if dmxReq.User.ID != "" { + hasId = append(hasId, true) + } + if dmxReq.User.Ext != nil { + if err := json.Unmarshal(dmxReq.User.Ext, &user_ext); err == nil { + if len(user_ext.Eids) > 0 || user_ext.Digitrust.ID != "" { + hasId = append(hasId, true) + } + } } } + if len(hasId) == 0 { + return nil, []error{errors.New("This request contained no identifier")} + } + for _, inst := range dmxReq.Imp { var banner *openrtb.Banner var video *openrtb.Video @@ -120,7 +158,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte errs = append(errs, err) return nil, errs } - //dmxReq.User = &openrtb.User{ID: "msfnkafbhsbfdahmbahfsafasfdas"} headers := http.Header{} headers.Add("Content-Type", "Application/json;charset=utf-8") @@ -257,4 +294,4 @@ func isDmxParams(t interface{}) bool { default: return false } -} \ No newline at end of file +} diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 29bbfccc561..3ebad809836 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -495,6 +495,187 @@ func TestMakeBidsNoContent(t *testing.T) { } +func TestUserEidsOnly(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1, imp1, imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{Ext: json.RawMessage(`{"eids": [{ + "source": "adserver.org", + "uids": [{ + "id": "111111111111", + "ext": { + "rtiPartner": "TDID" + } + }] + },{ + "source": "netid.de", + "uids": [{ + "id": "11111111" + }] + }] + }`)}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if len(actualAdapterRequests) != 1 { + t.Errorf("should have 1 request") + } +} + +func TestUserDigitrustOnly(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1, imp1, imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{Ext: json.RawMessage(`{ + "digitrust": { + "id": "11111111111", + "keyv": 4 + }}`)}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if len(actualAdapterRequests) != 1 { + t.Errorf("should have 1 request") + } +} + +func TestUsersEids(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + }} + + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1, imp1, imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{ID: "districtmID", Ext: json.RawMessage(`{"eids": [{ + "source": "adserver.org", + "uids": [{ + "id": "111111111111", + "ext": { + "rtiPartner": "TDID" + } + }] + },{ + "source": "pubcid.org", + "uids": [{ + "id":"11111111" + }] + }, + { + "source": "id5-sync.com", + "uids": [{ + "id": "ID5-12345" + }] + }, + { + "source": "parrable.com", + "uids": [{ + "id": "01.1563917337.test-eid" + }] + },{ + "source": "identityLink", + "uids": [{ + "id": "11111111" + }] + },{ + "source": "criteo", + "uids": [{ + "id": "11111111" + }] + },{ + "source": "britepool.com", + "uids": [{ + "id": "11111111" + }] + },{ + "source": "liveintent.com", + "uids": [{ + "id": "11111111" + }] + },{ + "source": "netid.de", + "uids": [{ + "id": "11111111" + }] + }], + "digitrust": { + "id": "11111111111", + "keyv": 4 + }}`)}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if len(actualAdapterRequests) != 1 { + t.Errorf("should have 1 request") + } + var the_body openrtb.BidRequest + if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { + t.Errorf("failed to read bid request") + } + + if len(the_body.Imp) != 3 { + t.Errorf("must have 3 bids") + } +} func TestVideoImpInsertion(t *testing.T) { var bidResp openrtb.BidResponse var bid openrtb.Bid From c3f6364bdb7253f65734132021d2773b0be88d79 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Thu, 30 Apr 2020 10:49:46 -0400 Subject: [PATCH 32/42] create a full new instance of the App Site User value --- adapters/dmx/dmx.go | 56 +++++++++++++++++++++++++++++++++++++-------- config/config.go | 2 +- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 956f89a8a3d..466fa3ee65c 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -10,6 +10,7 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" "net/http" "net/url" + "reflect" "strings" ) @@ -63,16 +64,17 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte var publisherId string var sellerId string var user_ext dmxUserExt - var hasId []bool + var anyHasId = false + var dmxReq *openrtb.BidRequest = &openrtb.BidRequest{} - var dmxReq = request - - if dmxReq.User == nil { - if dmxReq.App == nil { - return nil, []error{errors.New("no user Id found and AppID, no request to DMX")} + if request.User == nil { + if request.App == nil { + return nil, []error{errors.New("No user id or app id found. Could not send request to DMX.")} } } + CloneValue(request, dmxReq) + if len(request.Imp) >= 1 { err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) if err != nil { @@ -83,10 +85,31 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } } + if request.App != nil { + appCopy := *request.App + dmxReq.App = &appCopy + } else { + dmxReq.App = nil + } + + if request.Site != nil { + siteCopy := *request.Site + dmxReq.Site = &siteCopy + } else { + dmxReq.Site = nil + } + + if request.User != nil { + userCopy := *request.User + dmxReq.User = &userCopy + } else { + dmxReq.User = nil + } + if dmxReq.App != nil { dmxReq.Site = nil if dmxReq.App.ID != "" { - hasId = append(hasId, true) + anyHasId = true } if dmxReq.App.Publisher != nil { dmxReq.App.Publisher.ID = publisherId @@ -101,18 +124,18 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } if dmxReq.User != nil { if dmxReq.User.ID != "" { - hasId = append(hasId, true) + anyHasId = true } if dmxReq.User.Ext != nil { if err := json.Unmarshal(dmxReq.User.Ext, &user_ext); err == nil { if len(user_ext.Eids) > 0 || user_ext.Digitrust.ID != "" { - hasId = append(hasId, true) + anyHasId = true } } } } - if len(hasId) == 0 { + if anyHasId == false { return nil, []error{errors.New("This request contained no identifier")} } @@ -295,3 +318,16 @@ func isDmxParams(t interface{}) bool { return false } } + +func CloneValue(source interface{}, destin interface{}) { + x := reflect.ValueOf(source) + if x.Kind() == reflect.Ptr { + starX := x.Elem() + y := reflect.New(starX.Type()) + starY := y.Elem() + starY.Set(starX) + reflect.ValueOf(destin).Elem().Set(y.Elem()) + } else { + destin = x.Interface() + } +} diff --git a/config/config.go b/config/config.go index 15f0137a6a6..0fb7ed7fc3b 100644 --- a/config/config.go +++ b/config/config.go @@ -486,7 +486,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConsumable, "https://e.serverbid.com/udb/9969/match?gdpr={{.GDPR}}&euconsent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconsumable%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderConversant, "https://prebid-match.dotomi.com/prebid/match?rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dconversant%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDatablocks, "https://search.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/10007?r="+url.QueryEscape(externalURL)+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/10007?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du=https%3A%2F%2Fads.us.e-planning.net%2Fgetuid%2F1%2F5a1ad71d2d53a0f5%3F"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") // openrtb_ext.BidderFacebook doesn't have a good default. From c851a32285971b2f3f545146c057f76f99a588b6 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 11 May 2020 10:40:22 -0400 Subject: [PATCH 33/42] adding support for test exemplary and race --- adapters/dmx/dmx.go | 6 +- .../dmx/dmxtest/exemplary/simple-app.json | 138 ++++++++++++++++++ .../dmx/dmxtest/exemplary/simple-banner.json | 126 ++++++++++++++++ .../dmx/dmxtest/exemplary/simple-video.json | 112 ++++++++++++++ adapters/dmx/dmxtest/params/race/banner.json | 4 + adapters/dmx/dmxtest/params/race/video.json | 4 + 6 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 adapters/dmx/dmxtest/exemplary/simple-app.json create mode 100644 adapters/dmx/dmxtest/exemplary/simple-banner.json create mode 100644 adapters/dmx/dmxtest/exemplary/simple-video.json create mode 100644 adapters/dmx/dmxtest/params/race/banner.json create mode 100644 adapters/dmx/dmxtest/params/race/video.json diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 466fa3ee65c..c1cd51632f8 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -95,6 +95,11 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte if request.Site != nil { siteCopy := *request.Site dmxReq.Site = &siteCopy + if dmxReq.Site.Publisher != nil { + dmxReq.Site.Publisher.ID = publisherId + } else { + dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} + } } else { dmxReq.Site = nil } @@ -190,7 +195,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte Body: oJson, Headers: headers, } - reqsBidder = append(reqsBidder, reqBidder) return } diff --git a/adapters/dmx/dmxtest/exemplary/simple-app.json b/adapters/dmx/dmxtest/exemplary/simple-app.json new file mode 100644 index 00000000000..a2d57163f3c --- /dev/null +++ b/adapters/dmx/dmxtest/exemplary/simple-app.json @@ -0,0 +1,138 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app":{ + "bundle":"302324249", + "id":"ed6207cefff74c14878963566683c070", + "name":"Skout - iOS Match Buy", + "publisher":{ + "id":"10400" + }, + "storeurl":"https://itunes.apple.com/app/id302324249" + }, + "imp": [ + { + + "id": "test-imp-id", + "banner": { + "w": 300, + "h": 250, + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "dmxid": "123454", + "publisher_id": "10400" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "", + "body": { + "id": "test-request-id", + "app":{ + "bundle":"302324249", + "id":"ed6207cefff74c14878963566683c070", + "name":"Skout - iOS Match Buy", + "publisher":{ + "id":"10400" + }, + "storeurl":"https://itunes.apple.com/app/id302324249" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "123454", + "secure": 1, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "publisher_id": "10400", + "dmxid": "123454" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [{ + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.75, + "adid": "29681110", + "adm": "
banner-ads
", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300 + }] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.75, + "adm": "
banner-ads
", + "adid": "29681110", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "w": 300, + "h": 250 + + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/dmx/dmxtest/exemplary/simple-banner.json b/adapters/dmx/dmxtest/exemplary/simple-banner.json new file mode 100644 index 00000000000..03ea6246ee4 --- /dev/null +++ b/adapters/dmx/dmxtest/exemplary/simple-banner.json @@ -0,0 +1,126 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "fhacacnasicnaic" + }, + "imp": [ + { + + "id": "test-imp-id", + "banner": { + "w": 300, + "h": 250, + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "dmxid": "123454", + "publisher_id": "10400" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "", + "body": { + "id": "test-request-id", + "user": { + "id": "fhacacnasicnaic" + }, + "imp": [ + { + "id": "test-imp-id", + "tagid": "123454", + "secure": 1, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "publisher_id": "10400", + "dmxid": "123454" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [{ + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.75, + "adid": "29681110", + "adm": "
banner-ads
", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300 + }] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.75, + "adm": "
banner-ads
", + "adid": "29681110", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "w": 300, + "h": 250 + + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/dmx/dmxtest/exemplary/simple-video.json b/adapters/dmx/dmxtest/exemplary/simple-video.json new file mode 100644 index 00000000000..b4c53188119 --- /dev/null +++ b/adapters/dmx/dmxtest/exemplary/simple-video.json @@ -0,0 +1,112 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "whateveryouwant" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": ["video/mp4"], + "minduration": 15, + "maxduration": 30, + "protocols": [2, 3, 5, 6, 7, 8], + "w": 940, + "h": 560 + }, + "ext": { + "bidder": { + "tagid": "12345", + "publisher_id": "10400" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "", + "body": { + "id": "test-request-id", + "user": { + "id": "whateveryouwant" + }, + "imp": [ + { + "ext": { + "bidder": { + "tagid": "12345", + "publisher_id": "10400" + } + }, + "id": "test-imp-id", + "tagid": "12345", + "secure": 1, + "video": { + "mimes": ["video/mp4"], + "minduration": 15, + "maxduration": 30, + "protocols": [2, 3, 5, 6, 7, 8], + "w": 940, + "h": 560 + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [{ + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.90, + "adid": "29681110", + "adm": "ads", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "h": 250, + "w": 300 + }] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 1.90, + "adm": "ads", + "adid": "29681110", + "adomain": ["dmx.districtm.io"], + "iurl": "https://dmx.districtm.io/b/v2", + "cid": "958", + "crid": "29681110", + "w": 300, + "h": 250 + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/dmx/dmxtest/params/race/banner.json b/adapters/dmx/dmxtest/params/race/banner.json new file mode 100644 index 00000000000..1c0adff78ac --- /dev/null +++ b/adapters/dmx/dmxtest/params/race/banner.json @@ -0,0 +1,4 @@ +{ + "tagid": "25251", + "publisher_id": "100152" +} \ No newline at end of file diff --git a/adapters/dmx/dmxtest/params/race/video.json b/adapters/dmx/dmxtest/params/race/video.json new file mode 100644 index 00000000000..3bbd83bd3b0 --- /dev/null +++ b/adapters/dmx/dmxtest/params/race/video.json @@ -0,0 +1,4 @@ +{ + "tagid": "25255", + "publisher_id": "100151" +} \ No newline at end of file From d7bb136ec568d98020de35774a89b8141efc3c42 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 11 May 2020 10:49:27 -0400 Subject: [PATCH 34/42] publisher share memory fix --- adapters/dmx/dmx.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index c1cd51632f8..bb04e96fcf6 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -87,14 +87,18 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte if request.App != nil { appCopy := *request.App + appPublisherCopy := *request.App.Publisher dmxReq.App = &appCopy + dmxReq.App.Publisher = &appPublisherCopy } else { dmxReq.App = nil } if request.Site != nil { siteCopy := *request.Site + sitePublisherCopy := *request.Site.Publisher dmxReq.Site = &siteCopy + dmxReq.Site.Publisher = &sitePublisherCopy if dmxReq.Site.Publisher != nil { dmxReq.Site.Publisher.ID = publisherId } else { From 9e6fe5913a2ed6e9a3b586a0f66593f9e83127e6 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 11 May 2020 11:01:01 -0400 Subject: [PATCH 35/42] code removed if dmxReq.App != nil { dmxReq.Site = nil if dmxReq.App.ID != "" { anyHasId = true } if dmxReq.App.Publisher != nil { dmxReq.App.Publisher.ID = publisherId } else { dmxReq.App.Publisher = &openrtb.Publisher{ID: publisherId} } } if dmxReq.Site != nil { if dmxReq.Site.Publisher == nil { dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} } } --- adapters/dmx/dmx.go | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index bb04e96fcf6..31dee583c86 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -90,6 +90,9 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte appPublisherCopy := *request.App.Publisher dmxReq.App = &appCopy dmxReq.App.Publisher = &appPublisherCopy + if dmxReq.App.ID != "" { + anyHasId = true + } } else { dmxReq.App = nil } @@ -115,22 +118,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte dmxReq.User = nil } - if dmxReq.App != nil { - dmxReq.Site = nil - if dmxReq.App.ID != "" { - anyHasId = true - } - if dmxReq.App.Publisher != nil { - dmxReq.App.Publisher.ID = publisherId - } else { - dmxReq.App.Publisher = &openrtb.Publisher{ID: publisherId} - } - } - if dmxReq.Site != nil { - if dmxReq.Site.Publisher == nil { - dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} - } - } + if dmxReq.User != nil { if dmxReq.User.ID != "" { anyHasId = true From 711e7792b67e685be4221715720b081472b4177a Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Tue, 12 May 2020 16:06:09 -0400 Subject: [PATCH 36/42] adding Digitrust verification 'nil' --- adapters/dmx/dmx.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 31dee583c86..b6f605d99fb 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -118,14 +118,13 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte dmxReq.User = nil } - if dmxReq.User != nil { if dmxReq.User.ID != "" { anyHasId = true } if dmxReq.User.Ext != nil { if err := json.Unmarshal(dmxReq.User.Ext, &user_ext); err == nil { - if len(user_ext.Eids) > 0 || user_ext.Digitrust.ID != "" { + if len(user_ext.Eids) > 0 || (&user_ext.Digitrust != nil && user_ext.Digitrust.ID != "") { anyHasId = true } } From cbbd51741f388e0bb924d3abd1b411794af265cc Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Wed, 13 May 2020 12:30:29 -0400 Subject: [PATCH 37/42] update the test with empty user.ext --- adapters/dmx/dmx.go | 2 +- adapters/dmx/dmx_test.go | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index b6f605d99fb..cfb10d6d687 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -124,7 +124,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } if dmxReq.User.Ext != nil { if err := json.Unmarshal(dmxReq.User.Ext, &user_ext); err == nil { - if len(user_ext.Eids) > 0 || (&user_ext.Digitrust != nil && user_ext.Digitrust.ID != "") { + if len(user_ext.Eids) > 0 || user_ext.Digitrust.ID != "" { anyHasId = true } } diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 3ebad809836..e9f195eb61d 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -494,7 +494,39 @@ func TestMakeBidsNoContent(t *testing.T) { } } +func TestUserExtEmptyObject(t *testing.T) { + var w, h int = 300, 250 + + var width, height uint64 = uint64(w), uint64(h) + + adapter := NewDmxBidder("https://dmx.districtm.io/b/v2") + imp1 := openrtb.Imp{ + ID: "imp1", + Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), + Banner: &openrtb.Banner{ + W: &width, + H: &height, + Format: []openrtb.Format{ + {W: 300, H: 250}, + }, + }} + inputRequest := openrtb.BidRequest{ + Imp: []openrtb.Imp{imp1, imp1, imp1}, + Site: &openrtb.Site{ + Publisher: &openrtb.Publisher{ + ID: "10007", + }, + }, + User: &openrtb.User{Ext: json.RawMessage(`{}`)}, + ID: "1234", + } + + actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) + if len(actualAdapterRequests) != 0 { + t.Errorf("should have 0 request") + } +} func TestUserEidsOnly(t *testing.T) { var w, h int = 300, 250 From 2b8261046771809cbb7aff6016412fe7a8bf6562 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Mon, 18 May 2020 16:59:52 -0400 Subject: [PATCH 38/42] remove deep copy function for performance issue --- adapters/dmx/dmx.go | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index cfb10d6d687..87b6c9716df 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -10,7 +10,6 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" "net/http" "net/url" - "reflect" "strings" ) @@ -65,7 +64,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte var sellerId string var user_ext dmxUserExt var anyHasId = false - var dmxReq *openrtb.BidRequest = &openrtb.BidRequest{} + var dmxReq *openrtb.BidRequest = request if request.User == nil { if request.App == nil { @@ -73,8 +72,6 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } } - CloneValue(request, dmxReq) - if len(request.Imp) >= 1 { err := json.Unmarshal(request.Imp[0].Ext, &rootExtInfo) if err != nil { @@ -313,16 +310,3 @@ func isDmxParams(t interface{}) bool { return false } } - -func CloneValue(source interface{}, destin interface{}) { - x := reflect.ValueOf(source) - if x.Kind() == reflect.Ptr { - starX := x.Elem() - y := reflect.New(starX.Type()) - starY := y.Elem() - starY.Set(starX) - reflect.ValueOf(destin).Elem().Set(y.Elem()) - } else { - destin = x.Interface() - } -} From e649de1ff2b0b8688c286ed628d1bf1dd1329f55 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Tue, 19 May 2020 15:50:54 -0400 Subject: [PATCH 39/42] remove custom struct for userExt --- adapters/dmx/dmx.go | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index 87b6c9716df..fe7f66dc4c2 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -40,29 +40,12 @@ func UserSellerOrPubId(str1, str2 string) string { return str2 } -type dmxUserExt struct { - Eids []dmxEids `json:"eids,omitempty"` - Digitrust dmxDigitrust `json:"digitrust,omitempty"` -} -type dmxEids struct { - Source string `json:"source,omitempty"` - Uids []struct { - ID string `json:"id,omitempty"` - Ext json.RawMessage - } `json:"uids,omitempty"` -} - -type dmxDigitrust struct { - ID string `json:"id,omitempty"` - Keyv int `json:"keyv,omitempty"` -} - func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { var imps []openrtb.Imp var rootExtInfo dmxExt var publisherId string var sellerId string - var user_ext dmxUserExt + var userExt openrtb_ext.ExtUser var anyHasId = false var dmxReq *openrtb.BidRequest = request @@ -120,8 +103,8 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte anyHasId = true } if dmxReq.User.Ext != nil { - if err := json.Unmarshal(dmxReq.User.Ext, &user_ext); err == nil { - if len(user_ext.Eids) > 0 || user_ext.Digitrust.ID != "" { + if err := json.Unmarshal(dmxReq.User.Ext, &userExt); err == nil { + if len(userExt.Eids) > 0 || (userExt.DigiTrust != nil && userExt.DigiTrust.ID != "") { anyHasId = true } } From 4bf0745d906f0a0a971eeef5cc494a98ab7b2893 Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Tue, 26 May 2020 21:50:00 -0400 Subject: [PATCH 40/42] inforced dmxReq to be a pointer --- adapters/dmx/dmx.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index fe7f66dc4c2..6b4f698d4b1 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -47,7 +47,8 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte var sellerId string var userExt openrtb_ext.ExtUser var anyHasId = false - var dmxReq *openrtb.BidRequest = request + var reqCopy openrtb.BidRequest = *request + var dmxReq *openrtb.BidRequest = &reqCopy if request.User == nil { if request.App == nil { From 8ed9ec3ff00ced81a34336e06724ce1fe1dd166f Mon Sep 17 00:00:00 2001 From: steve-a-districtm Date: Thu, 28 May 2020 23:55:33 -0400 Subject: [PATCH 41/42] fix code conflict for adapter_map.go --- exchange/adapter_map.go | 111 ++++++++++++++++++++++++++++------------ 1 file changed, 79 insertions(+), 32 deletions(-) mode change 100644 => 100755 exchange/adapter_map.go diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go old mode 100644 new mode 100755 index 24d3b93b0f0..f20f46a8aeb --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -2,24 +2,32 @@ package exchange import ( "fmt" - "github.com/prebid/prebid-server/adapters/kubient" "net/http" "strings" "github.com/prebid/prebid-server/adapters" ttx "github.com/prebid/prebid-server/adapters/33across" "github.com/prebid/prebid-server/adapters/adform" + "github.com/prebid/prebid-server/adapters/adgeneration" + "github.com/prebid/prebid-server/adapters/adhese" "github.com/prebid/prebid-server/adapters/adkernel" "github.com/prebid/prebid-server/adapters/adkernelAdn" + "github.com/prebid/prebid-server/adapters/admixer" + "github.com/prebid/prebid-server/adapters/adocean" + "github.com/prebid/prebid-server/adapters/adoppler" "github.com/prebid/prebid-server/adapters/adpone" "github.com/prebid/prebid-server/adapters/adtelligent" "github.com/prebid/prebid-server/adapters/advangelists" + "github.com/prebid/prebid-server/adapters/aja" + "github.com/prebid/prebid-server/adapters/applogy" "github.com/prebid/prebid-server/adapters/appnexus" "github.com/prebid/prebid-server/adapters/audienceNetwork" "github.com/prebid/prebid-server/adapters/beachfront" + "github.com/prebid/prebid-server/adapters/beintoo" "github.com/prebid/prebid-server/adapters/brightroll" "github.com/prebid/prebid-server/adapters/consumable" "github.com/prebid/prebid-server/adapters/conversant" + "github.com/prebid/prebid-server/adapters/cpmstar" "github.com/prebid/prebid-server/adapters/datablocks" "github.com/prebid/prebid-server/adapters/dmx" "github.com/prebid/prebid-server/adapters/emx_digital" @@ -31,28 +39,44 @@ import ( "github.com/prebid/prebid-server/adapters/gumgum" "github.com/prebid/prebid-server/adapters/improvedigital" "github.com/prebid/prebid-server/adapters/ix" + "github.com/prebid/prebid-server/adapters/kidoz" + "github.com/prebid/prebid-server/adapters/kubient" "github.com/prebid/prebid-server/adapters/lifestreet" "github.com/prebid/prebid-server/adapters/lockerdome" + "github.com/prebid/prebid-server/adapters/lunamedia" + "github.com/prebid/prebid-server/adapters/marsmedia" "github.com/prebid/prebid-server/adapters/mgid" + "github.com/prebid/prebid-server/adapters/mobilefuse" + "github.com/prebid/prebid-server/adapters/nanointeractive" + "github.com/prebid/prebid-server/adapters/ninthdecimal" "github.com/prebid/prebid-server/adapters/openx" + "github.com/prebid/prebid-server/adapters/orbidder" "github.com/prebid/prebid-server/adapters/pubmatic" + "github.com/prebid/prebid-server/adapters/pubnative" "github.com/prebid/prebid-server/adapters/pulsepoint" "github.com/prebid/prebid-server/adapters/rhythmone" "github.com/prebid/prebid-server/adapters/rtbhouse" "github.com/prebid/prebid-server/adapters/rubicon" "github.com/prebid/prebid-server/adapters/sharethrough" + "github.com/prebid/prebid-server/adapters/smartrtb" "github.com/prebid/prebid-server/adapters/somoaudience" "github.com/prebid/prebid-server/adapters/sonobi" "github.com/prebid/prebid-server/adapters/sovrn" "github.com/prebid/prebid-server/adapters/synacormedia" "github.com/prebid/prebid-server/adapters/tappx" + "github.com/prebid/prebid-server/adapters/telaria" "github.com/prebid/prebid-server/adapters/triplelift" "github.com/prebid/prebid-server/adapters/triplelift_native" + "github.com/prebid/prebid-server/adapters/ucfunnel" "github.com/prebid/prebid-server/adapters/unruly" + "github.com/prebid/prebid-server/adapters/valueimpression" "github.com/prebid/prebid-server/adapters/verizonmedia" "github.com/prebid/prebid-server/adapters/visx" "github.com/prebid/prebid-server/adapters/vrtcal" + "github.com/prebid/prebid-server/adapters/yeahmobi" "github.com/prebid/prebid-server/adapters/yieldmo" + "github.com/prebid/prebid-server/adapters/yieldone" + "github.com/prebid/prebid-server/adapters/zeroclickfraud" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" ) @@ -62,59 +86,82 @@ import ( func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapters.BidderInfos) map[openrtb_ext.BidderName]adaptedBidder { ortbBidders := map[openrtb_ext.BidderName]adapters.Bidder{ + openrtb_ext.Bidder33Across: ttx.New33AcrossBidder(cfg.Adapters[string(openrtb_ext.Bidder33Across)].Endpoint), openrtb_ext.BidderAdform: adform.NewAdformBidder(client, cfg.Adapters[string(openrtb_ext.BidderAdform)].Endpoint), + openrtb_ext.BidderAdgeneration: adgeneration.NewAdgenerationAdapter(cfg.Adapters[string(openrtb_ext.BidderAdgeneration)].Endpoint), + openrtb_ext.BidderAdhese: adhese.NewAdheseBidder(cfg.Adapters[string(openrtb_ext.BidderAdhese)].Endpoint), openrtb_ext.BidderAdkernel: adkernel.NewAdkernelAdapter(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdkernel))].Endpoint), openrtb_ext.BidderAdkernelAdn: adkernelAdn.NewAdkernelAdnAdapter(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdkernelAdn))].Endpoint), + openrtb_ext.BidderAdmixer: admixer.NewAdmixerBidder(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdmixer))].Endpoint), + openrtb_ext.BidderAdOcean: adocean.NewAdOceanBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderAdOcean))].Endpoint), + openrtb_ext.BidderAdoppler: adoppler.NewAdopplerBidder(cfg.Adapters[string(openrtb_ext.BidderAdoppler)].Endpoint), openrtb_ext.BidderAdpone: adpone.NewAdponeBidder(cfg.Adapters[string(openrtb_ext.BidderAdpone)].Endpoint), openrtb_ext.BidderAdtelligent: adtelligent.NewAdtelligentBidder(cfg.Adapters[string(openrtb_ext.BidderAdtelligent)].Endpoint), openrtb_ext.BidderAdvangelists: advangelists.NewAdvangelistsBidder(cfg.Adapters[string(openrtb_ext.BidderAdvangelists)].Endpoint), + openrtb_ext.BidderAJA: aja.NewAJABidder(cfg.Adapters[string(openrtb_ext.BidderAJA)].Endpoint), + openrtb_ext.BidderApplogy: applogy.NewApplogyBidder(cfg.Adapters[string(openrtb_ext.BidderApplogy)].Endpoint), openrtb_ext.BidderAppnexus: appnexus.NewAppNexusBidder(client, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].PlatformID), - // TODO #615: Update the config setup so that the Beachfront URLs can be configured, and use those in TestRaceIntegration in exchange_test.go - openrtb_ext.BidderBeachfront: beachfront.NewBeachfrontBidder(), - openrtb_ext.BidderBrightroll: brightroll.NewBrightrollBidder(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].Endpoint), - openrtb_ext.BidderConsumable: consumable.NewConsumableBidder(cfg.Adapters[string(openrtb_ext.BidderConsumable)].Endpoint), - openrtb_ext.BidderDatablocks: datablocks.NewDatablocksBidder(cfg.Adapters[string(openrtb_ext.BidderDatablocks)].Endpoint), - openrtb_ext.BidderDmx: dmx.NewDmxBidder(cfg.Adapters[string(openrtb_ext.BidderDmx)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderDmx)].PublisherId), - openrtb_ext.BidderEngageBDR: engagebdr.NewEngageBDRBidder(client, cfg.Adapters[string(openrtb_ext.BidderEngageBDR)].Endpoint), - openrtb_ext.BidderEmxDigital: emx_digital.NewEmxDigitalBidder(cfg.Adapters[string(openrtb_ext.BidderEmxDigital)].Endpoint), - openrtb_ext.BidderEPlanning: eplanning.NewEPlanningBidder(client, cfg.Adapters[string(openrtb_ext.BidderEPlanning)].Endpoint), - openrtb_ext.BidderGumGum: gumgum.NewGumGumBidder(cfg.Adapters[string(openrtb_ext.BidderGumGum)].Endpoint), - openrtb_ext.BidderLockerDome: lockerdome.NewLockerDomeBidder(cfg.Adapters[string(openrtb_ext.BidderLockerDome)].Endpoint), - openrtb_ext.BidderOpenx: openx.NewOpenxBidder(cfg.Adapters[string(openrtb_ext.BidderOpenx)].Endpoint), - openrtb_ext.BidderPubmatic: pubmatic.NewPubmaticBidder(client, cfg.Adapters[string(openrtb_ext.BidderPubmatic)].Endpoint), - openrtb_ext.BidderRhythmone: rhythmone.NewRhythmoneBidder(cfg.Adapters[string(openrtb_ext.BidderRhythmone)].Endpoint), - openrtb_ext.BidderRTBHouse: rtbhouse.NewRTBHouseBidder(cfg.Adapters[string(openrtb_ext.BidderRTBHouse)].Endpoint), + openrtb_ext.BidderBeachfront: beachfront.NewBeachfrontBidder(cfg.Adapters[string(openrtb_ext.BidderBeachfront)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderBeachfront)].ExtraAdapterInfo), + openrtb_ext.BidderBeintoo: beintoo.NewBeintooBidder(cfg.Adapters[string(openrtb_ext.BidderBeintoo)].Endpoint), + openrtb_ext.BidderBrightroll: brightroll.NewBrightrollBidder(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].Endpoint), + openrtb_ext.BidderConsumable: consumable.NewConsumableBidder(cfg.Adapters[string(openrtb_ext.BidderConsumable)].Endpoint), + openrtb_ext.BidderCpmstar: cpmstar.NewCpmstarBidder(cfg.Adapters[string(openrtb_ext.BidderCpmstar)].Endpoint), + openrtb_ext.BidderDatablocks: datablocks.NewDatablocksBidder(cfg.Adapters[string(openrtb_ext.BidderDatablocks)].Endpoint), + openrtb_ext.BidderDmx: dmx.NewDmxBidder(cfg.Adapters[string(openrtb_ext.BidderDmx)].Endpoint), + openrtb_ext.BidderEmxDigital: emx_digital.NewEmxDigitalBidder(cfg.Adapters[string(openrtb_ext.BidderEmxDigital)].Endpoint), + openrtb_ext.BidderEngageBDR: engagebdr.NewEngageBDRBidder(client, cfg.Adapters[string(openrtb_ext.BidderEngageBDR)].Endpoint), + openrtb_ext.BidderEPlanning: eplanning.NewEPlanningBidder(client, cfg.Adapters[string(openrtb_ext.BidderEPlanning)].Endpoint), + openrtb_ext.BidderFacebook: audienceNetwork.NewFacebookBidder( + client, + cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID, + cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].AppSecret), + openrtb_ext.BidderGamma: gamma.NewGammaBidder(cfg.Adapters[string(openrtb_ext.BidderGamma)].Endpoint), + openrtb_ext.BidderGamoshi: gamoshi.NewGamoshiBidder(cfg.Adapters[string(openrtb_ext.BidderGamoshi)].Endpoint), + openrtb_ext.BidderGrid: grid.NewGridBidder(cfg.Adapters[string(openrtb_ext.BidderGrid)].Endpoint), + openrtb_ext.BidderGumGum: gumgum.NewGumGumBidder(cfg.Adapters[string(openrtb_ext.BidderGumGum)].Endpoint), + openrtb_ext.BidderImprovedigital: improvedigital.NewImprovedigitalBidder(cfg.Adapters[string(openrtb_ext.BidderImprovedigital)].Endpoint), + openrtb_ext.BidderKidoz: kidoz.NewKidozBidder(cfg.Adapters[string(openrtb_ext.BidderKidoz)].Endpoint), + openrtb_ext.BidderKubient: kubient.NewKubientBidder(cfg.Adapters[string(openrtb_ext.BidderKubient)].Endpoint), + openrtb_ext.BidderLockerDome: lockerdome.NewLockerDomeBidder(cfg.Adapters[string(openrtb_ext.BidderLockerDome)].Endpoint), + openrtb_ext.BidderLunaMedia: lunamedia.NewLunaMediaBidder(cfg.Adapters[string(openrtb_ext.BidderLunaMedia)].Endpoint), + openrtb_ext.BidderMarsmedia: marsmedia.NewMarsmediaBidder(cfg.Adapters[string(openrtb_ext.BidderMarsmedia)].Endpoint), + openrtb_ext.BidderMgid: mgid.NewMgidBidder(cfg.Adapters[string(openrtb_ext.BidderMgid)].Endpoint), + openrtb_ext.BidderMobileFuse: mobilefuse.NewMobileFuseBidder(cfg.Adapters[string(openrtb_ext.BidderMobileFuse)].Endpoint), + openrtb_ext.BidderNanoInteractive: nanointeractive.NewNanoIneractiveBidder(cfg.Adapters[string(openrtb_ext.BidderNanoInteractive)].Endpoint), + openrtb_ext.BidderNinthDecimal: ninthdecimal.NewNinthDecimalBidder(cfg.Adapters[string(openrtb_ext.BidderNinthDecimal)].Endpoint), + openrtb_ext.BidderOrbidder: orbidder.NewOrbidderBidder(cfg.Adapters[string(openrtb_ext.BidderOrbidder)].Endpoint), + openrtb_ext.BidderOpenx: openx.NewOpenxBidder(cfg.Adapters[string(openrtb_ext.BidderOpenx)].Endpoint), + openrtb_ext.BidderPubmatic: pubmatic.NewPubmaticBidder(client, cfg.Adapters[string(openrtb_ext.BidderPubmatic)].Endpoint), + openrtb_ext.BidderPubnative: pubnative.NewPubnativeBidder(cfg.Adapters[string(openrtb_ext.BidderPubnative)].Endpoint), + openrtb_ext.BidderRhythmone: rhythmone.NewRhythmoneBidder(cfg.Adapters[string(openrtb_ext.BidderRhythmone)].Endpoint), + openrtb_ext.BidderRTBHouse: rtbhouse.NewRTBHouseBidder(cfg.Adapters[string(openrtb_ext.BidderRTBHouse)].Endpoint), openrtb_ext.BidderRubicon: rubicon.NewRubiconBidder( client, cfg.Adapters[string(openrtb_ext.BidderRubicon)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Username, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Password, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Tracker), + openrtb_ext.BidderSharethrough: sharethrough.NewSharethroughBidder(cfg.Adapters[string(openrtb_ext.BidderSharethrough)].Endpoint), + openrtb_ext.BidderSmartRTB: smartrtb.NewSmartRTBBidder(cfg.Adapters[string(openrtb_ext.BidderSmartRTB)].Endpoint), openrtb_ext.BidderSomoaudience: somoaudience.NewSomoaudienceBidder(cfg.Adapters[string(openrtb_ext.BidderSomoaudience)].Endpoint), - openrtb_ext.BidderSovrn: sovrn.NewSovrnBidder(client, cfg.Adapters[string(openrtb_ext.BidderSovrn)].Endpoint), - openrtb_ext.Bidder33Across: ttx.New33AcrossBidder(cfg.Adapters[string(openrtb_ext.Bidder33Across)].Endpoint), - openrtb_ext.BidderGrid: grid.NewGridBidder(cfg.Adapters[string(openrtb_ext.BidderGrid)].Endpoint), openrtb_ext.BidderSonobi: sonobi.NewSonobiBidder(client, cfg.Adapters[string(openrtb_ext.BidderSonobi)].Endpoint), + openrtb_ext.BidderSovrn: sovrn.NewSovrnBidder(client, cfg.Adapters[string(openrtb_ext.BidderSovrn)].Endpoint), openrtb_ext.BidderSynacormedia: synacormedia.NewSynacorMediaBidder(cfg.Adapters[string(openrtb_ext.BidderSynacormedia)].Endpoint), + openrtb_ext.BidderTappx: tappx.NewTappxBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTappx))].Endpoint), + openrtb_ext.BidderTelaria: telaria.NewTelariaBidder(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTelaria))].Endpoint), openrtb_ext.BidderTriplelift: triplelift.NewTripleliftBidder(client, cfg.Adapters[string(openrtb_ext.BidderTriplelift)].Endpoint), openrtb_ext.BidderTripleliftNative: triplelift_native.NewTripleliftNativeBidder(client, cfg.Adapters[string(openrtb_ext.BidderTripleliftNative)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderTripleliftNative)].ExtraAdapterInfo), + openrtb_ext.BidderUcfunnel: ucfunnel.NewUcfunnelBidder(cfg.Adapters[string(openrtb_ext.BidderUcfunnel)].Endpoint), openrtb_ext.BidderUnruly: unruly.NewUnrulyBidder(client, cfg.Adapters[string(openrtb_ext.BidderUnruly)].Endpoint), + openrtb_ext.BidderValueImpression: valueimpression.NewValueImpressionBidder(cfg.Adapters[string(openrtb_ext.BidderValueImpression)].Endpoint), + openrtb_ext.BidderVerizonMedia: verizonmedia.NewVerizonMediaBidder(client, cfg.Adapters[string(openrtb_ext.BidderVerizonMedia)].Endpoint), + openrtb_ext.BidderVisx: visx.NewVisxBidder(cfg.Adapters[string(openrtb_ext.BidderVisx)].Endpoint), openrtb_ext.BidderVrtcal: vrtcal.NewVrtcalBidder(cfg.Adapters[string(openrtb_ext.BidderVrtcal)].Endpoint), + openrtb_ext.BidderYeahmobi: yeahmobi.NewYeahmobiBidder(cfg.Adapters[string(openrtb_ext.BidderYeahmobi)].Endpoint), openrtb_ext.BidderYieldmo: yieldmo.NewYieldmoBidder(cfg.Adapters[string(openrtb_ext.BidderYieldmo)].Endpoint), - openrtb_ext.BidderGamma: gamma.NewGammaBidder(cfg.Adapters[string(openrtb_ext.BidderGamma)].Endpoint), - openrtb_ext.BidderVisx: visx.NewVisxBidder(cfg.Adapters[string(openrtb_ext.BidderVisx)].Endpoint), - openrtb_ext.BidderGamoshi: gamoshi.NewGamoshiBidder(cfg.Adapters[string(openrtb_ext.BidderGamoshi)].Endpoint), - openrtb_ext.BidderMgid: mgid.NewMgidBidder(cfg.Adapters[string(openrtb_ext.BidderMgid)].Endpoint), - openrtb_ext.BidderImprovedigital: improvedigital.NewImprovedigitalBidder(cfg.Adapters[string(openrtb_ext.BidderImprovedigital)].Endpoint), - openrtb_ext.BidderTappx: tappx.NewTappxBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTappx))].Endpoint), - openrtb_ext.BidderVerizonMedia: verizonmedia.NewVerizonMediaBidder(client, cfg.Adapters[string(openrtb_ext.BidderVerizonMedia)].Endpoint), - openrtb_ext.BidderKubient: kubient.NewKubientBidder(cfg.Adapters[string(openrtb_ext.BidderKubient)].Endpoint), - openrtb_ext.BidderFacebook: audienceNetwork.NewFacebookBidder( - client, - cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID, - cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].AppID, - cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].AppSecret), + openrtb_ext.BidderYieldone: yieldone.NewYieldoneBidder(cfg.Adapters[string(openrtb_ext.BidderYieldone)].Endpoint), + openrtb_ext.BidderZeroClickFraud: zeroclickfraud.NewZeroClickFraudBidder(cfg.Adapters[string(openrtb_ext.BidderZeroClickFraud)].Endpoint), } legacyBidders := map[openrtb_ext.BidderName]adapters.Adapter{ From a4ac24fca5d93dbb6e6c2c1943c5c116adf88153 Mon Sep 17 00:00:00 2001 From: steve alliance Date: Wed, 3 Jun 2020 11:28:47 -0400 Subject: [PATCH 42/42] update latest change for GDPR CCPA --- adapters/dmx/usersync_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adapters/dmx/usersync_test.go b/adapters/dmx/usersync_test.go index 60a9c510ee1..e4e3c7d8e55 100644 --- a/adapters/dmx/usersync_test.go +++ b/adapters/dmx/usersync_test.go @@ -1,6 +1,7 @@ package dmx import ( + "github.com/prebid/prebid-server/privacy" "testing" "text/template" @@ -10,7 +11,7 @@ import ( func TestDmxSyncer(t *testing.T) { temp := template.Must(template.New("sync-template").Parse("https://dmx.districtm.io/s/v1/img/s/10007")) syncer := NewDmxSyncer(temp) - syncInfo, err := syncer.GetUsersyncInfo("", "") + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) assert.NoError(t, err) assert.Equal(t, "https://dmx.districtm.io/s/v1/img/s/10007", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type)