From e29eec172fe2906717ac9e3bf6cc97e445d5bc7e Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Thu, 19 Dec 2024 13:13:21 +0100 Subject: [PATCH 01/10] [EXCH-11021] add native support --- adapters/openx/openx.go | 17 +++- .../openxtest/exemplary/simple-native.json | 87 +++++++++++++++++++ static/bidder-info/openx.yaml | 2 + 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 adapters/openx/openxtest/exemplary/simple-native.json diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index d56339df178..3938b26b7f8 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -35,13 +35,16 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt var errs []error var bannerImps []openrtb2.Imp var videoImps []openrtb2.Imp + var nativeImps []openrtb2.Imp for _, imp := range request.Imp { - // OpenX doesn't allow multi-type imp. Banner takes priority over video. + // OpenX doesn't allow multi-type imp. Banner takes priority over video and video takes priority over native if imp.Banner != nil { bannerImps = append(bannerImps, imp) } else if imp.Video != nil { videoImps = append(videoImps, imp) + } else if imp.Native != nil { + nativeImps = append(nativeImps, imp) } } @@ -66,6 +69,13 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt errs = append(errs, errors...) } + reqCopy.Imp = nativeImps + adapterReq, errors = a.makeRequest(&reqCopy) + if adapterReq != nil { + adapterRequests = append(adapterRequests, adapterReq) + } + errs = append(errs, errors...) + return adapterRequests, errs } @@ -243,12 +253,17 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRe // // OpenX doesn't support multi-type impressions. // If both banner and video exist, take banner as we do not want in-banner video. +// If both video and native exist and banner is nil, take video +// If both banner and native exist, take banner +// And if all the types exist, take banner func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { if imp.Banner == nil && imp.Video != nil { mediaType = openrtb_ext.BidTypeVideo + } else if imp.Banner == nil && imp.Native != nil { + mediaType = openrtb_ext.BidTypeNative } return mediaType } diff --git a/adapters/openx/openxtest/exemplary/simple-native.json b/adapters/openx/openxtest/exemplary/simple-native.json new file mode 100644 index 00000000000..d582acc1ef3 --- /dev/null +++ b/adapters/openx/openxtest/exemplary/simple-native.json @@ -0,0 +1,87 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "test-native", + "ver": "1.2" + }, + "ext": { + "bidder": { + "unit": "539439964", + "delDomain": "se-demo-d.openx.net" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://rtb.openx.net/prebid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "test-native", + "ver": "1.2" + }, + "tagid": "539439964" + } + ], + "ext": { + "bc": "hb_pbs_1.0.0", + "delDomain": "se-demo-d.openx.net" + } + }, + "impIDs":["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "openx", + "bid": [{ + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 300, + "h": 200 + }] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "crid": "crid_10", + "w": 300, + "h": 200 + }, + "type": "native" + } + ] + } + ] +} \ No newline at end of file diff --git a/static/bidder-info/openx.yaml b/static/bidder-info/openx.yaml index 7fcabad9652..13b9152859c 100644 --- a/static/bidder-info/openx.yaml +++ b/static/bidder-info/openx.yaml @@ -8,10 +8,12 @@ capabilities: mediaTypes: - banner - video + - native site: mediaTypes: - banner - video + - native modifyingVastXmlAllowed: true userSync: iframe: From 55f0f5b986215415197c982f3bf275121896b73e Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 08:24:53 +0100 Subject: [PATCH 02/10] [EXCH-11021] native and banner in one request --- adapters/openx/openx.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index 3938b26b7f8..db4c82133eb 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -33,18 +33,16 @@ type openxRespExt struct { func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var bannerImps []openrtb2.Imp + var bannerAndNativeImps []openrtb2.Imp var videoImps []openrtb2.Imp - var nativeImps []openrtb2.Imp for _, imp := range request.Imp { // OpenX doesn't allow multi-type imp. Banner takes priority over video and video takes priority over native - if imp.Banner != nil { - bannerImps = append(bannerImps, imp) + // Openx also wants to send banner and native imps in one request + if imp.Banner != nil || imp.Native != nil { + bannerAndNativeImps = append(bannerAndNativeImps, imp) } else if imp.Video != nil { videoImps = append(videoImps, imp) - } else if imp.Native != nil { - nativeImps = append(nativeImps, imp) } } @@ -52,7 +50,7 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt // Make a copy as we don't want to change the original request reqCopy := *request - reqCopy.Imp = bannerImps + reqCopy.Imp = bannerAndNativeImps adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) @@ -69,13 +67,6 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt errs = append(errs, errors...) } - reqCopy.Imp = nativeImps - adapterReq, errors = a.makeRequest(&reqCopy) - if adapterReq != nil { - adapterRequests = append(adapterRequests, adapterReq) - } - errs = append(errs, errors...) - return adapterRequests, errs } From 06786370837510d28fa45f50b100f35e16526e16 Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 10:45:38 +0100 Subject: [PATCH 03/10] [EXCH-11021] edit multi tests --- adapters/openx/openx.go | 4 +- .../openxtest/supplemental/multi-imp.json | 41 ++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index db4c82133eb..7b271afbf7d 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -39,10 +39,12 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapt for _, imp := range request.Imp { // OpenX doesn't allow multi-type imp. Banner takes priority over video and video takes priority over native // Openx also wants to send banner and native imps in one request - if imp.Banner != nil || imp.Native != nil { + if imp.Banner != nil { bannerAndNativeImps = append(bannerAndNativeImps, imp) } else if imp.Video != nil { videoImps = append(videoImps, imp) + } else if imp.Native != nil { + bannerAndNativeImps = append(bannerAndNativeImps, imp) } } diff --git a/adapters/openx/openxtest/supplemental/multi-imp.json b/adapters/openx/openxtest/supplemental/multi-imp.json index d49660a1541..1df9a2518df 100644 --- a/adapters/openx/openxtest/supplemental/multi-imp.json +++ b/adapters/openx/openxtest/supplemental/multi-imp.json @@ -22,6 +22,19 @@ } } }, + { + "id": "native-imp-1", + "native": { + "request": "test-native", + "ver": "1.2" + }, + "ext": { + "bidder": { + "unit": "123", + "delDomain": "se-demo-d.openx.net" + } + } + }, { "id": "banner-imp-2", "banner": {}, @@ -46,6 +59,10 @@ "id": "multi-type-imp", "banner": {}, "video": {"mimes": ["video/mp4"]}, + "native": { + "request": "test-native", + "ver": "1.2" + }, "ext": { "bidder": { "unit": "555", @@ -68,6 +85,11 @@ "banner": {}, "tagid": "111" }, + { + "id": "native-imp-1", + "banner": {}, + "tagid": "123" + }, { "id": "banner-imp-2", "banner": {}, @@ -77,6 +99,10 @@ "id": "multi-type-imp", "banner": {}, "video": {"mimes": ["video/mp4"]}, + "native": { + "request": "test-native", + "ver": "1.2" + }, "tagid": "555" } ], @@ -85,7 +111,7 @@ "delDomain": "se-demo-d.openx.net" } }, - "impIDs":["banner-imp-1","banner-imp-2","multi-type-imp"] + "impIDs":["banner-imp-1","native-imp-1","banner-imp-2","multi-type-imp"] }, "mockResponse": { "status": 200, @@ -100,6 +126,11 @@ "impid": "banner-imp-1", "price": 0.1 }, + { + "id": "native-bid-1", + "impid": "native-imp-1", + "price": 0.1 + }, { "id": "banner-bid-2", "impid": "banner-imp-2", @@ -206,6 +237,14 @@ }, "type": "banner" }, + { + "bid": { + "id": "native-bid-1", + "impid": "native-imp-1", + "price": 0.1 + }, + "type": "native" + }, { "bid": { "id": "banner-bid-2", From aae617321bbc2a5a39c573691ff7fefee9df6269 Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 11:30:50 +0100 Subject: [PATCH 04/10] [EXCH-11021] fix test --- adapters/openx/openxtest/supplemental/multi-imp.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/adapters/openx/openxtest/supplemental/multi-imp.json b/adapters/openx/openxtest/supplemental/multi-imp.json index 1df9a2518df..675fd65887e 100644 --- a/adapters/openx/openxtest/supplemental/multi-imp.json +++ b/adapters/openx/openxtest/supplemental/multi-imp.json @@ -87,7 +87,10 @@ }, { "id": "native-imp-1", - "banner": {}, + "native": { + "request": "test-native", + "ver": "1.2" + }, "tagid": "123" }, { From 18e4b91cfa0cb67b2a5a86758d35223d00e6c6a0 Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 12:07:16 +0100 Subject: [PATCH 05/10] [EXCH-11201] update go.sum file --- go.sum | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go.sum b/go.sum index 00827d6fb6c..ba0bedd026b 100644 --- a/go.sum +++ b/go.sum @@ -135,6 +135,7 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/frankban/quicktest v1.14.3/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= @@ -316,9 +317,11 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= @@ -436,6 +439,7 @@ github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqn github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= From 3aac66e3f6b9ef4ce1eec48d49919df76454ec9f Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 13:23:12 +0100 Subject: [PATCH 06/10] [EXCH-11201] new banner-native, video-native test cases --- .../openxtest/supplemental/multi-imp.json | 121 +++++++++++++++++- 1 file changed, 116 insertions(+), 5 deletions(-) diff --git a/adapters/openx/openxtest/supplemental/multi-imp.json b/adapters/openx/openxtest/supplemental/multi-imp.json index 675fd65887e..2962e699973 100644 --- a/adapters/openx/openxtest/supplemental/multi-imp.json +++ b/adapters/openx/openxtest/supplemental/multi-imp.json @@ -30,7 +30,7 @@ }, "ext": { "bidder": { - "unit": "123", + "unit": "666", "delDomain": "se-demo-d.openx.net" } } @@ -55,6 +55,34 @@ } } }, + { + "id": "banner-native-imp-1", + "banner": {}, + "native": { + "request": "test-native", + "ver": "1.2" + }, + "ext": { + "bidder": { + "unit": "777", + "delDomain": "se-demo-d.openx.net" + } + } + }, + { + "id": "video-native-imp-1", + "video": {"mimes": ["video/mp4"]}, + "native": { + "request": "test-native", + "ver": "1.2" + }, + "ext": { + "bidder": { + "unit": "888", + "delDomain": "se-demo-d.openx.net" + } + } + }, { "id": "multi-type-imp", "banner": {}, @@ -91,13 +119,22 @@ "request": "test-native", "ver": "1.2" }, - "tagid": "123" + "tagid": "666" }, { "id": "banner-imp-2", "banner": {}, "tagid": "222" }, + { + "id": "banner-native-imp-1", + "banner": {}, + "native": { + "request": "test-native", + "ver": "1.2" + }, + "tagid": "777" + }, { "id": "multi-type-imp", "banner": {}, @@ -114,7 +151,7 @@ "delDomain": "se-demo-d.openx.net" } }, - "impIDs":["banner-imp-1","native-imp-1","banner-imp-2","multi-type-imp"] + "impIDs":["banner-imp-1","native-imp-1","banner-imp-2","banner-native-imp-1","multi-type-imp"] }, "mockResponse": { "status": 200, @@ -139,6 +176,11 @@ "impid": "banner-imp-2", "price": 0.2 }, + { + "id": "banner-native-bid-1", + "impid": "banner-native-imp-1", + "price": 0 + }, { "id": "multi-type-bid", "impid": "multi-type-imp", @@ -196,7 +238,11 @@ "imp": [ { "id": "video-imp-2", - "video": {"mimes": ["video/mp4"]}, + "video": { + "mimes": [ + "video/mp4" + ] + }, "tagid": "444" } ], @@ -205,7 +251,9 @@ "delDomain": "se-demo-d.openx.net" } }, - "impIDs":["video-imp-2"] + "impIDs": [ + "video-imp-2" + ] }, "mockResponse": { "status": 200, @@ -225,6 +273,48 @@ ] } } + }, + { + "expectedRequest": { + "uri": "http://rtb.openx.net/prebid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "video-native-imp-1", + "video": {"mimes": ["video/mp4"]}, + "native": { + "request": "test-native", + "ver": "1.2" + }, + "tagid": "888" + } + ], + "ext": { + "bc": "hb_pbs_1.0.0", + "delDomain": "se-demo-d.openx.net" + } + }, + "impIDs":["video-native-imp-1"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "openx", + "bid": [ + { + "id": "video-native-bid-1", + "impid": "video-native-imp-1", + "price": 0.0 + } + ] + } + ] + } + } } ], @@ -256,6 +346,14 @@ }, "type": "banner" }, + { + "bid": { + "id": "banner-native-bid-1", + "impid": "banner-native-imp-1", + "price": 0 + }, + "type": "banner" + }, { "bid": { "id": "multi-type-bid", @@ -291,6 +389,19 @@ "type": "video" } ] + }, + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "video-native-bid-1", + "impid": "video-native-imp-1", + "price": 0.0 + }, + "type": "video" + } + ] } ] } From e225f56dee2453742374755f0de7ced4905af4cd Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Wed, 8 Jan 2025 13:48:27 +0100 Subject: [PATCH 07/10] [EXCH-11201] TestGetMediaTypeForImp --- adapters/openx/openx_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/adapters/openx/openx_test.go b/adapters/openx/openx_test.go index 092e9190f90..fcbeb866eaf 100644 --- a/adapters/openx/openx_test.go +++ b/adapters/openx/openx_test.go @@ -33,6 +33,23 @@ func TestResponseWithCurrencies(t *testing.T) { assertCurrencyInBidResponse(t, "EUR", ¤cy) } +func TestGetMediaTypeForImp(t *testing.T) { + imps := []openrtb2.Imp{ + {ID: "1", Banner: &openrtb2.Banner{}}, + {ID: "2", Video: &openrtb2.Video{}}, + {ID: "3", Native: &openrtb2.Native{}}, + {ID: "4", Video: &openrtb2.Video{}, Native: &openrtb2.Native{}}, + {ID: "5", Banner: &openrtb2.Banner{}, Video: &openrtb2.Video{}, Native: &openrtb2.Native{}}, + } + + assert.Equal(t, getMediaTypeForImp("1", imps), openrtb_ext.BidTypeBanner) + assert.Equal(t, getMediaTypeForImp("2", imps), openrtb_ext.BidTypeVideo) + assert.Equal(t, getMediaTypeForImp("3", imps), openrtb_ext.BidTypeNative) + assert.Equal(t, getMediaTypeForImp("4", imps), openrtb_ext.BidTypeVideo) + assert.Equal(t, getMediaTypeForImp("5", imps), openrtb_ext.BidTypeBanner) + +} + func assertCurrencyInBidResponse(t *testing.T, expectedCurrency string, currency *string) { bidder, buildErr := Builder(openrtb_ext.BidderOpenx, config.Adapter{ Endpoint: "http://rtb.openx.net/prebid"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) From 7e9918f96067d33b0a1eea7b2356ff3ea6194f6e Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Thu, 9 Jan 2025 07:37:22 +0100 Subject: [PATCH 08/10] [EXCH-11201] delete unnecessary test --- adapters/openx/openx_test.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/adapters/openx/openx_test.go b/adapters/openx/openx_test.go index fcbeb866eaf..092e9190f90 100644 --- a/adapters/openx/openx_test.go +++ b/adapters/openx/openx_test.go @@ -33,23 +33,6 @@ func TestResponseWithCurrencies(t *testing.T) { assertCurrencyInBidResponse(t, "EUR", ¤cy) } -func TestGetMediaTypeForImp(t *testing.T) { - imps := []openrtb2.Imp{ - {ID: "1", Banner: &openrtb2.Banner{}}, - {ID: "2", Video: &openrtb2.Video{}}, - {ID: "3", Native: &openrtb2.Native{}}, - {ID: "4", Video: &openrtb2.Video{}, Native: &openrtb2.Native{}}, - {ID: "5", Banner: &openrtb2.Banner{}, Video: &openrtb2.Video{}, Native: &openrtb2.Native{}}, - } - - assert.Equal(t, getMediaTypeForImp("1", imps), openrtb_ext.BidTypeBanner) - assert.Equal(t, getMediaTypeForImp("2", imps), openrtb_ext.BidTypeVideo) - assert.Equal(t, getMediaTypeForImp("3", imps), openrtb_ext.BidTypeNative) - assert.Equal(t, getMediaTypeForImp("4", imps), openrtb_ext.BidTypeVideo) - assert.Equal(t, getMediaTypeForImp("5", imps), openrtb_ext.BidTypeBanner) - -} - func assertCurrencyInBidResponse(t *testing.T, expectedCurrency string, currency *string) { bidder, buildErr := Builder(openrtb_ext.BidderOpenx, config.Adapter{ Endpoint: "http://rtb.openx.net/prebid"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) From efed6ba27d1dd777db77b093897f2176d1f2e378 Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Thu, 9 Jan 2025 10:21:19 +0100 Subject: [PATCH 09/10] [EXCH-11201] code improvement - suggestions --- adapters/openx/openx.go | 6 +++--- .../openx/openxtest/exemplary/simple-native.json | 4 ++-- .../openx/openxtest/supplemental/multi-imp.json | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index 725a30d9b74..11b5268b9bf 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -259,9 +259,9 @@ func getBidVideo(bid *openrtb2.Bid) *openrtb_ext.ExtBidPrebidVideo { // // OpenX doesn't support multi-type impressions. // If both banner and video exist, take banner as we do not want in-banner video. -// If both video and native exist and banner is nil, take video -// If both banner and native exist, take banner -// And if all the types exist, take banner +// If both video and native exist and banner is nil, take video. +// If both banner and native exist, take banner. +// If all of the types (banner, video, native) exist, take banner. func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { diff --git a/adapters/openx/openxtest/exemplary/simple-native.json b/adapters/openx/openxtest/exemplary/simple-native.json index d582acc1ef3..7287c22aa66 100644 --- a/adapters/openx/openxtest/exemplary/simple-native.json +++ b/adapters/openx/openxtest/exemplary/simple-native.json @@ -5,7 +5,7 @@ { "id": "test-imp-id", "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "ext": { @@ -28,7 +28,7 @@ { "id": "test-imp-id", "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "tagid": "539439964" diff --git a/adapters/openx/openxtest/supplemental/multi-imp.json b/adapters/openx/openxtest/supplemental/multi-imp.json index 2962e699973..a8c9be59513 100644 --- a/adapters/openx/openxtest/supplemental/multi-imp.json +++ b/adapters/openx/openxtest/supplemental/multi-imp.json @@ -25,7 +25,7 @@ { "id": "native-imp-1", "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "ext": { @@ -59,7 +59,7 @@ "id": "banner-native-imp-1", "banner": {}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "ext": { @@ -73,7 +73,7 @@ "id": "video-native-imp-1", "video": {"mimes": ["video/mp4"]}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "ext": { @@ -88,7 +88,7 @@ "banner": {}, "video": {"mimes": ["video/mp4"]}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "ext": { @@ -116,7 +116,7 @@ { "id": "native-imp-1", "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "tagid": "666" @@ -130,7 +130,7 @@ "id": "banner-native-imp-1", "banner": {}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "tagid": "777" @@ -140,7 +140,7 @@ "banner": {}, "video": {"mimes": ["video/mp4"]}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "tagid": "555" @@ -284,7 +284,7 @@ "id": "video-native-imp-1", "video": {"mimes": ["video/mp4"]}, "native": { - "request": "test-native", + "request": "{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":90}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1200,\"hmin\":627}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1,2]}]}", "ver": "1.2" }, "tagid": "888" From beba8f297d5fd07a35b326812bfb1d3d587fa869 Mon Sep 17 00:00:00 2001 From: Fuska1 Date: Thu, 9 Jan 2025 10:24:30 +0100 Subject: [PATCH 10/10] [EXCH-11201] code improvement - adm changes --- adapters/openx/openxtest/exemplary/simple-banner.json | 4 ++-- adapters/openx/openxtest/exemplary/simple-native.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/openx/openxtest/exemplary/simple-banner.json b/adapters/openx/openxtest/exemplary/simple-banner.json index 35b02878f38..aa9f9476dcf 100644 --- a/adapters/openx/openxtest/exemplary/simple-banner.json +++ b/adapters/openx/openxtest/exemplary/simple-banner.json @@ -50,7 +50,7 @@ "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.500000, - "adm": "some-test-ad", + "adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}", "crid": "crid_10", "h": 90, "w": 728 @@ -72,7 +72,7 @@ "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "some-test-ad", + "adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}", "crid": "crid_10", "w": 728, "h": 90 diff --git a/adapters/openx/openxtest/exemplary/simple-native.json b/adapters/openx/openxtest/exemplary/simple-native.json index 7287c22aa66..e9975b0b182 100644 --- a/adapters/openx/openxtest/exemplary/simple-native.json +++ b/adapters/openx/openxtest/exemplary/simple-native.json @@ -53,7 +53,7 @@ "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.500000, - "adm": "some-test-ad", + "adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}", "crid": "crid_10", "w": 300, "h": 200 @@ -74,7 +74,7 @@ "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.5, - "adm": "some-test-ad", + "adm": "{\"ver\": \"1.2\", \"assets\": [{\"id\": 1, \"required\": 1,\"title\": {\"text\": \"OpenX (Title)\"}}], \"link\": {\"url\": \"https://www.openx.com/\"}, \"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"}]}", "crid": "crid_10", "w": 300, "h": 200