From 2221b76868219ca146e6e393a138710c88188311 Mon Sep 17 00:00:00 2001 From: Scott Kay Date: Fri, 26 Mar 2021 13:19:25 -0400 Subject: [PATCH] Update OpenRTB Library (#1733) --- adapters/33across/33across.go | 20 +- adapters/acuityads/acuityads.go | 14 +- adapters/adapterstest/adapter_test_util.go | 10 +- adapters/adapterstest/test_json.go | 6 +- adapters/adform/adform.go | 31 +- adapters/adform/adform_test.go | 64 ++-- adapters/adgeneration/adgeneration.go | 24 +- adapters/adgeneration/adgeneration_test.go | 70 ++-- adapters/adhese/adhese.go | 30 +- adapters/adhese/utils.go | 16 +- adapters/adkernel/adkernel.go | 34 +- adapters/adkernelAdn/adkernelAdn.go | 34 +- adapters/adman/adman.go | 14 +- .../admantest/supplemental/bad_response.json | 2 +- adapters/admixer/admixer.go | 16 +- adapters/adocean/adocean.go | 28 +- adapters/adoppler/adoppler.go | 12 +- .../supplemental/invalid-response.json | 2 +- adapters/adot/adot.go | 13 +- adapters/adot/adot_test.go | 13 +- .../supplemental/unmarshal_error.json | 2 +- adapters/adpone/adpone.go | 8 +- .../adponetest/supplemental/bad_response.json | 2 +- adapters/adprime/adprime.go | 14 +- .../supplemental/bad_response.json | 2 +- adapters/adtarget/adtarget.go | 12 +- adapters/adtelligent/adtelligent.go | 12 +- adapters/advangelists/advangelists.go | 32 +- adapters/adyoulike/adyoulike.go | 12 +- .../supplemental/invalid-bid-response.json | 2 +- adapters/aja/aja.go | 12 +- adapters/amx/amx.go | 14 +- adapters/amx/amx_test.go | 48 +-- adapters/applogy/applogy.go | 14 +- adapters/appnexus/appnexus.go | 28 +- adapters/appnexus/appnexus_test.go | 132 ++++---- adapters/audienceNetwork/facebook.go | 121 +++---- adapters/avocet/avocet.go | 12 +- adapters/avocet/avocet_test.go | 22 +- adapters/beachfront/beachfront.go | 66 ++-- adapters/beintoo/beintoo.go | 18 +- .../invalid-response-unmarshall-error.json | 2 +- adapters/between/between.go | 18 +- .../supplemental/bad-response-body.json | 2 +- adapters/bidder.go | 10 +- adapters/brightroll/brightroll.go | 16 +- adapters/colossus/colossus.go | 14 +- .../supplemental/bad_response.json | 2 +- adapters/connectad/connectad.go | 18 +- .../supplemental/badresponse.json | 2 +- adapters/consumable/adtypes.go | 7 +- adapters/consumable/consumable.go | 14 +- adapters/conversant/cnvr_legacy.go | 20 +- adapters/conversant/cnvr_legacy_test.go | 40 +-- adapters/conversant/conversant.go | 24 +- adapters/cpmstar/cpmstar.go | 14 +- .../invalid-response-unmarshall-error.json | 2 +- adapters/datablocks/datablocks.go | 18 +- .../supplemental/bad-response-body.json | 2 +- adapters/decenterads/decenterads.go | 12 +- .../supplemental/bad_response.json | 2 +- adapters/deepintent/deepintent.go | 18 +- .../supplemental/bad_response.json | 2 +- adapters/dmx/dmx.go | 30 +- adapters/dmx/dmx_test.go | 253 ++++++++------- adapters/emx_digital/emx_digital.go | 26 +- .../invalid-response-unmarshall-error.json | 2 +- adapters/engagebdr/engagebdr.go | 12 +- adapters/eplanning/eplanning.go | 22 +- adapters/epom/epom.go | 12 +- adapters/gamma/gamma.go | 34 +- adapters/gamoshi/gamoshi.go | 10 +- adapters/grid/grid.go | 14 +- .../gridtest/supplemental/bad_response.json | 2 +- adapters/gumgum/gumgum.go | 20 +- adapters/improvedigital/improvedigital.go | 10 +- .../supplemental/bad_response.json | 2 +- adapters/infoawarebidder.go | 12 +- adapters/infoawarebidder_test.go | 72 ++--- adapters/inmobi/inmobi.go | 12 +- adapters/invibes/invibes.go | 32 +- adapters/ix/ix.go | 37 ++- adapters/ix/ix_test.go | 54 ++-- adapters/jixie/jixie.go | 8 +- adapters/kidoz/kidoz.go | 10 +- adapters/kidoz/kidoz_test.go | 22 +- adapters/krushmedia/krushmedia.go | 14 +- adapters/kubient/kubient.go | 12 +- .../supplemental/bad_response.json | 2 +- adapters/lifestreet/lifestreet.go | 8 +- adapters/lifestreet/lifestreet_test.go | 36 +-- adapters/lockerdome/lockerdome.go | 10 +- .../supplemental/bad_response.json | 2 +- adapters/logicad/logicad.go | 22 +- adapters/lunamedia/lunamedia.go | 28 +- adapters/marsmedia/marsmedia.go | 10 +- adapters/mgid/mgid.go | 12 +- adapters/mobfoxpb/mobfoxpb.go | 14 +- .../supplemental/bad_response.json | 2 +- adapters/mobilefuse/mobilefuse.go | 18 +- adapters/nanointeractive/nanointeractive.go | 14 +- adapters/ninthdecimal/ninthdecimal.go | 28 +- adapters/nobid/nobid.go | 12 +- adapters/onetag/onetag.go | 12 +- adapters/openrtb_util.go | 51 ++- adapters/openrtb_util_test.go | 66 ++-- adapters/openx/openx.go | 22 +- adapters/openx/openx_test.go | 8 +- adapters/orbidder/orbidder.go | 12 +- adapters/pangle/pangle.go | 14 +- adapters/pubmatic/pubmatic.go | 36 +-- adapters/pubmatic/pubmatic_test.go | 46 +-- adapters/pubnative/pubnative.go | 22 +- adapters/pulsepoint/pulsepoint.go | 33 +- adapters/pulsepoint/pulsepoint_test.go | 18 +- .../supplemental/bad-bid-data.json | 2 +- adapters/revcontent/revcontent.go | 13 +- .../supplemental/bad_response.json | 2 +- adapters/rhythmone/rhythmone.go | 12 +- adapters/rtbhouse/rtbhouse.go | 8 +- .../supplemental/bad_response.json | 2 +- adapters/rubicon/rubicon.go | 52 ++- adapters/rubicon/rubicon_test.go | 223 ++++++------- adapters/sharethrough/butler.go | 18 +- adapters/sharethrough/butler_test.go | 80 ++--- adapters/sharethrough/sharethrough.go | 6 +- adapters/sharethrough/sharethrough_test.go | 36 +-- adapters/sharethrough/utils.go | 25 +- adapters/sharethrough/utils_test.go | 67 ++-- adapters/silvermob/silvermob.go | 16 +- .../supplemental/invalid-response.json | 2 +- adapters/smaato/smaato.go | 24 +- adapters/smartadserver/smartadserver.go | 16 +- adapters/smartrtb/smartrtb.go | 12 +- .../supplemental/invalid-bid-json.json | 2 +- adapters/smartyads/smartyads.go | 14 +- adapters/somoaudience/somoaudience.go | 27 +- adapters/sonobi/sonobi.go | 14 +- adapters/sovrn/sovrn.go | 14 +- adapters/sovrn/sovrn_test.go | 22 +- adapters/synacormedia/synacormedia.go | 16 +- .../supplemental/bad_response.json | 2 +- adapters/tappx/tappx.go | 10 +- adapters/telaria/telaria.go | 24 +- adapters/triplelift/triplelift.go | 14 +- .../triplelift_native/triplelift_native.go | 18 +- adapters/ucfunnel/ucfunnel.go | 14 +- adapters/ucfunnel/ucfunnel_test.go | 60 ++-- adapters/unicorn/unicorn.go | 20 +- adapters/unruly/unruly.go | 20 +- adapters/unruly/unruly_test.go | 64 ++-- adapters/valueimpression/valueimpression.go | 12 +- .../invalid-response-unmarshall-error.json | 2 +- adapters/verizonmedia/verizonmedia.go | 20 +- adapters/visx/visx.go | 12 +- adapters/vrtcal/vrtcal.go | 8 +- adapters/yeahmobi/yeahmobi.go | 16 +- .../supplemental/bad_response.json | 2 +- adapters/yieldlab/yieldlab.go | 22 +- adapters/yieldmo/yieldmo.go | 14 +- adapters/yieldone/yieldone.go | 14 +- .../supplemental/bad_response.json | 2 +- adapters/zeroclickfraud/zeroclickfraud.go | 16 +- .../supplemental/bad-response-body.json | 2 +- amp/parse.go | 22 +- amp/parse_test.go | 12 +- analytics/config/config_test.go | 9 +- analytics/core.go | 14 +- analytics/filesystem/file_module_test.go | 7 +- analytics/pubstack/helpers/json_test.go | 9 +- analytics/pubstack/pubstack_module_test.go | 6 +- endpoints/auction.go | 4 +- endpoints/auction_test.go | 14 +- endpoints/openrtb2/amp_auction.go | 40 +-- endpoints/openrtb2/amp_auction_test.go | 114 +++---- endpoints/openrtb2/auction.go | 260 +++++++++++---- endpoints/openrtb2/auction_test.go | 302 +++++++++--------- endpoints/openrtb2/interstitial.go | 20 +- endpoints/openrtb2/interstitial_test.go | 14 +- .../audio-maxbitrate-negative.json | 28 ++ .../invalid-whole/audio-maxseq-negative.json | 28 ++ .../audio-minbitrate-negative.json | 28 ++ .../audio-sequence-negative.json | 28 ++ .../invalid-whole/banner-h-negative.json | 23 ++ .../invalid-whole/banner-w-negative.json | 23 ++ .../device-geo-accuracy-negative.json | 30 ++ .../invalid-whole/device-h-negative.json | 27 ++ .../invalid-whole/device-ppi-negative.json | 28 ++ .../invalid-whole/device-w-negative.json | 27 ++ .../invalid-whole/format-h-negative.json | 20 ++ .../invalid-whole/format-hratio-negative.json | 21 ++ .../invalid-whole/format-w-negative.json | 20 ++ .../invalid-whole/format-wmin-negative.json | 21 ++ .../invalid-whole/format-wratio-negative.json | 21 ++ .../user-geo-accuracy-negative.json | 28 ++ .../invalid-whole/video-h-negative.json | 28 ++ .../video-maxbitrate-negative.json | 28 ++ .../video-minbitrate-negative.json | 28 ++ .../invalid-whole/video-w-negative.json | 28 ++ endpoints/openrtb2/video_auction.go | 20 +- endpoints/openrtb2/video_auction_test.go | 136 ++++---- exchange/adapter_util_test.go | 8 +- exchange/auction.go | 20 +- exchange/auction_test.go | 24 +- exchange/bidder.go | 18 +- exchange/bidder_test.go | 83 +++-- exchange/bidder_validate_bids.go | 6 +- exchange/bidder_validate_bids_test.go | 38 +-- exchange/events_test.go | 6 +- exchange/exchange.go | 38 +-- exchange/exchange_test.go | 290 ++++++++--------- exchange/gdpr.go | 6 +- exchange/gdpr_test.go | 28 +- exchange/legacy.go | 32 +- exchange/legacy_test.go | 88 ++--- exchange/targeting.go | 6 +- exchange/targeting_test.go | 46 +-- exchange/utils.go | 36 +-- exchange/utils_test.go | 142 ++++---- go.mod | 5 +- go.sum | 18 +- openrtb_ext/bid_request_video.go | 18 +- openrtb_ext/deal_tier.go | 4 +- openrtb_ext/deal_tier_test.go | 4 +- openrtb_ext/response.go | 6 +- pbs/pbsrequest.go | 54 ++-- pbs/pbsresponse.go | 4 +- prebid_cache_client/client.go | 2 +- prebid_cache_client/prebid_cache.go | 4 +- privacy/ccpa/consentwriter.go | 6 +- privacy/ccpa/consentwriter_test.go | 20 +- privacy/ccpa/parsedpolicy_test.go | 4 +- privacy/ccpa/policy.go | 18 +- privacy/ccpa/policy_test.go | 144 ++++----- privacy/enforcement.go | 8 +- privacy/enforcement_test.go | 22 +- privacy/gdpr/consentwriter.go | 7 +- privacy/gdpr/consentwriter_test.go | 40 +-- privacy/lmt/ios.go | 14 +- privacy/lmt/ios_test.go | 140 ++++---- privacy/lmt/policy.go | 6 +- privacy/lmt/policy_test.go | 14 +- privacy/scrubber.go | 16 +- privacy/scrubber_test.go | 78 ++--- privacy/writer.go | 8 +- privacy/writer_test.go | 6 +- router/router.go | 2 +- 247 files changed, 3701 insertions(+), 3104 deletions(-) create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/audio-maxbitrate-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/audio-maxseq-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/audio-minbitrate-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/audio-sequence-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/banner-h-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/banner-w-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/device-geo-accuracy-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/device-h-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/device-ppi-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/device-w-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/format-h-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/format-hratio-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/format-w-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/format-wmin-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/format-wratio-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/user-geo-accuracy-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/video-h-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/video-maxbitrate-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/video-minbitrate-negative.json create mode 100644 endpoints/openrtb2/sample-requests/invalid-whole/video-w-negative.json diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index a48c18e9f58..bc7229eda99 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -51,7 +51,7 @@ type bidTtxExt struct { } // MakeRequests create the object for TTX Reqeust. -func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TtxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -77,14 +77,14 @@ func (a *TtxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters return adapterRequests, errs } -func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, error) { +func (a *TtxAdapter) makeRequest(request openrtb2.BidRequest, imp openrtb2.Imp) (*adapters.RequestData, error) { impCopy, err := makeImps(imp) if err != nil { return nil, err } - request.Imp = []openrtb.Imp{*impCopy} + request.Imp = []openrtb2.Imp{*impCopy} // Last Step reqJSON, err := json.Marshal(request) @@ -103,7 +103,7 @@ func (a *TtxAdapter) makeRequest(request openrtb.BidRequest, imp openrtb.Imp) (* }, nil } -func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) { +func makeImps(imp openrtb2.Imp) (*openrtb2.Imp, error) { if imp.Banner == nil && imp.Video == nil { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Imp ID %s must have at least one of [Banner, Video] defined", imp.ID), @@ -158,7 +158,7 @@ func makeImps(imp openrtb.Imp) (*openrtb.Imp, error) { return &imp, nil } -func makeReqExt(request *openrtb.BidRequest) ([]byte, error) { +func makeReqExt(request *openrtb2.BidRequest) ([]byte, error) { var reqExt reqExt if len(request.Ext) > 0 { @@ -181,7 +181,7 @@ func makeReqExt(request *openrtb.BidRequest) ([]byte, error) { } // MakeBids make the bids for the bid response. -func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TtxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -198,7 +198,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -227,7 +227,7 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque } -func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, error) { +func validateVideoParams(video *openrtb2.Video, prod string) (*openrtb2.Video, error) { videoCopy := *video if videoCopy.W == 0 || videoCopy.H == 0 || @@ -248,7 +248,7 @@ func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, err videoCopy.Placement = 1 if videoCopy.StartDelay == nil { - videoCopy.StartDelay = openrtb.StartDelay.Ptr(0) + videoCopy.StartDelay = openrtb2.StartDelay.Ptr(0) } } diff --git a/adapters/acuityads/acuityads.go b/adapters/acuityads/acuityads.go index 9c6f73c27f0..a461dada391 100644 --- a/adapters/acuityads/acuityads.go +++ b/adapters/acuityads/acuityads.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -31,7 +31,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getHeaders(request *openrtb.BidRequest) http.Header { +func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -55,7 +55,7 @@ func getHeaders(request *openrtb.BidRequest) http.Header { } func (a *AcuityAdsAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -87,7 +87,7 @@ func (a *AcuityAdsAdapter) MakeRequests( }}, nil } -func (a *AcuityAdsAdapter) getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtAcuityAds, error) { +func (a *AcuityAdsAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtAcuityAds, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -136,7 +136,7 @@ func (a *AcuityAdsAdapter) checkResponseStatusCodes(response *adapters.ResponseD } func (a *AcuityAdsAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -153,7 +153,7 @@ func (a *AcuityAdsAdapter) MakeBids( } responseBody := bidderRawResponse.Body - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", @@ -178,7 +178,7 @@ func (a *AcuityAdsAdapter) MakeBids( return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/adapterstest/adapter_test_util.go b/adapters/adapterstest/adapter_test_util.go index a5b3bb8b3f1..0c51a74e6b6 100644 --- a/adapters/adapterstest/adapter_test_util.go +++ b/adapters/adapterstest/adapter_test_util.go @@ -8,13 +8,13 @@ import ( "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" ) // OrtbMockService Represents a scaffolded OpenRTB service. type OrtbMockService struct { Server *httptest.Server - LastBidRequest *openrtb.BidRequest + LastBidRequest *openrtb2.BidRequest LastHttpRequest *http.Request } @@ -30,8 +30,8 @@ func BidOnTags(tags string) map[string]bool { } // SampleBid Produces a sample bid based on params given. -func SampleBid(width *uint64, height *uint64, impId string, index int) openrtb.Bid { - return openrtb.Bid{ +func SampleBid(width *int64, height *int64, impId string, index int) openrtb2.Bid { + return openrtb2.Bid{ ID: "Bid-123", ImpID: fmt.Sprintf("div-adunit-%d", index), Price: 2.1, @@ -64,7 +64,7 @@ func VerifyBoolValue(value bool, expected bool, t *testing.T) { } // VerifyBannerSize helper function to assert banner size -func VerifyBannerSize(banner *openrtb.Banner, expectedWidth int, expectedHeight int, t *testing.T) { +func VerifyBannerSize(banner *openrtb2.Banner, expectedWidth int, expectedHeight int, t *testing.T) { VerifyIntValue(int(*(banner.W)), expectedWidth, t) VerifyIntValue(int(*(banner.H)), expectedHeight, t) } diff --git a/adapters/adapterstest/test_json.go b/adapters/adapterstest/test_json.go index 1e3178ed23d..e33dbddaecf 100644 --- a/adapters/adapterstest/test_json.go +++ b/adapters/adapterstest/test_json.go @@ -7,7 +7,7 @@ import ( "regexp" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff/formatter" @@ -128,7 +128,7 @@ func runSpec(t *testing.T, filename string, spec *testSpec, bidder adapters.Bidd } type testSpec struct { - BidRequest openrtb.BidRequest `json:"mockBidRequest"` + BidRequest openrtb2.BidRequest `json:"mockBidRequest"` HttpCalls []httpCall `json:"httpCalls"` BidResponses []expectedBidResponse `json:"expectedBidResponses"` MakeRequestErrors []testSpecExpectedError `json:"expectedMakeRequestsErrors"` @@ -281,7 +281,7 @@ func diffBids(t *testing.T, description string, actual *adapters.TypedBid, expec } // diffOrtbBids compares the actual Bid made by the adapter to the expectation from the JSON file. -func diffOrtbBids(t *testing.T, description string, actual *openrtb.Bid, expected json.RawMessage) { +func diffOrtbBids(t *testing.T, description string, actual *openrtb2.Bid, expected json.RawMessage) { if actual == nil { t.Errorf("Bidders cannot return nil Bids. %s was nil.", description) return diff --git a/adapters/adform/adform.go b/adapters/adform/adform.go index 79bac580f0b..df294b56154 100644 --- a/adapters/adform/adform.go +++ b/adapters/adform/adform.go @@ -13,14 +13,13 @@ import ( "strconv" "strings" + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/pbs" - - "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" "golang.org/x/net/context/ctxhttp" ) @@ -235,8 +234,8 @@ func toPBSBidSlice(adformBids []*adformBid, r *adformRequest) pbs.PBSBidSlice { BidderCode: r.bidderCode, Price: bid.Price, Adm: adm, - Width: bid.Width, - Height: bid.Height, + Width: int64(bid.Width), + Height: int64(bid.Height), DealId: bid.DealId, Creative_id: bid.CreativeId, CreativeMediaType: string(bidType), @@ -374,7 +373,7 @@ func NewAdformLegacyAdapter(httpConfig *adapters.HTTPAdapterConfig, endpointURL } } -func (a *AdformAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdformAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { adformRequest, errors := openRtbToAdformRequest(request) if len(adformRequest.adUnits) == 0 { return nil, errors @@ -392,7 +391,7 @@ func (a *AdformAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt return requests, errors } -func openRtbToAdformRequest(request *openrtb.BidRequest) (*adformRequest, []error) { +func openRtbToAdformRequest(request *openrtb2.BidRequest) (*adformRequest, []error) { adUnits := make([]*adformAdUnit, 0, len(request.Imp)) errors := make([]error, 0, len(request.Imp)) secure := false @@ -529,35 +528,35 @@ func encodeEids(eids []openrtb_ext.ExtUserEid) string { return encodedEids } -func getIPSafely(device *openrtb.Device) string { +func getIPSafely(device *openrtb2.Device) string { if device == nil { return "" } return device.IP } -func getIFASafely(device *openrtb.Device) string { +func getIFASafely(device *openrtb2.Device) string { if device == nil { return "" } return device.IFA } -func getUASafely(device *openrtb.Device) string { +func getUASafely(device *openrtb2.Device) string { if device == nil { return "" } return device.UA } -func getBuyerUIDSafely(user *openrtb.User) string { +func getBuyerUIDSafely(user *openrtb2.User) string { if user == nil { return "" } return user.BuyerUID } -func (a *AdformAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdformAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -584,7 +583,7 @@ func (a *AdformAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return bidResponse, nil } -func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb.BidRequest) *adapters.BidderResponse { +func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb2.BidRequest) *adapters.BidderResponse { bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adformBids)) currency := bidResponse.Currency @@ -598,13 +597,13 @@ func toOpenRtbBidResponse(adformBids []*adformBid, r *openrtb.BidRequest) *adapt continue } - openRtbBid := openrtb.Bid{ + openRtbBid := openrtb2.Bid{ ID: r.Imp[i].ID, ImpID: r.Imp[i].ID, Price: bid.Price, AdM: adm, - W: bid.Width, - H: bid.Height, + W: int64(bid.Width), + H: int64(bid.Height), DealID: bid.DealId, CrID: bid.CreativeId, } diff --git a/adapters/adform/adform_test.go b/adapters/adform/adform_test.go index 558453e4030..f2056c499c5 100644 --- a/adapters/adform/adform_test.go +++ b/adapters/adform/adform_test.go @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/cache/dummycache" "github.com/prebid/prebid-server/pbs" @@ -17,7 +18,6 @@ import ( "fmt" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" @@ -172,7 +172,7 @@ func TestAdformBasicResponse(t *testing.T) { if bid.Price != tag.price { t.Errorf("Incorrect bid price '%.2f' expected '%.2f'", bid.Price, tag.price) } - if bid.Width != adformTestData.width || bid.Height != adformTestData.height { + if bid.Width != int64(adformTestData.width) || bid.Height != int64(adformTestData.height) { t.Errorf("Incorrect bid size %dx%d, expected %dx%d", bid.Width, bid.Height, adformTestData.width, adformTestData.height) } if bid.Adm != tag.content { @@ -249,7 +249,7 @@ func preparePrebidRequest(serverUrl string, t *testing.T) *pbs.PBSRequest { // so User and Regs are copied from OpenRTB request, see legacy.go -> toLegacyRequest regs := getRegs() r.Regs = ®s - user := openrtb.User{ + user := openrtb2.User{ Ext: getUserExt(), } r.User = &user @@ -260,7 +260,7 @@ func preparePrebidRequest(serverUrl string, t *testing.T) *pbs.PBSRequest { func preparePrebidRequestBody(requestData aBidInfo, t *testing.T) *bytes.Buffer { prebidRequest := pbs.PBSRequest{ AdUnits: make([]pbs.AdUnit, 4), - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: requestData.deviceUA, IP: requestData.deviceIP, IFA: requestData.deviceIFA, @@ -271,10 +271,10 @@ func preparePrebidRequestBody(requestData aBidInfo, t *testing.T) *bytes.Buffer for i, tag := range requestData.tags { prebidRequest.AdUnits[i] = pbs.AdUnit{ Code: tag.code, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { - W: requestData.width, - H: requestData.height, + W: int64(requestData.width), + H: int64(requestData.height), }, }, Bids: []pbs.Bids{ @@ -332,16 +332,16 @@ func TestOpenRTBRequest(t *testing.T) { func TestOpenRTBIncorrectRequest(t *testing.T) { bidder := new(AdformAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ {ID: "incorrect-bidder-field", Ext: json.RawMessage(`{"bidder1": { "mid": "32344" }}`)}, {ID: "incorrect-adform-params", Ext: json.RawMessage(`{"bidder": { : "33" }}`)}, {ID: "mid-integer", Ext: json.RawMessage(`{"bidder": { "mid": 1.234 }}`)}, {ID: "mid-greater-then-zero", Ext: json.RawMessage(`{"bidder": { "mid": -1 }}`)}, }, - Device: &openrtb.Device{UA: "ua", IP: "ip"}, - User: &openrtb.User{BuyerUID: "buyerUID"}, + Device: &openrtb2.Device{UA: "ua", IP: "ip"}, + User: &openrtb2.User{BuyerUID: "buyerUID"}, } httpRequests, errs := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) @@ -374,36 +374,36 @@ func createTestData(secure bool) aBidInfo { return testData } -func createOpenRtbRequest(testData *aBidInfo) *openrtb.BidRequest { +func createOpenRtbRequest(testData *aBidInfo) *openrtb2.BidRequest { secure := int8(0) if testData.secure { secure = int8(1) } - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: make([]openrtb.Imp, len(testData.tags)), - Site: &openrtb.Site{ + Imp: make([]openrtb2.Imp, len(testData.tags)), + Site: &openrtb2.Site{ Page: testData.referrer, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: testData.deviceUA, IP: testData.deviceIP, IFA: testData.deviceIFA, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: testData.tid, }, - User: &openrtb.User{ + User: &openrtb2.User{ BuyerUID: testData.buyerUID, }, } for i, tag := range testData.tags { - bidRequest.Imp[i] = openrtb.Imp{ + bidRequest.Imp[i] = openrtb2.Imp{ ID: tag.code, Secure: &secure, Ext: json.RawMessage(fmt.Sprintf("{\"bidder\": %s}", formatAdUnitJson(tag))), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, } } @@ -457,7 +457,7 @@ func TestOpenRTBStandardResponse(t *testing.T) { if bid.Price != tag.price { t.Errorf("Incorrect bid price '%.2f' expected '%.2f'", bid.Price, tag.price) } - if bid.W != testData.width || bid.H != testData.height { + if bid.W != int64(testData.width) || bid.H != int64(testData.height) { t.Errorf("Incorrect bid size %dx%d, expected %dx%d", bid.W, bid.H, testData.width, testData.height) } if bid.AdM != tag.content { @@ -511,12 +511,12 @@ func TestAdformProperties(t *testing.T) { // helpers -func getRegs() openrtb.Regs { +func getRegs() openrtb2.Regs { var gdpr int8 = 1 regsExt := openrtb_ext.ExtRegs{ GDPR: &gdpr, } - regs := openrtb.Regs{} + regs := openrtb2.Regs{} regsExtData, err := json.Marshal(regsExt) if err == nil { regs.Ext = regsExtData @@ -689,37 +689,37 @@ func TestToOpenRtbBidResponse(t *testing.T) { expectedBids := 4 lastCurrency, anotherCurrency, emptyCurrency := "EUR", "USD", "" - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "banner-imp-no1", Ext: json.RawMessage(`{"bidder1": { "mid": "32341" }}`), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, { ID: "banner-imp-no2", Ext: json.RawMessage(`{"bidder1": { "mid": "32342" }}`), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, { ID: "banner-imp-no3", Ext: json.RawMessage(`{"bidder1": { "mid": "32343" }}`), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, { ID: "banner-imp-no4", Ext: json.RawMessage(`{"bidder1": { "mid": "32344" }}`), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, { ID: "video-imp-no4", Ext: json.RawMessage(`{"bidder1": { "mid": "32345" }}`), - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, }, - Device: &openrtb.Device{UA: "ua", IP: "ip"}, - User: &openrtb.User{BuyerUID: "buyerUID"}, + Device: &openrtb2.Device{UA: "ua", IP: "ip"}, + User: &openrtb2.User{BuyerUID: "buyerUID"}, } testAdformBids := []*adformBid{ diff --git a/adapters/adgeneration/adgeneration.go b/adapters/adgeneration/adgeneration.go index b726d0c103a..fd87c6f4034 100644 --- a/adapters/adgeneration/adgeneration.go +++ b/adapters/adgeneration/adgeneration.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -41,7 +41,7 @@ type adgServerResponse struct { Results []interface{} `json:"results"` } -func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adg *AdgenerationAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { numRequests := len(request.Imp) var errs []error @@ -79,7 +79,7 @@ func (adg *AdgenerationAdapter) MakeRequests(request *openrtb.BidRequest, reqInf return bidRequestArray, errs } -func (adg *AdgenerationAdapter) getRequestUri(request *openrtb.BidRequest, index int) (string, error) { +func (adg *AdgenerationAdapter) getRequestUri(request *openrtb2.BidRequest, index int) (string, error) { imp := request.Imp[index] adgExt, err := unmarshalExtImpAdgeneration(&imp) if err != nil { @@ -98,7 +98,7 @@ func (adg *AdgenerationAdapter) getRequestUri(request *openrtb.BidRequest, index return uriObj.String(), err } -func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidRequest, imp *openrtb.Imp) *url.Values { +func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb2.BidRequest, imp *openrtb2.Imp) *url.Values { v := url.Values{} v.Set("posall", "SSPLOC") v.Set("id", id) @@ -121,7 +121,7 @@ func (adg *AdgenerationAdapter) getRawQuery(id string, request *openrtb.BidReque return &v } -func unmarshalExtImpAdgeneration(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdgeneration, error) { +func unmarshalExtImpAdgeneration(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdgeneration, error) { var bidderExt adapters.ExtImpBidder var adgExt openrtb_ext.ExtImpAdgeneration if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { @@ -136,13 +136,13 @@ func unmarshalExtImpAdgeneration(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdgenerat return &adgExt, nil } -func getSizes(imp *openrtb.Imp) string { +func getSizes(imp *openrtb2.Imp) string { if imp.Banner == nil || len(imp.Banner.Format) == 0 { return "" } var sizeStr string for _, v := range imp.Banner.Format { - sizeStr += strconv.FormatUint(v.W, 10) + "x" + strconv.FormatUint(v.H, 10) + "," + sizeStr += strconv.FormatInt(v.W, 10) + "x" + strconv.FormatInt(v.H, 10) + "," } if len(sizeStr) > 0 && strings.LastIndex(sizeStr, ",") == len(sizeStr)-1 { sizeStr = sizeStr[:len(sizeStr)-1] @@ -150,7 +150,7 @@ func getSizes(imp *openrtb.Imp) string { return sizeStr } -func (adg *AdgenerationAdapter) getCurrency(request *openrtb.BidRequest) string { +func (adg *AdgenerationAdapter) getCurrency(request *openrtb2.BidRequest) string { if len(request.Cur) <= 0 { return adg.defaultCurrency } else { @@ -163,7 +163,7 @@ func (adg *AdgenerationAdapter) getCurrency(request *openrtb.BidRequest) string } } -func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -202,13 +202,13 @@ func (adg *AdgenerationAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex impId = v.ID bitType = openrtb_ext.BidTypeBanner adm = createAd(&bidResp, impId) - bid := openrtb.Bid{ + bid := openrtb2.Bid{ ID: bidResp.Locationid, ImpID: impId, AdM: adm, Price: bidResp.Cpm, - W: bidResp.W, - H: bidResp.H, + W: int64(bidResp.W), + H: int64(bidResp.H), CrID: bidResp.Creativeid, DealID: bidResp.Dealid, } diff --git a/adapters/adgeneration/adgeneration_test.go b/adapters/adgeneration/adgeneration_test.go index f63c99cb92d..01fff96ede1 100644 --- a/adapters/adgeneration/adgeneration_test.go +++ b/adapters/adgeneration/adgeneration_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -34,27 +34,27 @@ func TestgetRequestUri(t *testing.T) { bidderAdgeneration, _ := bidder.(*AdgenerationAdapter) // Test items - failedRequest := &openrtb.BidRequest{ + failedRequest := &openrtb2.BidRequest{ ID: "test-failed-bid-request", - Imp: []openrtb.Imp{ - {ID: "extImpBidder-failed-test", Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{{ "id": "58278" }}`)}, - {ID: "extImpBidder-failed-test", Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"_bidder": { "id": "58278" }}`)}, - {ID: "extImpAdgeneration-failed-test", Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "_id": "58278" }}`)}, + Imp: []openrtb2.Imp{ + {ID: "extImpBidder-failed-test", Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{{ "id": "58278" }}`)}, + {ID: "extImpBidder-failed-test", Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"_bidder": { "id": "58278" }}`)}, + {ID: "extImpAdgeneration-failed-test", Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "_id": "58278" }}`)}, }, - Source: &openrtb.Source{TID: "SourceTID"}, - Device: &openrtb.Device{UA: "testUA", IP: "testIP"}, - Site: &openrtb.Site{Page: "https://supership.com"}, - User: &openrtb.User{BuyerUID: "buyerID"}, + Source: &openrtb2.Source{TID: "SourceTID"}, + Device: &openrtb2.Device{UA: "testUA", IP: "testIP"}, + Site: &openrtb2.Site{Page: "https://supership.com"}, + User: &openrtb2.User{BuyerUID: "buyerID"}, } - successRequest := &openrtb.BidRequest{ + successRequest := &openrtb2.BidRequest{ ID: "test-success-bid-request", - Imp: []openrtb.Imp{ - {ID: "bidRequest-success-test", Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "id": "58278" }}`)}, + Imp: []openrtb2.Imp{ + {ID: "bidRequest-success-test", Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "id": "58278" }}`)}, }, - Source: &openrtb.Source{TID: "SourceTID"}, - Device: &openrtb.Device{UA: "testUA", IP: "testIP"}, - Site: &openrtb.Site{Page: "https://supership.com"}, - User: &openrtb.User{BuyerUID: "buyerID"}, + Source: &openrtb2.Source{TID: "SourceTID"}, + Device: &openrtb2.Device{UA: "testUA", IP: "testIP"}, + Site: &openrtb2.Site{Page: "https://supership.com"}, + User: &openrtb2.User{BuyerUID: "buyerID"}, } numRequests := len(failedRequest.Imp) @@ -108,23 +108,23 @@ func TestgetRequestUri(t *testing.T) { func TestGetSizes(t *testing.T) { // Test items - var request *openrtb.Imp + var request *openrtb2.Imp var size string - multiFormatBanner := &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 320, H: 50}}} - noFormatBanner := &openrtb.Banner{Format: []openrtb.Format{}} - nativeFormat := &openrtb.Native{} + multiFormatBanner := &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 320, H: 50}}} + noFormatBanner := &openrtb2.Banner{Format: []openrtb2.Format{}} + nativeFormat := &openrtb2.Native{} - request = &openrtb.Imp{Banner: multiFormatBanner} + request = &openrtb2.Imp{Banner: multiFormatBanner} size = getSizes(request) if size != "300x250,320x50" { t.Errorf("%v does not match size.", multiFormatBanner) } - request = &openrtb.Imp{Banner: noFormatBanner} + request = &openrtb2.Imp{Banner: noFormatBanner} size = getSizes(request) if size != "" { t.Errorf("%v does not match size.", noFormatBanner) } - request = &openrtb.Imp{Native: nativeFormat} + request = &openrtb2.Imp{Native: nativeFormat} size = getSizes(request) if size != "" { t.Errorf("%v does not match size.", nativeFormat) @@ -142,17 +142,17 @@ func TestGetCurrency(t *testing.T) { bidderAdgeneration, _ := bidder.(*AdgenerationAdapter) // Test items - var request *openrtb.BidRequest + var request *openrtb2.BidRequest var currency string innerDefaultCur := []string{"USD", "JPY"} usdCur := []string{"USD", "EUR"} - request = &openrtb.BidRequest{Cur: innerDefaultCur} + request = &openrtb2.BidRequest{Cur: innerDefaultCur} currency = bidderAdgeneration.getCurrency(request) if currency != "JPY" { t.Errorf("%v does not match currency.", innerDefaultCur) } - request = &openrtb.BidRequest{Cur: usdCur} + request = &openrtb2.BidRequest{Cur: usdCur} currency = bidderAdgeneration.getCurrency(request) if currency != "USD" { t.Errorf("%v does not match currency.", usdCur) @@ -212,14 +212,14 @@ func TestMakeBids(t *testing.T) { bidderAdgeneration, _ := bidder.(*AdgenerationAdapter) - internalRequest := &openrtb.BidRequest{ + internalRequest := &openrtb2.BidRequest{ ID: "test-success-bid-request", - Imp: []openrtb.Imp{ - {ID: "bidRequest-success-test", Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "id": "58278" }}`)}, + Imp: []openrtb2.Imp{ + {ID: "bidRequest-success-test", Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(`{"bidder": { "id": "58278" }}`)}, }, - Device: &openrtb.Device{UA: "testUA", IP: "testIP"}, - Site: &openrtb.Site{Page: "https://supership.com"}, - User: &openrtb.User{BuyerUID: "buyerID"}, + Device: &openrtb2.Device{UA: "testUA", IP: "testIP"}, + Site: &openrtb2.Site{Page: "https://supership.com"}, + User: &openrtb2.User{BuyerUID: "buyerID"}, } externalRequest := adapters.RequestData{} response := adapters.ResponseData{ @@ -254,8 +254,8 @@ func checkBidResponse(t *testing.T, bidderResponse *adapters.BidderResponse, exp var expectedID string = "58278" var expectedImpID = "bidRequest-success-test" var expectedPrice float64 = 30.0 - var expectedW uint64 = 300 - var expectedH uint64 = 250 + var expectedW int64 = 300 + var expectedH int64 = 250 var expectedCrID string = "Dummy_supership.jp" var extectedDealID string = "test-deal-id" diff --git a/adapters/adhese/adhese.go b/adapters/adhese/adhese.go index e13c03a101d..773b3b98fd6 100644 --- a/adapters/adhese/adhese.go +++ b/adapters/adhese/adhese.go @@ -11,7 +11,7 @@ import ( "text/template" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -57,7 +57,7 @@ func extractTargetParameters(parameters openrtb_ext.ExtImpAdhese) string { return parametersAsString } -func extractGdprParameter(request *openrtb.BidRequest) string { +func extractGdprParameter(request *openrtb2.BidRequest) string { if request.User != nil { var extUser openrtb_ext.ExtUser if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { @@ -67,21 +67,21 @@ func extractGdprParameter(request *openrtb.BidRequest) string { return "" } -func extractRefererParameter(request *openrtb.BidRequest) string { +func extractRefererParameter(request *openrtb2.BidRequest) string { if request.Site != nil && request.Site.Page != "" { return "/xf" + url.QueryEscape(request.Site.Page) } return "" } -func extractIfaParameter(request *openrtb.BidRequest) string { +func extractIfaParameter(request *openrtb2.BidRequest) string { if request.Device != nil && request.Device.IFA != "" { return "/xz" + url.QueryEscape(request.Device.IFA) } return "" } -func (a *AdheseAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdheseAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) var err error @@ -128,14 +128,14 @@ func (a *AdheseAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt }}, errs } -func (a *AdheseAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdheseAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } else if response.StatusCode != http.StatusOK { return nil, []error{WrapServerError(fmt.Sprintf("Unexpected status code: %d.", response.StatusCode))} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse var adheseBidResponseArray []AdheseBid if err := json.Unmarshal(response.Body, &adheseBidResponseArray); err != nil { @@ -163,11 +163,11 @@ func (a *AdheseAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe if err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Could not parse Price %v as float ", string(adheseBid.Extension.Prebid.Cpm.Amount)))} } - width, err := strconv.ParseUint(adheseBid.Width, 10, 64) + width, err := strconv.ParseInt(adheseBid.Width, 10, 64) if err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Could not parse Width %v as int ", string(adheseBid.Width)))} } - height, err := strconv.ParseUint(adheseBid.Height, 10, 64) + height, err := strconv.ParseInt(adheseBid.Height, 10, 64) if err != nil { return nil, []error{err, WrapServerError(fmt.Sprintf("Could not parse Height %v as int ", string(adheseBid.Height)))} } @@ -198,16 +198,16 @@ func (a *AdheseAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return bidderResponse, errs } -func convertAdheseBid(adheseBid AdheseBid, adheseExt AdheseExt, adheseOriginData AdheseOriginData) openrtb.BidResponse { +func convertAdheseBid(adheseBid AdheseBid, adheseExt AdheseExt, adheseOriginData AdheseOriginData) openrtb2.BidResponse { adheseExtJson, err := json.Marshal(adheseOriginData) if err != nil { glog.Error(fmt.Sprintf("Unable to parse adhese Origin Data as JSON due to %v", err)) adheseExtJson = make([]byte, 0) } - return openrtb.BidResponse{ + return openrtb2.BidResponse{ ID: adheseExt.Id, - SeatBid: []openrtb.SeatBid{{ - Bid: []openrtb.Bid{{ + SeatBid: []openrtb2.SeatBid{{ + Bid: []openrtb2.Bid{{ DealID: adheseExt.OrderId, CrID: adheseExt.Id, AdM: getAdMarkup(adheseBid, adheseExt), @@ -218,8 +218,8 @@ func convertAdheseBid(adheseBid AdheseBid, adheseExt AdheseExt, adheseOriginData } } -func convertAdheseOpenRtbBid(adheseBid AdheseBid) openrtb.BidResponse { - var response openrtb.BidResponse = adheseBid.OriginData +func convertAdheseOpenRtbBid(adheseBid AdheseBid) openrtb2.BidResponse { + var response openrtb2.BidResponse = adheseBid.OriginData if len(response.SeatBid) > 0 && len(response.SeatBid[0].Bid) > 0 { response.SeatBid[0].Bid[0].AdM = adheseBid.Body } diff --git a/adapters/adhese/utils.go b/adapters/adhese/utils.go index 9983be96d38..c83f9ef1480 100644 --- a/adapters/adhese/utils.go +++ b/adapters/adhese/utils.go @@ -1,6 +1,6 @@ package adhese -import "github.com/mxmCherry/openrtb" +import "github.com/mxmCherry/openrtb/v14/openrtb2" type AdheseOriginData struct { Priority string `json:"priority"` @@ -22,13 +22,13 @@ type AdheseExt struct { } type AdheseBid struct { - Origin string `json:"origin"` - OriginData openrtb.BidResponse `json:"originData"` - OriginInstance string `json:"originInstance,omitempty"` - Body string `json:"body,omitempty"` - Height string `json:"height"` - Width string `json:"width"` - Extension Prebid `json:"extension"` + Origin string `json:"origin"` + OriginData openrtb2.BidResponse `json:"originData"` + OriginInstance string `json:"originInstance,omitempty"` + Body string `json:"body,omitempty"` + Height string `json:"height"` + Width string `json:"width"` + Extension Prebid `json:"extension"` } type Prebid struct { diff --git a/adapters/adkernel/adkernel.go b/adapters/adkernel/adkernel.go index 6bedeec612f..93fb3c6f93d 100644 --- a/adapters/adkernel/adkernel.go +++ b/adapters/adkernel/adkernel.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,7 +20,7 @@ type adkernelAdapter struct { } //MakeRequests prepares request information for prebid-server core -func (adapter *adkernelAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *adkernelAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, newBadInputError("No impression in the bid request")) @@ -52,10 +52,10 @@ func (adapter *adkernelAdapter) MakeRequests(request *openrtb.BidRequest, reqInf } // getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts -func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImpAdkernel, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) ([]openrtb2.Imp, []openrtb_ext.ExtImpAdkernel, []error) { impsCount := len(imps) errors := make([]error, 0, impsCount) - resImps := make([]openrtb.Imp, 0, impsCount) + resImps := make([]openrtb2.Imp, 0, impsCount) resImpExts := make([]openrtb_ext.ExtImpAdkernel, 0, impsCount) for _, imp := range imps { @@ -74,7 +74,7 @@ func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImp return resImps, resImpExts, errors } -func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdkernel) error { +func validateImpression(imp *openrtb2.Imp, impExt *openrtb_ext.ExtImpAdkernel) error { if impExt.ZoneId < 1 { return newBadInputError(fmt.Sprintf("Invalid zoneId value: %d. Ignoring imp id=%s", impExt.ZoneId, imp.ID)) } @@ -88,8 +88,8 @@ func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdkernel) er } //Group impressions by AdKernel-specific parameters `zoneId` & `host` -func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkernel) (map[openrtb_ext.ExtImpAdkernel][]openrtb.Imp, []error) { - res := make(map[openrtb_ext.ExtImpAdkernel][]openrtb.Imp) +func dispatchImpressions(imps []openrtb2.Imp, impsExt []openrtb_ext.ExtImpAdkernel) (map[openrtb_ext.ExtImpAdkernel][]openrtb2.Imp, []error) { + res := make(map[openrtb_ext.ExtImpAdkernel][]openrtb2.Imp) errors := make([]error, 0) for idx := range imps { imp := imps[idx] @@ -100,7 +100,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkerne } impExt := impsExt[idx] if res[impExt] == nil { - res[impExt] = make([]openrtb.Imp, 0) + res[impExt] = make([]openrtb2.Imp, 0) } res[impExt] = append(res[impExt], imp) } @@ -108,7 +108,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkerne } //Alter impression info to comply with adkernel platform requirements -func compatImpression(imp *openrtb.Imp) error { +func compatImpression(imp *openrtb2.Imp) error { imp.Ext = nil //do not forward ext to adkernel platform if imp.Banner != nil { return compatBannerImpression(imp) @@ -119,21 +119,21 @@ func compatImpression(imp *openrtb.Imp) error { return newBadInputError("Invalid impression") } -func compatBannerImpression(imp *openrtb.Imp) error { +func compatBannerImpression(imp *openrtb2.Imp) error { imp.Audio = nil imp.Video = nil imp.Native = nil return nil } -func compatVideoImpression(imp *openrtb.Imp) error { +func compatVideoImpression(imp *openrtb2.Imp) error { imp.Banner = nil imp.Audio = nil imp.Native = nil return nil } -func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdkernel, error) { +func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdkernel, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -149,7 +149,7 @@ func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdkernel, error) { return &adkernelExt, nil } -func (adapter *adkernelAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdkernel, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *adkernelAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdkernel, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -173,7 +173,7 @@ func (adapter *adkernelAdapter) buildAdapterRequest(prebidBidRequest *openrtb.Bi Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdkernel, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdkernel, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps if bidRequest.Site != nil { @@ -198,7 +198,7 @@ func (adapter *adkernelAdapter) buildEndpointURL(params *openrtb_ext.ExtImpAdker } //MakeBids translates adkernel bid response to prebid-server specific format -func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -207,7 +207,7 @@ func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex newBadServerResponseError(fmt.Sprintf("Unexpected http status code: %d", response.StatusCode)), } } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ newBadServerResponseError(fmt.Sprintf("Bad server response: %d", err)), @@ -233,7 +233,7 @@ func (adapter *adkernelAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex } // getMediaTypeForImp figures out which media type this bid is for -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Banner != nil { return openrtb_ext.BidTypeBanner diff --git a/adapters/adkernelAdn/adkernelAdn.go b/adapters/adkernelAdn/adkernelAdn.go index acd27c9e894..01024baad61 100644 --- a/adapters/adkernelAdn/adkernelAdn.go +++ b/adapters/adkernelAdn/adkernelAdn.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -22,7 +22,7 @@ type adkernelAdnAdapter struct { } //MakeRequests prepares request information for prebid-server core -func (adapter *adkernelAdnAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *adkernelAdnAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, newBadInputError("No impression in the bid request")) @@ -54,10 +54,10 @@ func (adapter *adkernelAdnAdapter) MakeRequests(request *openrtb.BidRequest, req } // getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts -func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImpAdkernelAdn, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) ([]openrtb2.Imp, []openrtb_ext.ExtImpAdkernelAdn, []error) { impsCount := len(imps) errors := make([]error, 0, impsCount) - resImps := make([]openrtb.Imp, 0, impsCount) + resImps := make([]openrtb2.Imp, 0, impsCount) resImpExts := make([]openrtb_ext.ExtImpAdkernelAdn, 0, impsCount) for _, imp := range imps { @@ -77,7 +77,7 @@ func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImp return resImps, resImpExts, errors } -func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdkernelAdn) error { +func validateImpression(imp *openrtb2.Imp, impExt *openrtb_ext.ExtImpAdkernelAdn) error { if impExt.PublisherID < 1 { return newBadInputError(fmt.Sprintf("Invalid pubId value. Ignoring imp id=%s", imp.ID)) } @@ -88,8 +88,8 @@ func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdkernelAdn) } //Group impressions by AdKernel-specific parameters `pubId` & `host` -func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkernelAdn) (map[openrtb_ext.ExtImpAdkernelAdn][]openrtb.Imp, []error) { - res := make(map[openrtb_ext.ExtImpAdkernelAdn][]openrtb.Imp) +func dispatchImpressions(imps []openrtb2.Imp, impsExt []openrtb_ext.ExtImpAdkernelAdn) (map[openrtb_ext.ExtImpAdkernelAdn][]openrtb2.Imp, []error) { + res := make(map[openrtb_ext.ExtImpAdkernelAdn][]openrtb2.Imp) errors := make([]error, 0) for idx := range imps { imp := imps[idx] @@ -100,7 +100,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkerne } impExt := impsExt[idx] if res[impExt] == nil { - res[impExt] = make([]openrtb.Imp, 0) + res[impExt] = make([]openrtb2.Imp, 0) } res[impExt] = append(res[impExt], imp) @@ -109,7 +109,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdkerne } //Alter impression info to comply with adkernel platform requirements -func compatImpression(imp *openrtb.Imp) error { +func compatImpression(imp *openrtb2.Imp) error { imp.Ext = nil //do not forward ext to adkernel platform if imp.Banner != nil { return compatBannerImpression(imp) @@ -120,7 +120,7 @@ func compatImpression(imp *openrtb.Imp) error { return newBadInputError("Unsupported impression has been received") } -func compatBannerImpression(imp *openrtb.Imp) error { +func compatBannerImpression(imp *openrtb2.Imp) error { // Create a copy of the banner, since imp is a shallow copy of the original. bannerCopy := *imp.Banner banner := &bannerCopy @@ -143,14 +143,14 @@ func compatBannerImpression(imp *openrtb.Imp) error { return nil } -func compatVideoImpression(imp *openrtb.Imp) error { +func compatVideoImpression(imp *openrtb2.Imp) error { imp.Banner = nil imp.Audio = nil imp.Native = nil return nil } -func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdkernelAdn, error) { +func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdkernelAdn, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -166,7 +166,7 @@ func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdkernelAdn, error) return &adkernelAdnExt, nil } -func (adapter *adkernelAdnAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdkernelAdn, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *adkernelAdnAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdkernelAdn, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -190,7 +190,7 @@ func (adapter *adkernelAdnAdapter) buildAdapterRequest(prebidBidRequest *openrtb Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdkernelAdn, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdkernelAdn, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps @@ -222,7 +222,7 @@ func (adapter *adkernelAdnAdapter) buildEndpointURL(params *openrtb_ext.ExtImpAd } //MakeBids translates adkernel bid response to prebid-server specific format -func (adapter *adkernelAdnAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *adkernelAdnAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -231,7 +231,7 @@ func (adapter *adkernelAdnAdapter) MakeBids(internalRequest *openrtb.BidRequest, newBadServerResponseError(fmt.Sprintf("Unexpected http status code: %d", response.StatusCode)), } } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{ newBadServerResponseError(fmt.Sprintf("Bad server response: %d", err)), @@ -257,7 +257,7 @@ func (adapter *adkernelAdnAdapter) MakeBids(internalRequest *openrtb.BidRequest, } // getMediaTypeForImp figures out which media type this bid is for -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Banner != nil { return openrtb_ext.BidTypeBanner diff --git a/adapters/adman/adman.go b/adapters/adman/adman.go index e0f67db816f..0eab6204b6d 100644 --- a/adapters/adman/adman.go +++ b/adapters/adman/adman.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -30,7 +30,7 @@ type admanParams struct { } // MakeRequests create bid request for adman demand -func (a *AdmanAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdmanAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var admanExt openrtb_ext.ExtImpAdman var err error @@ -39,7 +39,7 @@ func (a *AdmanAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte reqCopy := *request for _, imp := range request.Imp { - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} var bidderExt adapters.ExtImpBidder if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { @@ -63,7 +63,7 @@ func (a *AdmanAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte return adapterRequests, errs } -func (a *AdmanAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *AdmanAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error @@ -86,7 +86,7 @@ func (a *AdmanAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Reque } // MakeBids makes the bids -func (a *AdmanAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdmanAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -99,7 +99,7 @@ func (a *AdmanAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -124,7 +124,7 @@ func (a *AdmanAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/adman/admantest/supplemental/bad_response.json b/adapters/adman/admantest/supplemental/bad_response.json index d5a28c74256..4431a328154 100644 --- a/adapters/adman/admantest/supplemental/bad_response.json +++ b/adapters/adman/admantest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/admixer/admixer.go b/adapters/admixer/admixer.go index eff93746df2..86d7bfd9d5f 100644 --- a/adapters/admixer/admixer.go +++ b/adapters/admixer/admixer.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -28,7 +28,7 @@ type admixerImpExt struct { CustomParams map[string]interface{} `json:"customParams"` } -func (a *AdmixerAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { +func (a *AdmixerAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { rq, errs := a.makeRequest(request) if len(errs) > 0 { @@ -43,9 +43,9 @@ func (a *AdmixerAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return } -func (a *AdmixerAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *AdmixerAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ @@ -84,7 +84,7 @@ func (a *AdmixerAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Req }, errs } -func preprocess(imp *openrtb.Imp) error { +func preprocess(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ @@ -126,7 +126,7 @@ func preprocess(imp *openrtb.Imp) error { return nil } -func (a *AdmixerAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdmixerAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -149,7 +149,7 @@ func (a *AdmixerAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -172,7 +172,7 @@ func (a *AdmixerAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR return bidResponse, nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/adocean/adocean.go b/adapters/adocean/adocean.go index 43aa067b3a9..97ace405ab0 100644 --- a/adapters/adocean/adocean.go +++ b/adapters/adocean/adocean.go @@ -13,7 +13,7 @@ import ( "strings" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -80,7 +80,7 @@ type AdOceanAdapter struct { measurementCode string } -func (a *AdOceanAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdOceanAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ Message: "No impression in the bid request", @@ -119,8 +119,8 @@ func (a *AdOceanAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap func (a *AdOceanAdapter) addNewBid( requestsData []*requestData, - imp *openrtb.Imp, - request *openrtb.BidRequest, + imp *openrtb2.Imp, + request *openrtb2.BidRequest, consentString string, ) ([]*requestData, error) { var bidderExt adapters.ExtImpBidder @@ -177,7 +177,7 @@ func (a *AdOceanAdapter) addNewBid( return requestsData, nil } -func addToExistingRequest(requestsData []*requestData, newParams *openrtb_ext.ExtImpAdOcean, imp *openrtb.Imp, testImp bool) bool { +func addToExistingRequest(requestsData []*requestData, newParams *openrtb_ext.ExtImpAdOcean, imp *openrtb2.Imp, testImp bool) bool { auctionID := imp.ID for _, requestData := range requestsData { @@ -209,8 +209,8 @@ func addToExistingRequest(requestsData []*requestData, newParams *openrtb_ext.Ex func (a *AdOceanAdapter) makeURL( params *openrtb_ext.ExtImpAdOcean, - imp *openrtb.Imp, - request *openrtb.BidRequest, + imp *openrtb2.Imp, + request *openrtb2.BidRequest, slaveSizes map[string]string, consentString string, ) (*url.URL, error) { @@ -256,7 +256,7 @@ func (a *AdOceanAdapter) makeURL( return endpointURL, nil } -func getImpSizes(imp *openrtb.Imp) string { +func getImpSizes(imp *openrtb2.Imp) string { if imp.Banner == nil { return "" } @@ -264,14 +264,14 @@ func getImpSizes(imp *openrtb.Imp) string { if len(imp.Banner.Format) > 0 { sizes := make([]string, len(imp.Banner.Format)) for i, format := range imp.Banner.Format { - sizes[i] = strconv.FormatUint(format.W, 10) + "x" + strconv.FormatUint(format.H, 10) + sizes[i] = strconv.FormatInt(format.W, 10) + "x" + strconv.FormatInt(format.H, 10) } return strings.Join(sizes, "_") } if imp.Banner.W != nil && imp.Banner.H != nil { - return strconv.FormatUint(*imp.Banner.W, 10) + "x" + strconv.FormatUint(*imp.Banner.H, 10) + return strconv.FormatInt(*imp.Banner.W, 10) + "x" + strconv.FormatInt(*imp.Banner.H, 10) } return "" @@ -304,7 +304,7 @@ func setSlaveSizesParam(queryParams *url.Values, slaveSizes map[string]string, o } func (a *AdOceanAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { @@ -337,8 +337,8 @@ func (a *AdOceanAdapter) MakeBids( } price, _ := strconv.ParseFloat(bid.Price, 64) - width, _ := strconv.ParseUint(bid.Width, 10, 64) - height, _ := strconv.ParseUint(bid.Height, 10, 64) + width, _ := strconv.ParseInt(bid.Width, 10, 64) + height, _ := strconv.ParseInt(bid.Height, 10, 64) adCode, err := a.prepareAdCodeForBid(bid) if err != nil { errors = append(errors, err) @@ -346,7 +346,7 @@ func (a *AdOceanAdapter) MakeBids( } parsedResponses.Bids = append(parsedResponses.Bids, &adapters.TypedBid{ - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ ID: bid.ID, ImpID: auctionID, Price: price, diff --git a/adapters/adoppler/adoppler.go b/adapters/adoppler/adoppler.go index adbb177d887..56fae4295b4 100644 --- a/adapters/adoppler/adoppler.go +++ b/adapters/adoppler/adoppler.go @@ -8,7 +8,7 @@ import ( "net/url" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -50,7 +50,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } func (ads *AdopplerAdapter) MakeRequests( - req *openrtb.BidRequest, + req *openrtb2.BidRequest, info *adapters.ExtraRequestInfo, ) ( []*adapters.RequestData, @@ -69,9 +69,9 @@ func (ads *AdopplerAdapter) MakeRequests( continue } - var r openrtb.BidRequest = *req + var r openrtb2.BidRequest = *req r.ID = req.ID + "-" + ext.AdUnit - r.Imp = []openrtb.Imp{imp} + r.Imp = []openrtb2.Imp{imp} body, err := json.Marshal(r) if err != nil { @@ -99,7 +99,7 @@ func (ads *AdopplerAdapter) MakeRequests( } func (ads *AdopplerAdapter) MakeBids( - intReq *openrtb.BidRequest, + intReq *openrtb2.BidRequest, extReq *adapters.RequestData, resp *adapters.ResponseData, ) ( @@ -119,7 +119,7 @@ func (ads *AdopplerAdapter) MakeBids( return nil, []error{err} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err := json.Unmarshal(resp.Body, &bidResp) if err != nil { err := &errortypes.BadServerResponse{ diff --git a/adapters/adoppler/adopplertest/supplemental/invalid-response.json b/adapters/adoppler/adopplertest/supplemental/invalid-response.json index d0a7d2ef84b..83aa35f0ec1 100644 --- a/adapters/adoppler/adopplertest/supplemental/invalid-response.json +++ b/adapters/adoppler/adopplertest/supplemental/invalid-response.json @@ -49,7 +49,7 @@ ], "expectedMakeBidsErrors":[ { - "value":"invalid body: json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value":"invalid body: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison":"literal" } ] diff --git a/adapters/adot/adot.go b/adapters/adot/adot.go index c58c4a1ee7a..f4fd6c23bdb 100644 --- a/adapters/adot/adot.go +++ b/adapters/adot/adot.go @@ -3,12 +3,13 @@ package adot import ( "encoding/json" "fmt" - "github.com/mxmCherry/openrtb" + "net/http" + + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" - "net/http" ) type adapter struct { @@ -32,7 +33,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var reqJSON []byte var err error @@ -53,7 +54,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex // MakeBids unpacks the server's response into Bids. // The bidder return a status code 204 when it cannot delivery an ad. -func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -70,7 +71,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -96,7 +97,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest } // getMediaTypeForBid determines which type of bid. -func getMediaTypeForBid(bid *openrtb.Bid) (openrtb_ext.BidType, error) { +func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { if bid == nil { return "", fmt.Errorf("the bid request object is nil") } diff --git a/adapters/adot/adot_test.go b/adapters/adot/adot_test.go index fca6b303626..3cb3d680ebd 100644 --- a/adapters/adot/adot_test.go +++ b/adapters/adot/adot_test.go @@ -2,13 +2,14 @@ package adot import ( "encoding/json" - "github.com/mxmCherry/openrtb" + "testing" + + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" - "testing" ) const testsBidderEndpoint = "https://dsp.adotmob.com/headerbidding/bidrequest" @@ -31,7 +32,7 @@ func TestMediaTypeError(t *testing.T) { assert.Error(t, err) byteInvalid, _ := json.Marshal(&adotBidExt{Adot: bidExt{"invalid"}}) - _, err = getMediaTypeForBid(&openrtb.Bid{Ext: json.RawMessage(byteInvalid)}) + _, err = getMediaTypeForBid(&openrtb2.Bid{Ext: json.RawMessage(byteInvalid)}) assert.Error(t, err) } @@ -59,17 +60,17 @@ func TestMediaTypeForBid(t *testing.T) { byteVideo, _ := json.Marshal(&adotBidExt{Adot: bidExt{"video"}}) byteNative, _ := json.Marshal(&adotBidExt{Adot: bidExt{"native"}}) - bidTypeBanner, _ := getMediaTypeForBid(&openrtb.Bid{Ext: json.RawMessage(byteBanner)}) + bidTypeBanner, _ := getMediaTypeForBid(&openrtb2.Bid{Ext: json.RawMessage(byteBanner)}) if bidTypeBanner != openrtb_ext.BidTypeBanner { t.Errorf("the type is not the valid one. actual: %v, expected: %v", bidTypeBanner, openrtb_ext.BidTypeBanner) } - bidTypeVideo, _ := getMediaTypeForBid(&openrtb.Bid{Ext: json.RawMessage(byteVideo)}) + bidTypeVideo, _ := getMediaTypeForBid(&openrtb2.Bid{Ext: json.RawMessage(byteVideo)}) if bidTypeVideo != openrtb_ext.BidTypeVideo { t.Errorf("the type is not the valid one. actual: %v, expected: %v", bidTypeVideo, openrtb_ext.BidTypeVideo) } - bidTypeNative, _ := getMediaTypeForBid(&openrtb.Bid{Ext: json.RawMessage(byteNative)}) + bidTypeNative, _ := getMediaTypeForBid(&openrtb2.Bid{Ext: json.RawMessage(byteNative)}) if bidTypeNative != openrtb_ext.BidTypeNative { t.Errorf("the type is not the valid one. actual: %v, expected: %v", bidTypeNative, openrtb_ext.BidTypeVideo) } diff --git a/adapters/adot/adottest/supplemental/unmarshal_error.json b/adapters/adot/adottest/supplemental/unmarshal_error.json index a87e1189a62..3094fa865e4 100644 --- a/adapters/adot/adottest/supplemental/unmarshal_error.json +++ b/adapters/adot/adottest/supplemental/unmarshal_error.json @@ -54,7 +54,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/adpone/adpone.go b/adapters/adpone/adpone.go index 7907ceb1891..ffc36cc5aba 100644 --- a/adapters/adpone/adpone.go +++ b/adapters/adpone/adpone.go @@ -5,10 +5,10 @@ import ( "fmt" "net/http" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" ) @@ -26,7 +26,7 @@ type adponeAdapter struct { } func (adapter *adponeAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -75,7 +75,7 @@ const unexpectedStatusCodeFormat = "" + "Unexpected status code: %d. Run with request.debug = 1 for more info" func (adapter *adponeAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -99,7 +99,7 @@ func (adapter *adponeAdapter) MakeBids( return nil, []error{err} } - var openRTBBidderResponse openrtb.BidResponse + var openRTBBidderResponse openrtb2.BidResponse if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/adpone/adponetest/supplemental/bad_response.json b/adapters/adpone/adponetest/supplemental/bad_response.json index 9cbc8b5d9c2..68da7064b97 100644 --- a/adapters/adpone/adponetest/supplemental/bad_response.json +++ b/adapters/adpone/adponetest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 0db9218fdb4..6489c543d56 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -27,7 +27,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests create bid request for adprime demand -func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdprimeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var err error var tagID string @@ -36,7 +36,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap reqCopy := *request for _, imp := range request.Imp { - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID") if err != nil { @@ -55,7 +55,7 @@ func (a *AdprimeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return adapterRequests, errs } -func (a *AdprimeAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *AdprimeAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error @@ -78,7 +78,7 @@ func (a *AdprimeAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Req } // MakeBids makes the bids -func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -97,7 +97,7 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -122,7 +122,7 @@ func (a *AdprimeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/adprime/adprimetest/supplemental/bad_response.json b/adapters/adprime/adprimetest/supplemental/bad_response.json index 329e9c7269f..435529a485c 100644 --- a/adapters/adprime/adprimetest/supplemental/bad_response.json +++ b/adapters/adprime/adprimetest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/adtarget/adtarget.go b/adapters/adtarget/adtarget.go index 511918bb3df..b43e7e51b07 100644 --- a/adapters/adtarget/adtarget.go +++ b/adapters/adtarget/adtarget.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,7 +20,7 @@ type adtargetImpExt struct { Adtarget openrtb_ext.ExtImpAdtarget `json:"adtarget"` } -func (a *AdtargetAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdtargetAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { totalImps := len(request.Imp) errors := make([]error, 0, totalImps) @@ -55,7 +55,7 @@ func (a *AdtargetAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada reqs := make([]*adapters.RequestData, 0, totalReqs) imps := request.Imp - request.Imp = make([]openrtb.Imp, 0, len(imps)) + request.Imp = make([]openrtb2.Imp, 0, len(imps)) for sourceId, impIndexes := range imp2source { request.Imp = request.Imp[:0] @@ -80,7 +80,7 @@ func (a *AdtargetAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada return reqs, errors } -func (a *AdtargetAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdtargetAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { if httpRes.StatusCode == http.StatusNoContent { return nil, nil @@ -90,7 +90,7 @@ func (a *AdtargetAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters. Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", httpRes.StatusCode), }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("error while decoding response, err: %s", err), @@ -137,7 +137,7 @@ func (a *AdtargetAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters. return bidResponse, errors } -func validateImpressionAndSetExt(imp *openrtb.Imp) (int, error) { +func validateImpressionAndSetExt(imp *openrtb2.Imp) (int, error) { if imp.Banner == nil && imp.Video == nil { return 0, &errortypes.BadInput{ diff --git a/adapters/adtelligent/adtelligent.go b/adapters/adtelligent/adtelligent.go index fd501fde01f..6c7bc1f3378 100644 --- a/adapters/adtelligent/adtelligent.go +++ b/adapters/adtelligent/adtelligent.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,7 +20,7 @@ type adtelligentImpExt struct { Adtelligent openrtb_ext.ExtImpAdtelligent `json:"adtelligent"` } -func (a *AdtelligentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AdtelligentAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { totalImps := len(request.Imp) errors := make([]error, 0, totalImps) @@ -55,7 +55,7 @@ func (a *AdtelligentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo * reqs := make([]*adapters.RequestData, 0, totalReqs) imps := request.Imp - request.Imp = make([]openrtb.Imp, 0, len(imps)) + request.Imp = make([]openrtb2.Imp, 0, len(imps)) for sourceId, impIds := range imp2source { request.Imp = request.Imp[:0] @@ -85,13 +85,13 @@ func (a *AdtelligentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo * } -func (a *AdtelligentAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AdtelligentAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { if httpRes.StatusCode == http.StatusNoContent { return nil, nil } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("error while decoding response, err: %s", err), @@ -138,7 +138,7 @@ func (a *AdtelligentAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapte return bidResponse, errors } -func validateImpression(imp *openrtb.Imp) (int, error) { +func validateImpression(imp *openrtb2.Imp) (int, error) { if imp.Banner == nil && imp.Video == nil { return 0, &errortypes.BadInput{ diff --git a/adapters/advangelists/advangelists.go b/adapters/advangelists/advangelists.go index 95ddec0f452..8a12089df90 100644 --- a/adapters/advangelists/advangelists.go +++ b/adapters/advangelists/advangelists.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,7 +19,7 @@ type AdvangelistsAdapter struct { } //MakeRequests prepares request information for prebid-server core -func (adapter *AdvangelistsAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *AdvangelistsAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, &errortypes.BadInput{Message: "No impression in the bid request"}) @@ -51,9 +51,9 @@ func (adapter *AdvangelistsAdapter) MakeRequests(request *openrtb.BidRequest, re } // getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts -func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImpAdvangelists, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) ([]openrtb2.Imp, []openrtb_ext.ExtImpAdvangelists, []error) { errors := make([]error, 0, len(imps)) - resImps := make([]openrtb.Imp, 0, len(imps)) + resImps := make([]openrtb2.Imp, 0, len(imps)) resImpExts := make([]openrtb_ext.ExtImpAdvangelists, 0, len(imps)) for _, imp := range imps { @@ -73,7 +73,7 @@ func getImpressionsInfo(imps []openrtb.Imp) ([]openrtb.Imp, []openrtb_ext.ExtImp return resImps, resImpExts, errors } -func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdvangelists) error { +func validateImpression(imp *openrtb2.Imp, impExt *openrtb_ext.ExtImpAdvangelists) error { if impExt.PublisherID == "" { return &errortypes.BadInput{Message: "No pubid value provided"} } @@ -81,8 +81,8 @@ func validateImpression(imp *openrtb.Imp, impExt *openrtb_ext.ExtImpAdvangelists } //Group impressions by advangelists-specific parameters `pubid -func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdvangelists) (map[openrtb_ext.ExtImpAdvangelists][]openrtb.Imp, []error) { - res := make(map[openrtb_ext.ExtImpAdvangelists][]openrtb.Imp) +func dispatchImpressions(imps []openrtb2.Imp, impsExt []openrtb_ext.ExtImpAdvangelists) (map[openrtb_ext.ExtImpAdvangelists][]openrtb2.Imp, []error) { + res := make(map[openrtb_ext.ExtImpAdvangelists][]openrtb2.Imp) errors := make([]error, 0) for idx, imp := range imps { err := compatImpression(&imp) @@ -92,7 +92,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdvange } impExt := impsExt[idx] if res[impExt] == nil { - res[impExt] = make([]openrtb.Imp, 0) + res[impExt] = make([]openrtb2.Imp, 0) } res[impExt] = append(res[impExt], imp) @@ -101,7 +101,7 @@ func dispatchImpressions(imps []openrtb.Imp, impsExt []openrtb_ext.ExtImpAdvange } //Alter impression info to comply with advangelists platform requirements -func compatImpression(imp *openrtb.Imp) error { +func compatImpression(imp *openrtb2.Imp) error { imp.Ext = nil //do not forward ext to advangelists platform if imp.Banner != nil { return compatBannerImpression(imp) @@ -109,7 +109,7 @@ func compatImpression(imp *openrtb.Imp) error { return nil } -func compatBannerImpression(imp *openrtb.Imp) error { +func compatBannerImpression(imp *openrtb2.Imp) error { // Create a copy of the banner, since imp is a shallow copy of the original. bannerCopy := *imp.Banner banner := &bannerCopy @@ -127,7 +127,7 @@ func compatBannerImpression(imp *openrtb.Imp) error { return nil } -func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdvangelists, error) { +func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpAdvangelists, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -143,7 +143,7 @@ func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpAdvangelists, error) return &advangelistsExt, nil } -func (adapter *AdvangelistsAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdvangelists, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *AdvangelistsAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdvangelists, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -167,7 +167,7 @@ func (adapter *AdvangelistsAdapter) buildAdapterRequest(prebidBidRequest *openrt Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpAdvangelists, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpAdvangelists, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps for idx := range bidRequest.Imp { @@ -197,7 +197,7 @@ func (adapter *AdvangelistsAdapter) buildEndpointURL(params *openrtb_ext.ExtImpA } //MakeBids translates advangelists bid response to prebid-server specific format -func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var msg = "" if response.StatusCode == http.StatusNoContent { return nil, nil @@ -206,7 +206,7 @@ func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb.BidRequest msg = fmt.Sprintf("Unexpected http status code: %d", response.StatusCode) return nil, []error{&errortypes.BadServerResponse{Message: msg}} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} @@ -230,7 +230,7 @@ func (adapter *AdvangelistsAdapter) MakeBids(internalRequest *openrtb.BidRequest } // getMediaTypeForImp figures out which media type this bid is for -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Video != nil { return openrtb_ext.BidTypeVideo diff --git a/adapters/adyoulike/adyoulike.go b/adapters/adyoulike/adyoulike.go index 9a137a41fef..4797341e7b5 100644 --- a/adapters/adyoulike/adyoulike.go +++ b/adapters/adyoulike/adyoulike.go @@ -9,7 +9,7 @@ import ( "net/http" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" ) @@ -25,7 +25,7 @@ type adapter struct { } func (a *adapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -35,7 +35,7 @@ func (a *adapter) MakeRequests( var tagID string reqCopy := *openRTBRequest - reqCopy.Imp = []openrtb.Imp{} + reqCopy.Imp = []openrtb2.Imp{} for ind, imp := range openRTBRequest.Imp { reqCopy.Imp = append(reqCopy.Imp, imp) @@ -77,7 +77,7 @@ const unexpectedStatusCodeFormat = "" + "Unexpected status code: %d. Run with request.debug = 1 for more info" func (a *adapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -101,7 +101,7 @@ func (a *adapter) MakeBids( return nil, []error{err} } - var openRTBBidderResponse openrtb.BidResponse + var openRTBBidderResponse openrtb2.BidResponse if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } @@ -121,7 +121,7 @@ func (a *adapter) MakeBids( } // getMediaTypeForBid determines which type of bid. -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json index b156dd65ae3..bda8d3e6640 100644 --- a/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json +++ b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json @@ -58,7 +58,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/aja/aja.go b/adapters/aja/aja.go index 07f9ad8bc96..1ff942ce4de 100644 --- a/adapters/aja/aja.go +++ b/adapters/aja/aja.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,10 +16,10 @@ type AJAAdapter struct { endpoint string } -func (a *AJAAdapter) MakeRequests(bidReq *openrtb.BidRequest, extraInfo *adapters.ExtraRequestInfo) (adapterReqs []*adapters.RequestData, errs []error) { +func (a *AJAAdapter) MakeRequests(bidReq *openrtb2.BidRequest, extraInfo *adapters.ExtraRequestInfo) (adapterReqs []*adapters.RequestData, errs []error) { // split imps by tagid tagIDs := []string{} - impsByTagID := map[string][]openrtb.Imp{} + impsByTagID := map[string][]openrtb2.Imp{} for _, imp := range bidReq.Imp { extAJA, err := parseExtAJA(imp) if err != nil { @@ -54,7 +54,7 @@ func (a *AJAAdapter) MakeRequests(bidReq *openrtb.BidRequest, extraInfo *adapter return } -func parseExtAJA(imp openrtb.Imp) (openrtb_ext.ExtImpAJA, error) { +func parseExtAJA(imp openrtb2.Imp) (openrtb_ext.ExtImpAJA, error) { var ( extImp adapters.ExtImpBidder extAJA openrtb_ext.ExtImpAJA @@ -75,7 +75,7 @@ func parseExtAJA(imp openrtb.Imp) (openrtb_ext.ExtImpAJA, error) { return extAJA, nil } -func (a *AJAAdapter) MakeBids(bidReq *openrtb.BidRequest, adapterReq *adapters.RequestData, adapterResp *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AJAAdapter) MakeBids(bidReq *openrtb2.BidRequest, adapterReq *adapters.RequestData, adapterResp *adapters.ResponseData) (*adapters.BidderResponse, []error) { if adapterResp.StatusCode != http.StatusOK { if adapterResp.StatusCode == http.StatusNoContent { return nil, nil @@ -90,7 +90,7 @@ func (a *AJAAdapter) MakeBids(bidReq *openrtb.BidRequest, adapterReq *adapters.R }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(adapterResp.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Failed to unmarshal bid response: %s", err.Error()), diff --git a/adapters/amx/amx.go b/adapters/amx/amx.go index a9dfd06f1b0..68f4ecdfbb4 100644 --- a/adapters/amx/amx.go +++ b/adapters/amx/amx.go @@ -7,7 +7,7 @@ import ( "net/url" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -49,9 +49,9 @@ type amxExt struct { Bidder openrtb_ext.ExtImpAMX `json:"bidder"` } -func ensurePublisherWithID(pub *openrtb.Publisher, publisherID string) openrtb.Publisher { +func ensurePublisherWithID(pub *openrtb2.Publisher, publisherID string) openrtb2.Publisher { if pub == nil { - return openrtb.Publisher{ID: publisherID} + return openrtb2.Publisher{ID: publisherID} } pubCopy := *pub @@ -60,7 +60,7 @@ func ensurePublisherWithID(pub *openrtb.Publisher, publisherID string) openrtb.P } // MakeRequests creates AMX adapter requests -func (adapter *AMXAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { +func (adapter *AMXAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { reqCopy := *request var publisherID string @@ -119,7 +119,7 @@ type amxBidExt struct { } // MakeBids will parse the bids from the AMX server -func (adapter *AMXAdapter) MakeBids(request *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *AMXAdapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if http.StatusNoContent == response.StatusCode { @@ -140,7 +140,7 @@ func (adapter *AMXAdapter) MakeBids(request *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -196,7 +196,7 @@ func pixelToImpression(pixel string) string { return fmt.Sprintf(vastImpressionFormat, pixel) } -func interpolateImpressions(bid openrtb.Bid, ext amxBidExt) string { +func interpolateImpressions(bid openrtb2.Bid, ext amxBidExt) string { var buffer strings.Builder if bid.NURL != "" { buffer.WriteString(pixelToImpression(bid.NURL)) diff --git a/adapters/amx/amx_test.go b/adapters/amx/amx_test.go index 8f05aec24d4..77947c068d0 100644 --- a/adapters/amx/amx_test.go +++ b/adapters/amx/amx_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" @@ -48,7 +48,7 @@ func TestEndpointQueryStringMalformed(t *testing.T) { func TestMakeRequestsTagID(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderAMX, config.Adapter{ Endpoint: amxTestEndpoint}) @@ -75,12 +75,12 @@ func TestMakeRequestsTagID(t *testing.T) { } for _, tc := range tests { - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "sample_imp_1", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} @@ -94,16 +94,16 @@ func TestMakeRequestsTagID(t *testing.T) { imp1.TagID = tc.tagID } - inputRequest := openrtb.BidRequest{ - User: &openrtb.User{}, - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{}, + inputRequest := openrtb2.BidRequest{ + User: &openrtb2.User{}, + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{}, } actualAdapterRequests, err := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) assert.Len(t, actualAdapterRequests, 1) assert.Empty(t, err) - var body openrtb.BidRequest + var body openrtb2.BidRequest assert.Nil(t, json.Unmarshal(actualAdapterRequests[0].Body, &body)) assert.Equal(t, tc.expectedTagID, body.Imp[0].TagID) } @@ -111,7 +111,7 @@ func TestMakeRequestsTagID(t *testing.T) { func TestMakeRequestsPublisherId(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderAMX, config.Adapter{ Endpoint: amxTestEndpoint}) @@ -137,12 +137,12 @@ func TestMakeRequestsPublisherId(t *testing.T) { } for _, tc := range tests { - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "sample_imp_1", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} @@ -152,15 +152,15 @@ func TestMakeRequestsPublisherId(t *testing.T) { fmt.Sprintf(`{"bidder":{"tagId":"%s"}}`, tc.extTagID)) } - inputRequest := openrtb.BidRequest{ - User: &openrtb.User{ID: "example_user_id"}, - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{}, + inputRequest := openrtb2.BidRequest{ + User: &openrtb2.User{ID: "example_user_id"}, + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{}, ID: "1234", } if tc.publisherID != "" || !tc.blankNil { - inputRequest.Site.Publisher = &openrtb.Publisher{ + inputRequest.Site.Publisher = &openrtb2.Publisher{ ID: tc.publisherID, } } @@ -168,7 +168,7 @@ func TestMakeRequestsPublisherId(t *testing.T) { actualAdapterRequests, err := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) assert.Len(t, actualAdapterRequests, 1) assert.Empty(t, err) - var body openrtb.BidRequest + var body openrtb2.BidRequest assert.Nil(t, json.Unmarshal(actualAdapterRequests[0].Body, &body)) assert.Equal(t, tc.expectedPublisherID, body.Site.Publisher.ID) } @@ -182,7 +182,7 @@ func countImpressionPixels(vast string) int { } func TestVideoImpInsertion(t *testing.T) { - markup := interpolateImpressions(openrtb.Bid{ + markup := interpolateImpressions(openrtb2.Bid{ AdM: sampleVastADM, NURL: "https://example2.com/nurl", }, amxBidExt{Himp: []string{"https://example.com/pixel.png"}}) @@ -191,14 +191,14 @@ func TestVideoImpInsertion(t *testing.T) { assert.Equal(t, 3, countImpressionPixels(markup), "should have 3 Impression pixels") // make sure that a blank NURL won't result in a blank impression tag - markup = interpolateImpressions(openrtb.Bid{ + markup = interpolateImpressions(openrtb2.Bid{ AdM: sampleVastADM, NURL: "", }, amxBidExt{}) assert.Equal(t, 1, countImpressionPixels(markup), "should have 1 impression pixels") // we should also ignore blank ext.Himp pixels - markup = interpolateImpressions(openrtb.Bid{ + markup = interpolateImpressions(openrtb2.Bid{ AdM: sampleVastADM, NURL: "https://example-nurl.com/nurl", }, amxBidExt{Himp: []string{"", "", ""}}) @@ -206,7 +206,7 @@ func TestVideoImpInsertion(t *testing.T) { } func TestNoDisplayImpInsertion(t *testing.T) { - data := interpolateImpressions(openrtb.Bid{ + data := interpolateImpressions(openrtb2.Bid{ AdM: sampleDisplayADM, NURL: "https://example2.com/nurl", }, amxBidExt{Himp: []string{"https://example.com/pixel.png"}}) diff --git a/adapters/applogy/applogy.go b/adapters/applogy/applogy.go index fe5fdc17933..6edc8135516 100644 --- a/adapters/applogy/applogy.go +++ b/adapters/applogy/applogy.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type ApplogyAdapter struct { endpoint string } -func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ApplogyAdapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -41,8 +41,8 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E continue } banner := *impression.Banner - banner.W = openrtb.Uint64Ptr(banner.Format[0].W) - banner.H = openrtb.Uint64Ptr(banner.Format[0].H) + banner.W = openrtb2.Int64Ptr(banner.Format[0].W) + banner.H = openrtb2.Int64Ptr(banner.Format[0].H) impression.Banner = &banner } } @@ -70,7 +70,7 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E errs = append(errs, errors.New("Applogy token required")) continue } - request.Imp = []openrtb.Imp{impression} + request.Imp = []openrtb2.Imp{impression} body, err := json.Marshal(request) if err != nil { errs = append(errs, err) @@ -92,7 +92,7 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E return result, errs } -func (a *ApplogyAdapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *ApplogyAdapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error switch responseData.StatusCode { @@ -110,7 +110,7 @@ func (a *ApplogyAdapter) MakeBids(request *openrtb.BidRequest, _ *adapters.Reque }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse err := json.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/appnexus/appnexus.go b/adapters/appnexus/appnexus.go index 0a8146fdc41..a384257d47b 100644 --- a/adapters/appnexus/appnexus.go +++ b/adapters/appnexus/appnexus.go @@ -12,12 +12,12 @@ import ( "strings" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/pbs" "golang.org/x/net/context/ctxhttp" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/metrics" @@ -163,9 +163,9 @@ func (a *AppNexusAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder } if anReq.Imp[i].Banner != nil && params.Position != "" { if params.Position == "above" { - anReq.Imp[i].Banner.Pos = openrtb.AdPositionAboveTheFold.Ptr() + anReq.Imp[i].Banner.Pos = openrtb2.AdPositionAboveTheFold.Ptr() } else if params.Position == "below" { - anReq.Imp[i].Banner.Pos = openrtb.AdPositionBelowTheFold.Ptr() + anReq.Imp[i].Banner.Pos = openrtb2.AdPositionBelowTheFold.Ptr() } } @@ -245,7 +245,7 @@ func (a *AppNexusAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder debug.ResponseBody = responseBody } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return nil, err @@ -288,7 +288,7 @@ func (a *AppNexusAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder return bids, nil } -func (a *AppNexusAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AppNexusAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { memberIds := make(map[string]bool) errs := make([]error, 0, len(request.Imp)) @@ -389,9 +389,9 @@ func generatePodId() string { return fmt.Sprint(val) } -func groupByPods(imps []openrtb.Imp) map[string]([]openrtb.Imp) { +func groupByPods(imps []openrtb2.Imp) map[string]([]openrtb2.Imp) { // find number of pods in response - podImps := make(map[string][]openrtb.Imp) + podImps := make(map[string][]openrtb2.Imp) for _, imp := range imps { pod := strings.Split(imp.ID, "_")[0] podImps[pod] = append(podImps[pod], imp) @@ -399,7 +399,7 @@ func groupByPods(imps []openrtb.Imp) map[string]([]openrtb.Imp) { return podImps } -func marshalAndSetRequestExt(request *openrtb.BidRequest, requestExtension appnexusReqExt, errs []error) { +func marshalAndSetRequestExt(request *openrtb2.BidRequest, requestExtension appnexusReqExt, errs []error) { var err error request.Ext, err = json.Marshal(requestExtension) if err != nil { @@ -407,7 +407,7 @@ func marshalAndSetRequestExt(request *openrtb.BidRequest, requestExtension appne } } -func splitRequests(imps []openrtb.Imp, request *openrtb.BidRequest, requestExtension appnexusReqExt, uri string, errs []error) ([]*adapters.RequestData, []error) { +func splitRequests(imps []openrtb2.Imp, request *openrtb2.BidRequest, requestExtension appnexusReqExt, uri string, errs []error) ([]*adapters.RequestData, []error) { // Initial capacity for future array of requests, memory optimization. // Let's say there are 35 impressions and limit impressions per request equals to 10. @@ -463,7 +463,7 @@ func keys(m map[string]bool) []string { // preprocess mutates the imp to get it ready to send to appnexus. // // It returns the member param, if it exists, and an error if anything went wrong during the preprocessing. -func preprocess(imp *openrtb.Imp, defaultDisplayManagerVer string) (string, error) { +func preprocess(imp *openrtb2.Imp, defaultDisplayManagerVer string) (string, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", err @@ -501,9 +501,9 @@ func preprocess(imp *openrtb.Imp, defaultDisplayManagerVer string) (string, erro if imp.Banner != nil { bannerCopy := *imp.Banner if appnexusExt.Position == "above" { - bannerCopy.Pos = openrtb.AdPositionAboveTheFold.Ptr() + bannerCopy.Pos = openrtb2.AdPositionAboveTheFold.Ptr() } else if appnexusExt.Position == "below" { - bannerCopy.Pos = openrtb.AdPositionBelowTheFold.Ptr() + bannerCopy.Pos = openrtb2.AdPositionBelowTheFold.Ptr() } // Fixes #307 @@ -550,7 +550,7 @@ func makeKeywordStr(keywords []*openrtb_ext.ExtImpAppnexusKeyVal) string { return strings.Join(kvs, ",") } -func (a *AppNexusAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AppNexusAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -565,7 +565,7 @@ func (a *AppNexusAdapter) MakeBids(internalRequest *openrtb.BidRequest, external return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/appnexus/appnexus_test.go b/adapters/appnexus/appnexus_test.go index d453a779854..076d93eacb6 100644 --- a/adapters/appnexus/appnexus_test.go +++ b/adapters/appnexus/appnexus_test.go @@ -11,6 +11,7 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" "github.com/prebid/prebid-server/cache/dummycache" @@ -20,7 +21,6 @@ import ( "fmt" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -65,16 +65,16 @@ func TestVideoSinglePod(t *testing.T) { var reqInfo adapters.ExtraRequestInfo reqInfo.PbsEntryPoint = "video" - var req openrtb.BidRequest + var req openrtb2.BidRequest req.ID = "test_id" reqExt := `{"prebid":{}}` impExt := `{"bidder":{"placementId":123}}` req.Ext = []byte(reqExt) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_2", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_2", Ext: []byte(impExt)}) result, err := a.MakeRequests(&req, &reqInfo) @@ -82,7 +82,7 @@ func TestVideoSinglePod(t *testing.T) { assert.Len(t, result, 1, "Only one request should be returned") var error error - var reqData *openrtb.BidRequest + var reqData *openrtb2.BidRequest error = json.Unmarshal(result[0].Body, &reqData) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -103,28 +103,28 @@ func TestVideoSinglePodManyImps(t *testing.T) { var reqInfo adapters.ExtraRequestInfo reqInfo.PbsEntryPoint = "video" - var req openrtb.BidRequest + var req openrtb2.BidRequest req.ID = "test_id" reqExt := `{"prebid":{}}` impExt := `{"bidder":{"placementId":123}}` req.Ext = []byte(reqExt) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_2", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_3", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_4", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_5", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_6", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_7", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_8", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_9", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_10", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_11", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_12", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_13", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_14", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_2", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_3", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_4", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_5", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_6", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_7", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_8", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_9", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_10", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_11", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_12", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_13", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_14", Ext: []byte(impExt)}) res, err := a.MakeRequests(&req, &reqInfo) @@ -132,7 +132,7 @@ func TestVideoSinglePodManyImps(t *testing.T) { assert.Len(t, res, 2, "Two requests should be returned") var error error - var reqData1 *openrtb.BidRequest + var reqData1 *openrtb2.BidRequest error = json.Unmarshal(res[0].Body, &reqData1) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -142,7 +142,7 @@ func TestVideoSinglePodManyImps(t *testing.T) { adPodId1 := reqDataExt1.Appnexus.AdPodId - var reqData2 *openrtb.BidRequest + var reqData2 *openrtb2.BidRequest error = json.Unmarshal(res[1].Body, &reqData2) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -163,20 +163,20 @@ func TestVideoTwoPods(t *testing.T) { var reqInfo adapters.ExtraRequestInfo reqInfo.PbsEntryPoint = "video" - var req openrtb.BidRequest + var req openrtb2.BidRequest req.ID = "test_id" reqExt := `{"prebid":{}}` impExt := `{"bidder":{"placementId":123}}` req.Ext = []byte(reqExt) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_2", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_2", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_2", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_2", Ext: []byte(impExt)}) res, err := a.MakeRequests(&req, &reqInfo) @@ -184,7 +184,7 @@ func TestVideoTwoPods(t *testing.T) { assert.Len(t, res, 2, "Two request should be returned") var error error - var reqData1 *openrtb.BidRequest + var reqData1 *openrtb2.BidRequest error = json.Unmarshal(res[0].Body, &reqData1) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -194,7 +194,7 @@ func TestVideoTwoPods(t *testing.T) { adPodId1 := reqDataExt1.Appnexus.AdPodId - var reqData2 *openrtb.BidRequest + var reqData2 *openrtb2.BidRequest error = json.Unmarshal(res[1].Body, &reqData2) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -215,32 +215,32 @@ func TestVideoTwoPodsManyImps(t *testing.T) { var reqInfo adapters.ExtraRequestInfo reqInfo.PbsEntryPoint = "video" - var req openrtb.BidRequest + var req openrtb2.BidRequest req.ID = "test_id" reqExt := `{"prebid":{}}` impExt := `{"bidder":{"placementId":123}}` req.Ext = []byte(reqExt) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "1_2", Ext: []byte(impExt)}) - - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_0", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_1", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_2", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_3", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_4", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_5", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_6", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_7", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_8", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_9", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_10", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_11", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_12", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_13", Ext: []byte(impExt)}) - req.Imp = append(req.Imp, openrtb.Imp{ID: "2_14", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "1_2", Ext: []byte(impExt)}) + + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_0", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_1", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_2", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_3", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_4", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_5", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_6", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_7", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_8", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_9", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_10", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_11", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_12", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_13", Ext: []byte(impExt)}) + req.Imp = append(req.Imp, openrtb2.Imp{ID: "2_14", Ext: []byte(impExt)}) res, err := a.MakeRequests(&req, &reqInfo) @@ -248,7 +248,7 @@ func TestVideoTwoPodsManyImps(t *testing.T) { assert.Len(t, res, 3, "Three requests should be returned") var error error - var reqData1 *openrtb.BidRequest + var reqData1 *openrtb2.BidRequest error = json.Unmarshal(res[0].Body, &reqData1) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -256,7 +256,7 @@ func TestVideoTwoPodsManyImps(t *testing.T) { error = json.Unmarshal(reqData1.Ext, &reqDataExt1) assert.NoError(t, error, "Response ext unmarshalling error should be nil") - var reqData2 *openrtb.BidRequest + var reqData2 *openrtb2.BidRequest error = json.Unmarshal(res[1].Body, &reqData2) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -264,7 +264,7 @@ func TestVideoTwoPodsManyImps(t *testing.T) { error = json.Unmarshal(reqData2.Ext, &reqDataExt2) assert.NoError(t, error, "Response ext unmarshalling error should be nil") - var reqData3 *openrtb.BidRequest + var reqData3 *openrtb2.BidRequest error = json.Unmarshal(res[2].Body, &reqData3) assert.NoError(t, error, "Response body unmarshalling error should be nil") @@ -286,7 +286,7 @@ func TestVideoTwoPodsManyImps(t *testing.T) { // ---------------------------------------------------------------------------- // Code below this line tests the legacy, non-openrtb code flow. It can be deleted after we -// clean up the existing code and make everything openrtb. +// clean up the existing code and make everything openrtb2. type anTagInfo struct { code string @@ -325,7 +325,7 @@ func DummyAppNexusServer(w http.ResponseWriter, r *http.Request) { return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -338,14 +338,14 @@ func DummyAppNexusServer(w http.ResponseWriter, r *http.Request) { return } - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: breq.ID, BidID: "a-random-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "Buyer Member ID", - Bid: make([]openrtb.Bid, 0, 2), + Bid: make([]openrtb2.Bid, 0, 2), }, }, } @@ -415,11 +415,11 @@ func DummyAppNexusServer(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprintf("Empty imp.banner.format array"), http.StatusInternalServerError) return } - if andata.tags[i].position == "above" && *imp.Banner.Pos != openrtb.AdPosition(1) { + if andata.tags[i].position == "above" && *imp.Banner.Pos != openrtb2.AdPosition(1) { http.Error(w, fmt.Sprintf("Mismatch in position - expected 1 for atf"), http.StatusInternalServerError) return } - if andata.tags[i].position == "below" && *imp.Banner.Pos != openrtb.AdPosition(3) { + if andata.tags[i].position == "below" && *imp.Banner.Pos != openrtb2.AdPosition(3) { http.Error(w, fmt.Sprintf("Mismatch in position - expected 3 for btf"), http.StatusInternalServerError) return } @@ -442,7 +442,7 @@ func DummyAppNexusServer(w http.ResponseWriter, r *http.Request) { } } - resBid := openrtb.Bid{ + resBid := openrtb2.Bid{ ID: "random-id", ImpID: imp.ID, Price: andata.tags[i].bid, @@ -451,7 +451,7 @@ func DummyAppNexusServer(w http.ResponseWriter, r *http.Request) { } if imp.Video != nil { - resBid.Attr = []openrtb.CreativeAttribute{openrtb.CreativeAttribute(6)} + resBid.Attr = []openrtb2.CreativeAttribute{openrtb2.CreativeAttribute(6)} } resp.SeatBid[0].Bid = append(resp.SeatBid[0].Bid, resBid) } @@ -568,7 +568,7 @@ func TestAppNexusLegacyBasicResponse(t *testing.T) { pbin.AdUnits[i] = pbs.AdUnit{ Code: tag.code, MediaTypes: []string{tag.mediaType}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 300, H: 600, diff --git a/adapters/audienceNetwork/facebook.go b/adapters/audienceNetwork/facebook.go index 909a03a2bcf..f2aaaed8f88 100644 --- a/adapters/audienceNetwork/facebook.go +++ b/adapters/audienceNetwork/facebook.go @@ -10,19 +10,18 @@ import ( "net/http" "strings" + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/util/maputil" - - "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" ) -var supportedBannerHeights = map[uint64]bool{ - 50: true, - 250: true, +var supportedBannerHeights = map[int64]struct{}{ + 50: {}, + 250: {}, } type FacebookAdapter struct { @@ -40,7 +39,7 @@ type facebookReqExt struct { AuthID string `json:"authentication_id"` } -func (this *FacebookAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (this *FacebookAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ Message: "No impressions provided", @@ -62,7 +61,7 @@ func (this *FacebookAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo * return this.buildRequests(request) } -func (this *FacebookAdapter) buildRequests(request *openrtb.BidRequest) ([]*adapters.RequestData, []error) { +func (this *FacebookAdapter) buildRequests(request *openrtb2.BidRequest) ([]*adapters.RequestData, []error) { // Documentation suggests bid request splitting by impression so that each // request only represents a single impression reqs := make([]*adapters.RequestData, 0, len(request.Imp)) @@ -77,7 +76,7 @@ func (this *FacebookAdapter) buildRequests(request *openrtb.BidRequest) ([]*adap // Make a copy of the request so that we don't change the original request which // is shared across multiple threads fbreq := *request - fbreq.Imp = []openrtb.Imp{imp} + fbreq.Imp = []openrtb2.Imp{imp} if err := this.modifyRequest(&fbreq); err != nil { errs = append(errs, err) @@ -109,14 +108,14 @@ func (this *FacebookAdapter) buildRequests(request *openrtb.BidRequest) ([]*adap // The authentication ID is a sha256 hmac hash encoded as a hex string, based on // the app secret and the ID of the bid request -func (this *FacebookAdapter) makeAuthID(req *openrtb.BidRequest) string { +func (this *FacebookAdapter) makeAuthID(req *openrtb2.BidRequest) string { h := hmac.New(sha256.New, []byte(this.appSecret)) h.Write([]byte(req.ID)) return hex.EncodeToString(h.Sum(nil)) } -func (this *FacebookAdapter) modifyRequest(out *openrtb.BidRequest) error { +func (this *FacebookAdapter) modifyRequest(out *openrtb2.BidRequest) error { if len(out.Imp) != 1 { panic("each bid request to facebook should only have a single impression") } @@ -146,7 +145,7 @@ func (this *FacebookAdapter) modifyRequest(out *openrtb.BidRequest) error { if out.App != nil { app := *out.App - app.Publisher = &openrtb.Publisher{ID: pubId} + app.Publisher = &openrtb2.Publisher{ID: pubId} out.App = &app } @@ -157,13 +156,8 @@ func (this *FacebookAdapter) modifyRequest(out *openrtb.BidRequest) error { return nil } -func (this *FacebookAdapter) modifyImp(out *openrtb.Imp) error { - impType, ok := resolveImpType(out) - if !ok { - return &errortypes.BadInput{ - Message: fmt.Sprintf("imp #%s with invalid type", out.ID), - } - } +func (this *FacebookAdapter) modifyImp(out *openrtb2.Imp) error { + impType := resolveImpType(out) if out.Instl == 1 && impType != openrtb_ext.BidTypeBanner { return &errortypes.BadInput{ @@ -176,10 +170,9 @@ func (this *FacebookAdapter) modifyImp(out *openrtb.Imp) error { out.Banner = &bannerCopy if out.Instl == 1 { - out.Banner.W = openrtb.Uint64Ptr(0) - out.Banner.H = openrtb.Uint64Ptr(0) + out.Banner.W = openrtb2.Int64Ptr(0) + out.Banner.H = openrtb2.Int64Ptr(0) out.Banner.Format = nil - return nil } @@ -204,15 +197,14 @@ func (this *FacebookAdapter) modifyImp(out *openrtb.Imp) error { } } - /* This will get overwritten post-serialization */ - out.Banner.W = openrtb.Uint64Ptr(0) + out.Banner.W = openrtb2.Int64Ptr(-1) out.Banner.Format = nil } return nil } -func (this *FacebookAdapter) extractPlacementAndPublisher(out *openrtb.Imp) (string, string, error) { +func (this *FacebookAdapter) extractPlacementAndPublisher(out *openrtb2.Imp) (string, string, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(out.Ext, &bidderExt); err != nil { return "", "", &errortypes.BadInput{ @@ -237,9 +229,9 @@ func (this *FacebookAdapter) extractPlacementAndPublisher(out *openrtb.Imp) (str publisherID := fbExt.PublisherId // Support the legacy path with the caller was expected to pass in just placementId - // which was an underscore concantenated string with the publisherId and placementId. + // which was an underscore concatenated string with the publisherId and placementId. // The new path for callers is to pass in the placementId and publisherId independently - // and the below code will prefix the placementId that we pass to FAN with the publsiherId + // and the below code will prefix the placementId that we pass to FAN with the publisherId // so that we can abstract the implementation details from the caller toks := strings.Split(placementID, "_") if len(toks) == 1 { @@ -262,17 +254,17 @@ func (this *FacebookAdapter) extractPlacementAndPublisher(out *openrtb.Imp) (str return placementID, publisherID, nil } -// XXX: This entire function is just a hack to get around mxmCherry 11.0.0 limitations, without -// having to fork the library and maintain our own branch -func modifyImpCustom(jsonData []byte, imp *openrtb.Imp) ([]byte, error) { - impType, ok := resolveImpType(imp) - if ok == false { - panic("processing an invalid impression") +// modifyImpCustom modifies the impression after it's marshalled to get around mxmCherry 14.0.0 limitations. +func modifyImpCustom(jsonData []byte, imp *openrtb2.Imp) ([]byte, error) { + impType := resolveImpType(imp) + + // we only need to modify video and native impressions + if impType != openrtb_ext.BidTypeVideo && impType != openrtb_ext.BidTypeNative { + return jsonData, nil } var jsonMap map[string]interface{} - err := json.Unmarshal(jsonData, &jsonMap) - if err != nil { + if err := json.Unmarshal(jsonData, &jsonMap); err != nil { return jsonData, err } @@ -286,28 +278,16 @@ func modifyImpCustom(jsonData []byte, imp *openrtb.Imp) ([]byte, error) { } switch impType { - case openrtb_ext.BidTypeBanner: - // The current version of mxmCherry (11.0.0) represents banner.w as an unsigned - // integer, so setting a value of -1 is not possible which is why we have to do it - // post-serialization - isInterstitial := imp.Instl == 1 - if !isInterstitial { - if bannerMap, ok := maputil.ReadEmbeddedMap(impMap, "banner"); ok { - bannerMap["w"] = json.RawMessage("-1") - } else { - return jsonData, errors.New("unable to find imp[0].banner in json data") - } + case openrtb_ext.BidTypeVideo: + videoMap, ok := maputil.ReadEmbeddedMap(impMap, "video") + if !ok { + return jsonData, errors.New("unable to find imp[0].video in json data") } - case openrtb_ext.BidTypeVideo: // mxmCherry omits video.w/h if set to zero, so we need to force set those // fields to zero post-serialization for the time being - if videoMap, ok := maputil.ReadEmbeddedMap(impMap, "video"); ok { - videoMap["w"] = json.RawMessage("0") - videoMap["h"] = json.RawMessage("0") - } else { - return jsonData, errors.New("unable to find imp[0].video in json data") - } + videoMap["w"] = json.RawMessage("0") + videoMap["h"] = json.RawMessage("0") case openrtb_ext.BidTypeNative: nativeMap, ok := maputil.ReadEmbeddedMap(impMap, "native") @@ -316,8 +296,8 @@ func modifyImpCustom(jsonData []byte, imp *openrtb.Imp) ([]byte, error) { } // Set w/h to -1 for native impressions based on the facebook native spec. - // We have to set this post-serialization since the OpenRTB protocol doesn't - // actually support w/h in the native object + // We have to set this post-serialization since these fields are not included + // in the OpenRTB 2.5 spec. nativeMap["w"] = json.RawMessage("-1") nativeMap["h"] = json.RawMessage("-1") @@ -335,13 +315,11 @@ func modifyImpCustom(jsonData []byte, imp *openrtb.Imp) ([]byte, error) { } } -func (this *FacebookAdapter) MakeBids(request *openrtb.BidRequest, adapterRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - /* No bid response */ +func (this *FacebookAdapter) MakeBids(request *openrtb2.BidRequest, adapterRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } - /* Any other http status codes outside of 200 and 204 should be treated as errors */ if response.StatusCode != http.StatusOK { msg := response.Headers.Get("x-fb-an-errors") return nil, []error{&errortypes.BadInput{ @@ -349,7 +327,7 @@ func (this *FacebookAdapter) MakeBids(request *openrtb.BidRequest, adapterReques }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -358,7 +336,9 @@ func (this *FacebookAdapter) MakeBids(request *openrtb.BidRequest, adapterReques var errs []error for _, seatbid := range bidResp.SeatBid { - for _, bid := range seatbid.Bid { + for i := range seatbid.Bid { + bid := seatbid.Bid[i] + if bid.AdM == "" { errs = append(errs, &errortypes.BadServerResponse{ Message: fmt.Sprintf("Bid %s missing 'adm'", bid.ID), @@ -394,38 +374,35 @@ func (this *FacebookAdapter) MakeBids(request *openrtb.BidRequest, adapterReques return out, errs } -func resolveBidType(bid *openrtb.Bid, req *openrtb.BidRequest) openrtb_ext.BidType { +func resolveBidType(bid *openrtb2.Bid, req *openrtb2.BidRequest) openrtb_ext.BidType { for _, imp := range req.Imp { if bid.ImpID == imp.ID { - if typ, ok := resolveImpType(&imp); ok { - return typ - } - - panic("Processing an invalid impression; cannot resolve impression type") + return resolveImpType(&imp) } } panic(fmt.Sprintf("Invalid bid imp ID %s does not match any imp IDs from the original bid request", bid.ImpID)) } -func resolveImpType(imp *openrtb.Imp) (openrtb_ext.BidType, bool) { +func resolveImpType(imp *openrtb2.Imp) openrtb_ext.BidType { if imp.Banner != nil { - return openrtb_ext.BidTypeBanner, true + return openrtb_ext.BidTypeBanner } if imp.Video != nil { - return openrtb_ext.BidTypeVideo, true + return openrtb_ext.BidTypeVideo } if imp.Audio != nil { - return openrtb_ext.BidTypeAudio, true + return openrtb_ext.BidTypeAudio } if imp.Native != nil { - return openrtb_ext.BidTypeNative, true + return openrtb_ext.BidTypeNative } - return openrtb_ext.BidTypeBanner, false + // Required to satisfy compiler. Not reachable in practice due to validations performed in PBS-Core. + return openrtb_ext.BidTypeBanner } // Builder builds a new instance of Facebook's Audience Network adapter for the given bidder with the given config. diff --git a/adapters/avocet/avocet.go b/adapters/avocet/avocet.go index dac7faaa4b3..b3cda3a1bdd 100644 --- a/adapters/avocet/avocet.go +++ b/adapters/avocet/avocet.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -18,7 +18,7 @@ type AvocetAdapter struct { Endpoint string } -func (a *AvocetAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *AvocetAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, nil } @@ -50,7 +50,7 @@ type avocetBidExtension struct { DealPriority int `json:"deal_priority"` } -func (a *AvocetAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *AvocetAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -68,7 +68,7 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe }} } - var br openrtb.BidResponse + var br openrtb2.BidResponse err := json.Unmarshal(response.Body, &br) if err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -105,12 +105,12 @@ func (a *AvocetAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe } // getBidType returns the openrtb_ext.BidType for the provided bid. -func getBidType(bid openrtb.Bid, ext avocetBidExt) openrtb_ext.BidType { +func getBidType(bid openrtb2.Bid, ext avocetBidExt) openrtb_ext.BidType { if ext.Avocet.Duration != 0 { return openrtb_ext.BidTypeVideo } switch bid.API { - case openrtb.APIFrameworkVPAID10, openrtb.APIFrameworkVPAID20: + case openrtb2.APIFrameworkVPAID10, openrtb2.APIFrameworkVPAID20: return openrtb_ext.BidTypeVideo default: return openrtb_ext.BidTypeBanner diff --git a/adapters/avocet/avocet_test.go b/adapters/avocet/avocet_test.go index e4a7c5f44fa..b256adc6f17 100644 --- a/adapters/avocet/avocet_test.go +++ b/adapters/avocet/avocet_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -30,7 +30,7 @@ func TestAvocetAdapter_MakeRequests(t *testing.T) { Endpoint string } type args struct { - request *openrtb.BidRequest + request *openrtb2.BidRequest reqInfo *adapters.ExtraRequestInfo } type reqData []*adapters.RequestData @@ -45,7 +45,7 @@ func TestAvocetAdapter_MakeRequests(t *testing.T) { name: "return nil if zero imps", fields: fields{Endpoint: "https://bid.avct.cloud"}, args: args{ - &openrtb.BidRequest{}, + &openrtb2.BidRequest{}, nil, }, want: nil, @@ -55,7 +55,7 @@ func TestAvocetAdapter_MakeRequests(t *testing.T) { name: "makes POST request with JSON content", fields: fields{Endpoint: "https://bid.avct.cloud"}, args: args{ - &openrtb.BidRequest{Imp: []openrtb.Imp{{}}}, + &openrtb2.BidRequest{Imp: []openrtb2.Imp{{}}}, nil, }, want: reqData{ @@ -100,7 +100,7 @@ func TestAvocetAdapter_MakeBids(t *testing.T) { Endpoint string } type args struct { - internalRequest *openrtb.BidRequest + internalRequest *openrtb2.BidRequest externalRequest *adapters.RequestData response *adapters.ResponseData } @@ -195,7 +195,7 @@ func TestAvocetAdapter_MakeBids(t *testing.T) { func Test_getBidType(t *testing.T) { type args struct { - bid openrtb.Bid + bid openrtb2.Bid ext avocetBidExt } tests := []struct { @@ -205,17 +205,17 @@ func Test_getBidType(t *testing.T) { }{ { name: "VPAID 1.0", - args: args{openrtb.Bid{API: openrtb.APIFrameworkVPAID10}, avocetBidExt{}}, + args: args{openrtb2.Bid{API: openrtb2.APIFrameworkVPAID10}, avocetBidExt{}}, want: openrtb_ext.BidTypeVideo, }, { name: "VPAID 2.0", - args: args{openrtb.Bid{API: openrtb.APIFrameworkVPAID20}, avocetBidExt{}}, + args: args{openrtb2.Bid{API: openrtb2.APIFrameworkVPAID20}, avocetBidExt{}}, want: openrtb_ext.BidTypeVideo, }, { name: "other", - args: args{openrtb.Bid{}, avocetBidExt{}}, + args: args{openrtb2.Bid{}, avocetBidExt{}}, want: openrtb_ext.BidTypeBanner, }, } @@ -228,7 +228,7 @@ func Test_getBidType(t *testing.T) { } } -var validBannerBid = openrtb.Bid{ +var validBannerBid = openrtb2.Bid{ AdM: "", ADomain: []string{"avocet.io"}, CID: "5b51e2d689654741306813a4", @@ -267,7 +267,7 @@ var validBannerBidResponseBody = []byte(`{ ] }`) -var validVideoBid = openrtb.Bid{ +var validVideoBid = openrtb2.Bid{ AdM: "Avocet", ADomain: []string{"avocet.io"}, CID: "5b51e2d689654741306813a4", diff --git a/adapters/beachfront/beachfront.go b/adapters/beachfront/beachfront.go index 09dd9e93929..ea4ff2c83e5 100644 --- a/adapters/beachfront/beachfront.go +++ b/adapters/beachfront/beachfront.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -51,9 +51,9 @@ type beachfrontRequests struct { // --------------------------------------------------- type beachfrontVideoRequest struct { - AppId string `json:"appId"` - VideoResponseType string `json:"videoResponseType"` - Request openrtb.BidRequest `json:"request"` + AppId string `json:"appId"` + VideoResponseType string `json:"videoResponseType"` + Request openrtb2.BidRequest `json:"request"` } // --------------------------------------------------- @@ -71,7 +71,7 @@ type beachfrontBannerRequest struct { IsMobile int8 `json:"isMobile"` UA string `json:"ua"` Dnt int8 `json:"dnt"` - User openrtb.User `json:"user"` + User openrtb2.User `json:"user"` AdapterName string `json:"adapterName"` AdapterVersion string `json:"adapterVersion"` IP string `json:"ip"` @@ -108,7 +108,7 @@ type beachfrontVideoBidExtension struct { Duration int `json:"duration"` } -func (a *BeachfrontAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *BeachfrontAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { beachfrontRequests, errs := preprocess(request) headers := http.Header{} @@ -198,9 +198,9 @@ func (a *BeachfrontAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a return reqs, errs } -func preprocess(request *openrtb.BidRequest) (beachfrontReqs beachfrontRequests, errs []error) { - var videoImps = make([]openrtb.Imp, 0) - var bannerImps = make([]openrtb.Imp, 0) +func preprocess(request *openrtb2.BidRequest) (beachfrontReqs beachfrontRequests, errs []error) { + var videoImps = make([]openrtb2.Imp, 0) + var bannerImps = make([]openrtb2.Imp, 0) for i := 0; i < len(request.Imp); i++ { if request.Imp[i].Banner != nil && request.Imp[i].Banner.Format != nil && @@ -267,7 +267,7 @@ func getAppId(ext openrtb_ext.ExtImpBeachfront, media openrtb_ext.BidType) (stri getBannerRequest, singular. A "Slot" is an "imp," and each Slot can have an AppId, so just one request to the beachfront banner endpoint gets all banner Imps. */ -func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []error) { +func getBannerRequest(request *openrtb2.BidRequest) (beachfrontBannerRequest, []error) { var bfr beachfrontBannerRequest var errs = make([]error, 0, len(request.Imp)) @@ -301,8 +301,8 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e for j := 0; j < len(request.Imp[i].Banner.Format); j++ { slot.Sizes = append(slot.Sizes, beachfrontSize{ - H: request.Imp[i].Banner.Format[j].H, - W: request.Imp[i].Banner.Format[j].W, + H: uint64(request.Imp[i].Banner.Format[j].H), + W: uint64(request.Imp[i].Banner.Format[j].W), }) } @@ -327,7 +327,7 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e var t = fallBackDeviceType(request) - if t == openrtb.DeviceTypeMobileTablet { + if t == openrtb2.DeviceTypeMobileTablet { bfr.Page = request.App.Bundle if request.App.Domain == "" { bfr.Domain = getDomain(request.App.Domain) @@ -336,7 +336,7 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e } bfr.IsMobile = 1 - } else if t == openrtb.DeviceTypePersonalComputer { + } else if t == openrtb2.DeviceTypePersonalComputer { bfr.Page = request.Site.Page if request.Site.Domain == "" { bfr.Domain = getDomain(request.Site.Page) @@ -373,15 +373,15 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e return bfr, errs } -func fallBackDeviceType(request *openrtb.BidRequest) openrtb.DeviceType { +func fallBackDeviceType(request *openrtb2.BidRequest) openrtb2.DeviceType { if request.Site != nil { - return openrtb.DeviceTypePersonalComputer + return openrtb2.DeviceTypePersonalComputer } - return openrtb.DeviceTypeMobileTablet + return openrtb2.DeviceTypeMobileTablet } -func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, []error) { +func getVideoRequests(request *openrtb2.BidRequest) ([]beachfrontVideoRequest, []error) { var bfReqs = make([]beachfrontVideoRequest, len(request.Imp)) var errs = make([]error, 0, len(request.Imp)) var failedRequestIndicies = make([]int, 0) @@ -409,9 +409,9 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] bfReqs[i].Request = *request var secure int8 - var deviceCopy openrtb.Device + var deviceCopy openrtb2.Device if bfReqs[i].Request.Device == nil { - deviceCopy = openrtb.Device{} + deviceCopy = openrtb2.Device{} } else { deviceCopy = *bfReqs[i].Request.Device } @@ -473,7 +473,7 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] } bfReqs[i].Request.Imp = nil - bfReqs[i].Request.Imp = make([]openrtb.Imp, 1) + bfReqs[i].Request.Imp = make([]openrtb2.Imp, 1) bfReqs[i].Request.Imp[0] = imp } @@ -488,7 +488,7 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] return bfReqs, errs } -func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -509,9 +509,9 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern return nil, []error{fmt.Errorf("unexpected status code %d from %s. Run with request.debug = 1 for more info", response.StatusCode, externalRequest.Uri)} } - var bids []openrtb.Bid + var bids []openrtb2.Bid var errs = make([]error, 0) - var xtrnal openrtb.BidRequest + var xtrnal openrtb2.BidRequest // For video, which uses RTB for the external request, this will unmarshal as expected. For banner, it will // only get the User struct and everything else will be nil @@ -560,10 +560,10 @@ func (a *BeachfrontAdapter) getBidType(externalRequest *adapters.RequestData) op return openrtb_ext.BidTypeBanner } -func postprocess(response *adapters.ResponseData, xtrnal openrtb.BidRequest, uri string, id string) ([]openrtb.Bid, []error) { +func postprocess(response *adapters.ResponseData, xtrnal openrtb2.BidRequest, uri string, id string) ([]openrtb2.Bid, []error) { var beachfrontResp []beachfrontResponseSlot - var openrtbResp openrtb.BidResponse + var openrtbResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &openrtbResp); err != nil || len(openrtbResp.SeatBid) == 0 { @@ -579,27 +579,27 @@ func postprocess(response *adapters.ResponseData, xtrnal openrtb.BidRequest, uri return postprocessVideo(openrtbResp.SeatBid[0].Bid, xtrnal, uri, id) } -func postprocessBanner(beachfrontResp []beachfrontResponseSlot, id string) ([]openrtb.Bid, []error) { +func postprocessBanner(beachfrontResp []beachfrontResponseSlot, id string) ([]openrtb2.Bid, []error) { - var bids = make([]openrtb.Bid, len(beachfrontResp)) + var bids = make([]openrtb2.Bid, len(beachfrontResp)) var errs = make([]error, 0) for i := 0; i < len(beachfrontResp); i++ { - bids[i] = openrtb.Bid{ + bids[i] = openrtb2.Bid{ CrID: beachfrontResp[i].CrID, ImpID: beachfrontResp[i].Slot, Price: beachfrontResp[i].Price, ID: fmt.Sprintf("%sBanner", beachfrontResp[i].Slot), AdM: beachfrontResp[i].Adm, - H: beachfrontResp[i].H, - W: beachfrontResp[i].W, + H: int64(beachfrontResp[i].H), + W: int64(beachfrontResp[i].W), } } return bids, errs } -func postprocessVideo(bids []openrtb.Bid, xtrnal openrtb.BidRequest, uri string, id string) ([]openrtb.Bid, []error) { +func postprocessVideo(bids []openrtb2.Bid, xtrnal openrtb2.BidRequest, uri string, id string) ([]openrtb2.Bid, []error) { var errs = make([]error, 0) @@ -633,7 +633,7 @@ func extractNurlVideoCrid(nurl string) string { return "" } -func getBeachfrontExtension(imp openrtb.Imp) (openrtb_ext.ExtImpBeachfront, error) { +func getBeachfrontExtension(imp openrtb2.Imp) (openrtb_ext.ExtImpBeachfront, error) { var err error var bidderExt adapters.ExtImpBidder var beachfrontExt openrtb_ext.ExtImpBeachfront diff --git a/adapters/beintoo/beintoo.go b/adapters/beintoo/beintoo.go index 5f22bfa7742..8b5698750e6 100644 --- a/adapters/beintoo/beintoo.go +++ b/adapters/beintoo/beintoo.go @@ -7,7 +7,7 @@ import ( "net/url" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -18,7 +18,7 @@ type BeintooAdapter struct { endpoint string } -func (a *BeintooAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *BeintooAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors []error if len(request.Imp) == 0 { @@ -64,7 +64,7 @@ func (a *BeintooAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap }}, errors } -func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBeintoo, error) { +func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBeintoo, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -89,7 +89,7 @@ func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBeintoo, error) { return &beintooExt, nil } -func buildImpBanner(imp *openrtb.Imp) error { +func buildImpBanner(imp *openrtb2.Imp) error { imp.Ext = nil if imp.Banner == nil { @@ -118,7 +118,7 @@ func buildImpBanner(imp *openrtb.Imp) error { } // Add Beintoo required properties to Imp object -func addImpProps(imp *openrtb.Imp, secure *int8, BeintooExt *openrtb_ext.ExtImpBeintoo) { +func addImpProps(imp *openrtb2.Imp, secure *int8, BeintooExt *openrtb_ext.ExtImpBeintoo) { imp.TagID = BeintooExt.TagID imp.Secure = secure @@ -144,9 +144,9 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // Handle request errors and formatting to be sent to Beintoo -func preprocess(request *openrtb.BidRequest) []error { +func preprocess(request *openrtb2.BidRequest) []error { errors := make([]error, 0, len(request.Imp)) - resImps := make([]openrtb.Imp, 0, len(request.Imp)) + resImps := make([]openrtb2.Imp, 0, len(request.Imp)) secure := int8(0) if request.Site != nil && request.Site.Page != "" { @@ -178,7 +178,7 @@ func preprocess(request *openrtb.BidRequest) []error { } // MakeBids make the bids for the bid response. -func (a *BeintooAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *BeintooAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { // no bid response @@ -191,7 +191,7 @@ func (a *BeintooAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json b/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json index 5c5462c2990..6d587c2252b 100644 --- a/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/beintoo/beintootest/supplemental/invalid-response-unmarshall-error.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type uint64", + "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type int64", "comparison": "regex" } ] diff --git a/adapters/between/between.go b/adapters/between/between.go index f8106bdd113..f1be7db5fc2 100644 --- a/adapters/between/between.go +++ b/adapters/between/between.go @@ -8,7 +8,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -24,7 +24,7 @@ type BetweenAdapter struct { // If BidFloor of openrtb_ext.ExtImpBetween is zero, set it to defaultBidFloor value, see addImpProps const defaultBidfloor = 0.00001 -func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *BetweenAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors []error if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ @@ -70,7 +70,7 @@ func (a *BetweenAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap }}, errors } -func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpBetween, error) { +func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpBetween, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -103,7 +103,7 @@ func (a *BetweenAdapter) buildEndpointURL(e *openrtb_ext.ExtImpBetween) (string, return macros.ResolveMacros(a.EndpointTemplate, macros.EndpointTemplateParams{Host: e.Host, PublisherID: e.PublisherID}) } -func buildImpBanner(imp *openrtb.Imp) error { +func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ Message: fmt.Sprintf("Request needs to include a Banner object"), @@ -127,7 +127,7 @@ func buildImpBanner(imp *openrtb.Imp) error { } // Add Between required properties to Imp object -func addImpProps(imp *openrtb.Imp, secure *int8, betweenExt *openrtb_ext.ExtImpBetween) { +func addImpProps(imp *openrtb2.Imp, secure *int8, betweenExt *openrtb_ext.ExtImpBetween) { imp.Secure = secure if betweenExt.BidFloor <= 0 { imp.BidFloor = defaultBidfloor @@ -147,9 +147,9 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // Handle request errors and formatting to be sent to Between -func preprocess(request *openrtb.BidRequest) (*openrtb_ext.ExtImpBetween, []error) { +func preprocess(request *openrtb2.BidRequest) (*openrtb_ext.ExtImpBetween, []error) { errors := make([]error, 0, len(request.Imp)) - resImps := make([]openrtb.Imp, 0, len(request.Imp)) + resImps := make([]openrtb2.Imp, 0, len(request.Imp)) secure := int8(0) if request.Site != nil && request.Site.Page != "" { @@ -181,7 +181,7 @@ func preprocess(request *openrtb.BidRequest) (*openrtb_ext.ExtImpBetween, []erro return betweenExt, errors } -func (a *BetweenAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *BetweenAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { // no bid response @@ -193,7 +193,7 @@ func (a *BetweenAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR Message: fmt.Sprintf("Invalid Status Returned: %d. Run with request.debug = 1 for more info", response.StatusCode), }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unable to unpackage bid response. Error %s", err.Error()), diff --git a/adapters/between/betweentest/supplemental/bad-response-body.json b/adapters/between/betweentest/supplemental/bad-response-body.json index 1712010a86b..fbd08206bd8 100644 --- a/adapters/between/betweentest/supplemental/bad-response-body.json +++ b/adapters/between/betweentest/supplemental/bad-response-body.json @@ -70,7 +70,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response. Error json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "Unable to unpackage bid response. Error json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/bidder.go b/adapters/bidder.go index 9800a49c9cb..a389299f888 100644 --- a/adapters/bidder.go +++ b/adapters/bidder.go @@ -5,7 +5,7 @@ import ( "encoding/json" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/metrics" "github.com/prebid/prebid-server/openrtb_ext" @@ -26,7 +26,7 @@ type Bidder interface { // "subpar" in some way. For example: the request contained ad types which this bidder doesn't support. // // If the error is caused by bad user input, return an errortypes.BadInput. - MakeRequests(request *openrtb.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error) + MakeRequests(request *openrtb2.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error) // MakeBids unpacks the server's response into Bids. // @@ -37,7 +37,7 @@ type Bidder interface { // // If the error was caused by bad user input, return a errortypes.BadInput. // If the error was caused by a bad server response, return a errortypes.BadServerResponse - MakeBids(internalRequest *openrtb.BidRequest, externalRequest *RequestData, response *ResponseData) (*BidderResponse, []error) + MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *RequestData, response *ResponseData) (*BidderResponse, []error) } // TimeoutBidder is used to identify bidders that support timeout notifications. @@ -84,7 +84,7 @@ func NewBidderResponse() *BidderResponse { return NewBidderResponseWithBidsCapacity(0) } -// TypedBid packages the openrtb.Bid with any bidder-specific information that PBS needs to populate an +// TypedBid packages the openrtb2.Bid with any bidder-specific information that PBS needs to populate an // openrtb_ext.ExtBidPrebid. // // TypedBid.Bid.Ext will become "response.seatbid[i].bid.ext.bidder" in the final OpenRTB response. @@ -92,7 +92,7 @@ func NewBidderResponse() *BidderResponse { // TypedBid.BidVideo will become "response.seatbid[i].bid.ext.prebid.video" in the final OpenRTB response. // TypedBid.DealPriority is optionally provided by adapters and used internally by the exchange to support deal targeted campaigns. type TypedBid struct { - Bid *openrtb.Bid + Bid *openrtb2.Bid BidType openrtb_ext.BidType BidVideo *openrtb_ext.ExtBidPrebidVideo DealPriority int diff --git a/adapters/brightroll/brightroll.go b/adapters/brightroll/brightroll.go index 0e3fcb0669c..fe770b07d16 100644 --- a/adapters/brightroll/brightroll.go +++ b/adapters/brightroll/brightroll.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -30,7 +30,7 @@ type Account struct { BidFloor float64 `json:"bidfloor"` } -func (a *BrightrollAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *BrightrollAdapter) MakeRequests(requestIn *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { request := *requestIn errs := make([]error, 0, len(request.Imp)) @@ -162,7 +162,7 @@ func (a *BrightrollAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo }}, errors } -func (a *BrightrollAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *BrightrollAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -180,7 +180,7 @@ func (a *BrightrollAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), @@ -199,10 +199,10 @@ func (a *BrightrollAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern return bidResponse, nil } -func getBlockedCreativetypes(attr []int8) []openrtb.CreativeAttribute { - var creativeAttr []openrtb.CreativeAttribute +func getBlockedCreativetypes(attr []int8) []openrtb2.CreativeAttribute { + var creativeAttr []openrtb2.CreativeAttribute for i := 0; i < len(attr); i++ { - creativeAttr = append(creativeAttr, openrtb.CreativeAttribute(attr[i])) + creativeAttr = append(creativeAttr, openrtb2.CreativeAttribute(attr[i])) } return creativeAttr } @@ -215,7 +215,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // getMediaTypeForImp figures out which media type this bid is for. -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner //default type for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/colossus/colossus.go b/adapters/colossus/colossus.go index 4a5360ce122..801b338478a 100644 --- a/adapters/colossus/colossus.go +++ b/adapters/colossus/colossus.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -26,7 +26,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests create bid request for colossus demand -func (a *ColossusAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ColossusAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var err error var tagID string @@ -35,7 +35,7 @@ func (a *ColossusAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada reqCopy := *request for _, imp := range request.Imp { - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} tagID, err = jsonparser.GetString(reqCopy.Imp[0].Ext, "bidder", "TagID") if err != nil { @@ -54,7 +54,7 @@ func (a *ColossusAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada return adapterRequests, errs } -func (a *ColossusAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *ColossusAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error @@ -77,7 +77,7 @@ func (a *ColossusAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Re } // MakeBids makes the bids -func (a *ColossusAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *ColossusAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -96,7 +96,7 @@ func (a *ColossusAdapter) MakeBids(internalRequest *openrtb.BidRequest, external }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -121,7 +121,7 @@ func (a *ColossusAdapter) MakeBids(internalRequest *openrtb.BidRequest, external return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/colossus/colossustest/supplemental/bad_response.json b/adapters/colossus/colossustest/supplemental/bad_response.json index c69b00c8e6e..62b862b181e 100644 --- a/adapters/colossus/colossustest/supplemental/bad_response.json +++ b/adapters/colossus/colossustest/supplemental/bad_response.json @@ -78,7 +78,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/connectad/connectad.go b/adapters/connectad/connectad.go index 024dabcee98..9192a520a05 100644 --- a/adapters/connectad/connectad.go +++ b/adapters/connectad/connectad.go @@ -7,7 +7,7 @@ import ( "net/url" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -30,7 +30,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *ConnectAdAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ConnectAdAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error @@ -73,7 +73,7 @@ func (a *ConnectAdAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ad }}, errs } -func (a *ConnectAdAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *ConnectAdAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, httpRes *adapters.ResponseData) (*adapters.BidderResponse, []error) { if httpRes.StatusCode == http.StatusNoContent { return nil, nil @@ -85,7 +85,7 @@ func (a *ConnectAdAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(httpRes.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -107,10 +107,10 @@ func (a *ConnectAdAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters return bidResponse, nil } -func preprocess(request *openrtb.BidRequest) []error { +func preprocess(request *openrtb2.BidRequest) []error { impsCount := len(request.Imp) errors := make([]error, 0, impsCount) - resImps := make([]openrtb.Imp, 0, impsCount) + resImps := make([]openrtb2.Imp, 0, impsCount) secure := int8(0) if request.Site != nil && request.Site.Page != "" { @@ -141,7 +141,7 @@ func preprocess(request *openrtb.BidRequest) []error { return errors } -func addImpInfo(imp *openrtb.Imp, secure *int8, cadExt *openrtb_ext.ExtImpConnectAd) { +func addImpInfo(imp *openrtb2.Imp, secure *int8, cadExt *openrtb_ext.ExtImpConnectAd) { imp.TagID = strconv.Itoa(cadExt.SiteID) imp.Secure = secure @@ -159,7 +159,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } } -func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpConnectAd, error) { +func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpConnectAd, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -183,7 +183,7 @@ func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpConnectAd, error) { return &cadExt, nil } -func buildImpBanner(imp *openrtb.Imp) error { +func buildImpBanner(imp *openrtb2.Imp) error { imp.Ext = nil if imp.Banner == nil { diff --git a/adapters/connectad/connectadtest/supplemental/badresponse.json b/adapters/connectad/connectadtest/supplemental/badresponse.json index de56d8b4c91..6c3bdaa4985 100644 --- a/adapters/connectad/connectadtest/supplemental/badresponse.json +++ b/adapters/connectad/connectadtest/supplemental/badresponse.json @@ -83,7 +83,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response. Error: json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "Unable to unpackage bid response. Error: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/consumable/adtypes.go b/adapters/consumable/adtypes.go index 5eb3d3b369e..20b89bdfe7f 100644 --- a/adapters/consumable/adtypes.go +++ b/adapters/consumable/adtypes.go @@ -1,16 +1,17 @@ package consumable import ( - "github.com/mxmCherry/openrtb" "strconv" + + "github.com/mxmCherry/openrtb/v14/openrtb2" ) /* Turn array of openrtb formats into consumable's code*/ -func getSizeCodes(Formats []openrtb.Format) []int { +func getSizeCodes(Formats []openrtb2.Format) []int { codes := make([]int, 0) for _, format := range Formats { - str := strconv.FormatUint(format.W, 10) + "x" + strconv.FormatUint(format.H, 10) + str := strconv.FormatInt(format.W, 10) + "x" + strconv.FormatInt(format.H, 10) if code, ok := sizeMap[str]; ok { codes = append(codes, code) } diff --git a/adapters/consumable/consumable.go b/adapters/consumable/consumable.go index 15511c0ebb7..d81bc20b0d3 100644 --- a/adapters/consumable/consumable.go +++ b/adapters/consumable/consumable.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -83,7 +83,7 @@ type pricing struct { ClearPrice *float64 `json:"clearPrice"` } -func (a *ConsumableAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ConsumableAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { headers := http.Header{ "Content-Type": {"application/json"}, "Accept": {"application/json"}, @@ -211,7 +211,7 @@ func (a *ConsumableAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a internal original request in OpenRTB, external = result of us having converted it (what comes out of MakeRequests) */ func (a *ConsumableAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { @@ -245,13 +245,13 @@ func (a *ConsumableAdapter) MakeBids( for impID, decision := range serverResponse.Decisions { if decision.Pricing != nil && decision.Pricing.ClearPrice != nil { - bid := openrtb.Bid{} + bid := openrtb2.Bid{} bid.ID = internalRequest.ID bid.ImpID = impID bid.Price = *decision.Pricing.ClearPrice bid.AdM = retrieveAd(decision) - bid.W = decision.Width - bid.H = decision.Height + bid.W = int64(decision.Width) + bid.H = int64(decision.Height) bid.CrID = strconv.FormatInt(decision.AdID, 10) bid.Exp = 30 // TODO: Check this is intention of TTL @@ -273,7 +273,7 @@ func (a *ConsumableAdapter) MakeBids( return bidderResponse, errors } -func extractExtensions(impression openrtb.Imp) (*adapters.ExtImpBidder, *openrtb_ext.ExtImpConsumable, []error) { +func extractExtensions(impression openrtb2.Imp) (*adapters.ExtImpBidder, *openrtb_ext.ExtImpConsumable, []error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(impression.Ext, &bidderExt); err != nil { return nil, nil, []error{&errortypes.BadInput{ diff --git a/adapters/conversant/cnvr_legacy.go b/adapters/conversant/cnvr_legacy.go index 4672ee156b4..e29fb7c019b 100644 --- a/adapters/conversant/cnvr_legacy.go +++ b/adapters/conversant/cnvr_legacy.go @@ -8,7 +8,7 @@ import ( "io/ioutil" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/pbs" @@ -54,7 +54,7 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, // Create a map of impression objects for both request creation // and response parsing. - impMap := make(map[string]*openrtb.Imp, len(cnvrReq.Imp)) + impMap := make(map[string]*openrtb2.Imp, len(cnvrReq.Imp)) for idx := range cnvrReq.Imp { impMap[cnvrReq.Imp[idx].ID] = &cnvrReq.Imp[idx] } @@ -98,9 +98,9 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, imp.BidFloor = params.BidFloor imp.TagID = params.TagID - var position *openrtb.AdPosition + var position *openrtb2.AdPosition if params.Position != nil { - position = openrtb.AdPosition(*params.Position).Ptr() + position = openrtb2.AdPosition(*params.Position).Ptr() } if imp.Banner != nil { @@ -109,9 +109,9 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, imp.Video.Pos = position if len(params.API) > 0 { - imp.Video.API = make([]openrtb.APIFramework, 0, len(params.API)) + imp.Video.API = make([]openrtb2.APIFramework, 0, len(params.API)) for _, api := range params.API { - imp.Video.API = append(imp.Video.API, openrtb.APIFramework(api)) + imp.Video.API = append(imp.Video.API, openrtb2.APIFramework(api)) } } @@ -120,9 +120,9 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, // but are overridden if the custom params object also contains them. if len(params.Protocols) > 0 { - imp.Video.Protocols = make([]openrtb.Protocol, 0, len(params.Protocols)) + imp.Video.Protocols = make([]openrtb2.Protocol, 0, len(params.Protocols)) for _, protocol := range params.Protocols { - imp.Video.Protocols = append(imp.Video.Protocols, openrtb.Protocol(protocol)) + imp.Video.Protocols = append(imp.Video.Protocols, openrtb2.Protocol(protocol)) } } @@ -164,7 +164,7 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, } if cnvrReq.Device == nil { - cnvrReq.Device = &openrtb.Device{} + cnvrReq.Device = &openrtb2.Device{} } // Convert request to json to be sent over http @@ -217,7 +217,7 @@ func (a *ConversantLegacyAdapter) Call(ctx context.Context, req *pbs.PBSRequest, debug.ResponseBody = string(body) } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { diff --git a/adapters/conversant/cnvr_legacy_test.go b/adapters/conversant/cnvr_legacy_test.go index 712f85f4404..ef8a780c746 100644 --- a/adapters/conversant/cnvr_legacy_test.go +++ b/adapters/conversant/cnvr_legacy_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/cache/dummycache" "github.com/prebid/prebid-server/config" @@ -497,12 +497,12 @@ func TestConversantVideoRequestWithParams(t *testing.T) { assertEqual(t, len(imp.Video.MIMEs), 1, "Request video MIMEs entries") assertEqual(t, imp.Video.MIMEs[0], "video/x-ms-wmv", "Requst video MIMEs type") assertEqual(t, len(imp.Video.Protocols), 2, "Request video protocols") - assertEqual(t, imp.Video.Protocols[0], openrtb.Protocol(1), "Request video protocols 1") - assertEqual(t, imp.Video.Protocols[1], openrtb.Protocol(2), "Request video protocols 2") + assertEqual(t, imp.Video.Protocols[0], openrtb2.Protocol(1), "Request video protocols 1") + assertEqual(t, imp.Video.Protocols[1], openrtb2.Protocol(2), "Request video protocols 2") assertEqual(t, imp.Video.MaxDuration, int64(90), "Request video 0 max duration") assertEqual(t, len(imp.Video.API), 2, "Request video api should be nil") - assertEqual(t, imp.Video.API[0], openrtb.APIFramework(1), "Request video api 1") - assertEqual(t, imp.Video.API[1], openrtb.APIFramework(2), "Request video api 2") + assertEqual(t, imp.Video.API[0], openrtb2.APIFramework(1), "Request video api 1") + assertEqual(t, imp.Video.API[1], openrtb2.APIFramework(2), "Request video api 2") } // Test video request with parameters in the video object @@ -557,8 +557,8 @@ func TestConversantVideoRequestWithParams2(t *testing.T) { assertEqual(t, len(imp.Video.MIMEs), 1, "Request video MIMEs entries") assertEqual(t, imp.Video.MIMEs[0], "video/x-ms-wmv", "Requst video MIMEs type") assertEqual(t, len(imp.Video.Protocols), 2, "Request video protocols") - assertEqual(t, imp.Video.Protocols[0], openrtb.Protocol(1), "Request video protocols 1") - assertEqual(t, imp.Video.Protocols[1], openrtb.Protocol(2), "Request video protocols 2") + assertEqual(t, imp.Video.Protocols[0], openrtb2.Protocol(1), "Request video protocols 1") + assertEqual(t, imp.Video.Protocols[1], openrtb2.Protocol(2), "Request video protocols 2") assertEqual(t, imp.Video.MaxDuration, int64(90), "Request video 0 max duration") } @@ -628,7 +628,7 @@ func CreateRequest(params ...string) *pbs.PBSRequest { for i := 0; i < num; i++ { req.AdUnits[i] = pbs.AdUnit{ Code: fmt.Sprintf("au-%03d", i), - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 300, H: 250, @@ -672,7 +672,7 @@ func ConvertToVideoRequest(req *pbs.PBSRequest, videoParams ...string) (*pbs.PBS // Convert a request to an app request by adding required properties func ConvertToAppRequest(req *pbs.PBSRequest, appParams string) (*pbs.PBSRequest, error) { - app := new(openrtb.App) + app := new(openrtb2.App) err := json.Unmarshal([]byte(appParams), &app) if err == nil { req.App = app @@ -728,8 +728,8 @@ func CreateVideoRequest(params ...string) (*pbs.PBSRequest, error) { // Helper to create a test http server that receives and generate openrtb requests and responses -func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { - var lastBidRequest openrtb.BidRequest +func CreateServer(prices ...float64) (*httptest.Server, *openrtb2.BidRequest) { + var lastBidRequest openrtb2.BidRequest server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) @@ -738,10 +738,10 @@ func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { return } - var bidReq openrtb.BidRequest + var bidReq openrtb2.BidRequest var price float64 - var bids []openrtb.Bid - var bid openrtb.Bid + var bids []openrtb2.Bid + var bid openrtb2.Bid err = json.Unmarshal(body, &bidReq) if err != nil { @@ -758,7 +758,7 @@ func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { } if price > 0 { - bid = openrtb.Bid{ + bid = openrtb2.Bid{ ID: imp.ID, ImpID: imp.ID, Price: price, @@ -775,7 +775,7 @@ func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { bid.H = imp.Video.H } } else { - bid = openrtb.Bid{ + bid = openrtb2.Bid{ ID: imp.ID, ImpID: imp.ID, Price: 0, @@ -788,9 +788,9 @@ func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { if len(bids) == 0 { w.WriteHeader(http.StatusNoContent) } else { - js, _ := json.Marshal(openrtb.BidResponse{ + js, _ := json.Marshal(openrtb2.BidResponse{ ID: bidReq.ID, - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Bid: bids, }, @@ -808,9 +808,9 @@ func CreateServer(prices ...float64) (*httptest.Server, *openrtb.BidRequest) { // Helper to remove impressions with $0 bids -func FilterZeroPrices(prices []float64, imps []openrtb.Imp) ([]float64, []openrtb.Imp) { +func FilterZeroPrices(prices []float64, imps []openrtb2.Imp) ([]float64, []openrtb2.Imp) { prices2 := make([]float64, 0) - imps2 := make([]openrtb.Imp, 0) + imps2 := make([]openrtb2.Imp, 0) for i := range prices { if prices[i] > 0 { diff --git a/adapters/conversant/conversant.go b/adapters/conversant/conversant.go index 248aa200d8e..d742033437a 100644 --- a/adapters/conversant/conversant.go +++ b/adapters/conversant/conversant.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type ConversantAdapter struct { URI string } -func (c ConversantAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (c ConversantAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { for i := 0; i < len(request.Imp); i++ { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(request.Imp[i].Ext, &bidderExt); err != nil { @@ -71,7 +71,7 @@ func (c ConversantAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ad }}, nil } -func parseCnvrParams(imp *openrtb.Imp, cnvrExt openrtb_ext.ExtImpConversant) { +func parseCnvrParams(imp *openrtb2.Imp, cnvrExt openrtb_ext.ExtImpConversant) { imp.DisplayManager = "prebid-s2s" imp.DisplayManagerVer = "2.0.0" imp.BidFloor = cnvrExt.BidFloor @@ -82,9 +82,9 @@ func parseCnvrParams(imp *openrtb.Imp, cnvrExt openrtb_ext.ExtImpConversant) { imp.Secure = cnvrExt.Secure } - var position *openrtb.AdPosition + var position *openrtb2.AdPosition if cnvrExt.Position != nil { - position = openrtb.AdPosition(*cnvrExt.Position).Ptr() + position = openrtb2.AdPosition(*cnvrExt.Position).Ptr() } if imp.Banner != nil { tmpBanner := *imp.Banner @@ -97,9 +97,9 @@ func parseCnvrParams(imp *openrtb.Imp, cnvrExt openrtb_ext.ExtImpConversant) { imp.Video.Pos = position if len(cnvrExt.API) > 0 { - imp.Video.API = make([]openrtb.APIFramework, 0, len(cnvrExt.API)) + imp.Video.API = make([]openrtb2.APIFramework, 0, len(cnvrExt.API)) for _, api := range cnvrExt.API { - imp.Video.API = append(imp.Video.API, openrtb.APIFramework(api)) + imp.Video.API = append(imp.Video.API, openrtb2.APIFramework(api)) } } @@ -108,9 +108,9 @@ func parseCnvrParams(imp *openrtb.Imp, cnvrExt openrtb_ext.ExtImpConversant) { // but are overridden if the custom params object also contains them. if len(cnvrExt.Protocols) > 0 { - imp.Video.Protocols = make([]openrtb.Protocol, 0, len(cnvrExt.Protocols)) + imp.Video.Protocols = make([]openrtb2.Protocol, 0, len(cnvrExt.Protocols)) for _, protocol := range cnvrExt.Protocols { - imp.Video.Protocols = append(imp.Video.Protocols, openrtb.Protocol(protocol)) + imp.Video.Protocols = append(imp.Video.Protocols, openrtb2.Protocol(protocol)) } } @@ -125,7 +125,7 @@ func parseCnvrParams(imp *openrtb.Imp, cnvrExt openrtb_ext.ExtImpConversant) { } } -func (c ConversantAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (c ConversantAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil // no bid response } @@ -136,7 +136,7 @@ func (c ConversantAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa }} } - var resp openrtb.BidResponse + var resp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &resp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), @@ -160,7 +160,7 @@ func (c ConversantAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa return bidResponse, nil } -func getBidType(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getBidType(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { bidType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/cpmstar/cpmstar.go b/adapters/cpmstar/cpmstar.go index f3fbdf70516..b3100222e98 100644 --- a/adapters/cpmstar/cpmstar.go +++ b/adapters/cpmstar/cpmstar.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type Adapter struct { endpoint string } -func (a *Adapter) MakeRequests(request *openrtb.BidRequest, unused *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *Adapter) MakeRequests(request *openrtb2.BidRequest, unused *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -36,7 +36,7 @@ func (a *Adapter) MakeRequests(request *openrtb.BidRequest, unused *adapters.Ext return adapterRequests, errs } -func (a *Adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, error) { +func (a *Adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { var err error jsonBody, err := json.Marshal(request) @@ -55,7 +55,7 @@ func (a *Adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat }, nil } -func preprocess(request *openrtb.BidRequest) error { +func preprocess(request *openrtb2.BidRequest) error { if len(request.Imp) == 0 { return &errortypes.BadInput{ Message: "No Imps in Bid Request", @@ -88,7 +88,7 @@ func preprocess(request *openrtb.BidRequest) error { return nil } -func validateImp(imp *openrtb.Imp) error { +func validateImp(imp *openrtb2.Imp) error { if imp.Banner == nil && imp.Video == nil { return &errortypes.BadInput{ Message: "Only Banner and Video bid-types are supported at this time", @@ -98,7 +98,7 @@ func validateImp(imp *openrtb.Imp) error { } // MakeBids based on cpmstar server response -func (a *Adapter) MakeBids(bidRequest *openrtb.BidRequest, unused *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *Adapter) MakeBids(bidRequest *openrtb2.BidRequest, unused *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { return nil, nil } @@ -109,7 +109,7 @@ func (a *Adapter) MakeBids(bidRequest *openrtb.BidRequest, unused *adapters.Requ }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse if err := json.Unmarshal(responseData.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json b/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json index e20acefe2c3..4350b2dc714 100644 --- a/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/cpmstar/cpmstartest/supplemental/invalid-response-unmarshall-error.json @@ -59,7 +59,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type uint64", + "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type int64", "comparison": "regex" } ] diff --git a/adapters/datablocks/datablocks.go b/adapters/datablocks/datablocks.go index 56ac8f681d7..28b9c36360e 100644 --- a/adapters/datablocks/datablocks.go +++ b/adapters/datablocks/datablocks.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,7 +19,7 @@ type DatablocksAdapter struct { EndpointTemplate template.Template } -func (a *DatablocksAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *DatablocksAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) headers := http.Header{ @@ -69,7 +69,7 @@ func (a *DatablocksAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a internal original request in OpenRTB, external = result of us having converted it (what comes out of MakeRequests) */ func (a *DatablocksAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { @@ -84,7 +84,7 @@ func (a *DatablocksAdapter) MakeBids( }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -106,9 +106,9 @@ func (a *DatablocksAdapter) MakeBids( return bidResponse, nil } -func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpDatablocks][]openrtb.Imp, error) { +func splitImpressions(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpDatablocks][]openrtb2.Imp, error) { - var m = make(map[openrtb_ext.ExtImpDatablocks][]openrtb.Imp) + var m = make(map[openrtb_ext.ExtImpDatablocks][]openrtb2.Imp) for _, imp := range imps { bidderParams, err := getBidderParams(&imp) @@ -120,14 +120,14 @@ func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpDatablocks][]op if ok { m[*bidderParams] = append(v, imp) } else { - m[*bidderParams] = []openrtb.Imp{imp} + m[*bidderParams] = []openrtb2.Imp{imp} } } return m, nil } -func getBidderParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpDatablocks, error) { +func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpDatablocks, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -156,7 +156,7 @@ func getBidderParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpDatablocks, error) { return &datablocksExt, nil } -func getMediaType(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaType(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { bidType := openrtb_ext.BidTypeBanner diff --git a/adapters/datablocks/datablockstest/supplemental/bad-response-body.json b/adapters/datablocks/datablockstest/supplemental/bad-response-body.json index c7ecf3c0eaa..7c4801e1685 100644 --- a/adapters/datablocks/datablockstest/supplemental/bad-response-body.json +++ b/adapters/datablocks/datablockstest/supplemental/bad-response-body.json @@ -81,7 +81,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/decenterads/decenterads.go b/adapters/decenterads/decenterads.go index 5719bf1e4b3..ac60a4042ae 100644 --- a/adapters/decenterads/decenterads.go +++ b/adapters/decenterads/decenterads.go @@ -7,7 +7,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -18,7 +18,7 @@ type adapter struct { endpoint string } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -40,7 +40,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraReq } impression.Ext = bidderExt - request.Imp = []openrtb.Imp{impression} + request.Imp = []openrtb2.Imp{impression} body, err := json.Marshal(request) if err != nil { errs = append(errs, err) @@ -58,7 +58,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraReq return result, errs } -func (a *adapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error switch responseData.StatusCode { @@ -76,7 +76,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse err := json.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -98,7 +98,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, return response, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/decenterads/decenteradstest/supplemental/bad_response.json b/adapters/decenterads/decenteradstest/supplemental/bad_response.json index 9d9d977b14a..487d6adf413 100644 --- a/adapters/decenterads/decenteradstest/supplemental/bad_response.json +++ b/adapters/decenterads/decenteradstest/supplemental/bad_response.json @@ -76,7 +76,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/deepintent/deepintent.go b/adapters/deepintent/deepintent.go index 1ddaa1563c9..17168ae05f8 100644 --- a/adapters/deepintent/deepintent.go +++ b/adapters/deepintent/deepintent.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -33,7 +33,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } //MakeRequests which creates request object for Deepintent DSP -func (d *DeepintentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (d *DeepintentAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var deepintentExt openrtb_ext.ExtImpDeepintent var err error @@ -42,7 +42,7 @@ func (d *DeepintentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a reqCopy := *request for _, imp := range request.Imp { - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} var bidderExt adapters.ExtImpBidder if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { @@ -76,7 +76,7 @@ func (d *DeepintentAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a } // MakeBids makes the bids -func (d *DeepintentAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (d *DeepintentAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -89,7 +89,7 @@ func (d *DeepintentAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -114,11 +114,11 @@ func (d *DeepintentAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern return bidResponse, errs } -func (d *DeepintentAdapter) preprocess(request openrtb.BidRequest) (*adapters.RequestData, []error) { +func (d *DeepintentAdapter) preprocess(request openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error impsCount := len(request.Imp) - resImps := make([]openrtb.Imp, 0, impsCount) + resImps := make([]openrtb2.Imp, 0, impsCount) for _, imp := range request.Imp { @@ -150,7 +150,7 @@ func (d *DeepintentAdapter) preprocess(request openrtb.BidRequest) (*adapters.Re }, errs } -func buildImpBanner(imp *openrtb.Imp) error { +func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ @@ -176,7 +176,7 @@ func buildImpBanner(imp *openrtb.Imp) error { return nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/deepintent/deepintenttest/supplemental/bad_response.json b/adapters/deepintent/deepintenttest/supplemental/bad_response.json index c03531b6232..b2c4c210df6 100644 --- a/adapters/deepintent/deepintenttest/supplemental/bad_response.json +++ b/adapters/deepintent/deepintenttest/supplemental/bad_response.json @@ -84,7 +84,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/dmx/dmx.go b/adapters/dmx/dmx.go index c66c6bf38fa..79e1d751712 100644 --- a/adapters/dmx/dmx.go +++ b/adapters/dmx/dmx.go @@ -8,7 +8,7 @@ import ( "net/url" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -55,15 +55,15 @@ func UserSellerOrPubId(str1, str2 string) string { return str2 } -func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { - var imps []openrtb.Imp +func (adapter *DmxAdapter) MakeRequests(request *openrtb2.BidRequest, req *adapters.ExtraRequestInfo) (reqsBidder []*adapters.RequestData, errs []error) { + var imps []openrtb2.Imp var rootExtInfo dmxExt var publisherId string var sellerId string var userExt openrtb_ext.ExtUser var anyHasId = false - var reqCopy openrtb.BidRequest = *request - var dmxReq *openrtb.BidRequest = &reqCopy + var reqCopy openrtb2.BidRequest = *request + var dmxReq *openrtb2.BidRequest = &reqCopy var dmxRawPubId dmxPubExt if request.User == nil { @@ -121,7 +121,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } dmxReq.Site.Publisher.Ext = ext } else { - dmxReq.Site.Publisher = &openrtb.Publisher{ID: publisherId} + dmxReq.Site.Publisher = &openrtb2.Publisher{ID: publisherId} } } else { dmxReq.Site = nil @@ -152,9 +152,9 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte } for _, inst := range dmxReq.Imp { - var banner *openrtb.Banner - var video *openrtb.Video - var ins openrtb.Imp + var banner *openrtb2.Banner + var video *openrtb2.Video + var ins openrtb2.Imp var params dmxExt const intVal int8 = 1 source := (*json.RawMessage)(&inst.Ext) @@ -207,7 +207,7 @@ func (adapter *DmxAdapter) MakeRequests(request *openrtb.BidRequest, req *adapte return } -func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *DmxAdapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if http.StatusNoContent == response.StatusCode { @@ -226,7 +226,7 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -255,8 +255,8 @@ func (adapter *DmxAdapter) MakeBids(request *openrtb.BidRequest, externalRequest } -func fetchParams(params dmxExt, inst openrtb.Imp, ins openrtb.Imp, imps []openrtb.Imp, banner *openrtb.Banner, video *openrtb.Video, intVal int8) []openrtb.Imp { - var tempimp openrtb.Imp +func fetchParams(params dmxExt, inst openrtb2.Imp, ins openrtb2.Imp, imps []openrtb2.Imp, banner *openrtb2.Banner, video *openrtb2.Video, intVal int8) []openrtb2.Imp { + var tempimp openrtb2.Imp tempimp = inst if params.Bidder.Bidfloor != 0 { tempimp.BidFloor = params.Bidder.Bidfloor @@ -292,7 +292,7 @@ func addParams(str string) string { return "" } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { @@ -309,7 +309,7 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, } } -func videoImpInsertion(bid *openrtb.Bid) string { +func videoImpInsertion(bid *openrtb2.Bid) string { adm := bid.AdM nurl := bid.NURL search := "" diff --git a/adapters/dmx/dmx_test.go b/adapters/dmx/dmx_test.go index 80498de6e04..4288f2fa940 100644 --- a/adapters/dmx/dmx_test.go +++ b/adapters/dmx/dmx_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" @@ -20,17 +20,17 @@ var ( func TestFetchParams(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) - var arrImp []openrtb.Imp + var width, height int64 = int64(w), int64(h) + var arrImp []openrtb2.Imp var imps = fetchParams( dmxExt{Bidder: dmxParams{ TagId: "222", PublisherId: "5555", }}, - openrtb.Imp{ID: "32"}, - openrtb.Imp{ID: "32"}, + openrtb2.Imp{ID: "32"}, + openrtb2.Imp{ID: "32"}, arrImp, - &openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + &openrtb2.Banner{W: &width, H: &height, Format: []openrtb2.Format{ {W: 300, H: 250}, }}, nil, @@ -40,10 +40,10 @@ func TestFetchParams(t *testing.T) { DmxId: "222", MemberId: "5555", }}, - openrtb.Imp{ID: "32"}, - openrtb.Imp{ID: "32"}, + openrtb2.Imp{ID: "32"}, + openrtb2.Imp{ID: "32"}, arrImp, - &openrtb.Banner{W: &width, H: &height, Format: []openrtb.Format{ + &openrtb2.Banner{W: &width, H: &height, Format: []openrtb2.Format{ {W: 300, H: 250}, }}, nil, @@ -70,7 +70,7 @@ func TestJsonSamples(t *testing.T) { func TestMakeRequestsOtherPlacement(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -79,22 +79,22 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - User: &openrtb.User{ID: "bscakucbkasucbkasunscancasuin"}, - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + User: &openrtb2.User{ID: "bscakucbkasucbkasunscancasuin"}, + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, @@ -115,7 +115,7 @@ func TestMakeRequestsOtherPlacement(t *testing.T) { func TestMakeRequestsInvalid(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -124,21 +124,21 @@ func TestMakeRequestsInvalid(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, @@ -159,7 +159,7 @@ func TestMakeRequestsInvalid(t *testing.T) { func TestMakeRequestNoSite(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -168,20 +168,20 @@ func TestMakeRequestNoSite(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + App: &openrtb2.App{ID: "cansanuabnua", Publisher: &openrtb2.Publisher{ID: "whatever"}}, ID: "1234", } @@ -190,7 +190,7 @@ func TestMakeRequestNoSite(t *testing.T) { if len(actualAdapterRequests) != 1 { t.Errorf("openrtb type should be an Array when it's an App") } - var the_body openrtb.BidRequest + var the_body openrtb2.BidRequest if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { t.Errorf("failed to read bid request") } @@ -207,7 +207,7 @@ func TestMakeRequestNoSite(t *testing.T) { func TestMakeRequestsApp(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -216,25 +216,25 @@ func TestMakeRequestsApp(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - App: &openrtb.App{ID: "cansanuabnua", Publisher: &openrtb.Publisher{ID: "whatever"}}, + App: &openrtb2.App{ID: "cansanuabnua", Publisher: &openrtb2.Publisher{ID: "whatever"}}, ID: "1234", } @@ -243,7 +243,7 @@ func TestMakeRequestsApp(t *testing.T) { if len(actualAdapterRequests) != 1 { t.Errorf("openrtb type should be an Array when it's an App") } - var the_body openrtb.BidRequest + var the_body openrtb2.BidRequest if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { t.Errorf("failed to read bid request") } @@ -257,7 +257,7 @@ func TestMakeRequestsApp(t *testing.T) { func TestMakeRequestsNoUser(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -266,21 +266,21 @@ func TestMakeRequestsNoUser(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, @@ -296,10 +296,9 @@ func TestMakeRequestsNoUser(t *testing.T) { } 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) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -308,45 +307,45 @@ func TestMakeRequests(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - imp2 := openrtb.Imp{ + imp2 := openrtb2.Imp{ ID: "imp2", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - imp3 := openrtb.Imp{ + imp3 := openrtb2.Imp{ ID: "imp3", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1, imp2, imp3}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1, imp2, imp3}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{ID: "districtmID"}, + User: &openrtb2.User{ID: "districtmID"}, ID: "1234", } @@ -355,7 +354,7 @@ func TestMakeRequests(t *testing.T) { if len(actualAdapterRequests) != 1 { t.Errorf("should have 1 request") } - var the_body openrtb.BidRequest + var the_body openrtb2.BidRequest if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { t.Errorf("failed to read bid request") } @@ -369,7 +368,7 @@ func TestMakeRequests(t *testing.T) { func TestMakeBidVideo(t *testing.T) { var w, h int = 640, 480 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -378,23 +377,23 @@ func TestMakeBidVideo(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Video: &openrtb.Video{ + Video: &openrtb2.Video{ W: width, H: height, MIMEs: []string{"video/mp4"}, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{ID: "districtmID"}, + User: &openrtb2.User{ID: "districtmID"}, ID: "1234", } @@ -403,7 +402,7 @@ func TestMakeBidVideo(t *testing.T) { if len(actualAdapterRequests) != 1 { t.Errorf("should have 1 request") } - var the_body openrtb.BidRequest + var the_body openrtb2.BidRequest if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { t.Errorf("failed to read bid request") } @@ -416,7 +415,7 @@ func TestMakeBidVideo(t *testing.T) { func TestMakeBidsNoContent(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -425,25 +424,25 @@ func TestMakeBidsNoContent(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{ID: "districtmID"}, + User: &openrtb2.User{ID: "districtmID"}, ID: "1234", } @@ -554,7 +553,7 @@ func TestMakeBidsNoContent(t *testing.T) { func TestUserExtEmptyObject(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -563,25 +562,25 @@ func TestUserExtEmptyObject(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1, imp1, imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1, imp1, imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{Ext: json.RawMessage(`{}`)}, + User: &openrtb2.User{Ext: json.RawMessage(`{}`)}, ID: "1234", } @@ -593,7 +592,7 @@ func TestUserExtEmptyObject(t *testing.T) { func TestUserEidsOnly(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -602,25 +601,25 @@ func TestUserEidsOnly(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1, imp1, imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1, imp1, imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{Ext: json.RawMessage(`{"eids": [{ + User: &openrtb2.User{Ext: json.RawMessage(`{"eids": [{ "source": "adserver.org", "uids": [{ "id": "111111111111", @@ -647,7 +646,7 @@ func TestUserEidsOnly(t *testing.T) { func TestUserDigitrustOnly(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -656,25 +655,25 @@ func TestUserDigitrustOnly(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1, imp1, imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1, imp1, imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{Ext: json.RawMessage(`{ + User: &openrtb2.User{Ext: json.RawMessage(`{ "digitrust": { "id": "11111111111", "keyv": 4 @@ -691,7 +690,7 @@ func TestUserDigitrustOnly(t *testing.T) { func TestUsersEids(t *testing.T) { var w, h int = 300, 250 - var width, height uint64 = uint64(w), uint64(h) + var width, height int64 = int64(w), int64(h) bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{ Endpoint: "https://dmx.districtm.io/b/v2"}) @@ -700,25 +699,25 @@ func TestUsersEids(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } - imp1 := openrtb.Imp{ + imp1 := openrtb2.Imp{ ID: "imp1", Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"), - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &width, H: &height, - Format: []openrtb.Format{ + Format: []openrtb2.Format{ {W: 300, H: 250}, }, }} - inputRequest := openrtb.BidRequest{ - Imp: []openrtb.Imp{imp1, imp1, imp1}, - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + inputRequest := openrtb2.BidRequest{ + Imp: []openrtb2.Imp{imp1, imp1, imp1}, + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "10007", }, }, - User: &openrtb.User{ID: "districtmID", Ext: json.RawMessage(`{"eids": [{ + User: &openrtb2.User{ID: "districtmID", Ext: json.RawMessage(`{"eids": [{ "source": "adserver.org", "uids": [{ "id": "111111111111", @@ -780,7 +779,7 @@ func TestUsersEids(t *testing.T) { if len(actualAdapterRequests) != 1 { t.Errorf("should have 1 request") } - var the_body openrtb.BidRequest + var the_body openrtb2.BidRequest if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil { t.Errorf("failed to read bid request") } @@ -790,8 +789,8 @@ func TestUsersEids(t *testing.T) { } } func TestVideoImpInsertion(t *testing.T) { - var bidResp openrtb.BidResponse - var bid openrtb.Bid + var bidResp openrtb2.BidResponse + var bid openrtb2.Bid payload := []byte(`{ "id": "some-request-id", "seatbid": [ @@ -853,7 +852,7 @@ func TestVideoImpInsertion(t *testing.T) { if err != nil { t.Errorf("Payload is invalid") } - bid = openrtb.Bid(bidResp.SeatBid[0].Bid[0]) + bid = openrtb2.Bid(bidResp.SeatBid[0].Bid[0]) data := videoImpInsertion(&bid) find := strings.Index(data, "demo.arripiblik.com") if find == -1 { diff --git a/adapters/emx_digital/emx_digital.go b/adapters/emx_digital/emx_digital.go index e87f0681075..98a8b6eb943 100644 --- a/adapters/emx_digital/emx_digital.go +++ b/adapters/emx_digital/emx_digital.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func buildEndpoint(endpoint string, testing bool, timeout int64) string { return endpoint + "?t=" + strconv.FormatInt(timeout, 10) + "&ts=" + strconv.FormatInt(time.Now().Unix(), 10) + "&src=pbserver" } -func (a *EmxDigitalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *EmxDigitalAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error if len(request.Imp) == 0 { @@ -80,7 +80,7 @@ func (a *EmxDigitalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a }}, errs } -func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpEmxDigital, error) { +func unpackImpExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpEmxDigital, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -111,7 +111,7 @@ func unpackImpExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpEmxDigital, error) { return &emxExt, nil } -func buildImpBanner(imp *openrtb.Imp) error { +func buildImpBanner(imp *openrtb2.Imp) error { if imp.Banner == nil { return &errortypes.BadInput{ @@ -138,7 +138,7 @@ func buildImpBanner(imp *openrtb.Imp) error { return nil } -func buildImpVideo(imp *openrtb.Imp) error { +func buildImpVideo(imp *openrtb2.Imp) error { if len(imp.Video.MIMEs) == 0 { return &errortypes.BadInput{ @@ -162,11 +162,11 @@ func buildImpVideo(imp *openrtb.Imp) error { } // not supporting VAST protocol 7 (VAST 4.0); -func cleanProtocol(protocols []openrtb.Protocol) []openrtb.Protocol { - newitems := make([]openrtb.Protocol, 0, len(protocols)) +func cleanProtocol(protocols []openrtb2.Protocol) []openrtb2.Protocol { + newitems := make([]openrtb2.Protocol, 0, len(protocols)) for _, i := range protocols { - if i != openrtb.ProtocolVAST40 { + if i != openrtb2.ProtocolVAST40 { newitems = append(newitems, i) } } @@ -175,7 +175,7 @@ func cleanProtocol(protocols []openrtb.Protocol) []openrtb.Protocol { } // Add EMX required properties to Imp object -func addImpProps(imp *openrtb.Imp, secure *int8, emxExt *openrtb_ext.ExtImpEmxDigital) { +func addImpProps(imp *openrtb2.Imp, secure *int8, emxExt *openrtb_ext.ExtImpEmxDigital) { imp.TagID = emxExt.TagID imp.Secure = secure @@ -202,10 +202,10 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // Handle request errors and formatting to be sent to EMX -func preprocess(request *openrtb.BidRequest) []error { +func preprocess(request *openrtb2.BidRequest) []error { impsCount := len(request.Imp) errors := make([]error, 0, impsCount) - resImps := make([]openrtb.Imp, 0, impsCount) + resImps := make([]openrtb2.Imp, 0, impsCount) secure := int8(0) domain := "" if request.Site != nil && request.Site.Page != "" { @@ -252,7 +252,7 @@ func preprocess(request *openrtb.BidRequest) []error { } // MakeBids make the bids for the bid response. -func (a *EmxDigitalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *EmxDigitalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { // no bid response @@ -265,7 +265,7 @@ func (a *EmxDigitalAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/emx_digital/emx_digitaltest/supplemental/invalid-response-unmarshall-error.json b/adapters/emx_digital/emx_digitaltest/supplemental/invalid-response-unmarshall-error.json index 1281db66fd8..4108c7a524a 100644 --- a/adapters/emx_digital/emx_digitaltest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/emx_digital/emx_digitaltest/supplemental/invalid-response-unmarshall-error.json @@ -61,7 +61,7 @@ "expectedMakeBidsErrors": [ { - "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type uint64", + "value": "Unable to unpackage bid response\\. Error: json: cannot unmarshal string into Go struct field (Bid\\.seatbid\\.bid\\.w|Bid\\.w) of type int64", "comparison": "regex" } ] diff --git a/adapters/engagebdr/engagebdr.go b/adapters/engagebdr/engagebdr.go index 16d20afa611..6c55b99987b 100644 --- a/adapters/engagebdr/engagebdr.go +++ b/adapters/engagebdr/engagebdr.go @@ -4,12 +4,12 @@ import ( "encoding/json" "net/http" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "fmt" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" ) @@ -18,7 +18,7 @@ type EngageBDRAdapter struct { URI string } -func (adapter *EngageBDRAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *EngageBDRAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errors := make([]error, 0, len(request.Imp)) @@ -30,7 +30,7 @@ func (adapter *EngageBDRAdapter) MakeRequests(request *openrtb.BidRequest, reqIn } // EngageBDR uses different sspid parameters for banner and video. - sspidImps := make(map[string][]openrtb.Imp) + sspidImps := make(map[string][]openrtb2.Imp) for _, imp := range request.Imp { if imp.Audio != nil { @@ -92,7 +92,7 @@ func (adapter *EngageBDRAdapter) MakeRequests(request *openrtb.BidRequest, reqIn return adapterRequests, errors } -func (adapter *EngageBDRAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *EngageBDRAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -109,7 +109,7 @@ func (adapter *EngageBDRAdapter) MakeBids(internalRequest *openrtb.BidRequest, e }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -127,7 +127,7 @@ func (adapter *EngageBDRAdapter) MakeBids(internalRequest *openrtb.BidRequest, e return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/eplanning/eplanning.go b/adapters/eplanning/eplanning.go index 8d0f7e8b662..2aa066ba2b2 100644 --- a/adapters/eplanning/eplanning.go +++ b/adapters/eplanning/eplanning.go @@ -11,7 +11,7 @@ import ( "fmt" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -64,7 +64,7 @@ type hbResponseAd struct { Height uint64 `json:"h,omitempty"` } -func (adapter *EPlanningAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *EPlanningAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errors := make([]error, 0, len(request.Imp)) totalImps := len(request.Imp) spacesStrings := make([]string, 0, totalImps) @@ -191,8 +191,8 @@ func (adapter *EPlanningAdapter) MakeRequests(request *openrtb.BidRequest, reqIn return requests, errors } -func isMobileDevice(request *openrtb.BidRequest) bool { - return request.Device != nil && (request.Device.DeviceType == openrtb.DeviceTypeMobileTablet || request.Device.DeviceType == openrtb.DeviceTypePhone || request.Device.DeviceType == openrtb.DeviceTypeTablet) +func isMobileDevice(request *openrtb2.BidRequest) bool { + return request.Device != nil && (request.Device.DeviceType == openrtb2.DeviceTypeMobileTablet || request.Device.DeviceType == openrtb2.DeviceTypePhone || request.Device.DeviceType == openrtb2.DeviceTypeTablet) } func cleanName(name string) string { @@ -202,7 +202,7 @@ func cleanName(name string) string { return name } -func verifyImp(imp *openrtb.Imp, isMobile bool) (*openrtb_ext.ExtImpEPlanning, error) { +func verifyImp(imp *openrtb2.Imp, isMobile bool) (*openrtb_ext.ExtImpEPlanning, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { @@ -240,7 +240,7 @@ func verifyImp(imp *openrtb.Imp, isMobile bool) (*openrtb_ext.ExtImpEPlanning, e return &impExt, nil } -func searchSizePriority(hashedFormats map[string]int, format []openrtb.Format, priorityOrderForSizesAsc []string) (uint64, uint64) { +func searchSizePriority(hashedFormats map[string]int, format []openrtb2.Format, priorityOrderForSizesAsc []string) (int64, int64) { for i := len(priorityOrderForSizesAsc) - 1; i >= 0; i-- { if formatIndex, wasFound := hashedFormats[priorityOrderForSizesAsc[i]]; wasFound { return format[formatIndex].W, format[formatIndex].H @@ -249,7 +249,7 @@ func searchSizePriority(hashedFormats map[string]int, format []openrtb.Format, p return format[0].W, format[0].H } -func getSizeFromImp(imp *openrtb.Imp, isMobile bool) (uint64, uint64) { +func getSizeFromImp(imp *openrtb2.Imp, isMobile bool) (int64, int64) { if imp.Banner.W != nil && imp.Banner.H != nil { return *imp.Banner.W, *imp.Banner.H } @@ -279,7 +279,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } } -func (adapter *EPlanningAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *EPlanningAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -322,15 +322,15 @@ func (adapter *EPlanningAdapter) MakeBids(internalRequest *openrtb.BidRequest, e for _, space := range parsedResponse.Spaces { for _, ad := range space.Ads { if price, err := strconv.ParseFloat(ad.Price, 64); err == nil { - bid := openrtb.Bid{ + bid := openrtb2.Bid{ ID: ad.ImpressionID, AdID: ad.AdID, ImpID: spaceNameToImpID[space.Name], Price: price, AdM: ad.AdM, CrID: ad.CrID, - W: ad.Width, - H: ad.Height, + W: int64(ad.Width), + H: int64(ad.Height), } bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go index 4cb9a364cbd..b15c7b1cc04 100644 --- a/adapters/epom/epom.go +++ b/adapters/epom/epom.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -24,7 +24,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { rq, errs := a.makeRequest(request) if len(errs) > 0 { @@ -38,7 +38,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex return requests, nil } -func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { if request.Device == nil || request.Device.IP == "" { return nil, []error{&errortypes.BadInput{ Message: "ipv4 address is required field", @@ -61,7 +61,7 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat }, nil } -func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -84,7 +84,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -111,7 +111,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/gamma/gamma.go b/adapters/gamma/gamma.go index f8681fb93c0..1408fdeeede 100644 --- a/adapters/gamma/gamma.go +++ b/adapters/gamma/gamma.go @@ -7,7 +7,7 @@ import ( "net/url" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,9 +19,9 @@ type GammaAdapter struct { } type gammaBid struct { - openrtb.Bid //base - VastXML string `json:"vastXml,omitempty"` - VastURL string `json:"vastUrl,omitempty"` + openrtb2.Bid //base + VastXML string `json:"vastXml,omitempty"` + VastURL string `json:"vastUrl,omitempty"` } type gammaSeatBid struct { @@ -30,13 +30,13 @@ type gammaSeatBid struct { Ext json.RawMessage `json:"ext,omitempty"` } type gammaBidResponse struct { - ID string `json:"id"` - SeatBid []gammaSeatBid `json:"seatbid,omitempty"` - BidID string `json:"bidid,omitempty"` - Cur string `json:"cur,omitempty"` - CustomData string `json:"customdata,omitempty"` - NBR *openrtb.NoBidReasonCode `json:"nbr,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + ID string `json:"id"` + SeatBid []gammaSeatBid `json:"seatbid,omitempty"` + BidID string `json:"bidid,omitempty"` + Cur string `json:"cur,omitempty"` + CustomData string `json:"customdata,omitempty"` + NBR *openrtb2.NoBidReasonCode `json:"nbr,omitempty"` + Ext json.RawMessage `json:"ext,omitempty"` } func checkParams(gammaExt openrtb_ext.ExtImpGamma) error { @@ -57,7 +57,7 @@ func checkParams(gammaExt openrtb_ext.ExtImpGamma) error { } return nil } -func (a *GammaAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, []error) { +func (a *GammaAdapter) makeRequest(request *openrtb2.BidRequest, imp openrtb2.Imp) (*adapters.RequestData, []error) { var errors []error var bidderExt adapters.ExtImpBidder @@ -139,7 +139,7 @@ func (a *GammaAdapter) makeRequest(request *openrtb.BidRequest, imp openrtb.Imp) Headers: headers, }, errors } -func (a *GammaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *GammaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { err := &errortypes.BadInput{ @@ -202,8 +202,8 @@ func (a *GammaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte return adapterRequests, errs } -func convertBid(gBid gammaBid, mediaType openrtb_ext.BidType) *openrtb.Bid { - var bid openrtb.Bid +func convertBid(gBid gammaBid, mediaType openrtb_ext.BidType) *openrtb2.Bid { + var bid openrtb2.Bid bid = gBid.Bid if mediaType == openrtb_ext.BidTypeVideo { @@ -224,7 +224,7 @@ func convertBid(gBid gammaBid, mediaType openrtb_ext.BidType) *openrtb.Bid { return &bid } -func (a *GammaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *GammaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -283,7 +283,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // getMediaTypeForImp figures out which media type this bid is for. -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner //default type for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/gamoshi/gamoshi.go b/adapters/gamoshi/gamoshi.go index c0791e66ddc..50b7e9d58a5 100644 --- a/adapters/gamoshi/gamoshi.go +++ b/adapters/gamoshi/gamoshi.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -18,7 +18,7 @@ type GamoshiAdapter struct { URI string } -func (a *GamoshiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *GamoshiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { @@ -125,7 +125,7 @@ func (a *GamoshiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap }}, errors } -func (a *GamoshiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *GamoshiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -143,7 +143,7 @@ func (a *GamoshiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %v. ", err), @@ -169,7 +169,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } } -func getMediaType(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaType(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impId { if imp.Video != nil { diff --git a/adapters/grid/grid.go b/adapters/grid/grid.go index e70b1ddd632..69bc1500bf9 100644 --- a/adapters/grid/grid.go +++ b/adapters/grid/grid.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type GridAdapter struct { endpoint string } -func processImp(imp *openrtb.Imp) error { +func processImp(imp *openrtb2.Imp) error { // get the grid extension var ext adapters.ExtImpBidder var gridExt openrtb_ext.ExtImpGrid @@ -38,13 +38,13 @@ func processImp(imp *openrtb.Imp) error { } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *GridAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *GridAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors = make([]error, 0) // copy the request, because we are going to mutate it requestCopy := *request // this will contain all the valid impressions - var validImps []openrtb.Imp + var validImps []openrtb2.Imp // pre-process the imps for _, imp := range requestCopy.Imp { if err := processImp(&imp); err == nil { @@ -80,7 +80,7 @@ func (a *GridAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapter } // MakeBids unpacks the server's response into Bids. -func (a *GridAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *GridAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -97,7 +97,7 @@ func (a *GridAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequ }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -129,7 +129,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/grid/gridtest/supplemental/bad_response.json b/adapters/grid/gridtest/supplemental/bad_response.json index 87436da7fc1..a9d38368ab2 100644 --- a/adapters/grid/gridtest/supplemental/bad_response.json +++ b/adapters/grid/gridtest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/gumgum/gumgum.go b/adapters/gumgum/gumgum.go index 426e6112655..0334aad9d43 100644 --- a/adapters/gumgum/gumgum.go +++ b/adapters/gumgum/gumgum.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,9 +20,9 @@ type GumGumAdapter struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (g *GumGumAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var validImps []openrtb.Imp - var siteCopy openrtb.Site +func (g *GumGumAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var validImps []openrtb2.Imp + var siteCopy openrtb2.Site if request.Site != nil { siteCopy = *request.Site } @@ -44,7 +44,7 @@ func (g *GumGumAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt if siteCopy.Publisher != nil { siteCopy.Publisher.ID = strconv.FormatFloat(gumgumExt.PubID, 'f', -1, 64) } else { - siteCopy.Publisher = &openrtb.Publisher{ID: strconv.FormatFloat(gumgumExt.PubID, 'f', -1, 64)} + siteCopy.Publisher = &openrtb2.Publisher{ID: strconv.FormatFloat(gumgumExt.PubID, 'f', -1, 64)} } } @@ -80,7 +80,7 @@ func (g *GumGumAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt } // MakeBids unpacks the server's response into Bids. -func (g *GumGumAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (g *GumGumAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -96,7 +96,7 @@ func (g *GumGumAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe Message: fmt.Sprintf("Bad server response: HTTP status %d", response.StatusCode), }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d. ", err), @@ -124,7 +124,7 @@ func (g *GumGumAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return bidResponse, errs } -func preprocess(imp *openrtb.Imp) (*openrtb_ext.ExtImpGumGum, error) { +func preprocess(imp *openrtb2.Imp) (*openrtb_ext.ExtImpGumGum, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { err = &errortypes.BadInput{ @@ -169,7 +169,7 @@ func preprocess(imp *openrtb.Imp) (*openrtb_ext.ExtImpGumGum, error) { return &gumgumExt, nil } -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Banner != nil { return openrtb_ext.BidTypeBanner @@ -178,7 +178,7 @@ func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType return openrtb_ext.BidTypeVideo } -func validateVideoParams(video *openrtb.Video) (err error) { +func validateVideoParams(video *openrtb2.Video) (err error) { if video.W == 0 || video.H == 0 || video.MinDuration == 0 || video.MaxDuration == 0 || video.Placement == 0 || video.Linearity == 0 { return &errortypes.BadInput{ Message: "Invalid or missing video field(s)", diff --git a/adapters/improvedigital/improvedigital.go b/adapters/improvedigital/improvedigital.go index b1cc3640714..b942336b410 100644 --- a/adapters/improvedigital/improvedigital.go +++ b/adapters/improvedigital/improvedigital.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type ImprovedigitalAdapter struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *ImprovedigitalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ImprovedigitalAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors = make([]error, 0) reqJSON, err := json.Marshal(request) @@ -38,7 +38,7 @@ func (a *ImprovedigitalAdapter) MakeRequests(request *openrtb.BidRequest, reqInf } // MakeBids unpacks the server's response into Bids. -func (a *ImprovedigitalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *ImprovedigitalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -55,7 +55,7 @@ func (a *ImprovedigitalAdapter) MakeBids(internalRequest *openrtb.BidRequest, ex }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -103,7 +103,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json b/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json index 7099526bd90..7b103f011a1 100644 --- a/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json +++ b/adapters/improvedigital/improvedigitaltest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/infoawarebidder.go b/adapters/infoawarebidder.go index 53d80b23fc6..67227d822b3 100644 --- a/adapters/infoawarebidder.go +++ b/adapters/infoawarebidder.go @@ -3,7 +3,7 @@ package adapters import ( "fmt" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" @@ -32,7 +32,7 @@ func BuildInfoAwareBidder(bidder Bidder, info config.BidderInfo) Bidder { } } -func (i *InfoAwareBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error) { +func (i *InfoAwareBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *ExtraRequestInfo) ([]*RequestData, []error) { var allowedMediaTypes parsedSupports if request.Site != nil { @@ -72,7 +72,7 @@ func (i *InfoAwareBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *Ext // pruneImps trims invalid media types from each imp, and returns true if any of the // Imps have _no_ valid Media Types left. -func pruneImps(imps []openrtb.Imp, allowedTypes parsedSupports) (int, []error) { +func pruneImps(imps []openrtb2.Imp, allowedTypes parsedSupports) (int, []error) { numToFilter := 0 var errs []error for i := 0; i < len(imps); i++ { @@ -115,12 +115,12 @@ func parseAllowedTypes(allowedTypes []openrtb_ext.BidType) (allowBanner bool, al return } -func hasAnyTypes(imp *openrtb.Imp) bool { +func hasAnyTypes(imp *openrtb2.Imp) bool { return imp.Banner != nil || imp.Video != nil || imp.Audio != nil || imp.Native != nil } -func filterImps(imps []openrtb.Imp, numToFilter int) ([]openrtb.Imp, []error) { - newImps := make([]openrtb.Imp, 0, len(imps)-numToFilter) +func filterImps(imps []openrtb2.Imp, numToFilter int) ([]openrtb2.Imp, []error) { + newImps := make([]openrtb2.Imp, 0, len(imps)-numToFilter) errs := make([]error, 0, numToFilter) for i := 0; i < len(imps); i++ { if hasAnyTypes(&imps[i]) { diff --git a/adapters/infoawarebidder_test.go b/adapters/infoawarebidder_test.go index 6053f18ada9..60e5af041da 100644 --- a/adapters/infoawarebidder_test.go +++ b/adapters/infoawarebidder_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -22,9 +22,9 @@ func TestAppNotSupported(t *testing.T) { }, } constrained := adapters.BuildInfoAwareBidder(bidder, info) - bids, errs := constrained.MakeRequests(&openrtb.BidRequest{ - Imp: []openrtb.Imp{{ID: "imp-1", Banner: &openrtb.Banner{}}}, - App: &openrtb.App{}, + bids, errs := constrained.MakeRequests(&openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ID: "imp-1", Banner: &openrtb2.Banner{}}}, + App: &openrtb2.App{}, }, &adapters.ExtraRequestInfo{}) if !assert.Len(t, errs, 1) { return @@ -44,9 +44,9 @@ func TestSiteNotSupported(t *testing.T) { }, } constrained := adapters.BuildInfoAwareBidder(bidder, info) - bids, errs := constrained.MakeRequests(&openrtb.BidRequest{ - Imp: []openrtb.Imp{{ID: "imp-1", Banner: &openrtb.Banner{}}}, - Site: &openrtb.Site{}, + bids, errs := constrained.MakeRequests(&openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ID: "imp-1", Banner: &openrtb2.Banner{}}}, + Site: &openrtb2.Site{}, }, &adapters.ExtraRequestInfo{}) if !assert.Len(t, errs, 1) { return @@ -73,15 +73,15 @@ func TestImpFiltering(t *testing.T) { testCases := []struct { description string - inBidRequest *openrtb.BidRequest + inBidRequest *openrtb2.BidRequest expectedErrors []error expectedImpLen int }{ { description: "Empty Imp array. MakeRequest() call not expected", - inBidRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{}, - Site: &openrtb.Site{}, + inBidRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{}, + Site: &openrtb2.Site{}, }, expectedErrors: []error{ &errortypes.BadInput{Message: "Bid request didn't contain media types supported by the bidder"}, @@ -90,9 +90,9 @@ func TestImpFiltering(t *testing.T) { }, { description: "Sole imp in bid request is of wrong media type. MakeRequest() call not expected", - inBidRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ID: "imp-1", Video: &openrtb.Video{}}}, - App: &openrtb.App{}, + inBidRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ID: "imp-1", Video: &openrtb2.Video{}}}, + App: &openrtb2.App{}, }, expectedErrors: []error{ &errortypes.BadInput{Message: "request.imp[0] uses video, but this bidder doesn't support it"}, @@ -102,13 +102,13 @@ func TestImpFiltering(t *testing.T) { }, { description: "All imps in bid request of wrong media type, MakeRequest() call not expected", - inBidRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{ - {ID: "imp-1", Video: &openrtb.Video{}}, - {ID: "imp-2", Native: &openrtb.Native{}}, - {ID: "imp-3", Audio: &openrtb.Audio{}}, + inBidRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ + {ID: "imp-1", Video: &openrtb2.Video{}}, + {ID: "imp-2", Native: &openrtb2.Native{}}, + {ID: "imp-3", Audio: &openrtb2.Audio{}}, }, - App: &openrtb.App{}, + App: &openrtb2.App{}, }, expectedErrors: []error{ &errortypes.BadInput{Message: "request.imp[0] uses video, but this bidder doesn't support it"}, @@ -120,25 +120,25 @@ func TestImpFiltering(t *testing.T) { }, { description: "Some imps with correct media type, MakeRequest() call expected", - inBidRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{ + inBidRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ { ID: "imp-1", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, }, { - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, }, { ID: "imp-2", - Video: &openrtb.Video{}, - Native: &openrtb.Native{}, + Video: &openrtb2.Video{}, + Native: &openrtb2.Native{}, }, { - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, }, - Site: &openrtb.Site{}, + Site: &openrtb2.Site{}, }, expectedErrors: []error{ &errortypes.BadInput{Message: "request.imp[1] uses native, but this bidder doesn't support it"}, @@ -151,12 +151,12 @@ func TestImpFiltering(t *testing.T) { }, { description: "All imps with correct media type, MakeRequest() call expected", - inBidRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{ - {ID: "imp-1", Video: &openrtb.Video{}}, - {ID: "imp-2", Video: &openrtb.Video{}}, + inBidRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ + {ID: "imp-1", Video: &openrtb2.Video{}}, + {ID: "imp-2", Video: &openrtb2.Video{}}, }, - Site: &openrtb.Site{}, + Site: &openrtb2.Site{}, }, expectedErrors: nil, expectedImpLen: 2, @@ -178,10 +178,10 @@ func TestImpFiltering(t *testing.T) { } type mockBidder struct { - gotRequest *openrtb.BidRequest + gotRequest *openrtb2.BidRequest } -func (m *mockBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (m *mockBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var adapterRequests []*adapters.RequestData for i := 0; i < len(request.Imp); i++ { @@ -191,6 +191,6 @@ func (m *mockBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters return adapterRequests, nil } -func (m *mockBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (m *mockBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { return nil, []error{errors.New("mock MakeBids error")} } diff --git a/adapters/inmobi/inmobi.go b/adapters/inmobi/inmobi.go index 5d978ec7935..5034f01d77b 100644 --- a/adapters/inmobi/inmobi.go +++ b/adapters/inmobi/inmobi.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -24,7 +24,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *InMobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *InMobiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error if len(request.Imp) == 0 { @@ -56,7 +56,7 @@ func (a *InMobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt }}, errs } -func (a *InMobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *InMobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -67,7 +67,7 @@ func (a *InMobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe }} } - var serverBidResponse openrtb.BidResponse + var serverBidResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &serverBidResponse); err != nil { return nil, []error{err} } @@ -87,7 +87,7 @@ func (a *InMobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return bidResponse, nil } -func preprocess(imp *openrtb.Imp) error { +func preprocess(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ @@ -117,7 +117,7 @@ func preprocess(imp *openrtb.Imp) error { return nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/invibes/invibes.go b/adapters/invibes/invibes.go index 31124bd108f..fb4d7641d79 100644 --- a/adapters/invibes/invibes.go +++ b/adapters/invibes/invibes.go @@ -9,7 +9,7 @@ import ( "strings" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -42,8 +42,8 @@ type InvibesBidParams struct { Properties map[string]InvibesPlacementProperty `json:"Properties"` } type InvibesPlacementProperty struct { - Formats []openrtb.Format `json:"Formats"` - ImpID string `json:"ImpId"` + Formats []openrtb2.Format `json:"Formats"` + ImpID string `json:"ImpId"` } type InvibesInternalParams struct { BidParams InvibesBidParams @@ -61,8 +61,8 @@ type BidServerBidderResponse struct { Error string `json:"error"` } type BidServerTypedBid struct { - Bid openrtb.Bid `json:"bid"` - DealPriority int `json:"dealPriority"` + Bid openrtb2.Bid `json:"bid"` + DealPriority int `json:"dealPriority"` } func (a *InvibesInternalParams) IsTestRequest() bool { @@ -86,7 +86,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return &bidder, nil } -func (a *InvibesAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *InvibesAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var httpRequests []*adapters.RequestData var tempErrors []error gdprApplies, consentString := readGDPR(request) @@ -155,7 +155,7 @@ func (a *InvibesAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return httpRequests, finalErrors } -func readGDPR(request *openrtb.BidRequest) (bool, string) { +func readGDPR(request *openrtb2.BidRequest) (bool, string) { consentString := "" if request.User != nil { var extUser openrtb_ext.ExtUser @@ -175,12 +175,12 @@ func readGDPR(request *openrtb.BidRequest) (bool, string) { return gdprApplies, consentString } -func readAdFormats(currentBanner openrtb.Banner) []openrtb.Format { - var adFormats []openrtb.Format +func readAdFormats(currentBanner openrtb2.Banner) []openrtb2.Format { + var adFormats []openrtb2.Format if currentBanner.Format != nil { adFormats = currentBanner.Format } else if currentBanner.W != nil && currentBanner.H != nil { - adFormats = []openrtb.Format{ + adFormats = []openrtb2.Format{ { W: *currentBanner.W, H: *currentBanner.H, @@ -190,7 +190,7 @@ func readAdFormats(currentBanner openrtb.Banner) []openrtb.Format { return adFormats } -func (a *InvibesAdapter) makeRequest(invibesParams InvibesInternalParams, reqInfo *adapters.ExtraRequestInfo, existingRequests []*adapters.RequestData, request *openrtb.BidRequest) (*adapters.RequestData, error) { +func (a *InvibesAdapter) makeRequest(invibesParams InvibesInternalParams, reqInfo *adapters.ExtraRequestInfo, existingRequests []*adapters.RequestData, request *openrtb2.BidRequest) (*adapters.RequestData, error) { url, err := a.makeURL(request, invibesParams.DomainID) if err != nil { @@ -233,7 +233,7 @@ func (a *InvibesAdapter) makeRequest(invibesParams InvibesInternalParams, reqInf }, nil } -func (a *InvibesAdapter) makeParameter(invibesParams InvibesInternalParams, request *openrtb.BidRequest) (*InvibesAdRequest, error) { +func (a *InvibesAdapter) makeParameter(invibesParams InvibesInternalParams, request *openrtb2.BidRequest) (*InvibesAdRequest, error) { var lid string = "" if request.User != nil && request.User.BuyerUID != "" { lid = request.User.BuyerUID @@ -247,11 +247,11 @@ func (a *InvibesAdapter) makeParameter(invibesParams InvibesInternalParams, requ var width, height string if request.Device != nil { if request.Device.W > 0 { - width = strconv.FormatUint(request.Device.W, 10) + width = strconv.FormatInt(request.Device.W, 10) } if request.Device.H > 0 { - height = strconv.FormatUint(request.Device.H, 10) + height = strconv.FormatInt(request.Device.H, 10) } } @@ -278,7 +278,7 @@ func (a *InvibesAdapter) makeParameter(invibesParams InvibesInternalParams, requ return &invRequest, err } -func (a *InvibesAdapter) makeURL(request *openrtb.BidRequest, domainID int) (string, error) { +func (a *InvibesAdapter) makeURL(request *openrtb2.BidRequest, domainID int) (string, error) { host := "bid.videostep.com" if domainID == 1 { host = "adweb.videostepstage.com" @@ -307,7 +307,7 @@ func (a *InvibesAdapter) makeURL(request *openrtb.BidRequest, domainID int) (str } func (a *InvibesAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { diff --git a/adapters/ix/ix.go b/adapters/ix/ix.go index 96cd988de54..038a2c146b9 100644 --- a/adapters/ix/ix.go +++ b/adapters/ix/ix.go @@ -8,14 +8,13 @@ import ( "io/ioutil" "net/http" - "golang.org/x/net/context/ctxhttp" - - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/pbs" + "golang.org/x/net/context/ctxhttp" ) type IxAdapter struct { @@ -46,8 +45,8 @@ type ixBidResult struct { type callOneObject struct { requestJSON bytes.Buffer - width uint64 - height uint64 + width int64 + height int64 bidType string } @@ -87,11 +86,11 @@ func (a *IxAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pbs.P thisImp.TagID = unit.Code if thisImp.Banner != nil { - thisImp.Banner.Format = []openrtb.Format{format} + thisImp.Banner.Format = []openrtb2.Format{format} thisImp.Banner.W = &format.W thisImp.Banner.H = &format.H } - indexReq.Imp = []openrtb.Imp{thisImp} + indexReq.Imp = []openrtb2.Imp{thisImp} // Index spec says "adunit path representing ad server inventory" but we don't have this // ext is DFP div ID and KV pairs if avail //indexReq.Imp[i].Ext = json.RawMessage("{}") @@ -99,7 +98,7 @@ func (a *IxAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pbs.P if indexReq.Site != nil { // Any objects pointed to by indexReq *must not be mutated*, or we will get race conditions. siteCopy := *indexReq.Site - siteCopy.Publisher = &openrtb.Publisher{ID: params.SiteID} + siteCopy.Publisher = &openrtb2.Publisher{ID: params.SiteID} indexReq.Site = &siteCopy } @@ -221,7 +220,7 @@ func (a *IxAdapter) callOne(ctx context.Context, reqJSON bytes.Buffer) (ixBidRes } result.ResponseBody = string(body) - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return result, &errortypes.BadServerResponse{ @@ -251,7 +250,7 @@ func (a *IxAdapter) callOne(ctx context.Context, reqJSON bytes.Buffer) (ixBidRes return result, nil } -func (a *IxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *IxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { nImp := len(request.Imp) if nImp > a.maxRequests { request.Imp = request.Imp[:a.maxRequests] @@ -286,8 +285,8 @@ func (a *IxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters. formats := getBannerFormats(&banner) for iFmt := range formats { banner.Format = formats[iFmt : iFmt+1] - banner.W = openrtb.Uint64Ptr(banner.Format[0].W) - banner.H = openrtb.Uint64Ptr(banner.Format[0].H) + banner.W = openrtb2.Int64Ptr(banner.Format[0].W) + banner.H = openrtb2.Int64Ptr(banner.Format[0].H) if requestData, err := createRequestData(a, request, &headers); err == nil { if iFmt == 0 { requests = append(requests, requestData) @@ -312,12 +311,12 @@ func (a *IxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters. return append(requests, multiSizeRequests...), errs } -func setSitePublisherId(request *openrtb.BidRequest, iImp int) error { +func setSitePublisherId(request *openrtb2.BidRequest, iImp int) error { if iImp == 0 { // first impression - create a site and pub copy site := *request.Site if site.Publisher == nil { - site.Publisher = &openrtb.Publisher{} + site.Publisher = &openrtb2.Publisher{} } else { publisher := *site.Publisher site.Publisher = &publisher @@ -339,14 +338,14 @@ func setSitePublisherId(request *openrtb.BidRequest, iImp int) error { return nil } -func getBannerFormats(banner *openrtb.Banner) []openrtb.Format { +func getBannerFormats(banner *openrtb2.Banner) []openrtb2.Format { if len(banner.Format) == 0 && banner.W != nil && banner.H != nil { - banner.Format = []openrtb.Format{{W: *banner.W, H: *banner.H}} + banner.Format = []openrtb2.Format{{W: *banner.W, H: *banner.H}} } return banner.Format } -func createRequestData(a *IxAdapter, request *openrtb.BidRequest, headers *http.Header) (*adapters.RequestData, error) { +func createRequestData(a *IxAdapter, request *openrtb2.BidRequest, headers *http.Header) (*adapters.RequestData, error) { body, err := json.Marshal(request) return &adapters.RequestData{ Method: "POST", @@ -356,7 +355,7 @@ func createRequestData(a *IxAdapter, request *openrtb.BidRequest, headers *http. }, err } -func (a *IxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *IxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { switch { case response.StatusCode == http.StatusNoContent: return nil, nil @@ -370,7 +369,7 @@ func (a *IxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReques }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("JSON parsing error: %v", err), diff --git a/adapters/ix/ix_test.go b/adapters/ix/ix_test.go index 8a75e6852b7..4c0515b4c6b 100644 --- a/adapters/ix/ix_test.go +++ b/adapters/ix/ix_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -39,7 +39,7 @@ func getAdUnit() pbs.PBSAdUnit { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -54,7 +54,7 @@ func getVideoAdUnit() pbs.PBSAdUnit { Code: "unitCodeVideo", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO}, BidID: "bididvideo", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 100, H: 75, @@ -73,8 +73,8 @@ func getVideoAdUnit() pbs.PBSAdUnit { } } -func getOpenRTBBid(i openrtb.Imp) openrtb.Bid { - return openrtb.Bid{ +func getOpenRTBBid(i openrtb2.Imp) openrtb2.Bid { + return openrtb2.Bid{ ID: fmt.Sprintf("%d", rand.Intn(1000)), ImpID: i.ID, Price: 1.0, @@ -94,7 +94,7 @@ func dummyIXServer(w http.ResponseWriter, r *http.Request) { return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -103,10 +103,10 @@ func dummyIXServer(w http.ResponseWriter, r *http.Request) { impression := breq.Imp[0] - resp := openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + resp := openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ getOpenRTBBid(impression), }, }, @@ -141,7 +141,7 @@ func TestIxInvalidCall(t *testing.T) { func TestIxInvalidCallReqAppNil(t *testing.T) { ctx := context.TODO() pbReq := pbs.PBSRequest{ - App: &openrtb.App{}, + App: &openrtb2.App{}, } pbBidder := pbs.PBSBidder{} @@ -203,7 +203,7 @@ func TestIxTimeoutMultipleSlots(t *testing.T) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -212,10 +212,10 @@ func TestIxTimeoutMultipleSlots(t *testing.T) { impression := breq.Imp[0] - resp := openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + resp := openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ getOpenRTBBid(impression), }, }, @@ -247,7 +247,7 @@ func TestIxTimeoutMultipleSlots(t *testing.T) { adUnit1 := getAdUnit() adUnit2 := getAdUnit() adUnit2.Code = "unitCode2" - adUnit2.Sizes = []openrtb.Format{ + adUnit2.Sizes = []openrtb2.Format{ { W: 8, H: 10, @@ -382,7 +382,7 @@ func TestIxInvalidCallMissingSize(t *testing.T) { ctx := context.TODO() pbReq := pbs.PBSRequest{} adUnit := getAdUnit() - adUnit.Sizes = []openrtb.Format{} + adUnit.Sizes = []openrtb2.Format{} pbBidder := pbs.PBSBidder{ BidderCode: "bannerCode", AdUnits: []pbs.PBSAdUnit{ @@ -423,17 +423,17 @@ func TestIxMismatchUnitCode(t *testing.T) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - resp := openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + resp := openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ { ID: fmt.Sprintf("%d", rand.Intn(1000)), ImpID: "unitCode_bogus", @@ -477,14 +477,14 @@ func TestNoSeatBid(t *testing.T) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - resp := openrtb.BidResponse{} + resp := openrtb2.BidResponse{} js, err := json.Marshal(resp) if err != nil { @@ -516,15 +516,15 @@ func TestNoSeatBidBid(t *testing.T) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - resp := openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + resp := openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ {}, }, } @@ -650,7 +650,7 @@ func TestIxTwoSlotMultiSizeOnlyValidIXSizeResponse(t *testing.T) { ctx := context.TODO() pbReq := pbs.PBSRequest{} adUnit := getAdUnit() - adUnit.Sizes = append(adUnit.Sizes, openrtb.Format{W: 20, H: 22}) + adUnit.Sizes = append(adUnit.Sizes, openrtb2.Format{W: 20, H: 22}) pbBidder := pbs.PBSBidder{ BidderCode: "bannerCode", @@ -674,7 +674,7 @@ func TestIxTwoSlotMultiSizeOnlyValidIXSizeResponse(t *testing.T) { } } -func bidResponseForSizeExist(bids pbs.PBSBidSlice, h uint64, w uint64) bool { +func bidResponseForSizeExist(bids pbs.PBSBidSlice, h, w int64) bool { for _, v := range bids { if v.Height == h && v.Width == w { return true diff --git a/adapters/jixie/jixie.go b/adapters/jixie/jixie.go index 973bfcb42eb..565f8a588c3 100644 --- a/adapters/jixie/jixie.go +++ b/adapters/jixie/jixie.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs = make([]error, 0) data, err := json.Marshal(request) @@ -80,7 +80,7 @@ func getBidType(bidAdm string) openrtb_ext.BidType { } // MakeBids make the bids for the bid response. -func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { // no bid response @@ -99,7 +99,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/kidoz/kidoz.go b/adapters/kidoz/kidoz.go index fda6869e12f..670bfb80b49 100644 --- a/adapters/kidoz/kidoz.go +++ b/adapters/kidoz/kidoz.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type KidozAdapter struct { endpoint string } -func (a *KidozAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *KidozAdapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -102,7 +102,7 @@ func (a *KidozAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.Ext return result, errs } -func (a *KidozAdapter) MakeBids(request *openrtb.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *KidozAdapter) MakeBids(request *openrtb2.BidRequest, _ *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error switch responseData.StatusCode { @@ -129,7 +129,7 @@ func (a *KidozAdapter) MakeBids(request *openrtb.BidRequest, _ *adapters.Request }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse err := json.Unmarshal(responseData.Body, &bidResponse) if err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -169,7 +169,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters const UndefinedMediaType = openrtb_ext.BidType("") -func GetMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func GetMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { var bidType openrtb_ext.BidType = UndefinedMediaType for _, impression := range imps { if impression.ID != impID { diff --git a/adapters/kidoz/kidoz_test.go b/adapters/kidoz/kidoz_test.go index 5830f60ddb5..0de06392bba 100644 --- a/adapters/kidoz/kidoz_test.go +++ b/adapters/kidoz/kidoz_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -24,14 +24,14 @@ func TestJsonSamples(t *testing.T) { adapterstest.RunJSONBidderTest(t, "kidoztest", bidder) } -func makeBidRequest() *openrtb.BidRequest { - request := &openrtb.BidRequest{ +func makeBidRequest() *openrtb2.BidRequest { + request := &openrtb2.BidRequest{ ID: "test-req-id-0", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "test-imp-id-0", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ { W: 320, H: 50, @@ -89,22 +89,22 @@ func TestMakeBids(t *testing.T) { } func TestGetMediaTypeForImp(t *testing.T) { - imps := []openrtb.Imp{ + imps := []openrtb2.Imp{ { ID: "1", - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, }, { ID: "2", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, }, { ID: "3", - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, }, { ID: "4", - Audio: &openrtb.Audio{}, + Audio: &openrtb2.Audio{}, }, } diff --git a/adapters/krushmedia/krushmedia.go b/adapters/krushmedia/krushmedia.go index d05b6e7979a..54e89200844 100644 --- a/adapters/krushmedia/krushmedia.go +++ b/adapters/krushmedia/krushmedia.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getHeaders(request *openrtb.BidRequest) *http.Header { +func getHeaders(request *openrtb2.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -60,7 +60,7 @@ func getHeaders(request *openrtb.BidRequest) *http.Header { } func (a *KrushmediaAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -107,7 +107,7 @@ func (a *KrushmediaAdapter) MakeRequests( }}, nil } -func (a *KrushmediaAdapter) getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtKrushmedia, error) { +func (a *KrushmediaAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtKrushmedia, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -129,7 +129,7 @@ func (a *KrushmediaAdapter) buildEndpointURL(params *openrtb_ext.ExtKrushmedia) } func (a *KrushmediaAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -157,7 +157,7 @@ func (a *KrushmediaAdapter) MakeBids( } responseBody := bidderRawResponse.Body - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", @@ -176,7 +176,7 @@ func (a *KrushmediaAdapter) MakeBids( return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/kubient/kubient.go b/adapters/kubient/kubient.go index a995586533a..8b011b7f795 100644 --- a/adapters/kubient/kubient.go +++ b/adapters/kubient/kubient.go @@ -5,10 +5,10 @@ import ( "fmt" "net/http" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" ) @@ -28,7 +28,7 @@ type KubientAdapter struct { // MakeRequests prepares the HTTP requests which should be made to fetch bids. func (adapter *KubientAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ([]*adapters.RequestData, []error) { if len(openRTBRequest.Imp) == 0 { @@ -65,7 +65,7 @@ func (adapter *KubientAdapter) MakeRequests( return requestsToBidder, errs } -func checkImpExt(impObj openrtb.Imp) error { +func checkImpExt(impObj openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(impObj.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ @@ -87,7 +87,7 @@ func checkImpExt(impObj openrtb.Imp) error { } // MakeBids makes the bids -func (adapter *KubientAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *KubientAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -106,7 +106,7 @@ func (adapter *KubientAdapter) MakeBids(internalRequest *openrtb.BidRequest, ext }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -131,7 +131,7 @@ func (adapter *KubientAdapter) MakeBids(internalRequest *openrtb.BidRequest, ext return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/kubient/kubienttest/supplemental/bad_response.json b/adapters/kubient/kubienttest/supplemental/bad_response.json index 076acf29058..832dc975088 100644 --- a/adapters/kubient/kubienttest/supplemental/bad_response.json +++ b/adapters/kubient/kubienttest/supplemental/bad_response.json @@ -54,7 +54,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/lifestreet/lifestreet.go b/adapters/lifestreet/lifestreet.go index 4dbd7baed62..7114a9bbaac 100644 --- a/adapters/lifestreet/lifestreet.go +++ b/adapters/lifestreet/lifestreet.go @@ -9,9 +9,9 @@ import ( "net/http" "strings" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/pbs" @@ -63,7 +63,7 @@ func (a *LifestreetAdapter) callOne(ctx context.Context, req *pbs.PBSRequest, re return } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return @@ -98,11 +98,11 @@ func (a *LifestreetAdapter) callOne(ctx context.Context, req *pbs.PBSRequest, re return } -func (a *LifestreetAdapter) MakeOpenRtbBidRequest(req *pbs.PBSRequest, bidder *pbs.PBSBidder, slotTag string, mtype pbs.MediaType, unitInd int) (openrtb.BidRequest, error) { +func (a *LifestreetAdapter) MakeOpenRtbBidRequest(req *pbs.PBSRequest, bidder *pbs.PBSBidder, slotTag string, mtype pbs.MediaType, unitInd int) (openrtb2.BidRequest, error) { lsReq, err := adapters.MakeOpenRTBGeneric(req, bidder, a.Name(), []pbs.MediaType{mtype}) if err != nil { - return openrtb.BidRequest{}, err + return openrtb2.BidRequest{}, err } if lsReq.Imp != nil && len(lsReq.Imp) > 0 { diff --git a/adapters/lifestreet/lifestreet_test.go b/adapters/lifestreet/lifestreet_test.go index 412333c3714..215f137ccf4 100644 --- a/adapters/lifestreet/lifestreet_test.go +++ b/adapters/lifestreet/lifestreet_test.go @@ -10,13 +10,13 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/cache/dummycache" "github.com/prebid/prebid-server/pbs" "github.com/prebid/prebid-server/usersync" "fmt" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" ) @@ -53,7 +53,7 @@ func DummyLifestreetServer(w http.ResponseWriter, r *http.Request) { return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -84,7 +84,7 @@ func DummyLifestreetServer(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprintf("Model '%s' doesn't match '%s", breq.Device.Model, lsdata.deviceModel), http.StatusInternalServerError) return } - if *breq.Device.ConnectionType != openrtb.ConnectionType(lsdata.deviceConnectiontype) { + if *breq.Device.ConnectionType != openrtb2.ConnectionType(lsdata.deviceConnectiontype) { http.Error(w, fmt.Sprintf("Connectiontype '%d' doesn't match '%d", breq.Device.ConnectionType, lsdata.deviceConnectiontype), http.StatusInternalServerError) return } @@ -96,24 +96,24 @@ func DummyLifestreetServer(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprintf("Wrong number of imp objects sent: %d", len(breq.Imp)), http.StatusInternalServerError) return } - var bid *openrtb.Bid + var bid *openrtb2.Bid for _, tag := range lsdata.tags { if breq.Imp[0].Banner == nil { http.Error(w, fmt.Sprintf("No banner object sent"), http.StatusInternalServerError) return } - if *breq.Imp[0].Banner.W != lsdata.width || *breq.Imp[0].Banner.H != lsdata.height { + if *breq.Imp[0].Banner.W != int64(lsdata.width) || *breq.Imp[0].Banner.H != int64(lsdata.height) { http.Error(w, fmt.Sprintf("Size '%dx%d' doesn't match '%dx%d", breq.Imp[0].Banner.W, breq.Imp[0].Banner.H, lsdata.width, lsdata.height), http.StatusInternalServerError) return } if breq.Imp[0].TagID == tag.slotTag { - bid = &openrtb.Bid{ + bid = &openrtb2.Bid{ ID: "random-id", ImpID: breq.Imp[0].ID, Price: tag.bid, AdM: tag.content, - W: lsdata.width, - H: lsdata.height, + W: int64(lsdata.width), + H: int64(lsdata.height), } } } @@ -122,14 +122,14 @@ func DummyLifestreetServer(w http.ResponseWriter, r *http.Request) { return } - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "2345676337", BidID: "975537589956", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "LSM", - Bid: []openrtb.Bid{*bid}, + Bid: []openrtb2.Bid{*bid}, }, }, } @@ -181,25 +181,25 @@ func TestLifestreetBasicResponse(t *testing.T) { pbin := pbs.PBSRequest{ AdUnits: make([]pbs.AdUnit, 2), - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: lsdata.appBundle, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: lsdata.deviceUA, IP: lsdata.deviceIP, Make: lsdata.deviceMake, Model: lsdata.deviceModel, - ConnectionType: openrtb.ConnectionType(lsdata.deviceConnectiontype).Ptr(), + ConnectionType: openrtb2.ConnectionType(lsdata.deviceConnectiontype).Ptr(), IFA: lsdata.deviceIfa, }, } for i, tag := range lsdata.tags { pbin.AdUnits[i] = pbs.AdUnit{ Code: tag.code, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { - W: lsdata.width, - H: lsdata.height, + W: int64(lsdata.width), + H: int64(lsdata.height), }, }, Bids: []pbs.Bids{ @@ -266,7 +266,7 @@ func TestLifestreetBasicResponse(t *testing.T) { if bid.Price != tag.bid { t.Errorf("Incorrect bid price '%.2f' expected '%.2f'", bid.Price, tag.bid) } - if bid.Width != lsdata.width || bid.Height != lsdata.height { + if bid.Width != int64(lsdata.width) || bid.Height != int64(lsdata.height) { t.Errorf("Incorrect bid size %dx%d, expected %dx%d", bid.Width, bid.Height, lsdata.width, lsdata.height) } if bid.Adm != tag.content { diff --git a/adapters/lockerdome/lockerdome.go b/adapters/lockerdome/lockerdome.go index a81313c6e80..483ffbd5bd6 100644 --- a/adapters/lockerdome/lockerdome.go +++ b/adapters/lockerdome/lockerdome.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,7 +20,7 @@ type LockerDomeAdapter struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids [from the bidder, in this case, LockerDome] -func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb.BidRequest, extraReqInfo *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { +func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb2.BidRequest, extraReqInfo *adapters.ExtraRequestInfo) (requestsToBidder []*adapters.RequestData, errs []error) { numberOfImps := len(openRTBRequest.Imp) @@ -70,7 +70,7 @@ func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb.BidReques indexesOfValidImps = append(indexesOfValidImps, i) } if numberOfImps > len(indexesOfValidImps) { - var validImps []openrtb.Imp + var validImps []openrtb2.Imp for j := 0; j < len(indexesOfValidImps); j++ { validImps = append(validImps, openRTBRequest.Imp[j]) } @@ -109,7 +109,7 @@ func (adapter *LockerDomeAdapter) MakeRequests(openRTBRequest *openrtb.BidReques } // MakeBids unpacks the server's response into Bids. -func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData) (bidderResponse *adapters.BidderResponse, errs []error) { +func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData) (bidderResponse *adapters.BidderResponse, errs []error) { if bidderRawResponse.StatusCode == http.StatusNoContent { return nil, nil @@ -127,7 +127,7 @@ func (adapter *LockerDomeAdapter) MakeBids(openRTBRequest *openrtb.BidRequest, r }} } - var openRTBBidderResponse openrtb.BidResponse + var openRTBBidderResponse openrtb2.BidResponse if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{ fmt.Errorf("Error unmarshaling LockerDome bid response - %s", err.Error()), diff --git a/adapters/lockerdome/lockerdometest/supplemental/bad_response.json b/adapters/lockerdome/lockerdometest/supplemental/bad_response.json index 8df8a0e1633..d119a47da80 100644 --- a/adapters/lockerdome/lockerdometest/supplemental/bad_response.json +++ b/adapters/lockerdome/lockerdometest/supplemental/bad_response.json @@ -56,7 +56,7 @@ "expectedMakeBidsErrors": [ { - "value": "Error unmarshaling LockerDome bid response - json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "Error unmarshaling LockerDome bid response - json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/logicad/logicad.go b/adapters/logicad/logicad.go index 30d9dd5df4c..bc45652d127 100644 --- a/adapters/logicad/logicad.go +++ b/adapters/logicad/logicad.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type LogicadAdapter struct { endpoint string } -func (adapter *LogicadAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *LogicadAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{Message: "No impression in the bid request"}} } @@ -38,10 +38,10 @@ func (adapter *LogicadAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo return result, errs } -func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpLogicad][]openrtb.Imp, []openrtb.Imp, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpLogicad][]openrtb2.Imp, []openrtb2.Imp, []error) { errors := make([]error, 0, len(imps)) - resImps := make([]openrtb.Imp, 0, len(imps)) - res := make(map[openrtb_ext.ExtImpLogicad][]openrtb.Imp) + resImps := make([]openrtb2.Imp, 0, len(imps)) + res := make(map[openrtb_ext.ExtImpLogicad][]openrtb2.Imp) for _, imp := range imps { impExt, err := getImpressionExt(&imp) @@ -55,7 +55,7 @@ func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpLogicad][]ope } if res[impExt] == nil { - res[impExt] = make([]openrtb.Imp, 0) + res[impExt] = make([]openrtb2.Imp, 0) } res[impExt] = append(res[impExt], imp) resImps = append(resImps, imp) @@ -70,7 +70,7 @@ func validateImpression(impExt *openrtb_ext.ExtImpLogicad) error { return nil } -func getImpressionExt(imp *openrtb.Imp) (openrtb_ext.ExtImpLogicad, error) { +func getImpressionExt(imp *openrtb2.Imp) (openrtb_ext.ExtImpLogicad, error) { var bidderExt adapters.ExtImpBidder var logicadExt openrtb_ext.ExtImpLogicad @@ -87,7 +87,7 @@ func getImpressionExt(imp *openrtb.Imp) (openrtb_ext.ExtImpLogicad, error) { return logicadExt, nil } -func (adapter *LogicadAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpLogicad, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *LogicadAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpLogicad, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -105,7 +105,7 @@ func (adapter *LogicadAdapter) buildAdapterRequest(prebidBidRequest *openrtb.Bid Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpLogicad, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpLogicad, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps for idx := range bidRequest.Imp { @@ -117,7 +117,7 @@ func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext. } //MakeBids translates Logicad bid response to prebid-server specific format -func (adapter *LogicadAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *LogicadAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -126,7 +126,7 @@ func (adapter *LogicadAdapter) MakeBids(internalRequest *openrtb.BidRequest, ext return nil, []error{&errortypes.BadServerResponse{Message: msg}} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { msg := fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} diff --git a/adapters/lunamedia/lunamedia.go b/adapters/lunamedia/lunamedia.go index 289d062c8bb..a8040365964 100644 --- a/adapters/lunamedia/lunamedia.go +++ b/adapters/lunamedia/lunamedia.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,7 +19,7 @@ type LunaMediaAdapter struct { } //MakeRequests prepares request information for prebid-server core -func (adapter *LunaMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *LunaMediaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, &errortypes.BadInput{Message: "No impression in the bid request"}) @@ -49,10 +49,10 @@ func (adapter *LunaMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqIn } // getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts -func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpLunaMedia][]openrtb.Imp, []openrtb.Imp, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpLunaMedia][]openrtb2.Imp, []openrtb2.Imp, []error) { errors := make([]error, 0, len(imps)) - resImps := make([]openrtb.Imp, 0, len(imps)) - res := make(map[openrtb_ext.ExtImpLunaMedia][]openrtb.Imp) + resImps := make([]openrtb2.Imp, 0, len(imps)) + res := make(map[openrtb_ext.ExtImpLunaMedia][]openrtb2.Imp) for _, imp := range imps { impExt, err := getImpressionExt(&imp) @@ -71,7 +71,7 @@ func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpLunaMedia][]o continue } if res[*impExt] == nil { - res[*impExt] = make([]openrtb.Imp, 0) + res[*impExt] = make([]openrtb2.Imp, 0) } res[*impExt] = append(res[*impExt], imp) resImps = append(resImps, imp) @@ -87,7 +87,7 @@ func validateImpression(impExt *openrtb_ext.ExtImpLunaMedia) error { } //Alter impression info to comply with LunaMedia platform requirements -func compatImpression(imp *openrtb.Imp) error { +func compatImpression(imp *openrtb2.Imp) error { imp.Ext = nil //do not forward ext to LunaMedia platform if imp.Banner != nil { return compatBannerImpression(imp) @@ -95,7 +95,7 @@ func compatImpression(imp *openrtb.Imp) error { return nil } -func compatBannerImpression(imp *openrtb.Imp) error { +func compatBannerImpression(imp *openrtb2.Imp) error { // Create a copy of the banner, since imp is a shallow copy of the original. bannerCopy := *imp.Banner @@ -114,7 +114,7 @@ func compatBannerImpression(imp *openrtb.Imp) error { return nil } -func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpLunaMedia, error) { +func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpLunaMedia, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -130,7 +130,7 @@ func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpLunaMedia, error) { return &LunaMediaExt, nil } -func (adapter *LunaMediaAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpLunaMedia, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *LunaMediaAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpLunaMedia, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -154,7 +154,7 @@ func (adapter *LunaMediaAdapter) buildAdapterRequest(prebidBidRequest *openrtb.B Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpLunaMedia, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpLunaMedia, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps for idx := range bidRequest.Imp { @@ -184,7 +184,7 @@ func (adapter *LunaMediaAdapter) buildEndpointURL(params *openrtb_ext.ExtImpLuna } //MakeBids translates LunaMedia bid response to prebid-server specific format -func (adapter *LunaMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *LunaMediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var msg = "" if response.StatusCode == http.StatusNoContent { return nil, nil @@ -194,7 +194,7 @@ func (adapter *LunaMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, e return nil, []error{&errortypes.BadServerResponse{Message: msg}} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} @@ -218,7 +218,7 @@ func (adapter *LunaMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, e } // getMediaTypeForImp figures out which media type this bid is for -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Video != nil { return openrtb_ext.BidTypeVideo diff --git a/adapters/marsmedia/marsmedia.go b/adapters/marsmedia/marsmedia.go index eb1e8da0858..20d0d1fc645 100644 --- a/adapters/marsmedia/marsmedia.go +++ b/adapters/marsmedia/marsmedia.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type MarsmediaAdapter struct { URI string } -func (a *MarsmediaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *MarsmediaAdapter) MakeRequests(requestIn *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { request := *requestIn @@ -106,7 +106,7 @@ func (a *MarsmediaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo * }}, []error{} } -func (a *MarsmediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *MarsmediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -124,7 +124,7 @@ func (a *MarsmediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d. ", err), @@ -150,7 +150,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } // getMediaTypeForImp figures out which media type this bid is for. -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner //default type for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/mgid/mgid.go b/adapters/mgid/mgid.go index d6ba175d336..0917003ab82 100644 --- a/adapters/mgid/mgid.go +++ b/adapters/mgid/mgid.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -26,7 +26,7 @@ type RespBidExt struct { CreativeType openrtb_ext.BidType `json:"crtype"` } -func (a *MgidAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (adapterRequests []*adapters.RequestData, errs []error) { +func (a *MgidAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) (adapterRequests []*adapters.RequestData, errs []error) { adapterReq, errs := a.makeRequest(request) if adapterReq != nil && len(errs) == 0 { @@ -36,7 +36,7 @@ func (a *MgidAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapter return } -func (a *MgidAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *MgidAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error path, err := preprocess(request) @@ -65,7 +65,7 @@ func (a *MgidAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Reques } // Mutate the request to get it ready to send to yieldmo. -func preprocess(request *openrtb.BidRequest) (path string, err error) { +func preprocess(request *openrtb2.BidRequest) (path string, err error) { if request.TMax == 0 { request.TMax = 200 } @@ -123,7 +123,7 @@ func preprocess(request *openrtb.BidRequest) (path string, err error) { return } -func (a *MgidAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *MgidAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -140,7 +140,7 @@ func (a *MgidAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.Requ }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} diff --git a/adapters/mobfoxpb/mobfoxpb.go b/adapters/mobfoxpb/mobfoxpb.go index 6982e419cd5..d39fbfb74e9 100644 --- a/adapters/mobfoxpb/mobfoxpb.go +++ b/adapters/mobfoxpb/mobfoxpb.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -37,7 +37,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests create bid request for mobfoxpb demand -func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var route string var method string @@ -67,7 +67,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex requestURI = strings.Replace(requestURI, MACROS_ROUTE, route, 1) requestURI = strings.Replace(requestURI, MACROS_METHOD, method, 1) - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} adapterReq, err := a.makeRequest(&reqCopy, requestURI) if err != nil { errs = append(errs, err) @@ -78,7 +78,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex return adapterRequests, errs } -func (a *adapter) makeRequest(request *openrtb.BidRequest, requestURI string) (*adapters.RequestData, error) { +func (a *adapter) makeRequest(request *openrtb2.BidRequest, requestURI string) (*adapters.RequestData, error) { reqJSON, err := json.Marshal(request) if err != nil { @@ -97,7 +97,7 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest, requestURI string) (* } // MakeBids makes the bids -func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -110,7 +110,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -134,7 +134,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json index efd1ac90d9d..d61cb8837c4 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json @@ -78,7 +78,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/mobilefuse/mobilefuse.go b/adapters/mobilefuse/mobilefuse.go index 76c18e27007..217f0f24b7b 100644 --- a/adapters/mobilefuse/mobilefuse.go +++ b/adapters/mobilefuse/mobilefuse.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (adapter *MobileFuseAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *MobileFuseAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var adapterRequests []*adapters.RequestData adapterRequest, errs := adapter.makeRequest(request) @@ -44,7 +44,7 @@ func (adapter *MobileFuseAdapter) MakeRequests(request *openrtb.BidRequest, reqI return adapterRequests, errs } -func (adapter *MobileFuseAdapter) MakeBids(incomingRequest *openrtb.BidRequest, outgoingRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *MobileFuseAdapter) MakeBids(incomingRequest *openrtb2.BidRequest, outgoingRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -61,7 +61,7 @@ func (adapter *MobileFuseAdapter) MakeBids(incomingRequest *openrtb.BidRequest, }} } - var incomingBidResponse openrtb.BidResponse + var incomingBidResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &incomingBidResponse); err != nil { return nil, []error{err} @@ -81,7 +81,7 @@ func (adapter *MobileFuseAdapter) MakeBids(incomingRequest *openrtb.BidRequest, return outgoingBidResponse, nil } -func (adapter *MobileFuseAdapter) makeRequest(bidRequest *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (adapter *MobileFuseAdapter) makeRequest(bidRequest *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error mobileFuseExtension, errs := adapter.getFirstMobileFuseExtension(bidRequest) @@ -124,7 +124,7 @@ func (adapter *MobileFuseAdapter) makeRequest(bidRequest *openrtb.BidRequest) (* }, errs } -func (adapter *MobileFuseAdapter) getFirstMobileFuseExtension(request *openrtb.BidRequest) (*openrtb_ext.ExtImpMobileFuse, []error) { +func (adapter *MobileFuseAdapter) getFirstMobileFuseExtension(request *openrtb2.BidRequest) (*openrtb_ext.ExtImpMobileFuse, []error) { var mobileFuseImpExtension openrtb_ext.ExtImpMobileFuse var errs []error @@ -167,8 +167,8 @@ func (adapter *MobileFuseAdapter) getEndpoint(ext *openrtb_ext.ExtImpMobileFuse) return url, nil } -func (adapter *MobileFuseAdapter) getValidImps(bidRequest *openrtb.BidRequest, ext *openrtb_ext.ExtImpMobileFuse) []openrtb.Imp { - var validImps []openrtb.Imp +func (adapter *MobileFuseAdapter) getValidImps(bidRequest *openrtb2.BidRequest, ext *openrtb_ext.ExtImpMobileFuse) []openrtb2.Imp { + var validImps []openrtb2.Imp for _, imp := range bidRequest.Imp { if imp.Banner != nil || imp.Video != nil { @@ -187,7 +187,7 @@ func (adapter *MobileFuseAdapter) getValidImps(bidRequest *openrtb.BidRequest, e return validImps } -func (adapter *MobileFuseAdapter) getBidType(imp_id string, imps []openrtb.Imp) openrtb_ext.BidType { +func (adapter *MobileFuseAdapter) getBidType(imp_id string, imps []openrtb2.Imp) openrtb_ext.BidType { if imps[0].Video != nil { return openrtb_ext.BidTypeVideo } diff --git a/adapters/nanointeractive/nanointeractive.go b/adapters/nanointeractive/nanointeractive.go index 7189543e0f8..afe80bcbfee 100644 --- a/adapters/nanointeractive/nanointeractive.go +++ b/adapters/nanointeractive/nanointeractive.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,10 +16,10 @@ type NanoInteractiveAdapter struct { endpoint string } -func (a *NanoInteractiveAdapter) MakeRequests(bidRequest *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *NanoInteractiveAdapter) MakeRequests(bidRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp var adapterRequests []*adapters.RequestData var referer string = "" @@ -47,7 +47,7 @@ func (a *NanoInteractiveAdapter) MakeRequests(bidRequest *openrtb.BidRequest, re // set referer origin if referer != "" { if bidRequest.Site == nil { - bidRequest.Site = &openrtb.Site{} + bidRequest.Site = &openrtb2.Site{} } bidRequest.Site.Ref = referer } @@ -88,7 +88,7 @@ func (a *NanoInteractiveAdapter) MakeRequests(bidRequest *openrtb.BidRequest, re } func (a *NanoInteractiveAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { @@ -104,7 +104,7 @@ func (a *NanoInteractiveAdapter) MakeBids( }} } - var openRtbBidResponse openrtb.BidResponse + var openRtbBidResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &openRtbBidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -129,7 +129,7 @@ func (a *NanoInteractiveAdapter) MakeBids( return bidResponse, nil } -func checkImp(imp *openrtb.Imp) (string, error) { +func checkImp(imp *openrtb2.Imp) (string, error) { // We support only banner impression if imp.Banner == nil { return "", fmt.Errorf("invalid MediaType. NanoInteractive only supports Banner type. ImpID=%s", imp.ID) diff --git a/adapters/ninthdecimal/ninthdecimal.go b/adapters/ninthdecimal/ninthdecimal.go index 03095ee6c44..e819a2787a2 100755 --- a/adapters/ninthdecimal/ninthdecimal.go +++ b/adapters/ninthdecimal/ninthdecimal.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,7 +19,7 @@ type NinthDecimalAdapter struct { } //MakeRequests prepares request information for prebid-server core -func (adapter *NinthDecimalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *NinthDecimalAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, &errortypes.BadInput{Message: "No impression in the bid request"}) @@ -49,10 +49,10 @@ func (adapter *NinthDecimalAdapter) MakeRequests(request *openrtb.BidRequest, re } // getImpressionsInfo checks each impression for validity and returns impressions copy with corresponding exts -func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthDecimal][]openrtb.Imp, []openrtb.Imp, []error) { +func getImpressionsInfo(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpNinthDecimal][]openrtb2.Imp, []openrtb2.Imp, []error) { errors := make([]error, 0, len(imps)) - resImps := make([]openrtb.Imp, 0, len(imps)) - res := make(map[openrtb_ext.ExtImpNinthDecimal][]openrtb.Imp) + resImps := make([]openrtb2.Imp, 0, len(imps)) + res := make(map[openrtb_ext.ExtImpNinthDecimal][]openrtb2.Imp) for _, imp := range imps { impExt, err := getImpressionExt(&imp) @@ -71,7 +71,7 @@ func getImpressionsInfo(imps []openrtb.Imp) (map[openrtb_ext.ExtImpNinthDecimal] continue } if res[*impExt] == nil { - res[*impExt] = make([]openrtb.Imp, 0) + res[*impExt] = make([]openrtb2.Imp, 0) } res[*impExt] = append(res[*impExt], imp) resImps = append(resImps, imp) @@ -87,7 +87,7 @@ func validateImpression(impExt *openrtb_ext.ExtImpNinthDecimal) error { } //Alter impression info to comply with NinthDecimal platform requirements -func compatImpression(imp *openrtb.Imp) error { +func compatImpression(imp *openrtb2.Imp) error { imp.Ext = nil //do not forward ext to NinthDecimal platform if imp.Banner != nil { return compatBannerImpression(imp) @@ -95,7 +95,7 @@ func compatImpression(imp *openrtb.Imp) error { return nil } -func compatBannerImpression(imp *openrtb.Imp) error { +func compatBannerImpression(imp *openrtb2.Imp) error { // Create a copy of the banner, since imp is a shallow copy of the original. bannerCopy := *imp.Banner @@ -114,7 +114,7 @@ func compatBannerImpression(imp *openrtb.Imp) error { return nil } -func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpNinthDecimal, error) { +func getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtImpNinthDecimal, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -130,7 +130,7 @@ func getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtImpNinthDecimal, error) return &NinthDecimalExt, nil } -func (adapter *NinthDecimalAdapter) buildAdapterRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb.Imp) (*adapters.RequestData, error) { +func (adapter *NinthDecimalAdapter) buildAdapterRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb2.Imp) (*adapters.RequestData, error) { newBidRequest := createBidRequest(prebidBidRequest, params, imps) reqJSON, err := json.Marshal(newBidRequest) if err != nil { @@ -154,7 +154,7 @@ func (adapter *NinthDecimalAdapter) buildAdapterRequest(prebidBidRequest *openrt Headers: headers}, nil } -func createBidRequest(prebidBidRequest *openrtb.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb.Imp) *openrtb.BidRequest { +func createBidRequest(prebidBidRequest *openrtb2.BidRequest, params *openrtb_ext.ExtImpNinthDecimal, imps []openrtb2.Imp) *openrtb2.BidRequest { bidRequest := *prebidBidRequest bidRequest.Imp = imps for idx := range bidRequest.Imp { @@ -184,7 +184,7 @@ func (adapter *NinthDecimalAdapter) buildEndpointURL(params *openrtb_ext.ExtImpN } //MakeBids translates NinthDecimal bid response to prebid-server specific format -func (adapter *NinthDecimalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (adapter *NinthDecimalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var msg = "" if response.StatusCode == http.StatusNoContent { return nil, nil @@ -194,7 +194,7 @@ func (adapter *NinthDecimalAdapter) MakeBids(internalRequest *openrtb.BidRequest return nil, []error{&errortypes.BadServerResponse{Message: msg}} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { msg = fmt.Sprintf("Bad server response: %d", err) return nil, []error{&errortypes.BadServerResponse{Message: msg}} @@ -218,7 +218,7 @@ func (adapter *NinthDecimalAdapter) MakeBids(internalRequest *openrtb.BidRequest } // getMediaTypeForImp figures out which media type this bid is for -func getMediaTypeForImpID(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImpID(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID && imp.Video != nil { return openrtb_ext.BidTypeVideo diff --git a/adapters/nobid/nobid.go b/adapters/nobid/nobid.go index 875a7260e80..7fc7669b7c4 100644 --- a/adapters/nobid/nobid.go +++ b/adapters/nobid/nobid.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -26,7 +26,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests Makes the OpenRTB request payload -func (a *NoBidAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *NoBidAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ @@ -52,7 +52,7 @@ func (a *NoBidAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte } // MakeBids makes the bids -func (a *NoBidAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *NoBidAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -70,7 +70,7 @@ func (a *NoBidAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -98,7 +98,7 @@ func (a *NoBidAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq return bidResponse, errs } -func getBidCount(bidResponse openrtb.BidResponse) int { +func getBidCount(bidResponse openrtb2.BidResponse) int { c := 0 for _, sb := range bidResponse.SeatBid { c = c + len(sb.Bid) @@ -106,7 +106,7 @@ func getBidCount(bidResponse openrtb.BidResponse) int { return c } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/onetag/onetag.go b/adapters/onetag/onetag.go index ebf428439ed..6069682bc2a 100644 --- a/adapters/onetag/onetag.go +++ b/adapters/onetag/onetag.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -31,7 +31,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { pubID := "" for idx, imp := range request.Imp { onetagExt, err := getImpressionExt(imp) @@ -73,7 +73,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapter return []*adapters.RequestData{requestData}, nil } -func getImpressionExt(imp openrtb.Imp) (*openrtb_ext.ExtImpOnetag, error) { +func getImpressionExt(imp openrtb2.Imp) (*openrtb_ext.ExtImpOnetag, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -96,7 +96,7 @@ func (a *adapter) buildEndpointURL(pubID string) (string, error) { return macros.ResolveMacros(a.endpointTemplate, endpointParams) } -func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { return nil, nil } @@ -108,7 +108,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.Re return nil, []error{err} } - var response openrtb.BidResponse + var response openrtb2.BidResponse if err := json.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } @@ -131,7 +131,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.Re return bidResponse, nil } -func getMediaTypeForBid(impressions []openrtb.Imp, bid openrtb.Bid) (openrtb_ext.BidType, error) { +func getMediaTypeForBid(impressions []openrtb2.Imp, bid openrtb2.Bid) (openrtb_ext.BidType, error) { for _, impression := range impressions { if impression.ID == bid.ImpID { if impression.Banner != nil { diff --git a/adapters/openrtb_util.go b/adapters/openrtb_util.go index 55064ea7d07..bc18b9ebf17 100644 --- a/adapters/openrtb_util.go +++ b/adapters/openrtb_util.go @@ -3,10 +3,9 @@ package adapters import ( "encoding/json" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/pbs" - - "github.com/mxmCherry/openrtb" ) func min(x, y int) int { @@ -37,37 +36,37 @@ func commonMediaTypes(l1 []pbs.MediaType, l2 []pbs.MediaType) []pbs.MediaType { return res[:i] } -func makeBanner(unit pbs.PBSAdUnit) *openrtb.Banner { - return &openrtb.Banner{ - W: openrtb.Uint64Ptr(unit.Sizes[0].W), - H: openrtb.Uint64Ptr(unit.Sizes[0].H), +func makeBanner(unit pbs.PBSAdUnit) *openrtb2.Banner { + return &openrtb2.Banner{ + W: openrtb2.Int64Ptr(unit.Sizes[0].W), + H: openrtb2.Int64Ptr(unit.Sizes[0].H), Format: copyFormats(unit.Sizes), // defensive copy because adapters may mutate Imps, and this is shared data TopFrame: unit.TopFrame, } } -func makeVideo(unit pbs.PBSAdUnit) *openrtb.Video { +func makeVideo(unit pbs.PBSAdUnit) *openrtb2.Video { // empty mimes array is a sign of uninitialized Video object if len(unit.Video.Mimes) < 1 { return nil } mimes := make([]string, len(unit.Video.Mimes)) copy(mimes, unit.Video.Mimes) - pbm := make([]openrtb.PlaybackMethod, 1) + pbm := make([]openrtb2.PlaybackMethod, 1) //this will become int8 soon, so we only care about the first index in the array - pbm[0] = openrtb.PlaybackMethod(unit.Video.PlaybackMethod) + pbm[0] = openrtb2.PlaybackMethod(unit.Video.PlaybackMethod) - protocols := make([]openrtb.Protocol, 0, len(unit.Video.Protocols)) + protocols := make([]openrtb2.Protocol, 0, len(unit.Video.Protocols)) for _, protocol := range unit.Video.Protocols { - protocols = append(protocols, openrtb.Protocol(protocol)) + protocols = append(protocols, openrtb2.Protocol(protocol)) } - return &openrtb.Video{ + return &openrtb2.Video{ MIMEs: mimes, MinDuration: unit.Video.Minduration, MaxDuration: unit.Video.Maxduration, W: unit.Sizes[0].W, H: unit.Sizes[0].H, - StartDelay: openrtb.StartDelay(unit.Video.Startdelay).Ptr(), + StartDelay: openrtb2.StartDelay(unit.Video.Startdelay).Ptr(), PlaybackMethod: pbm, Protocols: protocols, } @@ -77,8 +76,8 @@ func makeVideo(unit pbs.PBSAdUnit) *openrtb.Video { // // Any objects pointed to by the returned BidRequest *must not be mutated*, or we will get race conditions. // The only exception is the Imp property, whose objects will be created new by this method and can be mutated freely. -func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily string, allowedMediatypes []pbs.MediaType) (openrtb.BidRequest, error) { - imps := make([]openrtb.Imp, 0, len(bidder.AdUnits)*len(allowedMediatypes)) +func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily string, allowedMediatypes []pbs.MediaType) (openrtb2.BidRequest, error) { + imps := make([]openrtb2.Imp, 0, len(bidder.AdUnits)*len(allowedMediatypes)) for _, unit := range bidder.AdUnits { if len(unit.Sizes) <= 0 { continue @@ -88,7 +87,7 @@ func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily continue } - newImp := openrtb.Imp{ + newImp := openrtb2.Imp{ ID: unit.Code, Secure: &req.Secure, Instl: unit.Instl, @@ -101,7 +100,7 @@ func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily newImp.Video = makeVideo(unit) // It's strange to error here... but preserves legacy behavior in legacy code. See #603. if newImp.Video == nil { - return openrtb.BidRequest{}, &errortypes.BadInput{ + return openrtb2.BidRequest{}, &errortypes.BadInput{ Message: "Invalid AdUnit: VIDEO media type with no video data", } } @@ -113,19 +112,19 @@ func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily } if len(imps) < 1 { - return openrtb.BidRequest{}, &errortypes.BadInput{ + return openrtb2.BidRequest{}, &errortypes.BadInput{ Message: "openRTB bids need at least one Imp", } } if req.App != nil { - return openrtb.BidRequest{ + return openrtb2.BidRequest{ ID: req.Tid, Imp: imps, App: req.App, Device: req.Device, User: req.User, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: req.Tid, }, AT: 1, @@ -142,20 +141,20 @@ func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily userExt = req.User.Ext } - return openrtb.BidRequest{ + return openrtb2.BidRequest{ ID: req.Tid, Imp: imps, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ Domain: req.Domain, Page: req.Url, }, Device: req.Device, - User: &openrtb.User{ + User: &openrtb2.User{ BuyerUID: buyerUID, ID: id, Ext: userExt, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ FD: 1, // upstream, aka header TID: req.Tid, }, @@ -165,8 +164,8 @@ func MakeOpenRTBGeneric(req *pbs.PBSRequest, bidder *pbs.PBSBidder, bidderFamily }, nil } -func copyFormats(sizes []openrtb.Format) []openrtb.Format { - sizesCopy := make([]openrtb.Format, len(sizes)) +func copyFormats(sizes []openrtb2.Format) []openrtb2.Format { + sizesCopy := make([]openrtb2.Format, len(sizes)) for i := 0; i < len(sizes); i++ { sizesCopy[i] = sizes[i] sizesCopy[i].Ext = append([]byte(nil), sizes[i].Ext...) diff --git a/adapters/openrtb_util_test.go b/adapters/openrtb_util_test.go index 2cf67c22537..d859114b646 100644 --- a/adapters/openrtb_util_test.go +++ b/adapters/openrtb_util_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/pbs" "github.com/prebid/prebid-server/usersync" "github.com/stretchr/testify/assert" @@ -42,7 +42,7 @@ func TestOpenRTB(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -73,7 +73,7 @@ func TestOpenRTBVideo(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -96,8 +96,8 @@ func TestOpenRTBVideo(t *testing.T) { assert.Equal(t, resp.Imp[0].ID, "unitCode") assert.EqualValues(t, resp.Imp[0].Video.MaxDuration, 30) assert.EqualValues(t, resp.Imp[0].Video.MinDuration, 15) - assert.EqualValues(t, *resp.Imp[0].Video.StartDelay, openrtb.StartDelay(5)) - assert.EqualValues(t, resp.Imp[0].Video.PlaybackMethod, []openrtb.PlaybackMethod{openrtb.PlaybackMethod(1)}) + assert.EqualValues(t, *resp.Imp[0].Video.StartDelay, openrtb2.StartDelay(5)) + assert.EqualValues(t, resp.Imp[0].Video.PlaybackMethod, []openrtb2.PlaybackMethod{openrtb2.PlaybackMethod(1)}) assert.EqualValues(t, resp.Imp[0].Video.MIMEs, []string{"video/mp4"}) } @@ -110,7 +110,7 @@ func TestOpenRTBVideoNoVideoData(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -134,7 +134,7 @@ func TestOpenRTBVideoFilteredOut(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -152,7 +152,7 @@ func TestOpenRTBVideoFilteredOut(t *testing.T) { { Code: "unitCode2", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -179,7 +179,7 @@ func TestOpenRTBMultiMediaImp(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO, pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -215,7 +215,7 @@ func TestOpenRTBMultiMediaImpFiltered(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO, pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -237,7 +237,7 @@ func TestOpenRTBMultiMediaImpFiltered(t *testing.T) { assert.Equal(t, len(resp.Imp), 1) assert.Equal(t, resp.Imp[0].ID, "unitCode") assert.EqualValues(t, *resp.Imp[0].Banner.W, 10) - assert.EqualValues(t, resp.Imp[0].Video, (*openrtb.Video)(nil)) + assert.EqualValues(t, resp.Imp[0].Video, (*openrtb2.Video)(nil)) } func TestOpenRTBNoSize(t *testing.T) { @@ -267,20 +267,20 @@ func TestOpenRTBMobile(t *testing.T) { MaxKeyLength: 20, Secure: 1, TimeoutMillis: 1000, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "AppNexus.PrebidMobileDemo", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "1995257847363113", }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: "test_ua", IP: "test_ip", Make: "test_make", Model: "test_model", IFA: "test_ifa", }, - User: &openrtb.User{ + User: &openrtb2.User{ BuyerUID: "test_buyeruid", }, } @@ -290,7 +290,7 @@ func TestOpenRTBMobile(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 300, H: 250, @@ -318,7 +318,7 @@ func TestOpenRTBMobile(t *testing.T) { func TestOpenRTBEmptyUser(t *testing.T) { pbReq := pbs.PBSRequest{ - User: &openrtb.User{}, + User: &openrtb2.User{}, } pbBidder := pbs.PBSBidder{ BidderCode: "bannerCode", @@ -326,7 +326,7 @@ func TestOpenRTBEmptyUser(t *testing.T) { { Code: "unitCode2", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -337,14 +337,14 @@ func TestOpenRTBEmptyUser(t *testing.T) { } resp, err := MakeOpenRTBGeneric(&pbReq, &pbBidder, "test", []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}) assert.Equal(t, err, nil) - assert.EqualValues(t, resp.User, &openrtb.User{}) + assert.EqualValues(t, resp.User, &openrtb2.User{}) } func TestOpenRTBUserWithCookie(t *testing.T) { pbsCookie := usersync.NewPBSCookie() pbsCookie.TrySync("test", "abcde") pbReq := pbs.PBSRequest{ - User: &openrtb.User{}, + User: &openrtb2.User{}, } pbBidder := pbs.PBSBidder{ BidderCode: "bannerCode", @@ -352,7 +352,7 @@ func TestOpenRTBUserWithCookie(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 300, H: 250, @@ -368,7 +368,7 @@ func TestOpenRTBUserWithCookie(t *testing.T) { } func TestSizesCopy(t *testing.T) { - formats := []openrtb.Format{ + formats := []openrtb2.Format{ { W: 10, }, @@ -402,7 +402,7 @@ func TestMakeVideo(t *testing.T) { adUnit := pbs.PBSAdUnit{ Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_VIDEO}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -421,7 +421,7 @@ func TestMakeVideo(t *testing.T) { video := makeVideo(adUnit) assert.EqualValues(t, video.MinDuration, 15) assert.EqualValues(t, video.MaxDuration, 30) - assert.EqualValues(t, *video.StartDelay, openrtb.StartDelay(5)) + assert.EqualValues(t, *video.StartDelay, openrtb2.StartDelay(5)) assert.EqualValues(t, len(video.PlaybackMethod), 1) assert.EqualValues(t, len(video.Protocols), 4) } @@ -435,10 +435,10 @@ func TestGDPR(t *testing.T) { regsExt, _ := json.Marshal(rawRegsExt) pbReq := pbs.PBSRequest{ - User: &openrtb.User{ + User: &openrtb2.User{ Ext: userExt, }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ Ext: regsExt, }, } @@ -449,7 +449,7 @@ func TestGDPR(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -486,24 +486,24 @@ func TestGDPRMobile(t *testing.T) { MaxKeyLength: 20, Secure: 1, TimeoutMillis: 1000, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "AppNexus.PrebidMobileDemo", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "1995257847363113", }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: "test_ua", IP: "test_ip", Make: "test_make", Model: "test_model", IFA: "test_ifa", }, - User: &openrtb.User{ + User: &openrtb2.User{ BuyerUID: "test_buyeruid", Ext: userExt, }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ Ext: regsExt, }, } @@ -513,7 +513,7 @@ func TestGDPRMobile(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 300, H: 250, diff --git a/adapters/openx/openx.go b/adapters/openx/openx.go index b6640b1f5e9..c8c0de8d9d2 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -28,10 +28,10 @@ type openxReqExt struct { BidderConfig string `json:"bc"` } -func (a *OpenxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *OpenxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var bannerImps []openrtb.Imp - var videoImps []openrtb.Imp + var bannerImps []openrtb2.Imp + var videoImps []openrtb2.Imp for _, imp := range request.Imp { // OpenX doesn't allow multi-type imp. Banner takes priority over video. @@ -55,7 +55,7 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte // OpenX only supports single imp video request for _, videoImp := range videoImps { - reqCopy.Imp = []openrtb.Imp{videoImp} + reqCopy.Imp = []openrtb2.Imp{videoImp} adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) @@ -66,9 +66,9 @@ func (a *OpenxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapte return adapterRequests, errs } -func (a *OpenxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *OpenxAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp reqExt := openxReqExt{BidderConfig: hbconfig} for _, imp := range request.Imp { @@ -111,7 +111,7 @@ func (a *OpenxAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Reque } // Mutate the imp to get it ready to send to openx. -func preprocess(imp *openrtb.Imp, reqExt *openxReqExt) error { +func preprocess(imp *openrtb2.Imp, reqExt *openxReqExt) error { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ @@ -158,7 +158,7 @@ func preprocess(imp *openrtb.Imp, reqExt *openxReqExt) error { return nil } -func (a *OpenxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *OpenxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -175,7 +175,7 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -202,7 +202,7 @@ func (a *OpenxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq // // OpenX doesn't support multi-type impressions. // If both banner and video exist, take banner as we do not want in-banner video. -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/openx/openx_test.go b/adapters/openx/openx_test.go index 81d2ff227ec..aaf7ecf85a2 100644 --- a/adapters/openx/openx_test.go +++ b/adapters/openx/openx_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -41,10 +41,10 @@ func assertCurrencyInBidResponse(t *testing.T, expectedCurrency string, currency t.Fatalf("Builder returned unexpected error %v", buildErr) } - prebidRequest := &openrtb.BidRequest{ - Imp: []openrtb.Imp{}, + prebidRequest := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{}, } - mockedBidResponse := &openrtb.BidResponse{} + mockedBidResponse := &openrtb2.BidResponse{} if currency != nil { mockedBidResponse.Cur = *currency } diff --git a/adapters/orbidder/orbidder.go b/adapters/orbidder/orbidder.go index e26ad4efc0c..b0b3bcfbb7a 100644 --- a/adapters/orbidder/orbidder.go +++ b/adapters/orbidder/orbidder.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,9 +17,9 @@ type OrbidderAdapter struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids from orbidder. -func (rcv *OrbidderAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (rcv *OrbidderAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp // check if imps exists, if not return error and do send request to orbidder. if len(request.Imp) == 0 { @@ -62,7 +62,7 @@ func (rcv *OrbidderAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a }}, errs } -func preprocess(imp *openrtb.Imp) error { +func preprocess(imp *openrtb2.Imp) error { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return &errortypes.BadInput{ @@ -81,7 +81,7 @@ func preprocess(imp *openrtb.Imp) error { } // MakeBids unpacks server response into Bids. -func (rcv OrbidderAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (rcv OrbidderAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -104,7 +104,7 @@ func (rcv OrbidderAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/pangle/pangle.go b/adapters/pangle/pangle.go index 97f9b542734..cc215412a5f 100644 --- a/adapters/pangle/pangle.go +++ b/adapters/pangle/pangle.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -41,7 +41,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters /* MakeRequests */ -func getAdType(imp openrtb.Imp, parsedImpExt *wrappedExtImpBidder) int { +func getAdType(imp openrtb2.Imp, parsedImpExt *wrappedExtImpBidder) int { // video if imp.Video != nil { if parsedImpExt != nil && parsedImpExt.Prebid != nil && parsedImpExt.Prebid.IsRewardedInventory == 1 { @@ -67,7 +67,7 @@ func getAdType(imp openrtb.Imp, parsedImpExt *wrappedExtImpBidder) int { return -1 } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var requests []*adapters.RequestData var errs []error @@ -98,7 +98,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapter continue } - requestCopy.Imp = []openrtb.Imp{imp} + requestCopy.Imp = []openrtb2.Imp{imp} requestJSON, err := json.Marshal(requestCopy) if err != nil { errs = append(errs, err) @@ -122,7 +122,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapter /* MakeBids */ -func getMediaTypeForBid(bid *openrtb.Bid) (openrtb_ext.BidType, error) { +func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { if bid == nil { return "", fmt.Errorf("the bid request object is nil") } @@ -150,7 +150,7 @@ func getMediaTypeForBid(bid *openrtb.Bid) (openrtb_ext.BidType, error) { return "", fmt.Errorf("unrecognized adtype in response") } -func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { return nil, nil } @@ -169,7 +169,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.Re return nil, []error{err} } - var response openrtb.BidResponse + var response openrtb2.BidResponse if err := json.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/pubmatic/pubmatic.go b/adapters/pubmatic/pubmatic.go index be3ebb313f3..f3f5785492d 100644 --- a/adapters/pubmatic/pubmatic.go +++ b/adapters/pubmatic/pubmatic.go @@ -12,7 +12,7 @@ import ( "strings" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -158,8 +158,8 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder } pbReq.Imp[i].TagID = strings.TrimSpace(adSlot[0]) - pbReq.Imp[i].Banner.H = openrtb.Uint64Ptr(uint64(height)) - pbReq.Imp[i].Banner.W = openrtb.Uint64Ptr(uint64(width)) + pbReq.Imp[i].Banner.H = openrtb2.Int64Ptr(int64(height)) + pbReq.Imp[i].Banner.W = openrtb2.Int64Ptr(int64(width)) if len(params.Keywords) != 0 { kvstr := prepareImpressionExt(params.Keywords) @@ -190,12 +190,12 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder if pbReq.Site != nil { siteCopy := *pbReq.Site - siteCopy.Publisher = &openrtb.Publisher{ID: params.PublisherId, Domain: req.Domain} + siteCopy.Publisher = &openrtb2.Publisher{ID: params.PublisherId, Domain: req.Domain} pbReq.Site = &siteCopy } if pbReq.App != nil { appCopy := *pbReq.App - appCopy.Publisher = &openrtb.Publisher{ID: params.PublisherId, Domain: req.Domain} + appCopy.Publisher = &openrtb2.Publisher{ID: params.PublisherId, Domain: req.Domain} pbReq.App = &appCopy } } @@ -264,7 +264,7 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder debug.ResponseBody = string(body) } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return nil, &errortypes.BadServerResponse{ @@ -314,7 +314,7 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder return bids, nil } -func (a *PubmaticAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *PubmaticAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) var err error @@ -343,7 +343,7 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada publisherCopy.ID = pubID siteCopy.Publisher = &publisherCopy } else { - siteCopy.Publisher = &openrtb.Publisher{ID: pubID} + siteCopy.Publisher = &openrtb2.Publisher{ID: pubID} } request.Site = &siteCopy } else if request.App != nil { @@ -353,7 +353,7 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada publisherCopy.ID = pubID appCopy.Publisher = &publisherCopy } else { - appCopy.Publisher = &openrtb.Publisher{ID: pubID} + appCopy.Publisher = &openrtb2.Publisher{ID: pubID} } request.App = &appCopy } @@ -384,7 +384,7 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada // validateAdslot validate the optional adslot string // valid formats are 'adslot@WxH', 'adslot' and no adslot -func validateAdSlot(adslot string, imp *openrtb.Imp) error { +func validateAdSlot(adslot string, imp *openrtb2.Imp) error { adSlotStr := strings.TrimSpace(adslot) if len(adSlotStr) == 0 { @@ -418,7 +418,7 @@ func validateAdSlot(adslot string, imp *openrtb.Imp) error { //In case of video, size could be derived from the player size if imp.Banner != nil { - imp.Banner = assignBannerHeightAndWidth(imp.Banner, uint64(height), uint64(width)) + imp.Banner = assignBannerHeightAndWidth(imp.Banner, int64(height), int64(width)) } } else { return errors.New(fmt.Sprintf("Invalid adSlot %v", adSlotStr)) @@ -427,7 +427,7 @@ func validateAdSlot(adslot string, imp *openrtb.Imp) error { return nil } -func assignBannerSize(banner *openrtb.Banner) (*openrtb.Banner, error) { +func assignBannerSize(banner *openrtb2.Banner) (*openrtb2.Banner, error) { if banner.W != nil && banner.H != nil { return banner, nil } @@ -439,17 +439,17 @@ func assignBannerSize(banner *openrtb.Banner) (*openrtb.Banner, error) { return assignBannerHeightAndWidth(banner, banner.Format[0].H, banner.Format[0].H), nil } -func assignBannerHeightAndWidth(banner *openrtb.Banner, h uint64, w uint64) *openrtb.Banner { +func assignBannerHeightAndWidth(banner *openrtb2.Banner, h, w int64) *openrtb2.Banner { bannerCopy := *banner - bannerCopy.W = openrtb.Uint64Ptr(w) - bannerCopy.H = openrtb.Uint64Ptr(h) + bannerCopy.W = openrtb2.Int64Ptr(w) + bannerCopy.H = openrtb2.Int64Ptr(h) return &bannerCopy } // parseImpressionObject parse the imp to get it ready to send to pubmatic -func parseImpressionObject(imp *openrtb.Imp, wrapExt *string, pubID *string) error { +func parseImpressionObject(imp *openrtb2.Imp, wrapExt *string, pubID *string) error { // PubMatic supports banner and video impressions. if imp.Banner == nil && imp.Video == nil { return fmt.Errorf("Invalid MediaType. PubMatic only supports Banner and Video. Ignoring ImpID=%s", imp.ID) @@ -537,7 +537,7 @@ func prepareImpressionExt(keywords map[string]string) string { return kvStr } -func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -552,7 +552,7 @@ func (a *PubmaticAdapter) MakeBids(internalRequest *openrtb.BidRequest, external return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/pubmatic/pubmatic_test.go b/adapters/pubmatic/pubmatic_test.go index 8ed2ccd391c..7e8f177a1ba 100644 --- a/adapters/pubmatic/pubmatic_test.go +++ b/adapters/pubmatic/pubmatic_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/cache/dummycache" @@ -35,7 +35,7 @@ func TestJsonSamples(t *testing.T) { // ---------------------------------------------------------------------------- // Code below this line tests the legacy, non-openrtb code flow. It can be deleted after we -// clean up the existing code and make everything openrtb. +// clean up the existing code and make everything openrtb2. func CompareStringValue(val1 string, val2 string, t *testing.T) { if val1 != val2 { @@ -51,29 +51,29 @@ func DummyPubMaticServer(w http.ResponseWriter, r *http.Request) { return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: breq.ID, BidID: "bidResponse_ID", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "pubmatic", - Bid: make([]openrtb.Bid, 0), + Bid: make([]openrtb2.Bid, 0), }, }, } rand.Seed(int64(time.Now().UnixNano())) - var bids []openrtb.Bid + var bids []openrtb2.Bid for i, imp := range breq.Imp { - bids = append(bids, openrtb.Bid{ + bids = append(bids, openrtb2.Bid{ ID: fmt.Sprintf("SeatID_%d", i), ImpID: imp.ID, Price: float64(int(rand.Float64()*1000)) / 100, @@ -130,7 +130,7 @@ func TestPubmaticTimeout(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -165,7 +165,7 @@ func TestPubmaticInvalidJson(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -201,7 +201,7 @@ func TestPubmaticInvalidStatusCode(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -234,7 +234,7 @@ func TestPubmaticInvalidInputParameters(t *testing.T) { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -306,7 +306,7 @@ func TestPubmaticBasicResponse_MandatoryParams(t *testing.T) { Code: "unitCode", BidID: "bidid", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 336, H: 280, @@ -342,7 +342,7 @@ func TestPubmaticBasicResponse_AllParams(t *testing.T) { Code: "unitCode", BidID: "bidid", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 336, H: 280, @@ -387,7 +387,7 @@ func TestPubmaticMultiImpressionResponse(t *testing.T) { Code: "unitCode1", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 336, H: 280, @@ -399,7 +399,7 @@ func TestPubmaticMultiImpressionResponse(t *testing.T) { Code: "unitCode1", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 800, H: 200, @@ -435,7 +435,7 @@ func TestPubmaticMultiAdUnitResponse(t *testing.T) { Code: "unitCode1", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 336, H: 280, @@ -447,7 +447,7 @@ func TestPubmaticMultiAdUnitResponse(t *testing.T) { Code: "unitCode2", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, BidID: "bidid", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 800, H: 200, @@ -484,7 +484,7 @@ func TestPubmaticMobileResponse(t *testing.T) { Code: "unitCode", BidID: "bidid", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 336, H: 280, @@ -495,7 +495,7 @@ func TestPubmaticMobileResponse(t *testing.T) { }, } - pbReq.App = &openrtb.App{ + pbReq.App = &openrtb2.App{ ID: "com.test", Name: "testApp", } @@ -524,7 +524,7 @@ func TestPubmaticInvalidLookupBidIDParameter(t *testing.T) { { Code: "unitCode", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -556,7 +556,7 @@ func TestPubmaticAdSlotParams(t *testing.T) { Code: "unitCode", BidID: "bidid", MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 120, H: 240, @@ -636,7 +636,7 @@ func TestPubmaticSampleRequest(t *testing.T) { } pbReq.AdUnits[0] = pbs.AdUnit{ Code: "adUnit_1", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 100, H: 120, diff --git a/adapters/pubnative/pubnative.go b/adapters/pubnative/pubnative.go index 9144d6ddaae..35bc7553db3 100644 --- a/adapters/pubnative/pubnative.go +++ b/adapters/pubnative/pubnative.go @@ -7,7 +7,7 @@ import ( "net/url" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -18,7 +18,7 @@ type PubnativeAdapter struct { URI string } -func (a *PubnativeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *PubnativeAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { impCount := len(request.Imp) requestData := make([]*adapters.RequestData, 0, impCount) errs := []error{} @@ -53,7 +53,7 @@ func (a *PubnativeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ad continue } - requestCopy.Imp = []openrtb.Imp{imp} + requestCopy.Imp = []openrtb2.Imp{imp} reqJSON, err := json.Marshal(&requestCopy) if err != nil { errs = append(errs, err) @@ -77,7 +77,7 @@ func (a *PubnativeAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ad return requestData, errs } -func checkRequest(request *openrtb.BidRequest) error { +func checkRequest(request *openrtb2.BidRequest) error { if request.Device == nil || len(request.Device.OS) == 0 { return &errortypes.BadInput{ Message: "Impression is missing device OS information", @@ -87,7 +87,7 @@ func checkRequest(request *openrtb.BidRequest) error { return nil } -func convertImpression(imp *openrtb.Imp) error { +func convertImpression(imp *openrtb2.Imp) error { if imp.Banner == nil && imp.Video == nil && imp.Native == nil { return &errortypes.BadInput{ Message: "Pubnative only supports banner, video or native ads.", @@ -105,15 +105,15 @@ func convertImpression(imp *openrtb.Imp) error { } // make sure that banner has openrtb 2.3-compatible size information -func convertBanner(banner *openrtb.Banner) (*openrtb.Banner, error) { +func convertBanner(banner *openrtb2.Banner) (*openrtb2.Banner, error) { if banner.W == nil || banner.H == nil || *banner.W == 0 || *banner.H == 0 { if len(banner.Format) > 0 { f := banner.Format[0] bannerCopy := *banner - bannerCopy.W = openrtb.Uint64Ptr(f.W) - bannerCopy.H = openrtb.Uint64Ptr(f.H) + bannerCopy.W = openrtb2.Int64Ptr(f.W) + bannerCopy.H = openrtb2.Int64Ptr(f.H) return &bannerCopy, nil } else { @@ -125,7 +125,7 @@ func convertBanner(banner *openrtb.Banner) (*openrtb.Banner, error) { return banner, nil } -func (a *PubnativeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *PubnativeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -142,7 +142,7 @@ func (a *PubnativeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa }} } - var parsedResponse openrtb.BidResponse + var parsedResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &parsedResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), @@ -173,7 +173,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/pulsepoint/pulsepoint.go b/adapters/pulsepoint/pulsepoint.go index b07a2cba66f..35297d795a6 100644 --- a/adapters/pulsepoint/pulsepoint.go +++ b/adapters/pulsepoint/pulsepoint.go @@ -1,17 +1,16 @@ package pulsepoint import ( + "bytes" + "context" "encoding/json" "fmt" + "io/ioutil" "net/http" "strconv" - - "bytes" - "context" - "io/ioutil" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -33,12 +32,12 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *PulsePointAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *PulsePointAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) var err error pubID := "" - imps := make([]openrtb.Imp, 0, len(request.Imp)) + imps := make([]openrtb2.Imp, 0, len(request.Imp)) for i := 0; i < len(request.Imp); i++ { imp := request.Imp[i] var bidderExt adapters.ExtImpBidder @@ -77,7 +76,7 @@ func (a *PulsePointAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a publisher.ID = pubID site.Publisher = &publisher } else { - site.Publisher = &openrtb.Publisher{ID: pubID} + site.Publisher = &openrtb2.Publisher{ID: pubID} } request.Site = &site } else if request.App != nil { @@ -87,7 +86,7 @@ func (a *PulsePointAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a publisher.ID = pubID app.Publisher = &publisher } else { - app.Publisher = &openrtb.Publisher{ID: pubID} + app.Publisher = &openrtb2.Publisher{ID: pubID} } request.App = &app } @@ -109,7 +108,7 @@ func (a *PulsePointAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a }}, errs } -func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { // passback if response.StatusCode == http.StatusNoContent { return nil, nil @@ -127,14 +126,14 @@ func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern }} } // parse response - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } bidResponse := adapters.NewBidderResponseWithBidsCapacity(5) // map imps by id - impsByID := make(map[string]openrtb.Imp) + impsByID := make(map[string]openrtb2.Imp) for i := 0; i < len(internalRequest.Imp); i++ { impsByID[internalRequest.Imp[i].ID] = internalRequest.Imp[i] } @@ -156,7 +155,7 @@ func (a *PulsePointAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern return bidResponse, errs } -func getBidType(imp openrtb.Imp) openrtb_ext.BidType { +func getBidType(imp openrtb2.Imp) openrtb_ext.BidType { // derive the bidtype purely from the impression itself if imp.Banner != nil { return openrtb_ext.BidTypeBanner @@ -235,7 +234,7 @@ func (a *PulsePointAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidde break } ppReq.Imp[i].TagID = strconv.Itoa(params.TagId) - publisher := &openrtb.Publisher{ID: strconv.Itoa(params.PublisherId)} + publisher := &openrtb2.Publisher{ID: strconv.Itoa(params.PublisherId)} if ppReq.Site != nil { siteCopy := *ppReq.Site siteCopy.Publisher = publisher @@ -250,7 +249,7 @@ func (a *PulsePointAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidde if len(size) == 2 { width, err := strconv.Atoi(size[0]) if err == nil { - ppReq.Imp[i].Banner.W = openrtb.Uint64Ptr(uint64(width)) + ppReq.Imp[i].Banner.W = openrtb2.Int64Ptr(int64(width)) } else { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Invalid Width param %s", size[0]), @@ -258,7 +257,7 @@ func (a *PulsePointAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidde } height, err := strconv.Atoi(size[1]) if err == nil { - ppReq.Imp[i].Banner.H = openrtb.Uint64Ptr(uint64(height)) + ppReq.Imp[i].Banner.H = openrtb2.Int64Ptr(int64(height)) } else { return nil, &errortypes.BadInput{ Message: fmt.Sprintf("Invalid Height param %s", size[1]), @@ -318,7 +317,7 @@ func (a *PulsePointAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidde debug.ResponseBody = string(body) } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return nil, &errortypes.BadServerResponse{ diff --git a/adapters/pulsepoint/pulsepoint_test.go b/adapters/pulsepoint/pulsepoint_test.go index 33023d0500a..a16f9a0e470 100644 --- a/adapters/pulsepoint/pulsepoint_test.go +++ b/adapters/pulsepoint/pulsepoint_test.go @@ -5,7 +5,7 @@ import ( "net/http" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/openrtb_ext" @@ -187,7 +187,7 @@ func TestMobileAppRequest(t *testing.T) { server := service.Server ctx := context.TODO() req := SampleRequest(1, t) - req.App = &openrtb.App{ + req.App = &openrtb2.App{ ID: "com.facebook.katana", Name: "facebook", } @@ -215,7 +215,7 @@ func SampleRequest(numberOfImpressions int, t *testing.T) *pbs.PBSRequest { for i := 0; i < numberOfImpressions; i++ { req.AdUnits[i] = pbs.AdUnit{ Code: fmt.Sprintf("div-adunit-%d", i+1), - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 10, H: 12, @@ -265,7 +265,7 @@ func SampleRequest(numberOfImpressions int, t *testing.T) *pbs.PBSRequest { */ func CreateService(tagsToBid map[string]bool) adapterstest.OrtbMockService { service := adapterstest.OrtbMockService{} - var lastBidRequest openrtb.BidRequest + var lastBidRequest openrtb2.BidRequest server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { defer r.Body.Close() body, err := ioutil.ReadAll(r.Body) @@ -273,14 +273,14 @@ func CreateService(tagsToBid map[string]bool) adapterstest.OrtbMockService { http.Error(w, err.Error(), http.StatusInternalServerError) return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } lastBidRequest = breq - var bids []openrtb.Bid + var bids []openrtb2.Bid for i, imp := range breq.Imp { if tagsToBid[imp.TagID] { bids = append(bids, adapterstest.SampleBid(imp.Banner.W, imp.Banner.H, imp.ID, i+1)) @@ -290,9 +290,9 @@ func CreateService(tagsToBid map[string]bool) adapterstest.OrtbMockService { if len(bids) == 0 { w.WriteHeader(204) } else { - // serialize the bids to openrtb.BidResponse - js, _ := json.Marshal(openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + // serialize the bids to openrtb2.BidResponse + js, _ := json.Marshal(openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { Bid: bids, }, diff --git a/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json b/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json index b5209ed4bbe..8d34bab0578 100644 --- a/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json +++ b/adapters/pulsepoint/pulsepointtest/supplemental/bad-bid-data.json @@ -83,7 +83,7 @@ }], "expectedBidResponses": [], "expectedMakeBidsErrors": [{ - "value": "json: cannot unmarshal string into Go struct field Bid.seatbid.bid.w of type uint64", + "value": "json: cannot unmarshal string into Go struct field Bid.seatbid.bid.w of type int64", "comparison": "literal" } ] diff --git a/adapters/revcontent/revcontent.go b/adapters/revcontent/revcontent.go index 5a34f3ef199..f3b24436d63 100644 --- a/adapters/revcontent/revcontent.go +++ b/adapters/revcontent/revcontent.go @@ -3,12 +3,13 @@ package revcontent import ( "encoding/json" "fmt" - "github.com/mxmCherry/openrtb" + "net/http" + + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" - "net/http" ) type adapter struct { @@ -23,7 +24,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { reqBody, err := json.Marshal(request) if err != nil { @@ -46,7 +47,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex return []*adapters.RequestData{req}, nil } -func checkRequest(request *openrtb.BidRequest) error { +func checkRequest(request *openrtb2.BidRequest) error { if (request.App == nil || len(request.App.Name) == 0) && (request.Site == nil || len(request.Site.Domain) == 0) { return &errortypes.BadInput{ Message: "Impression is missing app name or site domain, and must contain one.", @@ -57,7 +58,7 @@ func checkRequest(request *openrtb.BidRequest) error { } // MakeBids make the bids for the bid response. -func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -74,7 +75,7 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} diff --git a/adapters/revcontent/revcontenttest/supplemental/bad_response.json b/adapters/revcontent/revcontenttest/supplemental/bad_response.json index bd562373f1b..751aed92c27 100644 --- a/adapters/revcontent/revcontenttest/supplemental/bad_response.json +++ b/adapters/revcontent/revcontenttest/supplemental/bad_response.json @@ -43,7 +43,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse" + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" } ] } diff --git a/adapters/rhythmone/rhythmone.go b/adapters/rhythmone/rhythmone.go index a507e778550..096e9190622 100644 --- a/adapters/rhythmone/rhythmone.go +++ b/adapters/rhythmone/rhythmone.go @@ -6,7 +6,7 @@ import ( "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type RhythmoneAdapter struct { endPoint string } -func (a *RhythmoneAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *RhythmoneAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) var uri string @@ -43,7 +43,7 @@ func (a *RhythmoneAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ad return nil, errs } -func (a *RhythmoneAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *RhythmoneAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -59,7 +59,7 @@ func (a *RhythmoneAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: %d. ", err), @@ -80,7 +80,7 @@ func (a *RhythmoneAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa return bidResponse, errs } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { @@ -103,7 +103,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *RhythmoneAdapter) preProcess(req *openrtb.BidRequest, errors []error) (*openrtb.BidRequest, string, []error) { +func (a *RhythmoneAdapter) preProcess(req *openrtb2.BidRequest, errors []error) (*openrtb2.BidRequest, string, []error) { numRequests := len(req.Imp) var uri string = "" for i := 0; i < numRequests; i++ { diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 1f86d4f365b..b2eccd76305 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -27,7 +27,7 @@ type RTBHouseAdapter struct { // MakeRequests prepares the HTTP requests which should be made to fetch bids. func (adapter *RTBHouseAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -57,7 +57,7 @@ const unexpectedStatusCodeFormat = "" + // MakeBids unpacks the server's response into Bids. func (adapter *RTBHouseAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -81,7 +81,7 @@ func (adapter *RTBHouseAdapter) MakeBids( return nil, []error{err} } - var openRTBBidderResponse openrtb.BidResponse + var openRTBBidderResponse openrtb2.BidResponse if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { return nil, []error{err} } diff --git a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json index b6af4209f48..f84f5555259 100644 --- a/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json +++ b/adapters/rtbhouse/rtbhousetest/supplemental/bad_response.json @@ -54,7 +54,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 32bf971cb6b..dff961cc79f 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -11,15 +11,13 @@ import ( "strings" "github.com/golang/glog" - "github.com/prebid/prebid-server/config" - "github.com/prebid/prebid-server/pbs" - - "golang.org/x/net/context/ctxhttp" - - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "golang.org/x/net/context/ctxhttp" ) const badvLimitSize = 50 @@ -326,7 +324,7 @@ func findPrimary(alt []int) (int, []int) { return primary, alt } -func parseRubiconSizes(sizes []openrtb.Format) (primary int, alt []int, err error) { +func parseRubiconSizes(sizes []openrtb2.Format) (primary int, alt []int, err error) { // Fixes #317 if len(sizes) < 1 { err = &errortypes.BadInput{ @@ -385,7 +383,7 @@ func (a *RubiconAdapter) callOne(ctx context.Context, reqJSON bytes.Buffer) (res return } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { err = &errortypes.BadServerResponse{ @@ -523,14 +521,14 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * if rubiReq.Site != nil { siteCopy := *rubiReq.Site siteCopy.Ext, err = json.Marshal(&siteExt) - siteCopy.Publisher = &openrtb.Publisher{} + siteCopy.Publisher = &openrtb2.Publisher{} siteCopy.Publisher.Ext, err = json.Marshal(&pubExt) - siteCopy.Content = &openrtb.Content{} + siteCopy.Content = &openrtb2.Content{} siteCopy.Content.Language = rubiconUser.Language rubiReq.Site = &siteCopy } else { - site := &openrtb.Site{} - site.Content = &openrtb.Content{} + site := &openrtb2.Site{} + site.Content = &openrtb2.Content{} site.Content.Language = rubiconUser.Language rubiReq.Site = site } @@ -538,12 +536,12 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * if rubiReq.App != nil { appCopy := *rubiReq.App appCopy.Ext, err = json.Marshal(&siteExt) - appCopy.Publisher = &openrtb.Publisher{} + appCopy.Publisher = &openrtb2.Publisher{} appCopy.Publisher.Ext, err = json.Marshal(&pubExt) rubiReq.App = &appCopy } - rubiReq.Imp = []openrtb.Imp{thisImp} + rubiReq.Imp = []openrtb2.Imp{thisImp} var reqBuffer bytes.Buffer err = json.NewEncoder(&reqBuffer).Encode(rubiReq) @@ -616,7 +614,7 @@ func (a *RubiconAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder * return bids, nil } -func resolveVideoSizeId(placement openrtb.VideoPlacementType, instl int8, impId string) (sizeID int, err error) { +func resolveVideoSizeId(placement openrtb2.VideoPlacementType, instl int8, impId string) (sizeID int, err error) { if placement != 0 { if placement == 1 { return 201, nil @@ -674,7 +672,7 @@ func NewRubiconLegacyAdapter(httpConfig *adapters.HTTPAdapterConfig, uri string, } } -func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *RubiconAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { numRequests := len(request.Imp) errs := make([]error, 0, len(request.Imp)) var err error @@ -853,14 +851,14 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap if request.Site != nil { siteCopy := *request.Site siteCopy.Ext, err = json.Marshal(&siteExt) - siteCopy.Publisher = &openrtb.Publisher{} + siteCopy.Publisher = &openrtb2.Publisher{} siteCopy.Publisher.Ext, err = json.Marshal(&pubExt) rubiconRequest.Site = &siteCopy } if request.App != nil { appCopy := *request.App appCopy.Ext, err = json.Marshal(&siteExt) - appCopy.Publisher = &openrtb.Publisher{} + appCopy.Publisher = &openrtb2.Publisher{} appCopy.Publisher.Ext, err = json.Marshal(&pubExt) rubiconRequest.App = &appCopy } @@ -872,7 +870,7 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap } } - rubiconRequest.Imp = []openrtb.Imp{thisImp} + rubiconRequest.Imp = []openrtb2.Imp{thisImp} rubiconRequest.Cur = nil rubiconRequest.Ext = nil @@ -895,7 +893,7 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return requestData, errs } -func updateUserExtWithIabAttribute(userExtRP *rubiconUserExt, data []openrtb.Data) error { +func updateUserExtWithIabAttribute(userExtRP *rubiconUserExt, data []openrtb2.Data) error { var segmentIdsToCopy = make([]string, 0) for _, dataRecord := range data { @@ -1018,7 +1016,7 @@ func updateUserExtWithTpIdsAndSegments(userExtRP *rubiconUserExt, rubiconUidsPar return nil } -func isVideo(imp openrtb.Imp) bool { +func isVideo(imp openrtb2.Imp) bool { video := imp.Video if video != nil { // Do any other media types exist? Or check required video fields. @@ -1027,12 +1025,12 @@ func isVideo(imp openrtb.Imp) bool { return false } -func isFullyPopulatedVideo(video *openrtb.Video) bool { +func isFullyPopulatedVideo(video *openrtb2.Video) bool { // These are just recommended video fields for XAPI return video.MIMEs != nil && video.Protocols != nil && video.MaxDuration != 0 && video.Linearity != 0 && video.API != nil } -func (a *RubiconAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *RubiconAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -1049,14 +1047,14 @@ func (a *RubiconAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), }} } - var bidReq openrtb.BidRequest + var bidReq openrtb2.BidRequest if err := json.Unmarshal(externalRequest.Body, &bidReq); err != nil { return nil, []error{err} } @@ -1103,7 +1101,7 @@ func (a *RubiconAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR return bidResponse, nil } -func cmpOverrideFromBidRequest(bidRequest *openrtb.BidRequest) float64 { +func cmpOverrideFromBidRequest(bidRequest *openrtb2.BidRequest) float64 { var bidRequestExt bidRequestExt if err := json.Unmarshal(bidRequest.Ext, &bidRequestExt); err != nil { return 0 @@ -1112,7 +1110,7 @@ func cmpOverrideFromBidRequest(bidRequest *openrtb.BidRequest) float64 { return bidRequestExt.Prebid.Bidders.Rubicon.Debug.CpmOverride } -func mapImpIdToCpmOverride(imps []openrtb.Imp) map[string]float64 { +func mapImpIdToCpmOverride(imps []openrtb2.Imp) map[string]float64 { impIdToCmpOverride := make(map[string]float64) for _, imp := range imps { var bidderExt adapters.ExtImpBidder diff --git a/adapters/rubicon/rubicon_test.go b/adapters/rubicon/rubicon_test.go index 41e37f41126..747758bc820 100644 --- a/adapters/rubicon/rubicon_test.go +++ b/adapters/rubicon/rubicon_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "encoding/json" - "github.com/prebid/prebid-server/errortypes" "io/ioutil" "net/http" "net/http/httptest" @@ -12,6 +11,9 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/cache/dummycache" "github.com/prebid/prebid-server/pbs" @@ -21,7 +23,6 @@ import ( "strings" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" @@ -81,7 +82,7 @@ func DummyRubiconServer(w http.ResponseWriter, r *http.Request) { return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) @@ -126,14 +127,14 @@ func DummyRubiconServer(w http.ResponseWriter, r *http.Request) { return } - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "test-response-id", BidID: "test-bid-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "RUBICON", - Bid: make([]openrtb.Bid, 2), + Bid: make([]openrtb2.Bid, 2), }, }, } @@ -185,7 +186,7 @@ func DummyRubiconServer(w http.ResponseWriter, r *http.Request) { targeting := "{\"rp\":{\"targeting\":[{\"key\":\"key1\",\"values\":[\"value1\"]},{\"key\":\"key2\",\"values\":[\"value2\"]}]}}" rawTargeting := json.RawMessage(targeting) - resp.SeatBid[0].Bid[0] = openrtb.Bid{ + resp.SeatBid[0].Bid[0] = openrtb2.Bid{ ID: "random-id", ImpID: imp.ID, Price: rubidata.tags[ix].bid, @@ -320,8 +321,8 @@ func TestRubiconUserSyncInfo(t *testing.T) { assert.False(t, an.SkipNoCookies(), "SkipNoCookies should be false") } -func getTestSizes() map[int]openrtb.Format { - return map[int]openrtb.Format{ +func getTestSizes() map[int]openrtb2.Format { + return map[int]openrtb2.Format{ 15: {W: 300, H: 250}, 10: {W: 300, H: 600}, 2: {W: 728, H: 91}, @@ -335,7 +336,7 @@ func getTestSizes() map[int]openrtb.Format { func TestParseSizes(t *testing.T) { SIZE_ID := getTestSizes() - sizes := []openrtb.Format{ + sizes := []openrtb2.Format{ SIZE_ID[10], SIZE_ID[15], } @@ -345,7 +346,7 @@ func TestParseSizes(t *testing.T) { assert.Equal(t, 1, len(alt), "Alt not len 1") assert.Equal(t, 10, alt[0], "Alt not 10: %d", alt[0]) - sizes = []openrtb.Format{ + sizes = []openrtb2.Format{ { W: 1111, H: 2222, @@ -357,7 +358,7 @@ func TestParseSizes(t *testing.T) { assert.Equal(t, 15, primary, "Primary %d != 15", primary) assert.Equal(t, 0, len(alt), "Alt len %d != 0", len(alt)) - sizes = []openrtb.Format{ + sizes = []openrtb2.Format{ SIZE_ID[15], } primary, alt, err = parseRubiconSizes(sizes) @@ -365,7 +366,7 @@ func TestParseSizes(t *testing.T) { assert.Equal(t, 15, primary, "Primary %d != 15", primary) assert.Equal(t, 0, len(alt), "Alt len %d != 0", len(alt)) - sizes = []openrtb.Format{ + sizes = []openrtb2.Format{ { W: 1111, H: 1222, @@ -385,20 +386,20 @@ func TestMASAlgorithm(t *testing.T) { ok bool } type testStub struct { - input []openrtb.Format + input []openrtb2.Format output output } testStubs := []testStub{ { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[2], SIZE_ID[9], }, output{2, []int{9}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[9], SIZE_ID[15], @@ -406,14 +407,14 @@ func TestMASAlgorithm(t *testing.T) { output{15, []int{9}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[2], SIZE_ID[15], }, output{15, []int{2}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[15], SIZE_ID[9], SIZE_ID[2], @@ -421,7 +422,7 @@ func TestMASAlgorithm(t *testing.T) { output{15, []int{2, 9}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[10], SIZE_ID[9], SIZE_ID[2], @@ -429,7 +430,7 @@ func TestMASAlgorithm(t *testing.T) { output{2, []int{10, 9}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[33], SIZE_ID[8], SIZE_ID[15], @@ -437,7 +438,7 @@ func TestMASAlgorithm(t *testing.T) { output{15, []int{33, 8}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[33], SIZE_ID[8], SIZE_ID[9], @@ -446,7 +447,7 @@ func TestMASAlgorithm(t *testing.T) { output{2, []int{33, 8, 9}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[33], SIZE_ID[8], SIZE_ID[9], @@ -454,7 +455,7 @@ func TestMASAlgorithm(t *testing.T) { output{9, []int{33, 8}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[33], SIZE_ID[8], SIZE_ID[2], @@ -462,24 +463,24 @@ func TestMASAlgorithm(t *testing.T) { output{2, []int{33, 8}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[33], SIZE_ID[2], }, output{2, []int{33}, false}, }, { - []openrtb.Format{ + []openrtb2.Format{ SIZE_ID[8], }, output{8, []int{}, false}, }, { - []openrtb.Format{}, + []openrtb2.Format{}, output{0, []int{}, true}, }, { - []openrtb.Format{ + []openrtb2.Format{ {W: 1111, H: 2345, }, @@ -527,7 +528,7 @@ func TestAppendTracker(t *testing.T) { func TestResolveVideoSizeId(t *testing.T) { testScenarios := []struct { - placement openrtb.VideoPlacementType + placement openrtb2.VideoPlacementType instl int8 impId string expected int @@ -626,11 +627,11 @@ func TestWrongFormatResponse(t *testing.T) { func TestZeroSeatBidResponse(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "test-response-id", BidID: "test-bid-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{}, + SeatBid: []openrtb2.SeatBid{}, } js, _ := json.Marshal(resp) w.Write(js) @@ -647,14 +648,14 @@ func TestZeroSeatBidResponse(t *testing.T) { func TestEmptyBidResponse(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "test-response-id", BidID: "test-bid-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "RUBICON", - Bid: make([]openrtb.Bid, 0), + Bid: make([]openrtb2.Bid, 0), }, }, } @@ -673,18 +674,18 @@ func TestEmptyBidResponse(t *testing.T) { func TestWrongBidIdResponse(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "test-response-id", BidID: "test-bid-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "RUBICON", - Bid: make([]openrtb.Bid, 2), + Bid: make([]openrtb2.Bid, 2), }, }, } - resp.SeatBid[0].Bid[0] = openrtb.Bid{ + resp.SeatBid[0].Bid[0] = openrtb2.Bid{ ID: "random-id", ImpID: "zma", Price: 1.67, @@ -710,18 +711,18 @@ func TestWrongBidIdResponse(t *testing.T) { func TestZeroPriceBidResponse(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - resp := openrtb.BidResponse{ + resp := openrtb2.BidResponse{ ID: "test-response-id", BidID: "test-bid-id", Cur: "USD", - SeatBid: []openrtb.SeatBid{ + SeatBid: []openrtb2.SeatBid{ { Seat: "RUBICON", - Bid: make([]openrtb.Bid, 1), + Bid: make([]openrtb2.Bid, 1), }, }, } - resp.SeatBid[0].Bid[0] = openrtb.Bid{ + resp.SeatBid[0].Bid[0] = openrtb2.Bid{ ID: "test-bid-id", ImpID: "first-tag", Price: 0, @@ -747,7 +748,7 @@ func TestDifferentRequest(t *testing.T) { an, ctx, pbReq := CreatePrebidRequest(server, t) // test app not nil - pbReq.App = &openrtb.App{ + pbReq.App = &openrtb2.App{ ID: "com.test", Name: "testApp", } @@ -775,13 +776,13 @@ func TestDifferentRequest(t *testing.T) { pbReq.Bidders[0].AdUnits[0].Params = json.RawMessage(fmt.Sprintf("{\"zoneId\": %d, \"siteId\": %d, \"accountId\": %d, \"visitor\": %s, \"inventory\": %s}", 8394, rubidata.siteID, rubidata.accountID, rubidata.visitorTargeting, rubidata.inventoryTargeting)) // test invalid size - pbReq.Bidders[0].AdUnits[0].Sizes = []openrtb.Format{ + pbReq.Bidders[0].AdUnits[0].Sizes = []openrtb2.Format{ { W: 2222, H: 333, }, } - pbReq.Bidders[0].AdUnits[1].Sizes = []openrtb.Format{ + pbReq.Bidders[0].AdUnits[1].Sizes = []openrtb2.Format{ { W: 222, H: 3333, @@ -795,7 +796,7 @@ func TestDifferentRequest(t *testing.T) { b, err := an.Call(ctx, pbReq, pbReq.Bidders[0]) assert.NotNil(t, err, "Should have gotten an error: %v", err) - pbReq.Bidders[0].AdUnits[1].Sizes = []openrtb.Format{ + pbReq.Bidders[0].AdUnits[1].Sizes = []openrtb2.Format{ { W: 222, H: 3333, @@ -861,7 +862,7 @@ func CreatePrebidRequest(server *httptest.Server, t *testing.T) (an *RubiconAdap pbin := pbs.PBSRequest{ AdUnits: make([]pbs.AdUnit, 3), - Device: &openrtb.Device{PxRatio: rubidata.devicePxRatio}, + Device: &openrtb2.Device{PxRatio: rubidata.devicePxRatio}, SDK: &pbs.SDK{Source: rubidata.sdkSource, Platform: rubidata.sdkPlatform, Version: rubidata.sdkVersion}, } @@ -869,7 +870,7 @@ func CreatePrebidRequest(server *httptest.Server, t *testing.T) (an *RubiconAdap pbin.AdUnits[i] = pbs.AdUnit{ Code: tag.code, MediaTypes: []string{tag.mediaType}, - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ SIZE_ID[10], SIZE_ID[15], }, @@ -946,12 +947,12 @@ func TestOpenRTBRequest(t *testing.T) { devicePxRatio: 4.0, } - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-banner-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], SIZE_ID[10], }, @@ -965,7 +966,7 @@ func TestOpenRTBRequest(t *testing.T) { }}`), }, { ID: "test-imp-video-id", - Video: &openrtb.Video{ + Video: &openrtb2.Video{ W: 640, H: 360, MIMEs: []string{"video/mp4"}, @@ -988,10 +989,10 @@ func TestOpenRTBRequest(t *testing.T) { } }}`), }}, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ PxRatio: rubidata.devicePxRatio, }, - User: &openrtb.User{ + User: &openrtb2.User{ Ext: json.RawMessage(`{"digitrust": { "id": "some-digitrust-id", "keyv": 1, @@ -1015,7 +1016,7 @@ func TestOpenRTBRequest(t *testing.T) { httpReq := reqs[i] assert.Equal(t, "POST", httpReq.Method, "Expected a POST message. Got %s", httpReq.Method) - var rpRequest openrtb.BidRequest + var rpRequest openrtb2.BidRequest if err := json.Unmarshal(httpReq.Body, &rpRequest); err != nil { t.Fatalf("Failed to unmarshal HTTP request: %v", rpRequest) } @@ -1031,16 +1032,16 @@ func TestOpenRTBRequest(t *testing.T) { t.Fatal("Error unmarshalling request from the outgoing request.") } - assert.Equal(t, uint64(300), rpRequest.Imp[0].Banner.Format[0].W, + assert.Equal(t, int64(300), rpRequest.Imp[0].Banner.Format[0].W, "Banner width does not match. Expected %d, Got %d", 300, rpRequest.Imp[0].Banner.Format[0].W) - assert.Equal(t, uint64(250), rpRequest.Imp[0].Banner.Format[0].H, + assert.Equal(t, int64(250), rpRequest.Imp[0].Banner.Format[0].H, "Banner height does not match. Expected %d, Got %d", 250, rpRequest.Imp[0].Banner.Format[0].H) - assert.Equal(t, uint64(300), rpRequest.Imp[0].Banner.Format[1].W, + assert.Equal(t, int64(300), rpRequest.Imp[0].Banner.Format[1].W, "Banner width does not match. Expected %d, Got %d", 300, rpRequest.Imp[0].Banner.Format[1].W) - assert.Equal(t, uint64(600), rpRequest.Imp[0].Banner.Format[1].H, + assert.Equal(t, int64(600), rpRequest.Imp[0].Banner.Format[1].H, "Banner height does not match. Expected %d, Got %d", 600, rpRequest.Imp[0].Banner.Format[1].H) } else if rpRequest.Imp[0].ID == "test-imp-video-id" { var rpExt rubiconVideoExt @@ -1048,10 +1049,10 @@ func TestOpenRTBRequest(t *testing.T) { t.Fatal("Error unmarshalling request from the outgoing request.") } - assert.Equal(t, uint64(640), rpRequest.Imp[0].Video.W, + assert.Equal(t, int64(640), rpRequest.Imp[0].Video.W, "Video width does not match. Expected %d, Got %d", 640, rpRequest.Imp[0].Video.W) - assert.Equal(t, uint64(360), rpRequest.Imp[0].Video.H, + assert.Equal(t, int64(360), rpRequest.Imp[0].Video.H, "Video height does not match. Expected %d, Got %d", 360, rpRequest.Imp[0].Video.H) assert.Equal(t, "video/mp4", rpRequest.Imp[0].Video.MIMEs[0], "Video MIMEs do not match. Expected %s, Got %s", "video/mp4", rpRequest.Imp[0].Video.MIMEs[0]) @@ -1084,17 +1085,17 @@ func TestOpenRTBRequestWithBannerImpEvenIfImpHasVideo(t *testing.T) { SIZE_ID := getTestSizes() bidder := new(RubiconAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], SIZE_ID[10], }, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ W: 640, H: 360, MIMEs: []string{"video/mp4"}, @@ -1115,7 +1116,7 @@ func TestOpenRTBRequestWithBannerImpEvenIfImpHasVideo(t *testing.T) { assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1131,12 +1132,12 @@ func TestOpenRTBRequestWithImpAndAdSlotIncluded(t *testing.T) { SIZE_ID := getTestSizes() bidder := new(RubiconAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], SIZE_ID[10], }, @@ -1160,7 +1161,7 @@ func TestOpenRTBRequestWithImpAndAdSlotIncluded(t *testing.T) { reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1191,13 +1192,13 @@ func TestOpenRTBRequestWithBadvOverflowed(t *testing.T) { badvOverflowed[i] = strconv.Itoa(i) } - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", BAdv: badvOverflowed, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], }, }, @@ -1215,7 +1216,7 @@ func TestOpenRTBRequestWithBadvOverflowed(t *testing.T) { reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1228,12 +1229,12 @@ func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) { SIZE_ID := getTestSizes() bidder := new(RubiconAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], SIZE_ID[10], }, @@ -1244,7 +1245,7 @@ func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) { "accountId": 7891 }}`), }}, - User: &openrtb.User{ + User: &openrtb2.User{ Ext: json.RawMessage(`{"eids": [ { "source": "pubcid", @@ -1283,7 +1284,7 @@ func TestOpenRTBRequestWithSpecificExtUserEids(t *testing.T) { reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1324,24 +1325,24 @@ func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t SIZE_ID := getTestSizes() bidder := new(RubiconAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ SIZE_ID[15], SIZE_ID[10], }, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ W: 640, H: 360, MIMEs: []string{"video/mp4"}, - Protocols: []openrtb.Protocol{openrtb.ProtocolVAST10}, + Protocols: []openrtb2.Protocol{openrtb2.ProtocolVAST10}, MaxDuration: 30, Linearity: 1, - API: []openrtb.APIFramework{}, + API: []openrtb2.APIFramework{}, }, Ext: json.RawMessage(`{"bidder": { "zoneId": 8394, @@ -1360,7 +1361,7 @@ func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t assert.Equal(t, 1, len(reqs), "Unexpected number of HTTP requests. Got %d. Expected %d", len(reqs), 1) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1376,18 +1377,18 @@ func TestOpenRTBRequestWithVideoImpEvenIfImpHasBannerButAllRequiredVideoFields(t func TestOpenRTBRequestWithVideoImpAndEnabledRewardedInventoryFlag(t *testing.T) { bidder := new(RubiconAdapter) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Video: &openrtb.Video{ + Video: &openrtb2.Video{ W: 640, H: 360, MIMEs: []string{"video/mp4"}, - Protocols: []openrtb.Protocol{openrtb.ProtocolVAST10}, + Protocols: []openrtb2.Protocol{openrtb2.ProtocolVAST10}, MaxDuration: 30, Linearity: 1, - API: []openrtb.APIFramework{}, + API: []openrtb2.APIFramework{}, }, Ext: json.RawMessage(`{ "prebid":{ @@ -1401,7 +1402,7 @@ func TestOpenRTBRequestWithVideoImpAndEnabledRewardedInventoryFlag(t *testing.T) reqs, _ := bidder.MakeRequests(request, &adapters.ExtraRequestInfo{}) - rubiconReq := &openrtb.BidRequest{} + rubiconReq := &openrtb2.BidRequest{} if err := json.Unmarshal(reqs[0].Body, rubiconReq); err != nil { t.Fatalf("Unexpected error while decoding request: %s", err) } @@ -1439,12 +1440,12 @@ func TestOpenRTBSurpriseResponse(t *testing.T) { } func TestOpenRTBStandardResponse(t *testing.T) { - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 320, H: 50, }}, @@ -1486,12 +1487,12 @@ func TestOpenRTBStandardResponse(t *testing.T) { } func TestOpenRTBResponseOverridePriceFromBidRequest(t *testing.T) { - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 320, H: 50, }}, @@ -1533,12 +1534,12 @@ func TestOpenRTBResponseOverridePriceFromBidRequest(t *testing.T) { } func TestOpenRTBResponseOverridePriceFromCorrespondingImp(t *testing.T) { - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "test-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 320, H: 50, }}, @@ -1583,9 +1584,9 @@ func TestOpenRTBResponseOverridePriceFromCorrespondingImp(t *testing.T) { } func TestOpenRTBCopyBidIdFromResponseIfZero(t *testing.T) { - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{{}}, + Imp: []openrtb2.Imp{{}}, } requestJson, _ := json.Marshal(request) diff --git a/adapters/sharethrough/butler.go b/adapters/sharethrough/butler.go index 36af79c4534..c9b9726ff4e 100644 --- a/adapters/sharethrough/butler.go +++ b/adapters/sharethrough/butler.go @@ -9,7 +9,7 @@ import ( "strconv" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" @@ -33,7 +33,7 @@ type StrAdSeverParams struct { } type StrOpenRTBInterface interface { - requestFromOpenRTB(openrtb.Imp, *openrtb.BidRequest, string) (*adapters.RequestData, error) + requestFromOpenRTB(openrtb2.Imp, *openrtb2.BidRequest, string) (*adapters.RequestData, error) responseToOpenRTB([]byte, *adapters.RequestData) (*adapters.BidderResponse, []error) } @@ -70,7 +70,7 @@ type StrOpenRTBTranslator struct { UserAgentParsers UserAgentParsers } -func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb.Imp, request *openrtb.BidRequest, domain string) (*adapters.RequestData, error) { +func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb2.Imp, request *openrtb2.BidRequest, domain string) (*adapters.RequestData, error) { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -111,8 +111,8 @@ func (s StrOpenRTBTranslator) requestFromOpenRTB(imp openrtb.Imp, request *openr ConsentString: userInfo.Consent, USPrivacySignal: usPolicySignal, Iframe: strImpParams.Iframe, - Height: height, - Width: width, + Height: uint64(height), + Width: uint64(width), InstantPlayCapable: s.Util.canAutoPlayVideo(request.Device.UA, s.UserAgentParsers), TheTradeDeskUserId: userInfo.TtdUid, SharethroughUserId: userInfo.StxUid, @@ -152,7 +152,7 @@ func (s StrOpenRTBTranslator) responseToOpenRTB(strRawResp []byte, btlrReq *adap return nil, errs } - bid := &openrtb.Bid{ + bid := &openrtb2.Bid{ AdID: strResp.AdServerRequestID, ID: strResp.BidID, ImpID: btlrParams.BidID, @@ -161,8 +161,8 @@ func (s StrOpenRTBTranslator) responseToOpenRTB(strRawResp []byte, btlrReq *adap CrID: creative.Metadata.CreativeKey, DealID: creative.Metadata.DealID, AdM: adm, - H: btlrParams.Height, - W: btlrParams.Width, + H: int64(btlrParams.Height), + W: int64(btlrParams.Width), } typedBid.Bid = bid @@ -171,7 +171,7 @@ func (s StrOpenRTBTranslator) responseToOpenRTB(strRawResp []byte, btlrReq *adap return bidResponse, errs } -func (h StrBodyHelper) buildBody(request *openrtb.BidRequest, strImpParams openrtb_ext.ExtImpSharethrough) (body []byte, err error) { +func (h StrBodyHelper) buildBody(request *openrtb2.BidRequest, strImpParams openrtb_ext.ExtImpSharethrough) (body []byte, err error) { timeout := request.TMax if timeout == 0 { timeout = defaultTmax diff --git a/adapters/sharethrough/butler_test.go b/adapters/sharethrough/butler_test.go index 402e8365dd0..3b1f2159bb7 100644 --- a/adapters/sharethrough/butler_test.go +++ b/adapters/sharethrough/butler_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" @@ -19,7 +19,7 @@ import ( type MockUtil struct { mockCanAutoPlayVideo func() bool mockGdprApplies func() bool - mockGetPlacementSize func() (uint64, uint64) + mockGetPlacementSize func() (int64, int64) mockParseUserInfo func() userInfo UtilityInterface } @@ -28,15 +28,15 @@ func (m MockUtil) canAutoPlayVideo(userAgent string, parsers UserAgentParsers) b return m.mockCanAutoPlayVideo() } -func (m MockUtil) gdprApplies(request *openrtb.BidRequest) bool { +func (m MockUtil) gdprApplies(request *openrtb2.BidRequest) bool { return m.mockGdprApplies() } -func (m MockUtil) getPlacementSize(imp openrtb.Imp, strImpParams openrtb_ext.ExtImpSharethrough) (height uint64, width uint64) { +func (m MockUtil) getPlacementSize(imp openrtb2.Imp, strImpParams openrtb_ext.ExtImpSharethrough) (height, width int64) { return m.mockGetPlacementSize() } -func (m MockUtil) parseUserInfo(user *openrtb.User) (ui userInfo) { +func (m MockUtil) parseUserInfo(user *openrtb2.User) (ui userInfo) { return m.mockParseUserInfo() } @@ -75,26 +75,26 @@ func assertRequestDataEquals(t *testing.T, testName string, expected *adapters.R func TestSuccessRequestFromOpenRTB(t *testing.T) { tests := map[string]struct { - inputImp openrtb.Imp - inputReq *openrtb.BidRequest + inputImp openrtb2.Imp + inputReq *openrtb2.BidRequest inputDom string expected *adapters.RequestData }{ "Generates the correct AdServer request from Imp (no user provided)": { - inputImp: openrtb.Imp{ + inputImp: openrtb2.Imp{ ID: "abc", Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true, "iframeSize": [10, 20], "bidfloor": 1.0} }`), - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{H: 30, W: 40}}, + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{H: 30, W: 40}}, }, }, - inputReq: &openrtb.BidRequest{ - App: &openrtb.App{Ext: []byte(`{}`)}, - Device: &openrtb.Device{ + inputReq: &openrtb2.BidRequest{ + App: &openrtb2.App{Ext: []byte(`{}`)}, + Device: &openrtb2.Device{ UA: "Android Chome/60", IP: "127.0.0.1", }, - Site: &openrtb.Site{Page: "http://a.domain.com/page"}, + Site: &openrtb2.Site{Page: "http://a.domain.com/page"}, BAdv: []string{"domain1.com", "domain2.com"}, TMax: 700, }, @@ -114,20 +114,20 @@ func TestSuccessRequestFromOpenRTB(t *testing.T) { }, }, "Generates width/height if not provided": { - inputImp: openrtb.Imp{ + inputImp: openrtb2.Imp{ ID: "abc", Ext: []byte(`{ "bidder": {"pkey": "pkey", "iframe": true} }`), - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{H: 30, W: 40}}, + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{H: 30, W: 40}}, }, }, - inputReq: &openrtb.BidRequest{ - App: &openrtb.App{Ext: []byte(`{}`)}, - Device: &openrtb.Device{ + inputReq: &openrtb2.BidRequest{ + App: &openrtb2.App{Ext: []byte(`{}`)}, + Device: &openrtb2.Device{ UA: "Android Chome/60", IP: "127.0.0.1", }, - Site: &openrtb.Site{Page: "http://a.domain.com/page"}, + Site: &openrtb2.Site{Page: "http://a.domain.com/page"}, BAdv: []string{"domain1.com", "domain2.com"}, TMax: 700, }, @@ -157,7 +157,7 @@ func TestSuccessRequestFromOpenRTB(t *testing.T) { mockUtil := MockUtil{ mockCanAutoPlayVideo: func() bool { return true }, mockGdprApplies: func() bool { return true }, - mockGetPlacementSize: func() (uint64, uint64) { return 100, 200 }, + mockGetPlacementSize: func() (int64, int64) { return 100, 200 }, mockParseUserInfo: func() userInfo { return userInfo{Consent: "ok", TtdUid: "ttduid", StxUid: "stxuid"} }, } @@ -177,27 +177,27 @@ func TestSuccessRequestFromOpenRTB(t *testing.T) { func TestFailureRequestFromOpenRTB(t *testing.T) { tests := map[string]struct { - inputImp openrtb.Imp - inputReq *openrtb.BidRequest + inputImp openrtb2.Imp + inputReq *openrtb2.BidRequest expectedError string }{ "Fails when unable to parse imp.Ext": { - inputImp: openrtb.Imp{ + inputImp: openrtb2.Imp{ Ext: []byte(`{"abc`), }, - inputReq: &openrtb.BidRequest{ - Device: &openrtb.Device{UA: "A", IP: "ip"}, - Site: &openrtb.Site{Page: "page"}, + inputReq: &openrtb2.BidRequest{ + Device: &openrtb2.Device{UA: "A", IP: "ip"}, + Site: &openrtb2.Site{Page: "page"}, }, expectedError: `unexpected end of JSON input`, }, "Fails when unable to parse imp.Ext.Bidder": { - inputImp: openrtb.Imp{ + inputImp: openrtb2.Imp{ Ext: []byte(`{ "bidder": "{ abc" }`), }, - inputReq: &openrtb.BidRequest{ - Device: &openrtb.Device{UA: "A", IP: "ip"}, - Site: &openrtb.Site{Page: "page"}, + inputReq: &openrtb2.BidRequest{ + Device: &openrtb2.Device{UA: "A", IP: "ip"}, + Site: &openrtb2.Site{Page: "page"}, }, expectedError: `json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpSharethrough`, }, @@ -212,7 +212,7 @@ func TestFailureRequestFromOpenRTB(t *testing.T) { mockUtil := MockUtil{ mockCanAutoPlayVideo: func() bool { return true }, mockGdprApplies: func() bool { return true }, - mockGetPlacementSize: func() (uint64, uint64) { return 100, 200 }, + mockGetPlacementSize: func() (int64, int64) { return 100, 200 }, mockParseUserInfo: func() userInfo { return userInfo{Consent: "ok", TtdUid: "ttduid", StxUid: "stxuid"} }, } @@ -288,7 +288,7 @@ func TestSuccessResponseToOpenRTB(t *testing.T) { expectedSuccess: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{{ BidType: openrtb_ext.BidTypeBanner, - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ AdID: "arid", ID: "bid", ImpID: "bidid", @@ -376,19 +376,19 @@ func TestFailResponseToOpenRTB(t *testing.T) { func TestBuildBody(t *testing.T) { tests := map[string]struct { - inputRequest *openrtb.BidRequest + inputRequest *openrtb2.BidRequest inputImp openrtb_ext.ExtImpSharethrough expectedJson []byte expectedError error }{ "Empty input: skips badomains, tmax default to 10 sec and sets deadline accordingly": { - inputRequest: &openrtb.BidRequest{}, + inputRequest: &openrtb2.BidRequest{}, inputImp: openrtb_ext.ExtImpSharethrough{}, expectedJson: []byte(`{"tmax":10000, "deadline":"2019-09-12T11:29:10.000123456Z"}`), expectedError: nil, }, "Sets badv as list of domains according to Badv (tmax default to 10 sec and sets deadline accordingly)": { - inputRequest: &openrtb.BidRequest{ + inputRequest: &openrtb2.BidRequest{ BAdv: []string{"dom1.com", "dom2.com"}, }, inputImp: openrtb_ext.ExtImpSharethrough{}, @@ -396,7 +396,7 @@ func TestBuildBody(t *testing.T) { expectedError: nil, }, "Sets tmax and deadline according to Tmax": { - inputRequest: &openrtb.BidRequest{ + inputRequest: &openrtb2.BidRequest{ TMax: 500, }, inputImp: openrtb_ext.ExtImpSharethrough{}, @@ -404,7 +404,7 @@ func TestBuildBody(t *testing.T) { expectedError: nil, }, "Sets bidfloor according to the Imp object": { - inputRequest: &openrtb.BidRequest{}, + inputRequest: &openrtb2.BidRequest{}, inputImp: openrtb_ext.ExtImpSharethrough{ BidFloor: 1.23, }, @@ -428,7 +428,7 @@ func TestBuildBody(t *testing.T) { func TestBuildUri(t *testing.T) { tests := map[string]struct { inputParams StrAdSeverParams - inputApp *openrtb.App + inputApp *openrtb2.App expected []string }{ "Generates expected URL, appending all params": { diff --git a/adapters/sharethrough/sharethrough.go b/adapters/sharethrough/sharethrough.go index a6ef4736fdf..65afb21adb7 100644 --- a/adapters/sharethrough/sharethrough.go +++ b/adapters/sharethrough/sharethrough.go @@ -5,7 +5,7 @@ import ( "net/http" "regexp" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -35,7 +35,7 @@ type SharethroughAdapter struct { AdServer StrOpenRTBInterface } -func (a SharethroughAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a SharethroughAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var reqs []*adapters.RequestData if request.Site == nil { @@ -56,7 +56,7 @@ func (a SharethroughAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo * return reqs, []error{} } -func (a SharethroughAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a SharethroughAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } diff --git a/adapters/sharethrough/sharethrough_test.go b/adapters/sharethrough/sharethrough_test.go index 9fca80e03ee..194894fd893 100644 --- a/adapters/sharethrough/sharethrough_test.go +++ b/adapters/sharethrough/sharethrough_test.go @@ -6,7 +6,7 @@ import ( "regexp" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -21,7 +21,7 @@ type MockStrAdServer struct { StrOpenRTBInterface } -func (m MockStrAdServer) requestFromOpenRTB(imp openrtb.Imp, request *openrtb.BidRequest, domain string) (*adapters.RequestData, error) { +func (m MockStrAdServer) requestFromOpenRTB(imp openrtb2.Imp, request *openrtb2.BidRequest, domain string) (*adapters.RequestData, error) { return m.mockRequestFromOpenRTB() } @@ -88,22 +88,22 @@ func TestSuccessMakeRequests(t *testing.T) { } tests := map[string]struct { - input *openrtb.BidRequest + input *openrtb2.BidRequest expected []*adapters.RequestData }{ "Generates expected Request": { - input: &openrtb.BidRequest{ - Site: &openrtb.Site{ + input: &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "test.com", }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: "Android Chome/60", }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "abc", Ext: []byte(`{"pkey": "pkey", "iframe": true, "iframeSize": [10, 20]}`), - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{H: 30, W: 40}}, + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{H: 30, W: 40}}, }, }}, }, @@ -137,22 +137,22 @@ func TestSuccessMakeRequests(t *testing.T) { func TestFailureMakeRequests(t *testing.T) { tests := map[string]struct { - input *openrtb.BidRequest + input *openrtb2.BidRequest expected string }{ "Returns nil if failed to generate request": { - input: &openrtb.BidRequest{ - Site: &openrtb.Site{ + input: &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "test.com", }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: "Android Chome/60", }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "abc", Ext: []byte(`{"pkey": "pkey", "iframe": true, "iframeSize": [10, 20]}`), - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{H: 30, W: 40}}, + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{H: 30, W: 40}}, }, }}, }, @@ -216,7 +216,7 @@ func TestSuccessMakeBids(t *testing.T) { for testName, test := range tests { t.Logf("Test case: %s\n", testName) - response, errors := adapter.MakeBids(&openrtb.BidRequest{}, &adapters.RequestData{}, test.inputResponse) + response, errors := adapter.MakeBids(&openrtb2.BidRequest{}, &adapters.RequestData{}, test.inputResponse) if len(errors) > 0 { t.Errorf("Expected no errors, got %d\n", len(errors)) } @@ -264,7 +264,7 @@ func TestFailureMakeBids(t *testing.T) { for testName, test := range tests { t.Logf("Test case: %s\n", testName) - response, errors := adapter.MakeBids(&openrtb.BidRequest{}, &adapters.RequestData{}, test.inputResponse) + response, errors := adapter.MakeBids(&openrtb2.BidRequest{}, &adapters.RequestData{}, test.inputResponse) if response != nil { t.Errorf("Expected response to be nil, got %+v\n", response) } diff --git a/adapters/sharethrough/utils.go b/adapters/sharethrough/utils.go index 76d8b7a1f76..4f27e738b99 100644 --- a/adapters/sharethrough/utils.go +++ b/adapters/sharethrough/utils.go @@ -5,27 +5,28 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" - "github.com/prebid/prebid-server/openrtb_ext" "html/template" "net" "net/url" "regexp" "strconv" "time" + + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" ) const minChromeVersion = 53 const minSafariVersion = 10 type UtilityInterface interface { - gdprApplies(*openrtb.BidRequest) bool - parseUserInfo(*openrtb.User) userInfo + gdprApplies(*openrtb2.BidRequest) bool + parseUserInfo(*openrtb2.User) userInfo getAdMarkup([]byte, openrtb_ext.ExtImpSharethroughResponse, *StrAdSeverParams) (string, error) - getBestFormat([]openrtb.Format) (uint64, uint64) - getPlacementSize(openrtb.Imp, openrtb_ext.ExtImpSharethrough) (uint64, uint64) + getBestFormat([]openrtb2.Format) (int64, int64) + getPlacementSize(openrtb2.Imp, openrtb_ext.ExtImpSharethrough) (int64, int64) canAutoPlayVideo(string, UserAgentParsers) bool isAndroid(string) bool @@ -123,10 +124,10 @@ func (u Util) getAdMarkup(strRawResp []byte, strResp openrtb_ext.ExtImpSharethro return templatedBuf.String(), nil } -func (u Util) getPlacementSize(imp openrtb.Imp, strImpParams openrtb_ext.ExtImpSharethrough) (height uint64, width uint64) { +func (u Util) getPlacementSize(imp openrtb2.Imp, strImpParams openrtb_ext.ExtImpSharethrough) (height, width int64) { height, width = 1, 1 if len(strImpParams.IframeSize) >= 2 { - height, width = uint64(strImpParams.IframeSize[0]), uint64(strImpParams.IframeSize[1]) + height, width = int64(strImpParams.IframeSize[0]), int64(strImpParams.IframeSize[1]) } else if imp.Banner != nil { height, width = u.getBestFormat(imp.Banner.Format) } @@ -134,7 +135,7 @@ func (u Util) getPlacementSize(imp openrtb.Imp, strImpParams openrtb_ext.ExtImpS return } -func (u Util) getBestFormat(formats []openrtb.Format) (height uint64, width uint64) { +func (u Util) getBestFormat(formats []openrtb2.Format) (height, width int64) { height, width = 1, 1 for i := 0; i < len(formats); i++ { format := formats[i] @@ -195,7 +196,7 @@ func (u Util) isAtMinSafariVersion(userAgent string, parser *regexp.Regexp) bool return u.isAtMinVersion(userAgent, parser, minSafariVersion) } -func (u Util) gdprApplies(request *openrtb.BidRequest) bool { +func (u Util) gdprApplies(request *openrtb2.BidRequest) bool { var gdprApplies int64 if request.Regs != nil { @@ -208,7 +209,7 @@ func (u Util) gdprApplies(request *openrtb.BidRequest) bool { return gdprApplies != 0 } -func (u Util) parseUserInfo(user *openrtb.User) (ui userInfo) { +func (u Util) parseUserInfo(user *openrtb2.User) (ui userInfo) { if user == nil { return } diff --git a/adapters/sharethrough/utils_test.go b/adapters/sharethrough/utils_test.go index fffc52f6140..fb199369e59 100644 --- a/adapters/sharethrough/utils_test.go +++ b/adapters/sharethrough/utils_test.go @@ -4,11 +4,12 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/mxmCherry/openrtb" - "github.com/prebid/prebid-server/openrtb_ext" - "github.com/stretchr/testify/assert" "regexp" "testing" + + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/stretchr/testify/assert" ) func TestGetAdMarkup(t *testing.T) { @@ -71,31 +72,31 @@ func TestGetAdMarkup(t *testing.T) { func TestGetPlacementSize(t *testing.T) { tests := map[string]struct { - imp openrtb.Imp + imp openrtb2.Imp strImpParams openrtb_ext.ExtImpSharethrough - expectedHeight uint64 - expectedWidth uint64 + expectedHeight int64 + expectedWidth int64 }{ "Returns size from STR params if provided": { - imp: openrtb.Imp{}, + imp: openrtb2.Imp{}, strImpParams: openrtb_ext.ExtImpSharethrough{IframeSize: []int{100, 200}}, expectedHeight: 100, expectedWidth: 200, }, "Skips size from STR params if malformed": { - imp: openrtb.Imp{}, + imp: openrtb2.Imp{}, strImpParams: openrtb_ext.ExtImpSharethrough{IframeSize: []int{100}}, expectedHeight: 1, expectedWidth: 1, }, "Returns size from banner format if provided": { - imp: openrtb.Imp{Banner: &openrtb.Banner{Format: []openrtb.Format{{H: 100, W: 200}}}}, + imp: openrtb2.Imp{Banner: &openrtb2.Banner{Format: []openrtb2.Format{{H: 100, W: 200}}}}, strImpParams: openrtb_ext.ExtImpSharethrough{}, expectedHeight: 100, expectedWidth: 200, }, "Defaults to 1x1": { - imp: openrtb.Imp{}, + imp: openrtb2.Imp{}, strImpParams: openrtb_ext.ExtImpSharethrough{}, expectedHeight: 1, expectedWidth: 1, @@ -114,22 +115,22 @@ func TestGetPlacementSize(t *testing.T) { func TestGetBestFormat(t *testing.T) { tests := map[string]struct { - input []openrtb.Format - expectedHeight uint64 - expectedWidth uint64 + input []openrtb2.Format + expectedHeight int64 + expectedWidth int64 }{ "Returns default size if empty input": { - input: []openrtb.Format{}, + input: []openrtb2.Format{}, expectedHeight: 1, expectedWidth: 1, }, "Returns size if only one is passed": { - input: []openrtb.Format{{H: 100, W: 100}}, + input: []openrtb2.Format{{H: 100, W: 100}}, expectedHeight: 100, expectedWidth: 100, }, "Returns biggest size if multiple are passed": { - input: []openrtb.Format{{H: 100, W: 100}, {H: 200, W: 200}, {H: 50, W: 50}}, + input: []openrtb2.Format{{H: 100, W: 100}, {H: 200, W: 200}, {H: 50, W: 50}}, expectedHeight: 200, expectedWidth: 200, }, @@ -344,27 +345,27 @@ func TestIsAtMinSafariVersion(t *testing.T) { } func TestGdprApplies(t *testing.T) { - bidRequestGdpr := openrtb.BidRequest{ - Regs: &openrtb.Regs{ + bidRequestGdpr := openrtb2.BidRequest{ + Regs: &openrtb2.Regs{ Ext: []byte(`{"gdpr": 1}`), }, } - bidRequestNonGdpr := openrtb.BidRequest{ - Regs: &openrtb.Regs{ + bidRequestNonGdpr := openrtb2.BidRequest{ + Regs: &openrtb2.Regs{ Ext: []byte(`{"gdpr": 0}`), }, } - bidRequestEmptyGdpr := openrtb.BidRequest{ - Regs: &openrtb.Regs{ + bidRequestEmptyGdpr := openrtb2.BidRequest{ + Regs: &openrtb2.Regs{ Ext: []byte(``), }, } - bidRequestEmptyRegs := openrtb.BidRequest{ - Regs: &openrtb.Regs{}, + bidRequestEmptyRegs := openrtb2.BidRequest{ + Regs: &openrtb2.Regs{}, } tests := map[string]struct { - input *openrtb.BidRequest + input *openrtb2.BidRequest expected bool }{ "Return true if gdpr set to 1": { @@ -396,7 +397,7 @@ func TestGdprApplies(t *testing.T) { func TestParseUserInfo(t *testing.T) { tests := map[string]struct { - input *openrtb.User + input *openrtb2.User expected userInfo }{ "Return empty strings if no User": { @@ -404,31 +405,31 @@ func TestParseUserInfo(t *testing.T) { expected: userInfo{Consent: "", TtdUid: "", StxUid: ""}, }, "Return empty strings if no uids": { - input: &openrtb.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": []}] }`)}, + input: &openrtb2.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": []}] }`)}, expected: userInfo{Consent: "", TtdUid: "", StxUid: ""}, }, "Return empty strings if ID is not defined or empty string": { - input: &openrtb.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": [{"id": null}]}, {"source": "adserver.org", "uids": [{"id": ""}]}] }`)}, + input: &openrtb2.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": [{"id": null}]}, {"source": "adserver.org", "uids": [{"id": ""}]}] }`)}, expected: userInfo{Consent: "", TtdUid: "", StxUid: ""}, }, "Return consent correctly": { - input: &openrtb.User{Ext: []byte(`{ "consent": "abc" }`)}, + input: &openrtb2.User{Ext: []byte(`{ "consent": "abc" }`)}, expected: userInfo{Consent: "abc", TtdUid: "", StxUid: ""}, }, "Return ttd uid correctly": { - input: &openrtb.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": [{"id": "abc123"}]}] }`)}, + input: &openrtb2.User{Ext: []byte(`{ "eids": [{"source": "adserver.org", "uids": [{"id": "abc123"}]}] }`)}, expected: userInfo{Consent: "", TtdUid: "abc123", StxUid: ""}, }, "Ignore non-trade-desk uid": { - input: &openrtb.User{Ext: []byte(`{ "eids": [{"source": "something", "uids": [{"id": "xyz"}]}] }`)}, + input: &openrtb2.User{Ext: []byte(`{ "eids": [{"source": "something", "uids": [{"id": "xyz"}]}] }`)}, expected: userInfo{Consent: "", TtdUid: "", StxUid: ""}, }, "Returns STX user id from buyer id": { - input: &openrtb.User{BuyerUID: "myid"}, + input: &openrtb2.User{BuyerUID: "myid"}, expected: userInfo{Consent: "", TtdUid: "", StxUid: "myid"}, }, "Full test": { - input: &openrtb.User{BuyerUID: "myid", Ext: []byte(`{ "consent": "abc", "eids": [{"source": "something", "uids": [{"id": "xyz"}]}, {"source": "adserver.org", "uids": [{"id": "abc123"}]}] }`)}, + input: &openrtb2.User{BuyerUID: "myid", Ext: []byte(`{ "consent": "abc", "eids": [{"source": "something", "uids": [{"id": "xyz"}]}, {"source": "adserver.org", "uids": [{"id": "abc123"}]}] }`)}, expected: userInfo{Consent: "abc", TtdUid: "abc123", StxUid: "myid"}, }, } diff --git a/adapters/silvermob/silvermob.go b/adapters/silvermob/silvermob.go index 2e31e51c0ad..47a762ecc04 100644 --- a/adapters/silvermob/silvermob.go +++ b/adapters/silvermob/silvermob.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -31,7 +31,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func GetHeaders(request *openrtb.BidRequest) *http.Header { +func GetHeaders(request *openrtb2.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -55,7 +55,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { } func (a *SilverMobAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( []*adapters.RequestData, @@ -84,7 +84,7 @@ func (a *SilverMobAdapter) MakeRequests( continue } - requestCopy.Imp = []openrtb.Imp{imp} + requestCopy.Imp = []openrtb2.Imp{imp} reqJSON, err := json.Marshal(requestCopy) if err != nil { errs = append(errs, err) @@ -104,7 +104,7 @@ func (a *SilverMobAdapter) MakeRequests( return requestData, errs } -func (a *SilverMobAdapter) getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtSilverMob, error) { +func (a *SilverMobAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSilverMob, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -126,7 +126,7 @@ func (a *SilverMobAdapter) buildEndpointURL(params *openrtb_ext.ExtSilverMob) (s } func (a *SilverMobAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -149,7 +149,7 @@ func (a *SilverMobAdapter) MakeBids( } responseBody := bidderRawResponse.Body - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Error unmarshaling server Response: %s", err), @@ -176,7 +176,7 @@ func (a *SilverMobAdapter) MakeBids( return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/silvermob/silvermobtest/supplemental/invalid-response.json b/adapters/silvermob/silvermobtest/supplemental/invalid-response.json index d2a1e890df0..4970678bef9 100644 --- a/adapters/silvermob/silvermobtest/supplemental/invalid-response.json +++ b/adapters/silvermob/silvermobtest/supplemental/invalid-response.json @@ -111,7 +111,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "Error unmarshaling server Response: json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "Error unmarshaling server Response: json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 29b4a5848bc..41229574f9e 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -58,7 +58,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *SmaatoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) if len(request.Imp) == 0 { errs = append(errs, &errortypes.BadInput{Message: "no impressions in bid request"}) @@ -84,7 +84,7 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt if request.Site != nil { siteCopy := *request.Site - siteCopy.Publisher = &openrtb.Publisher{ID: publisherID} + siteCopy.Publisher = &openrtb2.Publisher{ID: publisherID} if request.Site.Ext != nil { var siteExt siteExt @@ -101,7 +101,7 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt if request.App != nil { appCopy := *request.App - appCopy.Publisher = &openrtb.Publisher{ID: publisherID} + appCopy.Publisher = &openrtb2.Publisher{ID: publisherID} request.App = &appCopy } @@ -163,7 +163,7 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt } // MakeBids unpacks the server's response into Bids. -func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -178,7 +178,7 @@ func (a *SmaatoAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return nil, []error{fmt.Errorf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -259,7 +259,7 @@ func getAdMarkupType(response *adapters.ResponseData, adMarkup string) (adMarkup return "", fmt.Errorf("Invalid ad markup %s", adMarkup) } -func assignBannerSize(banner *openrtb.Banner) (*openrtb.Banner, error) { +func assignBannerSize(banner *openrtb2.Banner) (*openrtb2.Banner, error) { if banner.W != nil && banner.H != nil { return banner, nil } @@ -267,16 +267,14 @@ func assignBannerSize(banner *openrtb.Banner) (*openrtb.Banner, error) { return banner, fmt.Errorf("No sizes provided for Banner %v", banner.Format) } bannerCopy := *banner - bannerCopy.W = new(uint64) - *bannerCopy.W = banner.Format[0].W - bannerCopy.H = new(uint64) - *bannerCopy.H = banner.Format[0].H + bannerCopy.W = openrtb2.Int64Ptr(banner.Format[0].W) + bannerCopy.H = openrtb2.Int64Ptr(banner.Format[0].H) return &bannerCopy, nil } // parseImpressionObject parse the imp to get it ready to send to smaato -func parseImpressionObject(imp *openrtb.Imp) error { +func parseImpressionObject(imp *openrtb2.Imp) error { adSpaceID, err := jsonparser.GetString(imp.Ext, "bidder", "adspaceId") if err != nil { return err @@ -303,7 +301,7 @@ func parseImpressionObject(imp *openrtb.Imp) error { return fmt.Errorf("invalid MediaType. SMAATO only supports Banner and Video. Ignoring ImpID=%s", imp.ID) } -func extractUserExtAttributes(userExt userExt, userCopy *openrtb.User) { +func extractUserExtAttributes(userExt userExt, userCopy *openrtb2.User) { gender := userExt.Data.Gender if gender != "" { userCopy.Gender = gender diff --git a/adapters/smartadserver/smartadserver.go b/adapters/smartadserver/smartadserver.go index e2735d3bece..1e1eeac4f95 100644 --- a/adapters/smartadserver/smartadserver.go +++ b/adapters/smartadserver/smartadserver.go @@ -8,7 +8,7 @@ import ( "path" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -28,7 +28,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *SmartAdserverAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *SmartAdserverAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ Message: "No impression in the bid request", @@ -43,7 +43,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo // We create or copy the Site object. if smartRequest.Site == nil { - smartRequest.Site = &openrtb.Site{} + smartRequest.Site = &openrtb2.Site{} } else { site := *smartRequest.Site smartRequest.Site = &site @@ -51,7 +51,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo // We create or copy the Publisher object. if smartRequest.Site.Publisher == nil { - smartRequest.Site.Publisher = &openrtb.Publisher{} + smartRequest.Site.Publisher = &openrtb2.Publisher{} } else { publisher := *smartRequest.Site.Publisher smartRequest.Site.Publisher = &publisher @@ -79,7 +79,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo smartRequest.Site.Publisher.ID = strconv.Itoa(smartadserverExt.NetworkID) // We send one request for each impression. - smartRequest.Imp = []openrtb.Imp{imp} + smartRequest.Imp = []openrtb2.Imp{imp} var errMarshal error if imp.Ext, errMarshal = json.Marshal(smartadserverExt); errMarshal != nil { @@ -117,7 +117,7 @@ func (a *SmartAdserverAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo } // MakeBids unpacks the server's response into Bids. -func (a *SmartAdserverAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *SmartAdserverAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -134,7 +134,7 @@ func (a *SmartAdserverAdapter) MakeBids(internalRequest *openrtb.BidRequest, ext }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -169,7 +169,7 @@ func (a *SmartAdserverAdapter) BuildEndpointURL(params *openrtb_ext.ExtImpSmarta return uri.String(), nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { for _, imp := range imps { if imp.ID == impID { if imp.Video != nil { diff --git a/adapters/smartrtb/smartrtb.go b/adapters/smartrtb/smartrtb.go index 4950f1cefb3..548d4f36db5 100644 --- a/adapters/smartrtb/smartrtb.go +++ b/adapters/smartrtb/smartrtb.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -59,7 +59,7 @@ func (adapter *SmartRTBAdapter) buildEndpointURL(pubID string) (string, error) { return macros.ResolveMacros(adapter.EndpointTemplate, endpointParams) } -func parseExtImp(dst *bidRequestExt, imp *openrtb.Imp) error { +func parseExtImp(dst *bidRequestExt, imp *openrtb2.Imp) error { var ext adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &ext); err != nil { return &errortypes.BadInput{ @@ -84,8 +84,8 @@ func parseExtImp(dst *bidRequestExt, imp *openrtb.Imp) error { return nil } -func (s *SmartRTBAdapter) MakeRequests(brq *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var imps []openrtb.Imp +func (s *SmartRTBAdapter) MakeRequests(brq *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var imps []openrtb2.Imp var err error ext := bidRequestExt{} nrImps := len(brq.Imp) @@ -144,7 +144,7 @@ func (s *SmartRTBAdapter) MakeRequests(brq *openrtb.BidRequest, reqInfo *adapter } func (s *SmartRTBAdapter) MakeBids( - brq *openrtb.BidRequest, drq *adapters.RequestData, + brq *openrtb2.BidRequest, drq *adapters.RequestData, rs *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { if rs.StatusCode == http.StatusNoContent { @@ -157,7 +157,7 @@ func (s *SmartRTBAdapter) MakeBids( }} } - var brs openrtb.BidResponse + var brs openrtb2.BidResponse if err := json.Unmarshal(rs.Body, &brs); err != nil { return nil, []error{err} } diff --git a/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json b/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json index c56e7f21515..3d9f92df4a7 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/invalid-bid-json.json @@ -69,7 +69,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/smartyads/smartyads.go b/adapters/smartyads/smartyads.go index ba727b4730c..e02ba4200f3 100644 --- a/adapters/smartyads/smartyads.go +++ b/adapters/smartyads/smartyads.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func GetHeaders(request *openrtb.BidRequest) *http.Header { +func GetHeaders(request *openrtb2.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -64,7 +64,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { } func (a *SmartyAdsAdapter) MakeRequests( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo, ) ( requestsToBidder []*adapters.RequestData, @@ -106,7 +106,7 @@ func (a *SmartyAdsAdapter) MakeRequests( }}, nil } -func (a *SmartyAdsAdapter) getImpressionExt(imp *openrtb.Imp) (*openrtb_ext.ExtSmartyAds, error) { +func (a *SmartyAdsAdapter) getImpressionExt(imp *openrtb2.Imp) (*openrtb_ext.ExtSmartyAds, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -154,7 +154,7 @@ func (a *SmartyAdsAdapter) CheckResponseStatusCodes(response *adapters.ResponseD } func (a *SmartyAdsAdapter) MakeBids( - openRTBRequest *openrtb.BidRequest, + openRTBRequest *openrtb2.BidRequest, requestToBidder *adapters.RequestData, bidderRawResponse *adapters.ResponseData, ) ( @@ -167,7 +167,7 @@ func (a *SmartyAdsAdapter) MakeBids( } responseBody := bidderRawResponse.Body - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Bad Server Response", @@ -192,7 +192,7 @@ func (a *SmartyAdsAdapter) MakeBids( return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/somoaudience/somoaudience.go b/adapters/somoaudience/somoaudience.go index 2bcb0282fe6..d799b5bb5f7 100644 --- a/adapters/somoaudience/somoaudience.go +++ b/adapters/somoaudience/somoaudience.go @@ -6,12 +6,11 @@ import ( "net/http" "strconv" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" - - "github.com/mxmCherry/openrtb" ) const hbconfig = "hb_pbs_1.0.0" @@ -24,12 +23,12 @@ type somoaudienceReqExt struct { BidderConfig string `json:"prebid"` } -func (a *SomoaudienceAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *SomoaudienceAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error - var bannerImps []openrtb.Imp - var videoImps []openrtb.Imp - var nativeImps []openrtb.Imp + var bannerImps []openrtb2.Imp + var videoImps []openrtb2.Imp + var nativeImps []openrtb2.Imp for _, imp := range request.Imp { if imp.Banner != nil { @@ -53,7 +52,7 @@ func (a *SomoaudienceAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo // Somoaudience only supports single imp video request for _, videoImp := range videoImps { - reqCopy.Imp = []openrtb.Imp{videoImp} + reqCopy.Imp = []openrtb2.Imp{videoImp} adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) @@ -63,7 +62,7 @@ func (a *SomoaudienceAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo // Somoaudience only supports single imp video request for _, nativeImp := range nativeImps { - reqCopy.Imp = []openrtb.Imp{nativeImp} + reqCopy.Imp = []openrtb2.Imp{nativeImp} adapterReq, errors := a.makeRequest(&reqCopy) if adapterReq != nil { adapterRequests = append(adapterRequests, adapterReq) @@ -74,10 +73,10 @@ func (a *SomoaudienceAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo } -func (a *SomoaudienceAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *SomoaudienceAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error var err error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp reqExt := somoaudienceReqExt{BidderConfig: hbconfig} var placementHash string @@ -132,7 +131,7 @@ func (a *SomoaudienceAdapter) makeRequest(request *openrtb.BidRequest) (*adapter }, errs } -func preprocess(imp *openrtb.Imp, reqExt *somoaudienceReqExt) (string, error) { +func preprocess(imp *openrtb2.Imp, reqExt *somoaudienceReqExt) (string, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", &errortypes.BadInput{ @@ -153,7 +152,7 @@ func preprocess(imp *openrtb.Imp, reqExt *somoaudienceReqExt) (string, error) { return somoExt.PlacementHash, nil } -func (a *SomoaudienceAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *SomoaudienceAdapter) MakeBids(bidReq *openrtb2.BidRequest, unused *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -171,7 +170,7 @@ func (a *SomoaudienceAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapt }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -190,7 +189,7 @@ func (a *SomoaudienceAdapter) MakeBids(bidReq *openrtb.BidRequest, unused *adapt return bidResponse, nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/sonobi/sonobi.go b/adapters/sonobi/sonobi.go index a13e9c67d9a..c3527a6a73e 100644 --- a/adapters/sonobi/sonobi.go +++ b/adapters/sonobi/sonobi.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -30,7 +30,7 @@ type sonobiParams struct { } // MakeRequests Makes the OpenRTB request payload -func (a *SonobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *SonobiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var sonobiExt openrtb_ext.ExtImpSonobi var err error @@ -42,7 +42,7 @@ func (a *SonobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt for _, imp := range request.Imp { // Make a copy as we don't want to change the original request reqCopy := *request - reqCopy.Imp = append(make([]openrtb.Imp, 0, 1), imp) + reqCopy.Imp = append(make([]openrtb2.Imp, 0, 1), imp) var bidderExt adapters.ExtImpBidder if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil { @@ -69,7 +69,7 @@ func (a *SonobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt } // makeRequest helper method to crete the http request data -func (a *SonobiAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *SonobiAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error @@ -92,7 +92,7 @@ func (a *SonobiAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Requ } // MakeBids makes the bids -func (a *SonobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *SonobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error if response.StatusCode == http.StatusNoContent { @@ -111,7 +111,7 @@ func (a *SonobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -136,7 +136,7 @@ func (a *SonobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe return bidResponse, errs } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impID { diff --git a/adapters/sovrn/sovrn.go b/adapters/sovrn/sovrn.go index 9e904872903..fd2acc1fcbd 100644 --- a/adapters/sovrn/sovrn.go +++ b/adapters/sovrn/sovrn.go @@ -12,7 +12,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -49,7 +49,7 @@ func (s *SovrnAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb return nil, err } - sovrnReq := openrtb.BidRequest{ + sovrnReq := openrtb2.BidRequest{ ID: sReq.ID, Imp: sReq.Imp, Site: sReq.Site, @@ -133,7 +133,7 @@ func (s *SovrnAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb debug.ResponseBody = responseBody } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse err = json.Unmarshal(body, &bidResp) if err != nil { return nil, &errortypes.BadServerResponse{ @@ -173,7 +173,7 @@ func (s *SovrnAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb return bids, nil } -func (s *SovrnAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (s *SovrnAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) for i := 0; i < len(request.Imp); i++ { @@ -228,7 +228,7 @@ func addHeaderIfNonEmpty(headers http.Header, headerName string, headerValue str } } -func (s *SovrnAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (s *SovrnAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -245,7 +245,7 @@ func (s *SovrnAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: err.Error(), @@ -271,7 +271,7 @@ func (s *SovrnAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq return bidResponse, nil } -func preprocess(imp *openrtb.Imp) (string, error) { +func preprocess(imp *openrtb2.Imp) (string, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return "", &errortypes.BadInput{ diff --git a/adapters/sovrn/sovrn_test.go b/adapters/sovrn/sovrn_test.go index aa1b98f00f5..a7bd2a204b9 100644 --- a/adapters/sovrn/sovrn_test.go +++ b/adapters/sovrn/sovrn_test.go @@ -8,7 +8,7 @@ import ( "net/http/httptest" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/pbs" "github.com/prebid/prebid-server/usersync" @@ -38,7 +38,7 @@ func TestJsonSamples(t *testing.T) { // ---------------------------------------------------------------------------- // Code below this line tests the legacy, non-openrtb code flow. It can be deleted after we -// clean up the existing code and make everything openrtb. +// clean up the existing code and make everything openrtb2. var testSovrnUserId = "SovrnUser123" var testUserAgent = "user-agent-test" @@ -144,12 +144,12 @@ func checkHttpRequest(req http.Request, t *testing.T) { func SampleSovrnRequest(numberOfImpressions int, t *testing.T) *pbs.PBSRequest { dnt := int8(0) - device := openrtb.Device{ + device := openrtb2.Device{ Language: "murican", DNT: &dnt, } - user := openrtb.User{ + user := openrtb2.User{ ID: testSovrnUserId, } @@ -165,7 +165,7 @@ func SampleSovrnRequest(numberOfImpressions int, t *testing.T) *pbs.PBSRequest { for i := 0; i < numberOfImpressions; i++ { req.AdUnits[i] = pbs.AdUnit{ Code: fmt.Sprintf("div-adunit-%d", i+1), - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 728, H: 90, @@ -251,7 +251,7 @@ func TestNotFoundResponse(t *testing.T) { func CreateSovrnService(tagsToBid map[string]bool) adapterstest.OrtbMockService { service := adapterstest.OrtbMockService{} - var lastBidRequest openrtb.BidRequest + var lastBidRequest openrtb2.BidRequest var lastHttpReq http.Request server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -262,23 +262,23 @@ func CreateSovrnService(tagsToBid map[string]bool) adapterstest.OrtbMockService http.Error(w, err.Error(), http.StatusInternalServerError) return } - var breq openrtb.BidRequest + var breq openrtb2.BidRequest err = json.Unmarshal(body, &breq) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } lastBidRequest = breq - var bids []openrtb.Bid + var bids []openrtb2.Bid for i, imp := range breq.Imp { if tagsToBid[imp.TagID] { bids = append(bids, adapterstest.SampleBid(imp.Banner.W, imp.Banner.H, imp.ID, i+1)) } } - // serialize the bids to openrtb.BidResponse - js, _ := json.Marshal(openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + // serialize the bids to openrtb2.BidResponse + js, _ := json.Marshal(openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { Bid: bids, }, diff --git a/adapters/synacormedia/synacormedia.go b/adapters/synacormedia/synacormedia.go index 7c9b4fab19f..f6ead542d2e 100644 --- a/adapters/synacormedia/synacormedia.go +++ b/adapters/synacormedia/synacormedia.go @@ -6,7 +6,7 @@ import ( "net/http" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -40,7 +40,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *SynacorMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *SynacorMediaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var bidRequests []*adapters.RequestData @@ -53,9 +53,9 @@ func (a *SynacorMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo return bidRequests, errs } -func (a *SynacorMediaAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *SynacorMediaAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error - var validImps []openrtb.Imp + var validImps []openrtb2.Imp var re *ReqExt var firstExtImp *openrtb_ext.ExtImpSynacormedia = nil @@ -130,7 +130,7 @@ func (adapter *SynacorMediaAdapter) buildEndpointURL(params *openrtb_ext.ExtImpS return macros.ResolveMacros(adapter.EndpointTemplate, macros.EndpointTemplateParams{Host: params.SeatId}) } -func getExtImpObj(imp *openrtb.Imp) (*openrtb_ext.ExtImpSynacormedia, error) { +func getExtImpObj(imp *openrtb2.Imp) (*openrtb_ext.ExtImpSynacormedia, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -149,7 +149,7 @@ func getExtImpObj(imp *openrtb.Imp) (*openrtb_ext.ExtImpSynacormedia, error) { } // MakeBids make the bids for the bid response. -func (a *SynacorMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *SynacorMediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { const errorMessage string = "Unexpected status code: %d. Run with request.debug = 1 for more info" switch { case response.StatusCode == http.StatusNoContent: @@ -164,7 +164,7 @@ func (a *SynacorMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, exte }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -187,7 +187,7 @@ func (a *SynacorMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, exte return bidResponse, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/synacormedia/synacormediatest/supplemental/bad_response.json b/adapters/synacormedia/synacormediatest/supplemental/bad_response.json index 8e8b9a4d944..520f415bcf4 100644 --- a/adapters/synacormedia/synacormediatest/supplemental/bad_response.json +++ b/adapters/synacormedia/synacormediatest/supplemental/bad_response.json @@ -64,7 +64,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse" + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" } ] } diff --git a/adapters/tappx/tappx.go b/adapters/tappx/tappx.go index de8cb49a471..abe2d90b8a6 100644 --- a/adapters/tappx/tappx.go +++ b/adapters/tappx/tappx.go @@ -9,7 +9,7 @@ import ( "text/template" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -37,7 +37,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *TappxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TappxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{&errortypes.BadInput{ Message: "No impression in the bid request", @@ -146,7 +146,7 @@ func (a *TappxAdapter) buildEndpointURL(params *openrtb_ext.ExtImpTappx, test in return thisURI.String(), nil } -func (a *TappxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TappxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -161,7 +161,7 @@ func (a *TappxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -181,7 +181,7 @@ func (a *TappxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReq return bidResponse, []error{} } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { mediaType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index d99d4a98616..cda22e06937 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -6,7 +6,7 @@ import ( "net/http" "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -35,7 +35,7 @@ func (a *TelariaAdapter) FetchEndpoint() string { } // Checker method to ensure len(request.Imp) > 0 -func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { +func (a *TelariaAdapter) CheckHasImps(request *openrtb2.BidRequest) error { if len(request.Imp) == 0 { err := &errortypes.BadInput{ Message: "Telaria: Missing Imp Object", @@ -46,7 +46,7 @@ func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { } // Checking if Imp[i].Video exists and Imp[i].Banner doesn't exist -func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error { +func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb2.BidRequest) error { hasVideoObject := false for _, imp := range request.Imp { @@ -69,7 +69,7 @@ func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error } // Fetches the populated header object -func GetHeaders(request *openrtb.BidRequest) *http.Header { +func GetHeaders(request *openrtb2.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -97,7 +97,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { } // Checks the imp[i].ext object and returns a imp.ext object as per ExtImpTelaria format -func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpTelaria, error) { +func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpTelaria, error) { var bidderExt adapters.ExtImpBidder err := json.Unmarshal(imp.Ext, &bidderExt) @@ -125,7 +125,7 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex // Method to fetch the original publisher ID. Note that this method must be called // before we replace publisher.ID with seatCode -func (a *TelariaAdapter) FetchOriginalPublisherID(request *openrtb.BidRequest) string { +func (a *TelariaAdapter) FetchOriginalPublisherID(request *openrtb2.BidRequest) string { if request.Site != nil && request.Site.Publisher != nil { return request.Site.Publisher.ID @@ -137,8 +137,8 @@ func (a *TelariaAdapter) FetchOriginalPublisherID(request *openrtb.BidRequest) s } // Method to do a deep copy of the publisher object. It also adds the seatCode as publisher.ID -func (a *TelariaAdapter) MakePublisherObject(seatCode string, publisher *openrtb.Publisher) *openrtb.Publisher { - var pub = &openrtb.Publisher{ID: seatCode} +func (a *TelariaAdapter) MakePublisherObject(seatCode string, publisher *openrtb2.Publisher) *openrtb2.Publisher { + var pub = &openrtb2.Publisher{ID: seatCode} if publisher != nil { pub.Domain = publisher.Domain @@ -151,7 +151,7 @@ func (a *TelariaAdapter) MakePublisherObject(seatCode string, publisher *openrtb } // This method changes .publisher.id to the seatCode -func (a *TelariaAdapter) PopulatePublisherId(request *openrtb.BidRequest, seatCode string) (*openrtb.Site, *openrtb.App) { +func (a *TelariaAdapter) PopulatePublisherId(request *openrtb2.BidRequest, seatCode string) (*openrtb2.Site, *openrtb2.App) { if request.Site != nil { siteCopy := *request.Site siteCopy.Publisher = a.MakePublisherObject(seatCode, request.Site.Publisher) @@ -164,7 +164,7 @@ func (a *TelariaAdapter) PopulatePublisherId(request *openrtb.BidRequest, seatCo return nil, nil } -func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TelariaAdapter) MakeRequests(requestIn *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { // make a copy of the incoming request request := *requestIn @@ -263,7 +263,7 @@ func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseDat return nil } -func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TelariaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { httpStatusError := a.CheckResponseStatusCodes(response) if httpStatusError != nil { @@ -272,7 +272,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR responseBody := response.Body - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: "Telaria: Bad Server Response", diff --git a/adapters/triplelift/triplelift.go b/adapters/triplelift/triplelift.go index 0b100094dbb..2e2b525ea50 100644 --- a/adapters/triplelift/triplelift.go +++ b/adapters/triplelift/triplelift.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -32,7 +32,7 @@ func getBidType(ext TripleliftRespExt) openrtb_ext.BidType { return openrtb_ext.BidTypeBanner } -func processImp(imp *openrtb.Imp) error { +func processImp(imp *openrtb2.Imp) error { // get the triplelift extension var ext adapters.ExtImpBidder var tlext openrtb_ext.ExtImpTriplelift @@ -56,13 +56,13 @@ func processImp(imp *openrtb.Imp) error { return nil } -func (a *TripleliftAdapter) MakeRequests(request *openrtb.BidRequest, extra *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TripleliftAdapter) MakeRequests(request *openrtb2.BidRequest, extra *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)+1) reqs := make([]*adapters.RequestData, 0, 1) // copy the request, because we are going to mutate it tlRequest := *request // this will contain all the valid impressions - var validImps []openrtb.Imp + var validImps []openrtb2.Imp // pre-process the imps for _, imp := range tlRequest.Imp { if err := processImp(&imp); err == nil { @@ -94,7 +94,7 @@ func (a *TripleliftAdapter) MakeRequests(request *openrtb.BidRequest, extra *ada return reqs, errs } -func getBidCount(bidResponse openrtb.BidResponse) int { +func getBidCount(bidResponse openrtb2.BidResponse) int { c := 0 for _, sb := range bidResponse.SeatBid { c = c + len(sb.Bid) @@ -102,7 +102,7 @@ func getBidCount(bidResponse openrtb.BidResponse) int { return c } -func (a *TripleliftAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TripleliftAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -116,7 +116,7 @@ func (a *TripleliftAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern if response.StatusCode != http.StatusOK { return nil, []error{fmt.Errorf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/triplelift_native/triplelift_native.go b/adapters/triplelift_native/triplelift_native.go index 9936bf82283..3a4d0588e7a 100644 --- a/adapters/triplelift_native/triplelift_native.go +++ b/adapters/triplelift_native/triplelift_native.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -37,7 +37,7 @@ func getBidType(ext TripleliftRespExt) openrtb_ext.BidType { return openrtb_ext.BidTypeNative } -func processImp(imp *openrtb.Imp) error { +func processImp(imp *openrtb2.Imp) error { // get the triplelift extension var ext adapters.ExtImpBidder var tlext openrtb_ext.ExtImpTriplelift @@ -64,7 +64,7 @@ func processImp(imp *openrtb.Imp) error { } // Returns the effective publisher ID -func effectivePubID(pub *openrtb.Publisher) string { +func effectivePubID(pub *openrtb2.Publisher) string { if pub != nil { if pub.Ext != nil { var pubExt openrtb_ext.ExtPublisher @@ -80,13 +80,13 @@ func effectivePubID(pub *openrtb.Publisher) string { return "unknown" } -func (a *TripleliftNativeAdapter) MakeRequests(request *openrtb.BidRequest, extra *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TripleliftNativeAdapter) MakeRequests(request *openrtb2.BidRequest, extra *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)+1) reqs := make([]*adapters.RequestData, 0, 1) // copy the request, because we are going to mutate it tlRequest := *request // this will contain all the valid impressions - var validImps []openrtb.Imp + var validImps []openrtb2.Imp // pre-process the imps for _, imp := range tlRequest.Imp { if err := processImp(&imp); err == nil { @@ -124,14 +124,14 @@ func (a *TripleliftNativeAdapter) MakeRequests(request *openrtb.BidRequest, extr return reqs, errs } -func getPublisher(request *openrtb.BidRequest) *openrtb.Publisher { +func getPublisher(request *openrtb2.BidRequest) *openrtb2.Publisher { if request.App != nil { return request.App.Publisher } return request.Site.Publisher } -func getBidCount(bidResponse openrtb.BidResponse) int { +func getBidCount(bidResponse openrtb2.BidResponse) int { c := 0 for _, sb := range bidResponse.SeatBid { c = c + len(sb.Bid) @@ -139,7 +139,7 @@ func getBidCount(bidResponse openrtb.BidResponse) int { return c } -func (a *TripleliftNativeAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TripleliftNativeAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -153,7 +153,7 @@ func (a *TripleliftNativeAdapter) MakeBids(internalRequest *openrtb.BidRequest, if response.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadServerResponse{Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode)}} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } diff --git a/adapters/ucfunnel/ucfunnel.go b/adapters/ucfunnel/ucfunnel.go index 8df715e38be..f1d4fa9f175 100644 --- a/adapters/ucfunnel/ucfunnel.go +++ b/adapters/ucfunnel/ucfunnel.go @@ -6,7 +6,7 @@ import ( "net/http" "net/url" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -25,7 +25,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *UcfunnelAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *UcfunnelAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -43,12 +43,12 @@ func (a *UcfunnelAdapter) MakeBids(internalRequest *openrtb.BidRequest, external } var errs []error - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } - var bidReq openrtb.BidRequest + var bidReq openrtb2.BidRequest if err := json.Unmarshal(externalRequest.Body, &bidReq); err != nil { return nil, []error{err} } @@ -69,7 +69,7 @@ func (a *UcfunnelAdapter) MakeBids(internalRequest *openrtb.BidRequest, external return bidResponse, errs } -func (a *UcfunnelAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *UcfunnelAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) // If all the requests were malformed, don't bother making a server call with no impressions. @@ -101,7 +101,7 @@ func (a *UcfunnelAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada }}, errs } -func getPartnerId(request *openrtb.BidRequest) (string, []error) { +func getPartnerId(request *openrtb2.BidRequest) (string, []error) { var ext ExtBidderUcfunnel var errs = []error{} err := json.Unmarshal(request.Imp[0].Ext, &ext) @@ -125,7 +125,7 @@ func checkBidderParameter(ext ExtBidderUcfunnel) []error { return nil } -func getBidType(bidReq openrtb.BidRequest, impid string) openrtb_ext.BidType { +func getBidType(bidReq openrtb2.BidRequest, impid string) openrtb_ext.BidType { for i := range bidReq.Imp { if bidReq.Imp[i].ID == impid { if bidReq.Imp[i].Banner != nil { diff --git a/adapters/ucfunnel/ucfunnel_test.go b/adapters/ucfunnel/ucfunnel_test.go index 216c06dff7f..c735cb567ce 100644 --- a/adapters/ucfunnel/ucfunnel_test.go +++ b/adapters/ucfunnel/ucfunnel_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" @@ -13,32 +13,32 @@ import ( func TestMakeRequests(t *testing.T) { - imp := openrtb.Imp{ + imp := openrtb2.Imp{ ID: "1234", - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, } - imp2 := openrtb.Imp{ + imp2 := openrtb2.Imp{ ID: "1235", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } - imp3 := openrtb.Imp{ + imp3 := openrtb2.Imp{ ID: "1236", - Audio: &openrtb.Audio{}, + Audio: &openrtb2.Audio{}, } - imp4 := openrtb.Imp{ + imp4 := openrtb2.Imp{ ID: "1237", - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, } - imp5 := openrtb.Imp{ + imp5 := openrtb2.Imp{ ID: "1237", - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, } - internalRequest01 := openrtb.BidRequest{Imp: []openrtb.Imp{}} - internalRequest02 := openrtb.BidRequest{Imp: []openrtb.Imp{imp, imp2, imp3, imp4, imp5}} - internalRequest03 := openrtb.BidRequest{Imp: []openrtb.Imp{imp, imp2, imp3, imp4, imp5}} + internalRequest01 := openrtb2.BidRequest{Imp: []openrtb2.Imp{}} + internalRequest02 := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp, imp2, imp3, imp4, imp5}} + internalRequest03 := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp, imp2, imp3, imp4, imp5}} internalRequest03.Imp[0].Ext = []byte(`{"bidder": {"adunitid": "ad-488663D474E44841E8A293379892348","partnerid": "par-7E6D2DB9A8922AB07B44A444D2BA67"}}`) internalRequest03.Imp[1].Ext = []byte(`{"bidder": {"adunitid": "ad-488663D474E44841E8A293379892348","partnerid": "par-7E6D2DB9A8922AB07B44A444D2BA67"}}`) @@ -54,12 +54,12 @@ func TestMakeRequests(t *testing.T) { } var testCases = []struct { - in []openrtb.BidRequest + in []openrtb2.BidRequest out1 [](int) out2 [](bool) }{ { - in: []openrtb.BidRequest{internalRequest01, internalRequest02, internalRequest03}, + in: []openrtb2.BidRequest{internalRequest01, internalRequest02, internalRequest03}, out1: [](int){1, 1, 0}, out2: [](bool){false, false, true}, }, @@ -76,31 +76,31 @@ func TestMakeRequests(t *testing.T) { } func TestMakeBids(t *testing.T) { - imp := openrtb.Imp{ + imp := openrtb2.Imp{ ID: "1234", - Banner: &openrtb.Banner{}, + Banner: &openrtb2.Banner{}, } - imp2 := openrtb.Imp{ + imp2 := openrtb2.Imp{ ID: "1235", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } - imp3 := openrtb.Imp{ + imp3 := openrtb2.Imp{ ID: "1236", - Audio: &openrtb.Audio{}, + Audio: &openrtb2.Audio{}, } - imp4 := openrtb.Imp{ + imp4 := openrtb2.Imp{ ID: "1237", - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, } - imp5 := openrtb.Imp{ + imp5 := openrtb2.Imp{ ID: "1237", - Native: &openrtb.Native{}, + Native: &openrtb2.Native{}, } - internalRequest03 := openrtb.BidRequest{Imp: []openrtb.Imp{imp, imp2, imp3, imp4, imp5}} - internalRequest04 := openrtb.BidRequest{Imp: []openrtb.Imp{imp}} + internalRequest03 := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp, imp2, imp3, imp4, imp5}} + internalRequest04 := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp}} internalRequest03.Imp[0].Ext = []byte(`{"bidder": {"adunitid": "ad-488663D474E44841E8A293379892348","partnerid": "par-7E6D2DB9A8922AB07B44A444D2BA67"}}`) internalRequest03.Imp[1].Ext = []byte(`{"bidder": {"adunitid": "ad-488663D474E44841E8A293379892348","partnerid": "par-7E6D2DB9A8922AB07B44A444D2BA67"}}`) @@ -126,14 +126,14 @@ func TestMakeBids(t *testing.T) { } var testCases = []struct { - in1 []openrtb.BidRequest + in1 []openrtb2.BidRequest in2 []adapters.RequestData in3 []adapters.ResponseData out1 [](bool) out2 [](bool) }{ { - in1: []openrtb.BidRequest{internalRequest03, internalRequest03, internalRequest03, internalRequest03, internalRequest03, internalRequest04}, + in1: []openrtb2.BidRequest{internalRequest03, internalRequest03, internalRequest03, internalRequest03, internalRequest03, internalRequest04}, in2: []adapters.RequestData{RequestData01, RequestData01, RequestData01, RequestData01, RequestData01, RequestData02}, in3: []adapters.ResponseData{mockResponse200, mockResponse203, mockResponse204, mockResponse400, mockResponseError, mockResponse200}, out1: [](bool){true, false, false, false, false, false}, diff --git a/adapters/unicorn/unicorn.go b/adapters/unicorn/unicorn.go index 52441e1a882..b9741c8c9e3 100644 --- a/adapters/unicorn/unicorn.go +++ b/adapters/unicorn/unicorn.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -42,7 +42,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var extRegs openrtb_ext.ExtRegs if request.Regs != nil { if request.Regs.COPPA == 1 { @@ -69,11 +69,11 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapter return nil, []error{err} } - var modifiableSource openrtb.Source + var modifiableSource openrtb2.Source if request.Source != nil { modifiableSource = *request.Source } else { - modifiableSource = openrtb.Source{} + modifiableSource = openrtb2.Source{} } modifiableSource.Ext = setSourceExt() request.Source = &modifiableSource @@ -98,7 +98,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, requestInfo *adapter return []*adapters.RequestData{requestData}, nil } -func getHeaders(request *openrtb.BidRequest) http.Header { +func getHeaders(request *openrtb2.BidRequest) http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") @@ -121,7 +121,7 @@ func getHeaders(request *openrtb.BidRequest) http.Header { return headers } -func modifyImps(request *openrtb.BidRequest) error { +func modifyImps(request *openrtb2.BidRequest) error { for i := 0; i < len(request.Imp); i++ { imp := &request.Imp[i] @@ -157,7 +157,7 @@ func modifyImps(request *openrtb.BidRequest) error { return nil } -func getStoredRequestImpID(imp *openrtb.Imp) (string, error) { +func getStoredRequestImpID(imp *openrtb2.Imp) (string, error) { v, err := jsonparser.GetString(imp.Ext, "prebid", "storedrequest", "id") if err != nil { @@ -171,7 +171,7 @@ func setSourceExt() json.RawMessage { return json.RawMessage(`{"stype": "prebid_server_uncn", "bidder": "unicorn"}`) } -func setExt(request *openrtb.BidRequest) (json.RawMessage, error) { +func setExt(request *openrtb2.BidRequest) (json.RawMessage, error) { accountID, err := jsonparser.GetInt(request.Imp[0].Ext, "bidder", "accountId") if err != nil { accountID = 0 @@ -195,7 +195,7 @@ func setExt(request *openrtb.BidRequest) (json.RawMessage, error) { } // MakeBids unpacks the server's response into Bids. -func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { return nil, nil @@ -215,7 +215,7 @@ func (a *adapter) MakeBids(request *openrtb.BidRequest, requestData *adapters.Re return nil, []error{err} } - var response openrtb.BidResponse + var response openrtb2.BidResponse if err := json.Unmarshal(responseData.Body, &response); err != nil { return nil, []error{err} } diff --git a/adapters/unruly/unruly.go b/adapters/unruly/unruly.go index ae0243aaf4e..871af6df46d 100644 --- a/adapters/unruly/unruly.go +++ b/adapters/unruly/unruly.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -24,13 +24,13 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (a *UnrulyAdapter) ReplaceImp(imp openrtb.Imp, request *openrtb.BidRequest) *openrtb.BidRequest { +func (a *UnrulyAdapter) ReplaceImp(imp openrtb2.Imp, request *openrtb2.BidRequest) *openrtb2.BidRequest { reqCopy := *request - reqCopy.Imp = append(make([]openrtb.Imp, 0, 1), imp) + reqCopy.Imp = append(make([]openrtb2.Imp, 0, 1), imp) return &reqCopy } -func (a *UnrulyAdapter) BuildRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *UnrulyAdapter) BuildRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { reqJSON, err := json.Marshal(request) if err != nil { return nil, []error{err} @@ -52,7 +52,7 @@ func AddHeadersToRequest() http.Header { return headers } -func (a *UnrulyAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *UnrulyAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData for _, imp := range request.Imp { @@ -71,7 +71,7 @@ func (a *UnrulyAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt return adapterRequests, errs } -func getMediaTypeForImpWithId(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImpWithId(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { for _, imp := range imps { if imp.ID == impID { return openrtb_ext.BidTypeVideo, nil @@ -91,9 +91,9 @@ func CheckResponse(response *adapters.ResponseData) error { return nil } -func convertToAdapterBidResponse(response *adapters.ResponseData, internalRequest *openrtb.BidRequest) (*adapters.BidderResponse, []error) { +func convertToAdapterBidResponse(response *adapters.ResponseData, internalRequest *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { var errs []error - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -115,7 +115,7 @@ func convertToAdapterBidResponse(response *adapters.ResponseData, internalReques return bidResponse, errs } -func convertBidderNameInExt(imp *openrtb.Imp) (*openrtb.Imp, error) { +func convertBidderNameInExt(imp *openrtb2.Imp) (*openrtb2.Imp, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, err @@ -136,7 +136,7 @@ func convertBidderNameInExt(imp *openrtb.Imp) (*openrtb.Imp, error) { return imp, nil } -func (a *UnrulyAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *UnrulyAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if err := CheckResponse(response); err != nil { return nil, []error{err} } diff --git a/adapters/unruly/unruly_test.go b/adapters/unruly/unruly_test.go index 18a21b7dfd6..b7c9a28eb47 100644 --- a/adapters/unruly/unruly_test.go +++ b/adapters/unruly/unruly_test.go @@ -7,7 +7,7 @@ import ( "reflect" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/adapterstest" "github.com/prebid/prebid-server/config" @@ -41,7 +41,7 @@ func TestReturnsNewUnrulyBidderWithParams(t *testing.T) { } func TestBuildRequest(t *testing.T) { - request := openrtb.BidRequest{} + request := openrtb2.BidRequest{} expectedJson, _ := json.Marshal(request) mockHeaders := http.Header{} mockHeaders.Add("Content-Type", "application/json;charset=utf-8") @@ -65,19 +65,19 @@ func TestBuildRequest(t *testing.T) { } func TestReplaceImp(t *testing.T) { - imp1 := openrtb.Imp{ID: "imp1"} - imp2 := openrtb.Imp{ID: "imp2"} - imp3 := openrtb.Imp{ID: "imp3"} - newImp := openrtb.Imp{ID: "imp4"} - request := openrtb.BidRequest{Imp: []openrtb.Imp{imp1, imp2, imp3}} + imp1 := openrtb2.Imp{ID: "imp1"} + imp2 := openrtb2.Imp{ID: "imp2"} + imp3 := openrtb2.Imp{ID: "imp3"} + newImp := openrtb2.Imp{ID: "imp4"} + request := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp1, imp2, imp3}} adapter := UnrulyAdapter{URI: "http://mockEndpoint.com"} newRequest := adapter.ReplaceImp(newImp, &request) if len(newRequest.Imp) != 1 { t.Errorf("Size of Imp Array should be 1") } - if !reflect.DeepEqual(request, openrtb.BidRequest{Imp: []openrtb.Imp{imp1, imp2, imp3}}) { - t.Errorf("actual = %v expected = %v", request, openrtb.BidRequest{Imp: []openrtb.Imp{imp1, imp2, imp3}}) + if !reflect.DeepEqual(request, openrtb2.BidRequest{Imp: []openrtb2.Imp{imp1, imp2, imp3}}) { + t.Errorf("actual = %v expected = %v", request, openrtb2.BidRequest{Imp: []openrtb2.Imp{imp1, imp2, imp3}}) } if !reflect.DeepEqual(newImp, newRequest.Imp[0]) { t.Errorf("actual = %v expected = %v", newRequest.Imp[0], newImp) @@ -85,7 +85,7 @@ func TestReplaceImp(t *testing.T) { } func TestConvertBidderNameInExt(t *testing.T) { - imp := openrtb.Imp{Ext: json.RawMessage(`{"bidder": {"uuid": "1234", "siteid": "aSiteID"}}`)} + imp := openrtb2.Imp{Ext: json.RawMessage(`{"bidder": {"uuid": "1234", "siteid": "aSiteID"}}`)} actualImp, err := convertBidderNameInExt(&imp) @@ -112,17 +112,17 @@ func TestConvertBidderNameInExt(t *testing.T) { func TestMakeRequests(t *testing.T) { adapter := UnrulyAdapter{URI: "http://mockEndpoint.com"} - imp1 := openrtb.Imp{ID: "imp1", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid1", "siteid": "siteID1"}}`)} - imp2 := openrtb.Imp{ID: "imp2", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid2", "siteid": "siteID2"}}`)} - imp3 := openrtb.Imp{ID: "imp3", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid3", "siteid": "siteID3"}}`)} + imp1 := openrtb2.Imp{ID: "imp1", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid1", "siteid": "siteID1"}}`)} + imp2 := openrtb2.Imp{ID: "imp2", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid2", "siteid": "siteID2"}}`)} + imp3 := openrtb2.Imp{ID: "imp3", Ext: json.RawMessage(`{"bidder": {"uuid": "uuid3", "siteid": "siteID3"}}`)} - expectImp1 := openrtb.Imp{ID: "imp1", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid1", "siteid": "siteID1"}}`)} - expectImp2 := openrtb.Imp{ID: "imp2", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid2", "siteid": "siteID2"}}`)} - expectImp3 := openrtb.Imp{ID: "imp3", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid3", "siteid": "siteID3"}}`)} + expectImp1 := openrtb2.Imp{ID: "imp1", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid1", "siteid": "siteID1"}}`)} + expectImp2 := openrtb2.Imp{ID: "imp2", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid2", "siteid": "siteID2"}}`)} + expectImp3 := openrtb2.Imp{ID: "imp3", Ext: json.RawMessage(`{"unruly": {"uuid": "uuid3", "siteid": "siteID3"}}`)} - expectImps := []openrtb.Imp{expectImp1, expectImp2, expectImp3} + expectImps := []openrtb2.Imp{expectImp1, expectImp2, expectImp3} - inputRequest := openrtb.BidRequest{Imp: []openrtb.Imp{imp1, imp2, imp3}} + inputRequest := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp1, imp2, imp3}} actualAdapterRequests, _ := adapter.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{}) mockHeaders := http.Header{} mockHeaders.Add("Content-Type", "application/json;charset=utf-8") @@ -132,7 +132,7 @@ func TestMakeRequests(t *testing.T) { t.Errorf("should have 3 imps") } for n, imp := range expectImps { - request := openrtb.BidRequest{Imp: []openrtb.Imp{imp}} + request := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp}} expectedJson, _ := json.Marshal(request) data := adapters.RequestData{ Method: "POST", @@ -149,11 +149,11 @@ func TestMakeRequests(t *testing.T) { func TestGetMediaTypeForImpIsVideo(t *testing.T) { testID := string("4321") testBidMediaType := openrtb_ext.BidTypeVideo - imp := openrtb.Imp{ + imp := openrtb2.Imp{ ID: testID, - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } - imps := []openrtb.Imp{imp} + imps := []openrtb2.Imp{imp} actual, _ := getMediaTypeForImpWithId(testID, imps) if actual != "video" { @@ -162,11 +162,11 @@ func TestGetMediaTypeForImpIsVideo(t *testing.T) { } func TestGetMediaTypeForImpWithNoIDPresent(t *testing.T) { - imp := openrtb.Imp{ + imp := openrtb2.Imp{ ID: "4321", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } - imps := []openrtb.Imp{imp} + imps := []openrtb2.Imp{imp} _, err := getMediaTypeForImpWithId("1234", imps) expected := &errortypes.BadInput{ Message: fmt.Sprintf("Failed to find impression \"%s\" ", "1234"), @@ -177,26 +177,26 @@ func TestGetMediaTypeForImpWithNoIDPresent(t *testing.T) { } func TestConvertToAdapterBidResponseHasCorrectNumberOfBids(t *testing.T) { - imp := openrtb.Imp{ + imp := openrtb2.Imp{ ID: "1234", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } - imp2 := openrtb.Imp{ + imp2 := openrtb2.Imp{ ID: "1235", - Video: &openrtb.Video{}, + Video: &openrtb2.Video{}, } mockResponse := adapters.ResponseData{StatusCode: 200, Body: json.RawMessage(`{"seatbid":[{"bid":[{"impid":"1234"}]},{"bid":[{"impid":"1235"}]}]}`)} - internalRequest := openrtb.BidRequest{Imp: []openrtb.Imp{imp, imp2}} + internalRequest := openrtb2.BidRequest{Imp: []openrtb2.Imp{imp, imp2}} mockBidResponse := adapters.NewBidderResponseWithBidsCapacity(5) typedBid := &adapters.TypedBid{ - Bid: &openrtb.Bid{ImpID: "1234"}, + Bid: &openrtb2.Bid{ImpID: "1234"}, BidType: "Video", } typedBid2 := &adapters.TypedBid{ - Bid: &openrtb.Bid{ImpID: "1235"}, + Bid: &openrtb2.Bid{ImpID: "1235"}, BidType: "Video", } diff --git a/adapters/valueimpression/valueimpression.go b/adapters/valueimpression/valueimpression.go index 5cbcf3e19b5..1397f6e020d 100644 --- a/adapters/valueimpression/valueimpression.go +++ b/adapters/valueimpression/valueimpression.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type ValueImpressionAdapter struct { endpoint string } -func (a *ValueImpressionAdapter) MakeRequests(request *openrtb.BidRequest, unused *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ValueImpressionAdapter) MakeRequests(request *openrtb2.BidRequest, unused *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -36,7 +36,7 @@ func (a *ValueImpressionAdapter) MakeRequests(request *openrtb.BidRequest, unuse return adapterRequests, errs } -func (a *ValueImpressionAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, error) { +func (a *ValueImpressionAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) { var err error jsonBody, err := json.Marshal(request) @@ -55,7 +55,7 @@ func (a *ValueImpressionAdapter) makeRequest(request *openrtb.BidRequest) (*adap }, nil } -func preprocess(request *openrtb.BidRequest) error { +func preprocess(request *openrtb2.BidRequest) error { if len(request.Imp) == 0 { return &errortypes.BadInput{ Message: "No Imps in Bid Request", @@ -85,7 +85,7 @@ func preprocess(request *openrtb.BidRequest) error { } // MakeBids based on valueimpression server response -func (a *ValueImpressionAdapter) MakeBids(bidRequest *openrtb.BidRequest, unused *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *ValueImpressionAdapter) MakeBids(bidRequest *openrtb2.BidRequest, unused *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { if responseData.StatusCode == http.StatusNoContent { return nil, nil } @@ -102,7 +102,7 @@ func (a *ValueImpressionAdapter) MakeBids(bidRequest *openrtb.BidRequest, unused }} } - var bidResponse openrtb.BidResponse + var bidResponse openrtb2.BidResponse if err := json.Unmarshal(responseData.Body, &bidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ diff --git a/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-unmarshall-error.json b/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-unmarshall-error.json index c854548b78b..2de5213d686 100644 --- a/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-unmarshall-error.json +++ b/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-unmarshall-error.json @@ -59,7 +59,7 @@ ], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type uint64", + "value": "json: cannot unmarshal string into Go struct field Bid(\\.seatbid\\.bid)?\\.w of type int64", "comparison": "regex" } ] diff --git a/adapters/verizonmedia/verizonmedia.go b/adapters/verizonmedia/verizonmedia.go index a721b67cf05..edbb05a3a62 100644 --- a/adapters/verizonmedia/verizonmedia.go +++ b/adapters/verizonmedia/verizonmedia.go @@ -6,7 +6,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,7 +17,7 @@ type VerizonMediaAdapter struct { URI string } -func (a *VerizonMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *VerizonMediaAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errors := make([]error, 0, 1) if len(request.Imp) == 0 { @@ -79,7 +79,7 @@ func (a *VerizonMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo // Split up multi-impression requests into multiple requests so that // each split request is only associated to a single impression reqCopy := *request - reqCopy.Imp = []openrtb.Imp{imp} + reqCopy.Imp = []openrtb2.Imp{imp} if request.Site != nil { siteCopy := *request.Site @@ -111,7 +111,7 @@ func (a *VerizonMediaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo return reqs, errors } -func (a *VerizonMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *VerizonMediaAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -123,7 +123,7 @@ func (a *VerizonMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, exte }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Bad server response: %d.", err), @@ -156,7 +156,7 @@ func (a *VerizonMediaAdapter) MakeBids(internalRequest *openrtb.BidRequest, exte return bidResponse, nil } -func getImpInfo(impId string, imps []openrtb.Imp) (bool, openrtb_ext.BidType) { +func getImpInfo(impId string, imps []openrtb2.Imp) (bool, openrtb_ext.BidType) { var mediaType openrtb_ext.BidType var exists bool for _, imp := range imps { @@ -171,7 +171,7 @@ func getImpInfo(impId string, imps []openrtb.Imp) (bool, openrtb_ext.BidType) { return exists, mediaType } -func changeRequestForBidService(request *openrtb.BidRequest, extension *openrtb_ext.ExtImpVerizonMedia) error { +func changeRequestForBidService(request *openrtb2.BidRequest, extension *openrtb_ext.ExtImpVerizonMedia) error { /* Always override the tag ID and (site ID or app ID) of the request */ request.Imp[0].TagID = extension.Pos if request.Site != nil { @@ -198,10 +198,8 @@ func changeRequestForBidService(request *openrtb.BidRequest, extension *openrtb_ return errors.New(fmt.Sprintf("No sizes provided for Banner %v", banner.Format)) } - banner.W = new(uint64) - *banner.W = banner.Format[0].W - banner.H = new(uint64) - *banner.H = banner.Format[0].H + banner.W = openrtb2.Int64Ptr(banner.Format[0].W) + banner.H = openrtb2.Int64Ptr(banner.Format[0].H) return nil } diff --git a/adapters/visx/visx.go b/adapters/visx/visx.go index f5a21f2269e..1f1fae0a484 100644 --- a/adapters/visx/visx.go +++ b/adapters/visx/visx.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -38,7 +38,7 @@ type visxResponse struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *VisxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *VisxAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors = make([]error, 0) // copy the request, because we are going to mutate it @@ -65,7 +65,7 @@ func (a *VisxAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapter } // MakeBids unpacks the server's response into Bids. -func (a *VisxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *VisxAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -91,14 +91,14 @@ func (a *VisxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequ for _, sb := range bidResp.SeatBid { for i := range sb.Bid { - bid := openrtb.Bid{} + bid := openrtb2.Bid{} bid.ID = internalRequest.ID bid.CrID = sb.Bid[i].CrID bid.ImpID = sb.Bid[i].ImpID bid.Price = sb.Bid[i].Price bid.AdM = sb.Bid[i].AdM - bid.W = sb.Bid[i].W - bid.H = sb.Bid[i].H + bid.W = int64(sb.Bid[i].W) + bid.H = int64(sb.Bid[i].H) bid.ADomain = sb.Bid[i].ADomain bid.DealID = sb.Bid[i].DealID diff --git a/adapters/vrtcal/vrtcal.go b/adapters/vrtcal/vrtcal.go index dadb03238ae..ff5bc2dc733 100644 --- a/adapters/vrtcal/vrtcal.go +++ b/adapters/vrtcal/vrtcal.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -16,7 +16,7 @@ type VrtcalAdapter struct { endpoint string } -func (a *VrtcalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *VrtcalAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -42,7 +42,7 @@ func (a *VrtcalAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt } // MakeBids make the bids for the bid response. -func (a *VrtcalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *VrtcalAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -60,7 +60,7 @@ func (a *VrtcalAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRe }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} diff --git a/adapters/yeahmobi/yeahmobi.go b/adapters/yeahmobi/yeahmobi.go index d603397b09f..74208ca4c30 100644 --- a/adapters/yeahmobi/yeahmobi.go +++ b/adapters/yeahmobi/yeahmobi.go @@ -8,7 +8,7 @@ import ( "text/template" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -33,7 +33,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func (adapter *YeahmobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (adapter *YeahmobiAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var adapterRequests []*adapters.RequestData adapterRequest, errs := adapter.makeRequest(request) @@ -44,7 +44,7 @@ func (adapter *YeahmobiAdapter) MakeRequests(request *openrtb.BidRequest, reqInf return adapterRequests, errs } -func (adapter *YeahmobiAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (adapter *YeahmobiAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error yeahmobiExt, errs := getYeahmobiExt(request) @@ -75,7 +75,7 @@ func (adapter *YeahmobiAdapter) makeRequest(request *openrtb.BidRequest) (*adapt }, errs } -func transform(request *openrtb.BidRequest) { +func transform(request *openrtb2.BidRequest) { for i, imp := range request.Imp { if imp.Native != nil { var nativeRequest map[string]interface{} @@ -103,7 +103,7 @@ func transform(request *openrtb.BidRequest) { } } -func getYeahmobiExt(request *openrtb.BidRequest) (*openrtb_ext.ExtImpYeahmobi, []error) { +func getYeahmobiExt(request *openrtb2.BidRequest) (*openrtb_ext.ExtImpYeahmobi, []error) { var extImpYeahmobi openrtb_ext.ExtImpYeahmobi var errs []error @@ -131,7 +131,7 @@ func (adapter *YeahmobiAdapter) getEndpoint(ext *openrtb_ext.ExtImpYeahmobi) (st } // MakeBids make the bids for the bid response. -func (a *YeahmobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *YeahmobiAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -148,7 +148,7 @@ func (a *YeahmobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, external }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -169,7 +169,7 @@ func (a *YeahmobiAdapter) MakeBids(internalRequest *openrtb.BidRequest, external } -func getBidType(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getBidType(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { bidType := openrtb_ext.BidTypeBanner for _, imp := range imps { if imp.ID == impId { diff --git a/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json b/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json index 22939466309..0d77e5af93a 100644 --- a/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json +++ b/adapters/yeahmobi/yeahmobitest/supplemental/bad_response.json @@ -49,7 +49,7 @@ "expectedMakeBidsErrors": [ { "comparison": "literal", - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse" + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse" } ] } diff --git a/adapters/yieldlab/yieldlab.go b/adapters/yieldlab/yieldlab.go index 086ce059898..447f8aa55fd 100644 --- a/adapters/yieldlab/yieldlab.go +++ b/adapters/yieldlab/yieldlab.go @@ -9,9 +9,9 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" "golang.org/x/text/currency" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -36,7 +36,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } // Builds endpoint url based on adapter-specific pub settings from imp.ext -func (a *YieldlabAdapter) makeEndpointURL(req *openrtb.BidRequest, params *openrtb_ext.ExtImpYieldlab) (string, error) { +func (a *YieldlabAdapter) makeEndpointURL(req *openrtb2.BidRequest, params *openrtb_ext.ExtImpYieldlab) (string, error) { uri, err := url.Parse(a.endpoint) if err != nil { return "", fmt.Errorf("failed to parse yieldlab endpoint: %v", err) @@ -86,7 +86,7 @@ func (a *YieldlabAdapter) makeEndpointURL(req *openrtb.BidRequest, params *openr return uri.String(), nil } -func (a *YieldlabAdapter) getGDPR(request *openrtb.BidRequest) (string, string, error) { +func (a *YieldlabAdapter) getGDPR(request *openrtb2.BidRequest) (string, string, error) { gdpr := "" var extRegs openrtb_ext.ExtRegs if request.Regs != nil { @@ -118,7 +118,7 @@ func (a *YieldlabAdapter) makeTargetingValues(params *openrtb_ext.ExtImpYieldlab return values.Encode() } -func (a *YieldlabAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *YieldlabAdapter) MakeRequests(request *openrtb2.BidRequest, _ *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { if len(request.Imp) == 0 { return nil, []error{fmt.Errorf("invalid request %+v, no Impressions given", request)} } @@ -149,7 +149,7 @@ func (a *YieldlabAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters. } // parseRequest extracts the Yieldlab request information from the request -func (a *YieldlabAdapter) parseRequest(request *openrtb.BidRequest) []*openrtb_ext.ExtImpYieldlab { +func (a *YieldlabAdapter) parseRequest(request *openrtb2.BidRequest) []*openrtb_ext.ExtImpYieldlab { params := make([]*openrtb_ext.ExtImpYieldlab, 0) for i := 0; i < len(request.Imp); i++ { @@ -187,7 +187,7 @@ func (a *YieldlabAdapter) mergeParams(params []*openrtb_ext.ExtImpYieldlab) *ope } // MakeBids make the bids for the bid response. -func (a *YieldlabAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *YieldlabAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode != 200 { return nil, []error{ &errortypes.BadServerResponse{ @@ -226,14 +226,14 @@ func (a *YieldlabAdapter) MakeBids(internalRequest *openrtb.BidRequest, external } var bidType openrtb_ext.BidType - responseBid := &openrtb.Bid{ + responseBid := &openrtb2.Bid{ ID: strconv.FormatUint(bid.ID, 10), Price: float64(bid.Price) / 100, ImpID: internalRequest.Imp[i].ID, CrID: a.makeCreativeID(req, bid), DealID: strconv.FormatUint(bid.Pid, 10), - W: width, - H: height, + W: int64(width), + H: int64(height), } if internalRequest.Imp[i].Video != nil { @@ -268,11 +268,11 @@ func (a *YieldlabAdapter) findBidReq(adslotID uint64, params []*openrtb_ext.ExtI return nil } -func (a *YieldlabAdapter) makeBannerAdSource(req *openrtb.BidRequest, ext *openrtb_ext.ExtImpYieldlab, res *bidResponse) string { +func (a *YieldlabAdapter) makeBannerAdSource(req *openrtb2.BidRequest, ext *openrtb_ext.ExtImpYieldlab, res *bidResponse) string { return fmt.Sprintf(adSourceBanner, a.makeAdSourceURL(req, ext, res)) } -func (a *YieldlabAdapter) makeAdSourceURL(req *openrtb.BidRequest, ext *openrtb_ext.ExtImpYieldlab, res *bidResponse) string { +func (a *YieldlabAdapter) makeAdSourceURL(req *openrtb2.BidRequest, ext *openrtb_ext.ExtImpYieldlab, res *bidResponse) string { val := url.Values{} val.Set("ts", a.cacheBuster()) val.Set("id", ext.ExtId) diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 2d84444441e..6c9524a8823 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -20,7 +20,7 @@ type Ext struct { PlacementId string `json:"placement_id"` } -func (a *YieldmoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *YieldmoAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errs []error var adapterRequests []*adapters.RequestData @@ -33,7 +33,7 @@ func (a *YieldmoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return adapterRequests, errors } -func (a *YieldmoAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *YieldmoAdapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, []error) { var errs []error if err := preprocess(request); err != nil { @@ -59,7 +59,7 @@ func (a *YieldmoAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Req } // Mutate the request to get it ready to send to yieldmo. -func preprocess(request *openrtb.BidRequest) error { +func preprocess(request *openrtb2.BidRequest) error { for i := 0; i < len(request.Imp); i++ { var imp = request.Imp[i] var bidderExt adapters.ExtImpBidder @@ -95,7 +95,7 @@ func preprocess(request *openrtb.BidRequest) error { } // MakeBids make the bids for the bid response. -func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -112,7 +112,7 @@ func (a *YieldmoAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -140,7 +140,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func getMediaTypeForImp(impId string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaTypeForImp(impId string, imps []openrtb2.Imp) openrtb_ext.BidType { //default to video unless banner exists in impression for _, imp := range imps { if imp.ID == impId && imp.Banner != nil { diff --git a/adapters/yieldone/yieldone.go b/adapters/yieldone/yieldone.go index 5d7edd63018..813746e1d99 100644 --- a/adapters/yieldone/yieldone.go +++ b/adapters/yieldone/yieldone.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -17,10 +17,10 @@ type YieldoneAdapter struct { } // MakeRequests makes the HTTP requests which should be made to fetch bids. -func (a *YieldoneAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *YieldoneAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var errors = make([]error, 0) - var validImps []openrtb.Imp + var validImps []openrtb2.Imp for i := 0; i < len(request.Imp); i++ { if err := preprocess(&request.Imp[i]); err == nil { validImps = append(validImps, request.Imp[i]) @@ -49,7 +49,7 @@ func (a *YieldoneAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada } // MakeBids unpacks the server's response into Bids. -func (a *YieldoneAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *YieldoneAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -66,7 +66,7 @@ func (a *YieldoneAdapter) MakeBids(internalRequest *openrtb.BidRequest, external }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } @@ -98,7 +98,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters return bidder, nil } -func preprocess(imp *openrtb.Imp) error { +func preprocess(imp *openrtb2.Imp) error { var ext adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &ext); err != nil { @@ -122,7 +122,7 @@ func preprocess(imp *openrtb.Imp) error { return nil } -func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, error) { +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { for _, imp := range imps { if imp.ID == impID { if imp.Banner != nil { diff --git a/adapters/yieldone/yieldonetest/supplemental/bad_response.json b/adapters/yieldone/yieldonetest/supplemental/bad_response.json index fa993a2fff5..3112d1f7ba0 100644 --- a/adapters/yieldone/yieldonetest/supplemental/bad_response.json +++ b/adapters/yieldone/yieldonetest/supplemental/bad_response.json @@ -58,7 +58,7 @@ "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/adapters/zeroclickfraud/zeroclickfraud.go b/adapters/zeroclickfraud/zeroclickfraud.go index 17fbba747df..ab1938fa518 100644 --- a/adapters/zeroclickfraud/zeroclickfraud.go +++ b/adapters/zeroclickfraud/zeroclickfraud.go @@ -7,7 +7,7 @@ import ( "strconv" "text/template" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -19,7 +19,7 @@ type ZeroClickFraudAdapter struct { EndpointTemplate template.Template } -func (a *ZeroClickFraudAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *ZeroClickFraudAdapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { errs := make([]error, 0, len(request.Imp)) headers := http.Header{ @@ -69,7 +69,7 @@ func (a *ZeroClickFraudAdapter) MakeRequests(request *openrtb.BidRequest, reqInf internal original request in OpenRTB, external = result of us having converted it (what comes out of MakeRequests) */ func (a *ZeroClickFraudAdapter) MakeBids( - internalRequest *openrtb.BidRequest, + internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData, ) (*adapters.BidderResponse, []error) { @@ -88,7 +88,7 @@ func (a *ZeroClickFraudAdapter) MakeBids( }} } - var bidResp openrtb.BidResponse + var bidResp openrtb2.BidResponse if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} @@ -110,9 +110,9 @@ func (a *ZeroClickFraudAdapter) MakeBids( return bidResponse, nil } -func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpZeroClickFraud][]openrtb.Imp, error) { +func splitImpressions(imps []openrtb2.Imp) (map[openrtb_ext.ExtImpZeroClickFraud][]openrtb2.Imp, error) { - var m = make(map[openrtb_ext.ExtImpZeroClickFraud][]openrtb.Imp) + var m = make(map[openrtb_ext.ExtImpZeroClickFraud][]openrtb2.Imp) for _, imp := range imps { bidderParams, err := getBidderParams(&imp) @@ -126,7 +126,7 @@ func splitImpressions(imps []openrtb.Imp) (map[openrtb_ext.ExtImpZeroClickFraud] return m, nil } -func getBidderParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpZeroClickFraud, error) { +func getBidderParams(imp *openrtb2.Imp) (*openrtb_ext.ExtImpZeroClickFraud, error) { var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -155,7 +155,7 @@ func getBidderParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpZeroClickFraud, error return &zeroclickfraudExt, nil } -func getMediaType(impID string, imps []openrtb.Imp) openrtb_ext.BidType { +func getMediaType(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { bidType := openrtb_ext.BidTypeBanner diff --git a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json index 84d6bd9d889..87ad168467d 100644 --- a/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json +++ b/adapters/zeroclickfraud/zeroclickfraudtest/supplemental/bad-response-body.json @@ -81,7 +81,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", "comparison": "literal" } ] diff --git a/amp/parse.go b/amp/parse.go index 9e0e019f953..40604c774be 100644 --- a/amp/parse.go +++ b/amp/parse.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" ) // Params defines the paramters of an AMP request. @@ -24,11 +24,11 @@ type Params struct { // Size defines size information of an AMP request. type Size struct { - Height uint64 - Multisize []openrtb.Format - OverrideHeight uint64 - OverrideWidth uint64 - Width uint64 + Height int64 + Multisize []openrtb2.Format + OverrideHeight int64 + OverrideWidth int64 + Width int64 } // ParseParams parses the AMP paramters from a HTTP request. @@ -67,26 +67,26 @@ func parseIntPtr(value string) *uint64 { return nil } -func parseInt(value string) uint64 { - if parsed, err := strconv.ParseUint(value, 10, 64); err == nil { +func parseInt(value string) int64 { + if parsed, err := strconv.ParseInt(value, 10, 64); err == nil { return parsed } return 0 } -func parseMultisize(multisize string) []openrtb.Format { +func parseMultisize(multisize string) []openrtb2.Format { if multisize == "" { return nil } sizeStrings := strings.Split(multisize, ",") - sizes := make([]openrtb.Format, 0, len(sizeStrings)) + sizes := make([]openrtb2.Format, 0, len(sizeStrings)) for _, sizeString := range sizeStrings { wh := strings.Split(sizeString, "x") if len(wh) != 2 { return nil } - f := openrtb.Format{ + f := openrtb2.Format{ W: parseInt(wh[0]), H: parseInt(wh[1]), } diff --git a/amp/parse_test.go b/amp/parse_test.go index e2c82d71030..3a15e81ab46 100644 --- a/amp/parse_test.go +++ b/amp/parse_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) @@ -40,7 +40,7 @@ func TestParseParams(t *testing.T) { OverrideHeight: 3, OverrideWidth: 4, Width: 2, - Multisize: []openrtb.Format{ + Multisize: []openrtb2.Format{ {W: 10, H: 11}, {W: 12, H: 13}, }, }, @@ -96,7 +96,7 @@ func TestParseMultisize(t *testing.T) { testCases := []struct { description string multisize string - expectedFormats []openrtb.Format + expectedFormats []openrtb2.Format }{ { description: "Empty", @@ -106,18 +106,18 @@ func TestParseMultisize(t *testing.T) { { description: "One", multisize: "1x2", - expectedFormats: []openrtb.Format{{W: 1, H: 2}}, + expectedFormats: []openrtb2.Format{{W: 1, H: 2}}, }, { description: "Many", multisize: "1x2,3x4", - expectedFormats: []openrtb.Format{{W: 1, H: 2}, {W: 3, H: 4}}, + expectedFormats: []openrtb2.Format{{W: 1, H: 2}, {W: 3, H: 4}}, }, { // Existing Behavior: The " 3" token in the second size is parsed as 0. description: "Many With Space - Quirky Result", multisize: "1x2, 3x4", - expectedFormats: []openrtb.Format{{W: 1, H: 2}, {W: 0, H: 4}}, + expectedFormats: []openrtb2.Format{{W: 1, H: 2}, {W: 0, H: 4}}, }, { description: "One - Zero Size - Ignored", diff --git a/analytics/config/config_test.go b/analytics/config/config_test.go index 52edc79c2e3..1ec0c27e923 100644 --- a/analytics/config/config_test.go +++ b/analytics/config/config_test.go @@ -1,12 +1,13 @@ package config import ( - "github.com/stretchr/testify/assert" "net/http" "os" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/stretchr/testify/assert" + "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/config" ) @@ -19,8 +20,8 @@ func TestSampleModule(t *testing.T) { am.LogAuctionObject(&analytics.AuctionObject{ Status: http.StatusOK, Errors: nil, - Request: &openrtb.BidRequest{}, - Response: &openrtb.BidResponse{}, + Request: &openrtb2.BidRequest{}, + Response: &openrtb2.BidResponse{}, }) if count != 1 { t.Errorf("PBSAnalyticsModule failed at LogAuctionObject") diff --git a/analytics/core.go b/analytics/core.go index 6837304541d..e9403968c27 100644 --- a/analytics/core.go +++ b/analytics/core.go @@ -3,7 +3,7 @@ package analytics import ( "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/usersync" @@ -30,8 +30,8 @@ type PBSAnalyticsModule interface { type AuctionObject struct { Status int Errors []error - Request *openrtb.BidRequest - Response *openrtb.BidResponse + Request *openrtb2.BidRequest + Response *openrtb2.BidResponse Account *config.Account StartTime time.Time } @@ -40,8 +40,8 @@ type AuctionObject struct { type AmpObject struct { Status int Errors []error - Request *openrtb.BidRequest - AuctionResponse *openrtb.BidResponse + Request *openrtb2.BidRequest + AuctionResponse *openrtb2.BidResponse AmpTargetingValues map[string]string Origin string StartTime time.Time @@ -51,8 +51,8 @@ type AmpObject struct { type VideoObject struct { Status int Errors []error - Request *openrtb.BidRequest - Response *openrtb.BidResponse + Request *openrtb2.BidRequest + Response *openrtb2.BidResponse VideoRequest *openrtb_ext.BidRequestVideo VideoResponse *openrtb_ext.BidResponseVideo StartTime time.Time diff --git a/analytics/filesystem/file_module_test.go b/analytics/filesystem/file_module_test.go index cfc923c70f6..cfb72f487b0 100644 --- a/analytics/filesystem/file_module_test.go +++ b/analytics/filesystem/file_module_test.go @@ -1,13 +1,14 @@ package filesystem import ( - "github.com/prebid/prebid-server/config" "net/http" "os" "strings" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/usersync" ) @@ -18,7 +19,7 @@ func TestAmpObject_ToJson(t *testing.T) { ao := &analytics.AmpObject{ Status: http.StatusOK, Errors: make([]error, 0), - AuctionResponse: &openrtb.BidResponse{}, + AuctionResponse: &openrtb2.BidResponse{}, AmpTargetingValues: map[string]string{}, } if aoJson := jsonifyAmpObject(ao); strings.Contains(aoJson, "Transactional Logs Error") { diff --git a/analytics/pubstack/helpers/json_test.go b/analytics/pubstack/helpers/json_test.go index 4e36e8db2be..ba97d60da18 100644 --- a/analytics/pubstack/helpers/json_test.go +++ b/analytics/pubstack/helpers/json_test.go @@ -1,11 +1,12 @@ package helpers import ( - "github.com/mxmCherry/openrtb" - "github.com/prebid/prebid-server/analytics" - "github.com/prebid/prebid-server/usersync" "net/http" "testing" + + "github.com/mxmCherry/openrtb/v14/openrtb2" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/usersync" ) func TestJsonifyAuctionObject(t *testing.T) { @@ -52,7 +53,7 @@ func TestJsonifyAmpObject(t *testing.T) { ao := &analytics.AmpObject{ Status: http.StatusOK, Errors: make([]error, 0), - AuctionResponse: &openrtb.BidResponse{}, + AuctionResponse: &openrtb2.BidResponse{}, AmpTargetingValues: map[string]string{}, } if _, err := JsonifyAmpObject(ao, "scopeId"); err != nil { diff --git a/analytics/pubstack/pubstack_module_test.go b/analytics/pubstack/pubstack_module_test.go index 6bebc937f5e..8cc572022ef 100644 --- a/analytics/pubstack/pubstack_module_test.go +++ b/analytics/pubstack/pubstack_module_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/analytics" "github.com/stretchr/testify/assert" ) @@ -21,7 +21,7 @@ func loadJSONFromFile() (*analytics.AuctionObject, error) { } defer req.Close() - reqCtn := openrtb.BidRequest{} + reqCtn := openrtb2.BidRequest{} reqPayload, err := ioutil.ReadAll(req) if err != nil { return nil, err @@ -38,7 +38,7 @@ func loadJSONFromFile() (*analytics.AuctionObject, error) { } defer res.Close() - resCtn := openrtb.BidResponse{} + resCtn := openrtb2.BidResponse{} resPayload, err := ioutil.ReadAll(res) if err != nil { return nil, err diff --git a/endpoints/auction.go b/endpoints/auction.go index 92e9769d59e..069abfec4e5 100644 --- a/endpoints/auction.go +++ b/endpoints/auction.go @@ -307,8 +307,8 @@ func sortBidsAddKeywordsMobile(bids pbs.PBSBidSlice, pbs_req *pbs.PBSRequest, pr hbSize := "" if bid.Width != 0 && bid.Height != 0 { - width := strconv.FormatUint(bid.Width, 10) - height := strconv.FormatUint(bid.Height, 10) + width := strconv.FormatInt(bid.Width, 10) + height := strconv.FormatInt(bid.Height, 10) hbSize = width + "x" + height } diff --git a/endpoints/auction_test.go b/endpoints/auction_test.go index ed9a526d760..e99856129f7 100644 --- a/endpoints/auction_test.go +++ b/endpoints/auction_test.go @@ -10,7 +10,7 @@ import ( "net/http/httptest" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/cache/dummycache" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/gdpr" @@ -518,7 +518,7 @@ func TestBidSizeValidate(t *testing.T) { AdUnits: []pbs.PBSAdUnit{ { BidID: "test_bidid1", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 350, H: 250, @@ -535,7 +535,7 @@ func TestBidSizeValidate(t *testing.T) { }, { BidID: "test_bidid2", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 100, H: 100, @@ -548,7 +548,7 @@ func TestBidSizeValidate(t *testing.T) { }, { BidID: "test_bidid3", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 200, H: 200, @@ -561,7 +561,7 @@ func TestBidSizeValidate(t *testing.T) { }, { BidID: "test_bidid_video", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 400, H: 400, @@ -574,7 +574,7 @@ func TestBidSizeValidate(t *testing.T) { }, { BidID: "test_bidid3", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 150, H: 150, @@ -587,7 +587,7 @@ func TestBidSizeValidate(t *testing.T) { }, { BidID: "test_bidid_y", - Sizes: []openrtb.Format{ + Sizes: []openrtb2.Format{ { W: 150, H: 150, diff --git a/endpoints/openrtb2/amp_auction.go b/endpoints/openrtb2/amp_auction.go index 1f3d622b80d..cc8df0bf1b2 100644 --- a/endpoints/openrtb2/amp_auction.go +++ b/endpoints/openrtb2/amp_auction.go @@ -14,7 +14,7 @@ import ( "github.com/buger/jsonparser" "github.com/golang/glog" "github.com/julienschmidt/httprouter" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" accountService "github.com/prebid/prebid-server/account" "github.com/prebid/prebid-server/amp" "github.com/prebid/prebid-server/analytics" @@ -289,7 +289,7 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h // possible, it will return errors with messages that suggest improvements. // // If the errors list has at least one element, then no guarantees are made about the returned request. -func (deps *endpointDeps) parseAmpRequest(httpRequest *http.Request) (req *openrtb.BidRequest, errs []error) { +func (deps *endpointDeps) parseAmpRequest(httpRequest *http.Request) (req *openrtb2.BidRequest, errs []error) { // Load the stored request for the AMP ID. req, e := deps.loadRequestJSONForAmp(httpRequest) if errs = append(errs, e...); errortypes.ContainsFatalError(errs) { @@ -313,8 +313,8 @@ func (deps *endpointDeps) parseAmpRequest(httpRequest *http.Request) (req *openr } // Load the stored OpenRTB request for an incoming AMP request, or return the errors found. -func (deps *endpointDeps) loadRequestJSONForAmp(httpRequest *http.Request) (req *openrtb.BidRequest, errs []error) { - req = &openrtb.BidRequest{} +func (deps *endpointDeps) loadRequestJSONForAmp(httpRequest *http.Request) (req *openrtb2.BidRequest, errs []error) { + req = &openrtb2.BidRequest{} errs = nil ampParams, err := amp.ParseParams(httpRequest) @@ -372,9 +372,9 @@ func (deps *endpointDeps) loadRequestJSONForAmp(httpRequest *http.Request) (req return } -func (deps *endpointDeps) overrideWithParams(ampParams amp.Params, req *openrtb.BidRequest) []error { +func (deps *endpointDeps) overrideWithParams(ampParams amp.Params, req *openrtb2.BidRequest) []error { if req.Site == nil { - req.Site = &openrtb.Site{} + req.Site = &openrtb2.Site{} } // Override the stored request sizes with AMP ones, if they exist. @@ -423,25 +423,25 @@ func (deps *endpointDeps) overrideWithParams(ampParams amp.Params, req *openrtb. return nil } -func makeFormatReplacement(size amp.Size) []openrtb.Format { - var formats []openrtb.Format +func makeFormatReplacement(size amp.Size) []openrtb2.Format { + var formats []openrtb2.Format if size.OverrideWidth != 0 && size.OverrideHeight != 0 { - formats = []openrtb.Format{{ + formats = []openrtb2.Format{{ W: size.OverrideWidth, H: size.OverrideHeight, }} } else if size.OverrideWidth != 0 && size.Height != 0 { - formats = []openrtb.Format{{ + formats = []openrtb2.Format{{ W: size.OverrideWidth, H: size.Height, }} } else if size.Width != 0 && size.OverrideHeight != 0 { - formats = []openrtb.Format{{ + formats = []openrtb2.Format{{ W: size.Width, H: size.OverrideHeight, }} } else if size.Width != 0 && size.Height != 0 { - formats = []openrtb.Format{{ + formats = []openrtb2.Format{{ W: size.Width, H: size.Height, }} @@ -450,13 +450,13 @@ func makeFormatReplacement(size amp.Size) []openrtb.Format { return append(formats, size.Multisize...) } -func setWidths(formats []openrtb.Format, width uint64) { +func setWidths(formats []openrtb2.Format, width int64) { for i := 0; i < len(formats); i++ { formats[i].W = width } } -func setHeights(formats []openrtb.Format, height uint64) { +func setHeights(formats []openrtb2.Format, height int64) { for i := 0; i < len(formats); i++ { formats[i].H = height } @@ -464,7 +464,7 @@ func setHeights(formats []openrtb.Format, height uint64) { // AMP won't function unless ext.prebid.targeting and ext.prebid.cache.bids are defined. // If the user didn't include them, default those here. -func defaultRequestExt(req *openrtb.BidRequest) (errs []error) { +func defaultRequestExt(req *openrtb2.BidRequest) (errs []error) { errs = nil extRequest := &openrtb_ext.ExtRequest{} if req.Ext != nil && len(req.Ext) > 0 { @@ -506,7 +506,7 @@ func defaultRequestExt(req *openrtb.BidRequest) (errs []error) { return } -func setAmpExt(site *openrtb.Site, value string) { +func setAmpExt(site *openrtb2.Site, value string) { if len(site.Ext) > 0 { if _, dataType, _, _ := jsonparser.Get(site.Ext, "amp"); dataType == jsonparser.NotExist { if val, err := jsonparser.Set(site.Ext, []byte(value), "amp"); err == nil { @@ -538,16 +538,16 @@ func readPolicy(consent string) (privacy.PolicyWriter, error) { } // Sets the effective publisher ID for amp request -func setEffectiveAmpPubID(req *openrtb.BidRequest, account string) { - var pub *openrtb.Publisher +func setEffectiveAmpPubID(req *openrtb2.BidRequest, account string) { + var pub *openrtb2.Publisher if req.App != nil { if req.App.Publisher == nil { - req.App.Publisher = new(openrtb.Publisher) + req.App.Publisher = new(openrtb2.Publisher) } pub = req.App.Publisher } else if req.Site != nil { if req.Site.Publisher == nil { - req.Site.Publisher = new(openrtb.Publisher) + req.Site.Publisher = new(openrtb2.Publisher) } pub = req.Site.Publisher } diff --git a/endpoints/openrtb2/amp_auction_test.go b/endpoints/openrtb2/amp_auction_test.go index 77e76613c29..45bbb2dd3e5 100644 --- a/endpoints/openrtb2/amp_auction_test.go +++ b/endpoints/openrtb2/amp_auction_test.go @@ -11,10 +11,10 @@ import ( "strconv" "testing" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/mxmCherry/openrtb" analyticsConf "github.com/prebid/prebid-server/analytics/config" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/exchange" @@ -189,7 +189,7 @@ func TestGDPRConsent(t *testing.T) { // Build Request bid, err := getTestBidRequest(test.nilUser, test.userExt, true, nil) if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) + t.Fatalf("Failed to marshal the complete openrtb2.BidRequest object %v", err) } // Simulated Stored Request Backend @@ -341,7 +341,7 @@ func TestCCPAConsent(t *testing.T) { // Build Request bid, err := getTestBidRequest(true, nil, test.nilRegs, test.regsExt) if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) + t.Fatalf("Failed to marshal the complete openrtb2.BidRequest object %v", err) } // Simulated Stored Request Backend @@ -446,7 +446,7 @@ func TestConsentWarnings(t *testing.T) { bid, err := getTestBidRequest(true, nil, testCase.regs == nil, testCase.regs) if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) + t.Fatalf("Failed to marshal the complete openrtb2.BidRequest object %v", err) } // Simulated Stored Request Backend @@ -543,7 +543,7 @@ func TestNewAndLegacyConsentBothProvided(t *testing.T) { // Build Request bid, err := getTestBidRequest(false, nil, true, nil) if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) + t.Fatalf("Failed to marshal the complete openrtb2.BidRequest object %v", err) } // Simulated Stored Request Backend @@ -712,7 +712,7 @@ func TestAmpDebug(t *testing.T) { // Prevents #452 func TestAmpTargetingDefaults(t *testing.T) { - req := &openrtb.BidRequest{} + req := &openrtb2.BidRequest{} if errs := defaultRequestExt(req); len(errs) != 0 { t.Fatalf("Unexpected error defaulting request.ext for AMP: %v", errs) } @@ -797,7 +797,7 @@ func TestOverrideDimensions(t *testing.T) { formatOverrideSpec{ overrideWidth: 20, overrideHeight: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -808,7 +808,7 @@ func TestOverrideHeightNormalWidth(t *testing.T) { formatOverrideSpec{ width: 20, overrideHeight: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -819,7 +819,7 @@ func TestOverrideWidthNormalHeight(t *testing.T) { formatOverrideSpec{ overrideWidth: 20, height: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -829,7 +829,7 @@ func TestOverrideWidthNormalHeight(t *testing.T) { func TestMultisize(t *testing.T) { formatOverrideSpec{ multisize: "200x50,100x60", - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 200, H: 50, }, { @@ -844,7 +844,7 @@ func TestSizeWithMultisize(t *testing.T) { width: 20, height: 40, multisize: "200x50,100x60", - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }, { @@ -860,7 +860,7 @@ func TestSizeWithMultisize(t *testing.T) { func TestHeightOnly(t *testing.T) { formatOverrideSpec{ height: 200, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 300, H: 200, }}, @@ -870,7 +870,7 @@ func TestHeightOnly(t *testing.T) { func TestWidthOnly(t *testing.T) { formatOverrideSpec{ width: 150, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 150, H: 600, }}, @@ -884,7 +884,7 @@ type formatOverrideSpec struct { overrideHeight uint64 multisize string account string - expect []openrtb.Format + expect []openrtb2.Format } func (s formatOverrideSpec) execute(t *testing.T) { @@ -942,7 +942,7 @@ func (cf *mockAmpStoredReqFetcher) FetchRequests(ctx context.Context, requestIDs } type mockAmpExchange struct { - lastRequest *openrtb.BidRequest + lastRequest *openrtb2.BidRequest } var expectedErrorsFromHoldAuction map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage = map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage{ @@ -954,12 +954,12 @@ var expectedErrorsFromHoldAuction map[openrtb_ext.BidderName][]openrtb_ext.ExtBi }, } -func (m *mockAmpExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (m *mockAmpExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { m.lastRequest = r.BidRequest - response := &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ - Bid: []openrtb.Bid{{ + response := &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ + Bid: []openrtb2.Bid{{ AdM: "", Ext: json.RawMessage(`{ "prebid": {"targeting": { "hb_pb": "1.20", "hb_appnexus_pb": "1.20", "hb_cache_id": "some_id"}}}`), }}, @@ -980,10 +980,10 @@ func (m *mockAmpExchange) HoldAuction(ctx context.Context, r exchange.AuctionReq type mockAmpExchangeWarnings struct{} -func (m *mockAmpExchangeWarnings) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { - response := &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ - Bid: []openrtb.Bid{{ +func (m *mockAmpExchangeWarnings) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { + response := &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ + Bid: []openrtb2.Bid{{ AdM: "", Ext: json.RawMessage(`{ "prebid": {"targeting": { "hb_pb": "1.20", "hb_appnexus_pb": "1.20", "hb_cache_id": "some_id"}}}`), }}, @@ -994,16 +994,16 @@ func (m *mockAmpExchangeWarnings) HoldAuction(ctx context.Context, r exchange.Au } func getTestBidRequest(nilUser bool, userExt *openrtb_ext.ExtUser, nilRegs bool, regsExt *openrtb_ext.ExtRegs) ([]byte, error) { - var width uint64 = 300 - var height uint64 = 300 - bidRequest := &openrtb.BidRequest{ + var width int64 = 300 + var height int64 = 300 + bidRequest := &openrtb2.BidRequest{ ID: "test-request-id", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "/19968336/header-bid-tag-0", Ext: json.RawMessage(`{"appnexus": { "placementId":12883451 }}`), - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ { W: width, H: 250, @@ -1018,7 +1018,7 @@ func getTestBidRequest(nilUser bool, userExt *openrtb_ext.ExtUser, nilRegs bool, }, }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "site-id", Page: "some-page", }, @@ -1034,7 +1034,7 @@ func getTestBidRequest(nilUser bool, userExt *openrtb_ext.ExtUser, nilRegs bool, } if !nilUser { - bidRequest.User = &openrtb.User{ + bidRequest.User = &openrtb2.User{ ID: "aUserId", BuyerUID: "aBuyerID", Ext: userExtData, @@ -1051,7 +1051,7 @@ func getTestBidRequest(nilUser bool, userExt *openrtb_ext.ExtUser, nilRegs bool, } if !nilRegs { - bidRequest.Regs = &openrtb.Regs{ + bidRequest.Regs = &openrtb2.Regs{ COPPA: 1, Ext: regsExtData, } @@ -1064,14 +1064,14 @@ func TestSetEffectiveAmpPubID(t *testing.T) { testCases := []struct { description string - req *openrtb.BidRequest + req *openrtb2.BidRequest account string expectedPubID string }{ { description: "No publisher ID provided", - req: &openrtb.BidRequest{ - App: &openrtb.App{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ Publisher: nil, }, }, @@ -1079,9 +1079,9 @@ func TestSetEffectiveAmpPubID(t *testing.T) { }, { description: "Publisher ID present in req.App.Publisher.ID", - req: &openrtb.BidRequest{ - App: &openrtb.App{ - Publisher: &openrtb.Publisher{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ + Publisher: &openrtb2.Publisher{ ID: testPubID, }, }, @@ -1090,9 +1090,9 @@ func TestSetEffectiveAmpPubID(t *testing.T) { }, { description: "Publisher ID present in req.Site.Publisher.ID", - req: &openrtb.BidRequest{ - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + req: &openrtb2.BidRequest{ + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: testPubID, }, }, @@ -1101,9 +1101,9 @@ func TestSetEffectiveAmpPubID(t *testing.T) { }, { description: "Publisher ID present in account parameter", - req: &openrtb.BidRequest{ - App: &openrtb.App{ - Publisher: &openrtb.Publisher{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ + Publisher: &openrtb2.Publisher{ ID: "", }, }, @@ -1113,9 +1113,9 @@ func TestSetEffectiveAmpPubID(t *testing.T) { }, { description: "req.Site.Publisher present but ID set to empty string", - req: &openrtb.BidRequest{ - Site: &openrtb.Site{ - Publisher: &openrtb.Publisher{ + req: &openrtb2.BidRequest{ + Site: &openrtb2.Site{ + Publisher: &openrtb2.Publisher{ ID: "", }, }, @@ -1206,21 +1206,21 @@ func TestBuildAmpObject(t *testing.T) { expectedAmpObject: &analytics.AmpObject{ Status: http.StatusOK, Errors: nil, - Request: &openrtb.BidRequest{ + Request: &openrtb2.BidRequest{ ID: "some-request-id", - Device: &openrtb.Device{ + Device: &openrtb2.Device{ IP: "192.0.2.1", }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ Page: "prebid.org", - Publisher: &openrtb.Publisher{}, + Publisher: &openrtb2.Publisher{}, Ext: json.RawMessage(`{"amp":1}`), }, - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "some-impression-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ { W: 300, H: 250, @@ -1235,9 +1235,9 @@ func TestBuildAmpObject(t *testing.T) { TMax: 500, Ext: json.RawMessage(`{"prebid":{"cache":{"bids":{"returnCreative":null},"vastxml":null},"targeting":{"pricegranularity":{"precision":2,"ranges":[{"min":0,"max":20,"increment":0.1}]},"includewinners":true,"includebidderkeys":true,"includebrandcategory":null,"includeformat":false,"durationrangesec":null,"preferdeals":false}}}`), }, - AuctionResponse: &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ - Bid: []openrtb.Bid{{ + AuctionResponse: &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ + Bid: []openrtb2.Bid{{ AdM: "", Ext: json.RawMessage(`{ "prebid": {"targeting": { "hb_pb": "1.20", "hb_appnexus_pb": "1.20", "hb_cache_id": "some_id"}}}`), }}, diff --git a/endpoints/openrtb2/auction.go b/endpoints/openrtb2/auction.go index 70d8e72629e..91acab33ea1 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -18,9 +18,9 @@ import ( "github.com/gofrs/uuid" "github.com/golang/glog" "github.com/julienschmidt/httprouter" - "github.com/mxmCherry/openrtb" - "github.com/mxmCherry/openrtb/native" - nativeRequests "github.com/mxmCherry/openrtb/native/request" + "github.com/mxmCherry/openrtb/v14/native1" + nativeRequests "github.com/mxmCherry/openrtb/v14/native1/request" + "github.com/mxmCherry/openrtb/v14/openrtb2" accountService "github.com/prebid/prebid-server/account" "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/config" @@ -223,8 +223,8 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http // possible, it will return errors with messages that suggest improvements. // // If the errors list has at least one element, then no guarantees are made about the returned request. -func (deps *endpointDeps) parseRequest(httpRequest *http.Request) (req *openrtb.BidRequest, errs []error) { - req = &openrtb.BidRequest{} +func (deps *endpointDeps) parseRequest(httpRequest *http.Request) (req *openrtb2.BidRequest, errs []error) { + req = &openrtb2.BidRequest{} errs = nil // Pull the request body into a buffer, so we have it for later usage. @@ -292,7 +292,7 @@ func parseTimeout(requestJson []byte, defaultTimeout time.Duration) time.Duratio return defaultTimeout } -func (deps *endpointDeps) validateRequest(req *openrtb.BidRequest) []error { +func (deps *endpointDeps) validateRequest(req *openrtb2.BidRequest) []error { errL := []error{} if req.ID == "" { return []error{errors.New("request missing required field: \"id\"")} @@ -362,6 +362,10 @@ func (deps *endpointDeps) validateRequest(req *openrtb.BidRequest) []error { return append(errL, err) } + if err := validateDevice(req.Device); err != nil { + return append(errL, err) + } + if ccpaPolicy, err := ccpa.ReadFromRequest(req); err != nil { return append(errL, err) } else if _, err := ccpaPolicy.Parse(exchange.GetValidBidders(aliases)); err != nil { @@ -397,9 +401,9 @@ func (deps *endpointDeps) validateRequest(req *openrtb.BidRequest) []error { return errL } -func validateAndFillSourceTID(req *openrtb.BidRequest) error { +func validateAndFillSourceTID(req *openrtb2.BidRequest) error { if req.Source == nil { - req.Source = &openrtb.Source{} + req.Source = &openrtb2.Source{} } if req.Source.TID == "" { if rawUUID, err := uuid.NewV4(); err == nil { @@ -475,7 +479,7 @@ func validateBidders(bidders []string, knownBidders map[string]openrtb_ext.Bidde return nil } -func (deps *endpointDeps) validateImp(imp *openrtb.Imp, aliases map[string]string, index int) []error { +func (deps *endpointDeps) validateImp(imp *openrtb2.Imp, aliases map[string]string, index int) []error { if imp.ID == "" { return []error{fmt.Errorf("request.imp[%d] missing required field: \"id\"", index)} } @@ -492,12 +496,12 @@ func (deps *endpointDeps) validateImp(imp *openrtb.Imp, aliases map[string]strin return []error{err} } - if imp.Video != nil && len(imp.Video.MIMEs) < 1 { - return []error{fmt.Errorf("request.imp[%d].video.mimes must contain at least one supported MIME type", index)} + if err := validateVideo(imp.Video, index); err != nil { + return []error{err} } - if imp.Audio != nil && len(imp.Audio.MIMEs) < 1 { - return []error{fmt.Errorf("request.imp[%d].audio.mimes must contain at least one supported MIME type", index)} + if err := validateAudio(imp.Audio, index); err != nil { + return []error{err} } if err := fillAndValidateNative(imp.Native, index); err != nil { @@ -516,13 +520,22 @@ func (deps *endpointDeps) validateImp(imp *openrtb.Imp, aliases map[string]strin return nil } -func validateBanner(banner *openrtb.Banner, impIndex int) error { +func validateBanner(banner *openrtb2.Banner, impIndex int) error { if banner == nil { return nil } - // Although these are only deprecated in the spec... since this is a new endpoint, we know nobody uses them yet. - // Let's start things off by pointing callers in the right direction. + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if banner.W != nil && *banner.W < 0 { + return fmt.Errorf("request.imp[%d].banner.w must be a positive number", impIndex) + } + if banner.H != nil && *banner.H < 0 { + return fmt.Errorf("request.imp[%d].banner.h must be a positive number", impIndex) + } + + // The following fields are deprecated in the OpenRTB 2.5 spec but are still present + // in the OpenRTB library we use. Enforce they are not specified. if banner.WMin != 0 { return fmt.Errorf("request.imp[%d].banner uses unsupported property: \"wmin\". Use the \"format\" array instead.", impIndex) } @@ -541,16 +554,71 @@ func validateBanner(banner *openrtb.Banner, impIndex int) error { return fmt.Errorf("request.imp[%d].banner has no sizes. Define \"w\" and \"h\", or include \"format\" elements.", impIndex) } - for fmtIndex, format := range banner.Format { - if err := validateFormat(&format, impIndex, fmtIndex); err != nil { + for i, format := range banner.Format { + if err := validateFormat(&format, impIndex, i); err != nil { return err } } + + return nil +} + +func validateVideo(video *openrtb2.Video, impIndex int) error { + if video == nil { + return nil + } + + if len(video.MIMEs) < 1 { + return fmt.Errorf("request.imp[%d].video.mimes must contain at least one supported MIME type", impIndex) + } + + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if video.W < 0 { + return fmt.Errorf("request.imp[%d].video.w must be a positive number", impIndex) + } + if video.H < 0 { + return fmt.Errorf("request.imp[%d].video.h must be a positive number", impIndex) + } + if video.MinBitRate < 0 { + return fmt.Errorf("request.imp[%d].video.minbitrate must be a positive number", impIndex) + } + if video.MaxBitRate < 0 { + return fmt.Errorf("request.imp[%d].video.maxbitrate must be a positive number", impIndex) + } + + return nil +} + +func validateAudio(audio *openrtb2.Audio, impIndex int) error { + if audio == nil { + return nil + } + + if len(audio.MIMEs) < 1 { + return fmt.Errorf("request.imp[%d].audio.mimes must contain at least one supported MIME type", impIndex) + } + + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if audio.Sequence < 0 { + return fmt.Errorf("request.imp[%d].audio.sequence must be a positive number", impIndex) + } + if audio.MaxSeq < 0 { + return fmt.Errorf("request.imp[%d].audio.maxseq must be a positive number", impIndex) + } + if audio.MinBitrate < 0 { + return fmt.Errorf("request.imp[%d].audio.minbitrate must be a positive number", impIndex) + } + if audio.MaxBitrate < 0 { + return fmt.Errorf("request.imp[%d].audio.maxbitrate must be a positive number", impIndex) + } + return nil } // fillAndValidateNative validates the request, and assigns the Asset IDs as recommended by the Native v1.2 spec. -func fillAndValidateNative(n *openrtb.Native, impIndex int) error { +func fillAndValidateNative(n *openrtb2.Native, impIndex int) error { if n == nil { return nil } @@ -584,12 +652,12 @@ func fillAndValidateNative(n *openrtb.Native, impIndex int) error { return nil } -func validateNativeContextTypes(cType native.ContextType, cSubtype native.ContextSubType, impIndex int) error { +func validateNativeContextTypes(cType native1.ContextType, cSubtype native1.ContextSubType, impIndex int) error { if cType == 0 { // Context is only recommended, so none is a valid type. return nil } - if cType < native.ContextTypeContent || cType > native.ContextTypeProduct { + if cType < native1.ContextTypeContent || cType > native1.ContextTypeProduct { return fmt.Errorf("request.imp[%d].native.request.context is invalid. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex) } if cSubtype < 0 { @@ -602,20 +670,20 @@ func validateNativeContextTypes(cType native.ContextType, cSubtype native.Contex if cSubtype >= 500 { return fmt.Errorf("request.imp[%d].native.request.contextsubtype can't be greater than or equal to 500. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex) } - if cSubtype >= native.ContextSubTypeGeneral && cSubtype <= native.ContextSubTypeUserGenerated { - if cType != native.ContextTypeContent { + if cSubtype >= native1.ContextSubTypeGeneral && cSubtype <= native1.ContextSubTypeUserGenerated { + if cType != native1.ContextTypeContent { return fmt.Errorf("request.imp[%d].native.request.context is %d, but contextsubtype is %d. This is an invalid combination. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex, cType, cSubtype) } return nil } - if cSubtype >= native.ContextSubTypeSocial && cSubtype <= native.ContextSubTypeChat { - if cType != native.ContextTypeSocial { + if cSubtype >= native1.ContextSubTypeSocial && cSubtype <= native1.ContextSubTypeChat { + if cType != native1.ContextTypeSocial { return fmt.Errorf("request.imp[%d].native.request.context is %d, but contextsubtype is %d. This is an invalid combination. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex, cType, cSubtype) } return nil } - if cSubtype >= native.ContextSubTypeSelling && cSubtype <= native.ContextSubTypeProductReview { - if cType != native.ContextTypeProduct { + if cSubtype >= native1.ContextSubTypeSelling && cSubtype <= native1.ContextSubTypeProductReview { + if cType != native1.ContextTypeProduct { return fmt.Errorf("request.imp[%d].native.request.context is %d, but contextsubtype is %d. This is an invalid combination. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex, cType, cSubtype) } return nil @@ -624,12 +692,12 @@ func validateNativeContextTypes(cType native.ContextType, cSubtype native.Contex return fmt.Errorf("request.imp[%d].native.request.contextsubtype is invalid. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=39", impIndex) } -func validateNativePlacementType(pt native.PlacementType, impIndex int) error { +func validateNativePlacementType(pt native1.PlacementType, impIndex int) error { if pt == 0 { // Placement Type is only reccomended, not required. return nil } - if pt < native.PlacementTypeFeed || pt > native.PlacementTypeRecommendationWidget { + if pt < native1.PlacementTypeFeed || pt > native1.PlacementTypeRecommendationWidget { return fmt.Errorf("request.imp[%d].native.request.plcmttype is invalid. See https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=40", impIndex) } return nil @@ -686,7 +754,9 @@ func validateNativeAsset(asset nativeRequests.Asset, impIndex int, assetIndex in return fmt.Errorf(assetErr, impIndex, assetIndex) } foundType = true - // It is technically valid to have neither w/h nor wmin/hmin, so no check + if err := validateNativeAssetImage(asset.Img, impIndex, assetIndex); err != nil { + return err + } } if asset.Video != nil { @@ -727,20 +797,20 @@ func validateNativeEventTrackers(trackers []nativeRequests.EventTracker, impInde func validateNativeAssetTitle(title *nativeRequests.Title, impIndex int, assetIndex int) error { if title.Len < 1 { - return fmt.Errorf("request.imp[%d].native.request.assets[%d].title.len must be a positive integer", impIndex, assetIndex) + return fmt.Errorf("request.imp[%d].native.request.assets[%d].title.len must be a positive number", impIndex, assetIndex) } return nil } func validateNativeEventTracker(tracker nativeRequests.EventTracker, impIndex int, eventIndex int) error { - if tracker.Event < native.EventTypeImpression || tracker.Event > native.EventTypeViewableVideo50 { + if tracker.Event < native1.EventTypeImpression || tracker.Event > native1.EventTypeViewableVideo50 { return fmt.Errorf("request.imp[%d].native.request.eventtrackers[%d].event is invalid. See section 7.6: https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=43", impIndex, eventIndex) } if len(tracker.Methods) < 1 { return fmt.Errorf("request.imp[%d].native.request.eventtrackers[%d].method is required. See section 7.7: https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=43", impIndex, eventIndex) } for methodIndex, method := range tracker.Methods { - if method < native.EventTrackingMethodImage || method > native.EventTrackingMethodJS { + if method < native1.EventTrackingMethodImage || method > native1.EventTrackingMethodJS { return fmt.Errorf("request.imp[%d].native.request.eventtrackers[%d].methods[%d] is invalid. See section 7.7: https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=43", impIndex, eventIndex, methodIndex) } } @@ -748,6 +818,22 @@ func validateNativeEventTracker(tracker nativeRequests.EventTracker, impIndex in return nil } +func validateNativeAssetImage(img *nativeRequests.Image, impIndex int, assetIndex int) error { + if img.W < 0 { + return fmt.Errorf("request.imp[%d].native.request.assets[%d].img.w must be a positive integer", impIndex, assetIndex) + } + if img.H < 0 { + return fmt.Errorf("request.imp[%d].native.request.assets[%d].img.h must be a positive integer", impIndex, assetIndex) + } + if img.WMin < 0 { + return fmt.Errorf("request.imp[%d].native.request.assets[%d].img.wmin must be a positive integer", impIndex, assetIndex) + } + if img.HMin < 0 { + return fmt.Errorf("request.imp[%d].native.request.assets[%d].img.hmin must be a positive integer", impIndex, assetIndex) + } + return nil +} + func validateNativeAssetVideo(video *nativeRequests.Video, impIndex int, assetIndex int) error { if len(video.MIMEs) < 1 { return fmt.Errorf("request.imp[%d].native.request.assets[%d].video.mimes must be an array with at least one MIME type", impIndex, assetIndex) @@ -766,14 +852,14 @@ func validateNativeAssetVideo(video *nativeRequests.Video, impIndex int, assetIn } func validateNativeAssetData(data *nativeRequests.Data, impIndex int, assetIndex int) error { - if data.Type < native.DataAssetTypeSponsored || data.Type > native.DataAssetTypeCTAText { + if data.Type < native1.DataAssetTypeSponsored || data.Type > native1.DataAssetTypeCTAText { return fmt.Errorf("request.imp[%d].native.request.assets[%d].data.type is invalid. See section 7.4: https://iabtechlab.com/wp-content/uploads/2016/07/OpenRTB-Native-Ads-Specification-Final-1.2.pdf#page=40", impIndex, assetIndex) } return nil } -func validateNativeVideoProtocols(protocols []native.Protocol, impIndex int, assetIndex int) error { +func validateNativeVideoProtocols(protocols []native1.Protocol, impIndex int, assetIndex int) error { if len(protocols) < 1 { return fmt.Errorf("request.imp[%d].native.request.assets[%d].video.protocols must be an array with at least one element", impIndex, assetIndex) } @@ -785,16 +871,35 @@ func validateNativeVideoProtocols(protocols []native.Protocol, impIndex int, ass return nil } -func validateNativeVideoProtocol(protocol native.Protocol, impIndex int, assetIndex int, protocolIndex int) error { - if protocol < native.ProtocolVAST10 || protocol > native.ProtocolDAAST10Wrapper { +func validateNativeVideoProtocol(protocol native1.Protocol, impIndex int, assetIndex int, protocolIndex int) error { + if protocol < native1.ProtocolVAST10 || protocol > native1.ProtocolDAAST10Wrapper { return fmt.Errorf("request.imp[%d].native.request.assets[%d].video.protocols[%d] is invalid. See Section 5.8: https://www.iab.com/wp-content/uploads/2016/03/OpenRTB-API-Specification-Version-2-5-FINAL.pdf#page=52", impIndex, assetIndex, protocolIndex) } return nil } -func validateFormat(format *openrtb.Format, impIndex int, formatIndex int) error { +func validateFormat(format *openrtb2.Format, impIndex, formatIndex int) error { usesHW := format.W != 0 || format.H != 0 usesRatios := format.WMin != 0 || format.WRatio != 0 || format.HRatio != 0 + + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if format.W < 0 { + return fmt.Errorf("request.imp[%d].banner.format[%d].w must be a positive number", impIndex, formatIndex) + } + if format.H < 0 { + return fmt.Errorf("request.imp[%d].banner.format[%d].h must be a positive number", impIndex, formatIndex) + } + if format.WRatio < 0 { + return fmt.Errorf("request.imp[%d].banner.format[%d].wratio must be a positive number", impIndex, formatIndex) + } + if format.HRatio < 0 { + return fmt.Errorf("request.imp[%d].banner.format[%d].hratio must be a positive number", impIndex, formatIndex) + } + if format.WMin < 0 { + return fmt.Errorf("request.imp[%d].banner.format[%d].wmin must be a positive number", impIndex, formatIndex) + } + if usesHW && usesRatios { return fmt.Errorf("Request imp[%d].banner.format[%d] should define *either* {w, h} *or* {wmin, wratio, hratio}, but not both. If both are valid, send two \"format\" objects in the request.", impIndex, formatIndex) } @@ -810,7 +915,7 @@ func validateFormat(format *openrtb.Format, impIndex int, formatIndex int) error return nil } -func validatePmp(pmp *openrtb.PMP, impIndex int) error { +func validatePmp(pmp *openrtb2.PMP, impIndex int) error { if pmp == nil { return nil } @@ -823,7 +928,7 @@ func validatePmp(pmp *openrtb.PMP, impIndex int) error { return nil } -func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]string, impIndex int) []error { +func (deps *endpointDeps) validateImpExt(imp *openrtb2.Imp, aliases map[string]string, impIndex int) []error { errL := []error{} if len(imp.Ext) == 0 { return []error{fmt.Errorf("request.imp[%d].ext is required", impIndex)} @@ -937,7 +1042,7 @@ func (deps *endpointDeps) validateAliases(aliases map[string]string) error { return nil } -func (deps *endpointDeps) validateSite(site *openrtb.Site) error { +func (deps *endpointDeps) validateSite(site *openrtb2.Site) error { if site == nil { return nil } @@ -955,7 +1060,7 @@ func (deps *endpointDeps) validateSite(site *openrtb.Site) error { return nil } -func (deps *endpointDeps) validateApp(app *openrtb.App) error { +func (deps *endpointDeps) validateApp(app *openrtb2.App) error { if app == nil { return nil } @@ -976,9 +1081,18 @@ func (deps *endpointDeps) validateApp(app *openrtb.App) error { return nil } -func (deps *endpointDeps) validateUser(user *openrtb.User, aliases map[string]string) error { - // DigiTrust support - if user != nil && user.Ext != nil { +func (deps *endpointDeps) validateUser(user *openrtb2.User, aliases map[string]string) error { + if user == nil { + return nil + } + + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if user.Geo != nil && user.Geo.Accuracy < 0 { + return errors.New("request.user.geo.accuracy must be a positive number") + } + + if user.Ext != nil { // Creating ExtUser object to check if DigiTrust is valid var userExt openrtb_ext.ExtUser if err := json.Unmarshal(user.Ext, &userExt); err == nil { @@ -1030,7 +1144,6 @@ func (deps *endpointDeps) validateUser(user *openrtb.User, aliases map[string]st } } } else { - // Return error. return fmt.Errorf("request.user.ext object is not valid: %v", err) } } @@ -1038,7 +1151,7 @@ func (deps *endpointDeps) validateUser(user *openrtb.User, aliases map[string]st return nil } -func validateRegs(regs *openrtb.Regs) error { +func validateRegs(regs *openrtb2.Regs) error { if regs != nil && len(regs.Ext) > 0 { var regsExt openrtb_ext.ExtRegs if err := json.Unmarshal(regs.Ext, ®sExt); err != nil { @@ -1051,7 +1164,30 @@ func validateRegs(regs *openrtb.Regs) error { return nil } -func sanitizeRequest(r *openrtb.BidRequest, ipValidator iputil.IPValidator) { +func validateDevice(device *openrtb2.Device) error { + if device == nil { + return nil + } + + // The following fields were previously uints in the OpenRTB library we use, but have + // since been changed to ints. We decided to maintain the non-negative check. + if device.W < 0 { + return errors.New("request.device.w must be a positive number") + } + if device.H < 0 { + return errors.New("request.device.h must be a positive number") + } + if device.PPI < 0 { + return errors.New("request.device.ppi must be a positive number") + } + if device.Geo != nil && device.Geo.Accuracy < 0 { + return errors.New("request.device.geo.accuracy must be a positive number") + } + + return nil +} + +func sanitizeRequest(r *openrtb2.BidRequest, ipValidator iputil.IPValidator) { if r.Device != nil { if ip, ver := iputil.ParseIP(r.Device.IP); ip == nil || ver != iputil.IPv4 || !ipValidator.IsValid(ip, ver) { r.Device.IP = "" @@ -1068,7 +1204,7 @@ func sanitizeRequest(r *openrtb.BidRequest, ipValidator iputil.IPValidator) { // OpenRTB properties from the headers and other implicit info. // // This function _should not_ override any fields which were defined explicitly by the caller in the request. -func (deps *endpointDeps) setFieldsImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest) { +func (deps *endpointDeps) setFieldsImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest) { sanitizeRequest(bidReq, deps.privateNetworkIPValidator) setDeviceImplicitly(httpReq, bidReq, deps.privateNetworkIPValidator) @@ -1083,7 +1219,7 @@ func (deps *endpointDeps) setFieldsImplicitly(httpReq *http.Request, bidReq *ope } // setDeviceImplicitly uses implicit info from httpReq to populate bidReq.Device -func setDeviceImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest, ipValidtor iputil.IPValidator) { +func setDeviceImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest, ipValidtor iputil.IPValidator) { setIPImplicitly(httpReq, bidReq, ipValidtor) setUAImplicitly(httpReq, bidReq) setDoNotTrackImplicitly(httpReq, bidReq) @@ -1092,7 +1228,7 @@ func setDeviceImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest, ipVa // setAuctionTypeImplicitly sets the auction type to 1 if it wasn't on the request, // since header bidding is generally a first-price auction. -func setAuctionTypeImplicitly(bidReq *openrtb.BidRequest) { +func setAuctionTypeImplicitly(bidReq *openrtb2.BidRequest) { if bidReq.AT == 0 { bidReq.AT = 1 } @@ -1100,13 +1236,13 @@ func setAuctionTypeImplicitly(bidReq *openrtb.BidRequest) { } // setSiteImplicitly uses implicit info from httpReq to populate bidReq.Site -func setSiteImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest) { +func setSiteImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest) { if bidReq.Site == nil || bidReq.Site.Page == "" || bidReq.Site.Domain == "" { referrerCandidate := httpReq.Referer() if parsedUrl, err := url.Parse(referrerCandidate); err == nil { if domain, err := publicsuffix.EffectiveTLDPlusOne(parsedUrl.Host); err == nil { if bidReq.Site == nil { - bidReq.Site = &openrtb.Site{} + bidReq.Site = &openrtb2.Site{} } if bidReq.Site.Domain == "" { bidReq.Site.Domain = domain @@ -1125,7 +1261,7 @@ func setSiteImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest) { } } -func setImpsImplicitly(httpReq *http.Request, imps []openrtb.Imp) { +func setImpsImplicitly(httpReq *http.Request, imps []openrtb2.Imp) { secure := int8(1) for i := 0; i < len(imps); i++ { if imps[i].Secure == nil && httputil.IsSecure(httpReq) { @@ -1285,18 +1421,18 @@ func getStoredRequestId(data []byte) (string, bool, error) { } // setIPImplicitly sets the IP address on bidReq, if it's not explicitly defined and we can figure it out. -func setIPImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest, ipValidator iputil.IPValidator) { +func setIPImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest, ipValidator iputil.IPValidator) { if bidReq.Device == nil || (bidReq.Device.IP == "" && bidReq.Device.IPv6 == "") { if ip, ver := httputil.FindIP(httpReq, ipValidator); ip != nil { switch ver { case iputil.IPv4: if bidReq.Device == nil { - bidReq.Device = &openrtb.Device{} + bidReq.Device = &openrtb2.Device{} } bidReq.Device.IP = ip.String() case iputil.IPv6: if bidReq.Device == nil { - bidReq.Device = &openrtb.Device{} + bidReq.Device = &openrtb2.Device{} } bidReq.Device.IPv6 = ip.String() } @@ -1305,23 +1441,23 @@ func setIPImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest, ipValida } // setUAImplicitly sets the User Agent on bidReq, if it's not explicitly defined and it's defined on the request. -func setUAImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest) { +func setUAImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest) { if bidReq.Device == nil || bidReq.Device.UA == "" { if ua := httpReq.UserAgent(); ua != "" { if bidReq.Device == nil { - bidReq.Device = &openrtb.Device{} + bidReq.Device = &openrtb2.Device{} } bidReq.Device.UA = ua } } } -func setDoNotTrackImplicitly(httpReq *http.Request, bidReq *openrtb.BidRequest) { +func setDoNotTrackImplicitly(httpReq *http.Request, bidReq *openrtb2.BidRequest) { if bidReq.Device == nil || bidReq.Device.DNT == nil { dnt := httpReq.Header.Get(dntKey) if dnt == "0" || dnt == "1" { if bidReq.Device == nil { - bidReq.Device = &openrtb.Device{} + bidReq.Device = &openrtb2.Device{} } switch dnt { @@ -1368,7 +1504,7 @@ func writeError(errs []error, w http.ResponseWriter, labels *metrics.Labels) boo } // Returns the account ID for the request -func getAccountID(pub *openrtb.Publisher) string { +func getAccountID(pub *openrtb2.Publisher) string { if pub != nil { if pub.Ext != nil { var pubExt openrtb_ext.ExtPublisher diff --git a/endpoints/openrtb2/auction_test.go b/endpoints/openrtb2/auction_test.go index 19c58f05ae0..2deb5d1b762 100644 --- a/endpoints/openrtb2/auction_test.go +++ b/endpoints/openrtb2/auction_test.go @@ -17,11 +17,11 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/stored_requests" "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" - "github.com/mxmCherry/openrtb" analyticsConf "github.com/prebid/prebid-server/analytics/config" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -152,8 +152,8 @@ func runTestCase(t *testing.T, fileData []byte, testFile string) { } if len(test.ExpectedBidResponse) > 0 { - var expectedBidResponse openrtb.BidResponse - var actualBidResponse openrtb.BidResponse + var expectedBidResponse openrtb2.BidResponse + var actualBidResponse openrtb2.BidResponse var err error err = json.Unmarshal(test.ExpectedBidResponse, &expectedBidResponse) @@ -241,7 +241,7 @@ func (tc *testConfigValues) getAdaptersConfigMap() map[string]config.Adapter { // Once unmarshalled, bidResponse objects can't simply be compared with an `assert.Equalf()` call // because tests fail if the elements inside the `bidResponse.SeatBid` and `bidResponse.SeatBid.Bid` // arrays, if any, are not listed in the exact same order in the actual version and in the expected version. -func assertBidResponseEqual(t *testing.T, testFile string, expectedBidResponse openrtb.BidResponse, actualBidResponse openrtb.BidResponse) { +func assertBidResponseEqual(t *testing.T, testFile string, expectedBidResponse openrtb2.BidResponse, actualBidResponse openrtb2.BidResponse) { //Assert non-array BidResponse fields assert.Equalf(t, expectedBidResponse.ID, actualBidResponse.ID, "BidResponse.ID doesn't match expected. Test: %s\n", testFile) @@ -252,12 +252,12 @@ func assertBidResponseEqual(t *testing.T, testFile string, expectedBidResponse o assert.Len(t, actualBidResponse.SeatBid, len(expectedBidResponse.SeatBid), "BidResponse.SeatBid array doesn't match expected. Test: %s\n", testFile) //Given that bidResponses have the same length, compare them in an order-independent way using maps - var actualSeatBidsMap map[string]openrtb.SeatBid = make(map[string]openrtb.SeatBid, 0) + var actualSeatBidsMap map[string]openrtb2.SeatBid = make(map[string]openrtb2.SeatBid, 0) for _, seatBid := range actualBidResponse.SeatBid { actualSeatBidsMap[seatBid.Seat] = seatBid } - var expectedSeatBidsMap map[string]openrtb.SeatBid = make(map[string]openrtb.SeatBid, 0) + var expectedSeatBidsMap map[string]openrtb2.SeatBid = make(map[string]openrtb2.SeatBid, 0) for _, seatBid := range expectedBidResponse.SeatBid { expectedSeatBidsMap[seatBid.Seat] = seatBid } @@ -275,76 +275,76 @@ func assertBidResponseEqual(t *testing.T, testFile string, expectedBidResponse o } func TestBidRequestAssert(t *testing.T) { - appnexusB1 := openrtb.Bid{ID: "appnexus-bid-1", Price: 5.00} - appnexusB2 := openrtb.Bid{ID: "appnexus-bid-2", Price: 7.00} - rubiconB1 := openrtb.Bid{ID: "rubicon-bid-1", Price: 1.50} - rubiconB2 := openrtb.Bid{ID: "rubicon-bid-2", Price: 4.00} + appnexusB1 := openrtb2.Bid{ID: "appnexus-bid-1", Price: 5.00} + appnexusB2 := openrtb2.Bid{ID: "appnexus-bid-2", Price: 7.00} + rubiconB1 := openrtb2.Bid{ID: "rubicon-bid-1", Price: 1.50} + rubiconB2 := openrtb2.Bid{ID: "rubicon-bid-2", Price: 4.00} - sampleSeatBids := []openrtb.SeatBid{ + sampleSeatBids := []openrtb2.SeatBid{ { Seat: "appnexus-bids", - Bid: []openrtb.Bid{appnexusB1, appnexusB2}, + Bid: []openrtb2.Bid{appnexusB1, appnexusB2}, }, { Seat: "rubicon-bids", - Bid: []openrtb.Bid{rubiconB1, rubiconB2}, + Bid: []openrtb2.Bid{rubiconB1, rubiconB2}, }, } testSuites := []struct { description string - expectedBidResponse openrtb.BidResponse - actualBidResponse openrtb.BidResponse + expectedBidResponse openrtb2.BidResponse + actualBidResponse openrtb2.BidResponse }{ { "identical SeatBids, exact same SeatBid and Bid arrays order", - openrtb.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, - openrtb.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, + openrtb2.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, + openrtb2.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, }, { "identical SeatBids but Seatbid array elements come in different order", - openrtb.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, - openrtb.BidResponse{ID: "anId", BidID: "bidId", - SeatBid: []openrtb.SeatBid{ + openrtb2.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, + openrtb2.BidResponse{ID: "anId", BidID: "bidId", + SeatBid: []openrtb2.SeatBid{ { Seat: "rubicon-bids", - Bid: []openrtb.Bid{rubiconB1, rubiconB2}, + Bid: []openrtb2.Bid{rubiconB1, rubiconB2}, }, { Seat: "appnexus-bids", - Bid: []openrtb.Bid{appnexusB1, appnexusB2}, + Bid: []openrtb2.Bid{appnexusB1, appnexusB2}, }, }, }, }, { "SeatBids seem to be identical except for the different order of Bid array elements in one of them", - openrtb.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, - openrtb.BidResponse{ID: "anId", BidID: "bidId", - SeatBid: []openrtb.SeatBid{ + openrtb2.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, + openrtb2.BidResponse{ID: "anId", BidID: "bidId", + SeatBid: []openrtb2.SeatBid{ { Seat: "appnexus-bids", - Bid: []openrtb.Bid{appnexusB2, appnexusB1}, + Bid: []openrtb2.Bid{appnexusB2, appnexusB1}, }, { Seat: "rubicon-bids", - Bid: []openrtb.Bid{rubiconB1, rubiconB2}, + Bid: []openrtb2.Bid{rubiconB1, rubiconB2}, }, }, }, }, { "Both SeatBid elements and bid elements come in different order", - openrtb.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, - openrtb.BidResponse{ID: "anId", BidID: "bidId", - SeatBid: []openrtb.SeatBid{ + openrtb2.BidResponse{ID: "anId", BidID: "bidId", SeatBid: sampleSeatBids}, + openrtb2.BidResponse{ID: "anId", BidID: "bidId", + SeatBid: []openrtb2.SeatBid{ { Seat: "rubicon-bids", - Bid: []openrtb.Bid{rubiconB2, rubiconB1}, + Bid: []openrtb2.Bid{rubiconB2, rubiconB1}, }, { Seat: "appnexus-bids", - Bid: []openrtb.Bid{appnexusB2, appnexusB1}, + Bid: []openrtb2.Bid{appnexusB2, appnexusB1}, }, }, }, @@ -626,7 +626,7 @@ func TestExchangeError(t *testing.T) { func TestUserAgentSetting(t *testing.T) { httpReq := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(validRequest(t, "site.json"))) httpReq.Header.Set("User-Agent", "foo") - bidReq := &openrtb.BidRequest{} + bidReq := &openrtb2.BidRequest{} setUAImplicitly(httpReq, bidReq) @@ -642,8 +642,8 @@ func TestUserAgentSetting(t *testing.T) { func TestUserAgentOverride(t *testing.T) { httpReq := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(validRequest(t, "site.json"))) httpReq.Header.Set("User-Agent", "foo") - bidReq := &openrtb.BidRequest{ - Device: &openrtb.Device{ + bidReq := &openrtb2.BidRequest{ + Device: &openrtb2.Device{ UA: "bar", }, } @@ -656,7 +656,7 @@ func TestUserAgentOverride(t *testing.T) { } func TestAuctionTypeDefault(t *testing.T) { - bidReq := &openrtb.BidRequest{} + bidReq := &openrtb2.BidRequest{} setAuctionTypeImplicitly(bidReq) if bidReq.AT != 1 { @@ -757,21 +757,21 @@ func TestImplicitDNT(t *testing.T) { testCases := []struct { description string dntHeader string - request openrtb.BidRequest - expectedRequest openrtb.BidRequest + request openrtb2.BidRequest + expectedRequest openrtb2.BidRequest }{ { description: "Device Missing - Not Set In Header", dntHeader: "", - request: openrtb.BidRequest{}, - expectedRequest: openrtb.BidRequest{}, + request: openrtb2.BidRequest{}, + expectedRequest: openrtb2.BidRequest{}, }, { description: "Device Missing - Set To 0 In Header", dntHeader: "0", - request: openrtb.BidRequest{}, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + request: openrtb2.BidRequest{}, + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &disabled, }, }, @@ -779,9 +779,9 @@ func TestImplicitDNT(t *testing.T) { { description: "Device Missing - Set To 1 In Header", dntHeader: "1", - request: openrtb.BidRequest{}, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + request: openrtb2.BidRequest{}, + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, @@ -789,21 +789,21 @@ func TestImplicitDNT(t *testing.T) { { description: "Not Set In Request - Not Set In Header", dntHeader: "", - request: openrtb.BidRequest{ - Device: &openrtb.Device{}, + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{}, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{}, + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{}, }, }, { description: "Not Set In Request - Set To 0 In Header", dntHeader: "0", - request: openrtb.BidRequest{ - Device: &openrtb.Device{}, + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{}, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &disabled, }, }, @@ -811,11 +811,11 @@ func TestImplicitDNT(t *testing.T) { { description: "Not Set In Request - Set To 1 In Header", dntHeader: "1", - request: openrtb.BidRequest{ - Device: &openrtb.Device{}, + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{}, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, @@ -823,13 +823,13 @@ func TestImplicitDNT(t *testing.T) { { description: "Set In Request - Not Set In Header", dntHeader: "", - request: openrtb.BidRequest{ - Device: &openrtb.Device{ + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, @@ -837,13 +837,13 @@ func TestImplicitDNT(t *testing.T) { { description: "Set In Request - Set To 0 In Header", dntHeader: "0", - request: openrtb.BidRequest{ - Device: &openrtb.Device{ + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, @@ -851,13 +851,13 @@ func TestImplicitDNT(t *testing.T) { { description: "Set In Request - Set To 1 In Header", dntHeader: "1", - request: openrtb.BidRequest{ - Device: &openrtb.Device{ + request: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, - expectedRequest: openrtb.BidRequest{ - Device: &openrtb.Device{ + expectedRequest: openrtb2.BidRequest{ + Device: &openrtb2.Device{ DNT: &enabled, }, }, @@ -946,7 +946,7 @@ func TestImplicitSecure(t *testing.T) { httpReq := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(validRequest(t, "site.json"))) httpReq.Header.Set(http.CanonicalHeaderKey("X-Forwarded-Proto"), "https") - imps := []openrtb.Imp{ + imps := []openrtb2.Imp{ {}, {}, } @@ -961,7 +961,7 @@ func TestImplicitSecure(t *testing.T) { func TestRefererParsing(t *testing.T) { httpReq := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(validRequest(t, "site.json"))) httpReq.Header.Set("Referer", "http://test.mysite.com") - bidReq := &openrtb.BidRequest{} + bidReq := &openrtb2.BidRequest{} setSiteImplicitly(httpReq, bidReq) @@ -1123,8 +1123,8 @@ func TestImplicitAMPNoExt(t *testing.T) { return } - bidReq := openrtb.BidRequest{ - Site: &openrtb.Site{}, + bidReq := openrtb2.BidRequest{ + Site: &openrtb2.Site{}, } setSiteImplicitly(httpReq, &bidReq) assert.JSONEq(t, `{"amp":0}`, string(bidReq.Site.Ext)) @@ -1136,8 +1136,8 @@ func TestImplicitAMPOtherExt(t *testing.T) { return } - bidReq := openrtb.BidRequest{ - Site: &openrtb.Site{ + bidReq := openrtb2.BidRequest{ + Site: &openrtb2.Site{ Ext: json.RawMessage(`{"other":true}`), }, } @@ -1151,8 +1151,8 @@ func TestExplicitAMP(t *testing.T) { return } - bidReq := openrtb.BidRequest{ - Site: &openrtb.Site{ + bidReq := openrtb2.BidRequest{ + Site: &openrtb2.Site{ Ext: json.RawMessage(`{"amp":1}`), }, } @@ -1394,7 +1394,7 @@ func TestValidateImpExt(t *testing.T) { for _, group := range testGroups { for _, test := range group.testCases { - imp := &openrtb.Imp{Ext: test.impExt} + imp := &openrtb2.Imp{Ext: test.impExt} errs := deps.validateImpExt(imp, nil, 0) @@ -1438,20 +1438,20 @@ func TestCurrencyTrunc(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, Cur: []string{"USD", "EUR"}, @@ -1482,23 +1482,23 @@ func TestCCPAInvalid(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ Ext: json.RawMessage(`{"us_privacy": "invalid by length"}`), }, } @@ -1532,23 +1532,23 @@ func TestNoSaleInvalid(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ Ext: json.RawMessage(`{"us_privacy": "1NYN"}`), }, Ext: json.RawMessage(`{"prebid": {"nosale": ["*", "appnexus"]} }`), @@ -1583,20 +1583,20 @@ func TestValidateSourceTID(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, } @@ -1624,20 +1624,20 @@ func TestSChainInvalid(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, Ext: json.RawMessage(`{"prebid":{"schains":[{"bidders":["appnexus"],"schain":{"complete":1,"nodes":[{"asi":"directseller1.com","sid":"00001","rid":"BidRequest1","hp":1}],"ver":"1.0"}}, {"bidders":["appnexus"],"schain":{"complete":1,"nodes":[{"asi":"directseller2.com","sid":"00002","rid":"BidRequest2","hp":1}],"ver":"1.0"}}]}}`), @@ -1662,12 +1662,12 @@ func TestGetAccountID(t *testing.T) { testCases := []struct { description string - pub *openrtb.Publisher + pub *openrtb2.Publisher expectedAccID string }{ { description: "Publisher.ID and Publisher.Ext.Prebid.ParentAccount both present", - pub: &openrtb.Publisher{ + pub: &openrtb2.Publisher{ ID: testPubID, Ext: testPubExtJSON, }, @@ -1675,7 +1675,7 @@ func TestGetAccountID(t *testing.T) { }, { description: "Only Publisher.Ext.Prebid.ParentAccount present", - pub: &openrtb.Publisher{ + pub: &openrtb2.Publisher{ ID: "", Ext: testPubExtJSON, }, @@ -1683,14 +1683,14 @@ func TestGetAccountID(t *testing.T) { }, { description: "Only Publisher.ID present", - pub: &openrtb.Publisher{ + pub: &openrtb2.Publisher{ ID: testPubID, }, expectedAccID: testPubID, }, { description: "Neither Publisher.ID or Publisher.Ext.Prebid.ParentAccount present", - pub: &openrtb.Publisher{}, + pub: &openrtb2.Publisher{}, expectedAccID: metrics.PublisherUnknown, }, { @@ -1709,15 +1709,15 @@ func TestGetAccountID(t *testing.T) { func TestSanitizeRequest(t *testing.T) { testCases := []struct { description string - req *openrtb.BidRequest + req *openrtb2.BidRequest ipValidator iputil.IPValidator expectedIPv4 string expectedIPv6 string }{ { description: "Empty", - req: &openrtb.BidRequest{ - Device: &openrtb.Device{ + req: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ IP: "", IPv6: "", }, @@ -1727,8 +1727,8 @@ func TestSanitizeRequest(t *testing.T) { }, { description: "Valid", - req: &openrtb.BidRequest{ - Device: &openrtb.Device{ + req: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ IP: "1.1.1.1", IPv6: "1111::", }, @@ -1739,8 +1739,8 @@ func TestSanitizeRequest(t *testing.T) { }, { description: "Invalid", - req: &openrtb.BidRequest{ - Device: &openrtb.Device{ + req: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ IP: "1.1.1.1", IPv6: "1111::", }, @@ -1751,8 +1751,8 @@ func TestSanitizeRequest(t *testing.T) { }, { description: "Invalid - Wrong IP Types", - req: &openrtb.BidRequest{ - Device: &openrtb.Device{ + req: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ IP: "1111::", IPv6: "1.1.1.1", }, @@ -1763,8 +1763,8 @@ func TestSanitizeRequest(t *testing.T) { }, { description: "Malformed", - req: &openrtb.BidRequest{ - Device: &openrtb.Device{ + req: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ IP: "malformed", IPv6: "malformed", }, @@ -1785,26 +1785,26 @@ func TestValidateAndFillSourceTID(t *testing.T) { testTID := "some-tid" testCases := []struct { description string - req *openrtb.BidRequest + req *openrtb2.BidRequest expectRandTID bool expectedTID string }{ { description: "req.Source not present. Expecting a randomly generated TID value", - req: &openrtb.BidRequest{}, + req: &openrtb2.BidRequest{}, expectRandTID: true, }, { description: "req.Source.TID not present. Expecting a randomly generated TID value", - req: &openrtb.BidRequest{ - Source: &openrtb.Source{}, + req: &openrtb2.BidRequest{ + Source: &openrtb2.Source{}, }, expectRandTID: true, }, { description: "req.Source.TID present. Expecting no change", - req: &openrtb.BidRequest{ - Source: &openrtb.Source{ + req: &openrtb2.BidRequest{ + Source: &openrtb2.Source{ TID: testTID, }, }, @@ -1843,20 +1843,20 @@ func TestEidPermissionsInvalid(t *testing.T) { hardcodedResponseIPValidator{response: true}, } - ui := uint64(1) - req := openrtb.BidRequest{ + ui := int64(1) + req := openrtb2.BidRequest{ ID: "anyRequestID", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "anyImpID", - Banner: &openrtb.Banner{ + Banner: &openrtb2.Banner{ W: &ui, H: &ui, }, Ext: json.RawMessage(`{"appnexus": {"placementId": 5667}}`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "anySiteID", }, Ext: json.RawMessage(`{"prebid": {"data": {"eidpermissions": [{"source":"a", "bidders":[]}]} } }`), @@ -2150,39 +2150,39 @@ type warningsCheckExchange struct { auctionRequest exchange.AuctionRequest } -func (e *warningsCheckExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (e *warningsCheckExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { e.auctionRequest = r return nil, nil } // nobidExchange is a well-behaved exchange which always bids "no bid". type nobidExchange struct { - gotRequest *openrtb.BidRequest + gotRequest *openrtb2.BidRequest } -func (e *nobidExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (e *nobidExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { e.gotRequest = r.BidRequest - return &openrtb.BidResponse{ + return &openrtb2.BidResponse{ ID: r.BidRequest.ID, BidID: "test bid id", - NBR: openrtb.NoBidReasonCodeUnknownError.Ptr(), + NBR: openrtb2.NoBidReasonCodeUnknownError.Ptr(), }, nil } type mockBidExchange struct { - gotRequest *openrtb.BidRequest + gotRequest *openrtb2.BidRequest } // mockBidExchange is a well-behaved exchange that lists the bidders found in every bidRequest.Imp[i].Ext // into the bidResponse.Ext to assert the bidder adapters that were not filtered out in the validation process -func (e *mockBidExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { - bidResponse := &openrtb.BidResponse{ +func (e *mockBidExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { + bidResponse := &openrtb2.BidResponse{ ID: r.BidRequest.ID, BidID: "test bid id", - NBR: openrtb.NoBidReasonCodeUnknownError.Ptr(), + NBR: openrtb2.NoBidReasonCodeUnknownError.Ptr(), } if len(r.BidRequest.Imp) > 0 { - var SeatBidMap = make(map[string]openrtb.SeatBid, 0) + var SeatBidMap = make(map[string]openrtb2.SeatBid, 0) for _, imp := range r.BidRequest.Imp { var bidderExts map[string]json.RawMessage if err := json.Unmarshal(imp.Ext, &bidderExts); err != nil { @@ -2205,9 +2205,9 @@ func (e *mockBidExchange) HoldAuction(ctx context.Context, r exchange.AuctionReq for bidderNameOrAlias := range bidderExts { if isBidderToValidate(bidderNameOrAlias) { if val, ok := SeatBidMap[bidderNameOrAlias]; ok { - val.Bid = append(val.Bid, openrtb.Bid{ID: fmt.Sprintf("%s-bid", bidderNameOrAlias)}) + val.Bid = append(val.Bid, openrtb2.Bid{ID: fmt.Sprintf("%s-bid", bidderNameOrAlias)}) } else { - SeatBidMap[bidderNameOrAlias] = openrtb.SeatBid{Seat: fmt.Sprintf("%s-bids", bidderNameOrAlias), Bid: []openrtb.Bid{{ID: fmt.Sprintf("%s-bid", bidderNameOrAlias)}}} + SeatBidMap[bidderNameOrAlias] = openrtb2.SeatBid{Seat: fmt.Sprintf("%s-bids", bidderNameOrAlias), Bid: []openrtb2.Bid{{ID: fmt.Sprintf("%s-bid", bidderNameOrAlias)}}} } } } @@ -2222,7 +2222,7 @@ func (e *mockBidExchange) HoldAuction(ctx context.Context, r exchange.AuctionReq type brokenExchange struct{} -func (e *brokenExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (e *brokenExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { return nil, errors.New("Critical, unrecoverable error.") } @@ -2585,14 +2585,14 @@ func (af mockAccountFetcher) FetchAccount(ctx context.Context, accountID string) } type mockExchange struct { - lastRequest *openrtb.BidRequest + lastRequest *openrtb2.BidRequest } -func (m *mockExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (m *mockExchange) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { m.lastRequest = r.BidRequest - return &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ - Bid: []openrtb.Bid{{ + return &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ + Bid: []openrtb2.Bid{{ AdM: "", }}, }}, diff --git a/endpoints/openrtb2/interstitial.go b/endpoints/openrtb2/interstitial.go index b42945488cc..67f9bc37b28 100644 --- a/endpoints/openrtb2/interstitial.go +++ b/endpoints/openrtb2/interstitial.go @@ -4,13 +4,13 @@ import ( "encoding/json" "fmt" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" ) -func processInterstitials(req *openrtb.BidRequest) error { +func processInterstitials(req *openrtb2.BidRequest) error { var devExt openrtb_ext.ExtDevice unmarshalled := true for i := range req.Imp { @@ -38,8 +38,8 @@ func processInterstitials(req *openrtb.BidRequest) error { return nil } -func processInterstitialsForImp(imp *openrtb.Imp, devExt *openrtb_ext.ExtDevice, device *openrtb.Device) error { - var maxWidth, maxHeight, minWidth, minHeight uint64 +func processInterstitialsForImp(imp *openrtb2.Imp, devExt *openrtb_ext.ExtDevice, device *openrtb2.Device) error { + var maxWidth, maxHeight, minWidth, minHeight int64 if imp.Banner == nil { // custom interstitial support is only available for banner requests. return nil @@ -56,8 +56,8 @@ func processInterstitialsForImp(imp *openrtb.Imp, devExt *openrtb_ext.ExtDevice, maxWidth = device.W maxHeight = device.H } - minWidth = (maxWidth * devExt.Prebid.Interstitial.MinWidthPerc) / 100 - minHeight = (maxHeight * devExt.Prebid.Interstitial.MinHeightPerc) / 100 + minWidth = (maxWidth * int64(devExt.Prebid.Interstitial.MinWidthPerc)) / 100 + minHeight = (maxHeight * int64(devExt.Prebid.Interstitial.MinHeightPerc)) / 100 imp.Banner.Format = genInterstitialFormat(minWidth, maxWidth, minHeight, maxHeight) if len(imp.Banner.Format) == 0 { return &errortypes.BadInput{Message: fmt.Sprintf("Unable to set interstitial size list for Imp id=%s (No valid sizes between %dx%d and %dx%d)", imp.ID, minWidth, minHeight, maxWidth, maxHeight)} @@ -65,10 +65,10 @@ func processInterstitialsForImp(imp *openrtb.Imp, devExt *openrtb_ext.ExtDevice, return nil } -func genInterstitialFormat(minWidth, maxWidth, minHeight, maxHeight uint64) []openrtb.Format { +func genInterstitialFormat(minWidth, maxWidth, minHeight, maxHeight int64) []openrtb2.Format { sizes := make([]config.InterstitialSize, 0, 10) for _, size := range config.ResolvedInterstitialSizes { - if size.Width >= minWidth && size.Width <= maxWidth && size.Height >= minHeight && size.Height <= maxHeight { + if int64(size.Width) >= minWidth && int64(size.Width) <= maxWidth && int64(size.Height) >= minHeight && int64(size.Height) <= maxHeight { sizes = append(sizes, size) if len(sizes) >= 10 { // we have enough sizes @@ -76,9 +76,9 @@ func genInterstitialFormat(minWidth, maxWidth, minHeight, maxHeight uint64) []op } } } - formatList := make([]openrtb.Format, 0, len(sizes)) + formatList := make([]openrtb2.Format, 0, len(sizes)) for _, size := range sizes { - formatList = append(formatList, openrtb.Format{W: size.Width, H: size.Height}) + formatList = append(formatList, openrtb2.Format{W: int64(size.Width), H: int64(size.Height)}) } return formatList } diff --git a/endpoints/openrtb2/interstitial_test.go b/endpoints/openrtb2/interstitial_test.go index 1c6eb2555db..7691a6672e0 100644 --- a/endpoints/openrtb2/interstitial_test.go +++ b/endpoints/openrtb2/interstitial_test.go @@ -4,17 +4,17 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) -var request = &openrtb.BidRequest{ +var request = &openrtb2.BidRequest{ ID: "some-id", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "my-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{ { W: 300, H: 600, @@ -25,7 +25,7 @@ var request = &openrtb.BidRequest{ Ext: json.RawMessage(`{"appnexus": {"placementId": 12883451}}`), }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ H: 640, W: 320, Ext: json.RawMessage(`{"prebid": {"interstitial": {"minwidthperc": 60, "minheightperc": 60}}}`), @@ -37,7 +37,7 @@ func TestInterstitial(t *testing.T) { if err := processInterstitials(myRequest); err != nil { t.Fatalf("Error processing interstitials: %v", err) } - targetFormat := []openrtb.Format{ + targetFormat := []openrtb2.Format{ { W: 300, H: 600, diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxbitrate-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxbitrate-negative.json new file mode 100644 index 00000000000..62a96050121 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxbitrate-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative audio max bitrate.", + + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp4"], + "maxbitrate": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].audio.maxbitrate must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxseq-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxseq-negative.json new file mode 100644 index 00000000000..5eb48e0c396 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/audio-maxseq-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative audio max sequence.", + + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp4"], + "maxseq": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].audio.maxseq must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/audio-minbitrate-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/audio-minbitrate-negative.json new file mode 100644 index 00000000000..304b77e2165 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/audio-minbitrate-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative audio min bitrate.", + + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp4"], + "minbitrate": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].audio.minbitrate must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/audio-sequence-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/audio-sequence-negative.json new file mode 100644 index 00000000000..2c1e181d96b --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/audio-sequence-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative audio sequence.", + + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "some-imp-id", + "audio": { + "mimes": ["audio/mp4"], + "sequence": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].audio.sequence must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/banner-h-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/banner-h-negative.json new file mode 100644 index 00000000000..b4ab8eefadb --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/banner-h-negative.json @@ -0,0 +1,23 @@ +{ + "description": "Request has a negative banner height.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": -1 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.h must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/banner-w-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/banner-w-negative.json new file mode 100644 index 00000000000..968cc366b8f --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/banner-w-negative.json @@ -0,0 +1,23 @@ +{ + "description": "Request has a negative banner width.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": -1, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.w must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/device-geo-accuracy-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/device-geo-accuracy-negative.json new file mode 100644 index 00000000000..ce9cf24a860 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/device-geo-accuracy-negative.json @@ -0,0 +1,30 @@ +{ + "description": "Request has a negative device geography accuracy.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "device": { + "w": 50, + "h": 50, + "geo": { + "accuracy": -1 + } + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.device.geo.accuracy must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/device-h-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/device-h-negative.json new file mode 100644 index 00000000000..12a0b6cb662 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/device-h-negative.json @@ -0,0 +1,27 @@ +{ + "description": "Request has a negative device height.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "device": { + "w": 50, + "h": -1 + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.device.h must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/device-ppi-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/device-ppi-negative.json new file mode 100644 index 00000000000..8ca2c03c198 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/device-ppi-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative PPI height.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "device": { + "w": 50, + "h": 50, + "ppi": -1 + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.device.ppi must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/device-w-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/device-w-negative.json new file mode 100644 index 00000000000..f3c17cee1f8 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/device-w-negative.json @@ -0,0 +1,27 @@ +{ + "description": "Request has a negative device width.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "device": { + "w": -1, + "h": 50 + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.device.w must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/format-h-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/format-h-negative.json new file mode 100644 index 00000000000..3d47c9a00ec --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/format-h-negative.json @@ -0,0 +1,20 @@ +{ + "description": "Request has a negative banner format height.", + "mockBidRequest": { + "id": "req-id", + "imp": [{ + "id": "imp-id", + "banner": { + "format": [{ + "w": 50, + "h": -1 + }] + } + }], + "app": { + "id": "app_001" + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.format[0].h must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/format-hratio-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/format-hratio-negative.json new file mode 100644 index 00000000000..93832f566ae --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/format-hratio-negative.json @@ -0,0 +1,21 @@ +{ + "description": "Request has a negative banner format height ratio.", + "mockBidRequest": { + "id": "req-id", + "imp": [{ + "id": "imp-id", + "banner": { + "format": [{ + "w": 50, + "h": 50, + "hratio": -1 + }] + } + }], + "app": { + "id": "app_001" + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.format[0].hratio must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/format-w-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/format-w-negative.json new file mode 100644 index 00000000000..7e845c63bcd --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/format-w-negative.json @@ -0,0 +1,20 @@ +{ + "description": "Request has a negative banner format width.", + "mockBidRequest": { + "id": "req-id", + "imp": [{ + "id": "imp-id", + "banner": { + "format": [{ + "w": -1, + "h": 50 + }] + } + }], + "app": { + "id": "app_001" + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.format[0].w must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/format-wmin-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/format-wmin-negative.json new file mode 100644 index 00000000000..ed618c0f459 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/format-wmin-negative.json @@ -0,0 +1,21 @@ +{ + "description": "Request has a negative banner format width minimum.", + "mockBidRequest": { + "id": "req-id", + "imp": [{ + "id": "imp-id", + "banner": { + "format": [{ + "w": 50, + "h": 50, + "wmin": -1 + }] + } + }], + "app": { + "id": "app_001" + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.format[0].wmin must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/format-wratio-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/format-wratio-negative.json new file mode 100644 index 00000000000..84c72b47d69 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/format-wratio-negative.json @@ -0,0 +1,21 @@ +{ + "description": "Request has a negative banner format width ratio.", + "mockBidRequest": { + "id": "req-id", + "imp": [{ + "id": "imp-id", + "banner": { + "format": [{ + "w": 50, + "h": 50, + "wratio": -1 + }] + } + }], + "app": { + "id": "app_001" + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].banner.format[0].wratio must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/user-geo-accuracy-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/user-geo-accuracy-negative.json new file mode 100644 index 00000000000..163a88eeb79 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/user-geo-accuracy-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative user geography accuracy.", + "mockBidRequest": { + "id": "req-id", + "site": { + "id": "some-site" + }, + "imp": [{ + "id": "imp-id", + "banner": { + "w": 50, + "h": 50 + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }], + "user": { + "geo": { + "accuracy": -1 + } + } + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.user.geo.accuracy must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/video-h-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/video-h-negative.json new file mode 100644 index 00000000000..2534dd626ea --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/video-h-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative video height.", + + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "imp-id", + "video": { + "mimes": ["video/mp4"], + "h": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].video.h must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/video-maxbitrate-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/video-maxbitrate-negative.json new file mode 100644 index 00000000000..07c1af1d9a1 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/video-maxbitrate-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative video max bitrate.", + + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "imp-id", + "video": { + "mimes": ["video/mp4"], + "maxbitrate": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].video.maxbitrate must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/video-minbitrate-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/video-minbitrate-negative.json new file mode 100644 index 00000000000..54ead28e8e2 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/video-minbitrate-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative video min bitrate.", + + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "imp-id", + "video": { + "mimes": ["video/mp4"], + "minbitrate": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].video.minbitrate must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-whole/video-w-negative.json b/endpoints/openrtb2/sample-requests/invalid-whole/video-w-negative.json new file mode 100644 index 00000000000..cf50e8eddd7 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-whole/video-w-negative.json @@ -0,0 +1,28 @@ +{ + "description": "Request has a negative video width.", + + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "imp-id", + "video": { + "mimes": ["video/mp4"], + "w": -1 + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12345 + } + } + } + } + }] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request: request.imp[0].video.w must be a positive number" +} \ No newline at end of file diff --git a/endpoints/openrtb2/video_auction.go b/endpoints/openrtb2/video_auction.go index 7735d886730..f46a8c2a1d5 100644 --- a/endpoints/openrtb2/video_auction.go +++ b/endpoints/openrtb2/video_auction.go @@ -17,12 +17,12 @@ import ( "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" "github.com/gofrs/uuid" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/util/iputil" "github.com/golang/glog" "github.com/julienschmidt/httprouter" - "github.com/mxmCherry/openrtb" accountService "github.com/prebid/prebid-server/account" "github.com/prebid/prebid-server/analytics" "github.com/prebid/prebid-server/config" @@ -197,7 +197,7 @@ func (deps *endpointDeps) VideoAuctionEndpoint(w http.ResponseWriter, r *http.Re vo.VideoRequest = videoBidReq - var bidReq = &openrtb.BidRequest{} + var bidReq = &openrtb2.BidRequest{} if deps.defaultRequest { if err := json.Unmarshal(deps.defReqJSON, bidReq); err != nil { err = fmt.Errorf("Invalid JSON in Default Request Settings: %s", err) @@ -370,13 +370,13 @@ func handleError(labels *metrics.Labels, w http.ResponseWriter, errL []error, vo vo.Errors = append(vo.Errors, errL...) } -func (deps *endpointDeps) createImpressions(videoReq *openrtb_ext.BidRequestVideo, podErrors []PodError) ([]openrtb.Imp, []PodError) { +func (deps *endpointDeps) createImpressions(videoReq *openrtb_ext.BidRequestVideo, podErrors []PodError) ([]openrtb2.Imp, []PodError) { videoDur := videoReq.PodConfig.DurationRangeSec minDuration, maxDuration := minMax(videoDur) reqExactDur := videoReq.PodConfig.RequireExactDuration videoData := videoReq.Video - finalImpsArray := make([]openrtb.Imp, 0) + finalImpsArray := make([]openrtb2.Imp, 0) for ind, pod := range videoReq.PodConfig.Pods { //load stored impression @@ -400,7 +400,7 @@ func (deps *endpointDeps) createImpressions(videoReq *openrtb_ext.BidRequestVide } impDivNumber := numImps / len(videoDur) - impsArray := make([]openrtb.Imp, numImps) + impsArray := make([]openrtb2.Imp, numImps) for impInd := range impsArray { newImp := createImpressionTemplate(storedImp, videoData) impsArray[impInd] = newImp @@ -432,18 +432,18 @@ func max(a, b int) int { return b } -func createImpressionTemplate(imp openrtb.Imp, video *openrtb.Video) openrtb.Imp { +func createImpressionTemplate(imp openrtb2.Imp, video *openrtb2.Video) openrtb2.Imp { //for every new impression we need to have it's own copy of video object, because we customize it in further processing newVideo := *video imp.Video = &newVideo return imp } -func (deps *endpointDeps) loadStoredImp(storedImpId string) (openrtb.Imp, []error) { +func (deps *endpointDeps) loadStoredImp(storedImpId string) (openrtb2.Imp, []error) { ctx, cancel := context.WithTimeout(context.Background(), time.Duration(storedRequestTimeoutMillis)*time.Millisecond) defer cancel() - impr := openrtb.Imp{} + impr := openrtb2.Imp{} _, imp, err := deps.storedReqFetcher.FetchRequests(ctx, []string{}, []string{storedImpId}) if err != nil { return impr, err @@ -469,7 +469,7 @@ func minMax(array []int) (int, int) { return min, max } -func buildVideoResponse(bidresponse *openrtb.BidResponse, podErrors []PodError) (*openrtb_ext.BidResponseVideo, error) { +func buildVideoResponse(bidresponse *openrtb2.BidResponse, podErrors []PodError) (*openrtb_ext.BidResponseVideo, error) { adPods := make([]*openrtb_ext.AdPod, 0) anyBidsReturned := false @@ -561,7 +561,7 @@ func getVideoStoredRequestId(request []byte) (string, error) { return string(value), nil } -func mergeData(videoRequest *openrtb_ext.BidRequestVideo, bidRequest *openrtb.BidRequest) error { +func mergeData(videoRequest *openrtb_ext.BidRequestVideo, bidRequest *openrtb2.BidRequest) error { if videoRequest.Site != nil { bidRequest.Site = videoRequest.Site diff --git a/endpoints/openrtb2/video_auction_test.go b/endpoints/openrtb2/video_auction_test.go index a70d45ac3b8..16dc02ee97b 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -12,7 +12,7 @@ import ( "strings" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/analytics" analyticsConf "github.com/prebid/prebid-server/analytics/config" "github.com/prebid/prebid-server/config" @@ -364,7 +364,7 @@ func TestVideoEndpointValidationsPositive(t *testing.T) { mimes = append(mimes, "mp4") mimes = append(mimes, "") - videoProtocols := make([]openrtb.Protocol, 0) + videoProtocols := make([]openrtb2.Protocol, 0) videoProtocols = append(videoProtocols, 15) videoProtocols = append(videoProtocols, 30) @@ -375,13 +375,13 @@ func TestVideoEndpointValidationsPositive(t *testing.T) { RequireExactDuration: true, Pods: pods, }, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "pbs.com", }, IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ PrimaryAdserver: 1, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: mimes, Protocols: videoProtocols, }, @@ -407,7 +407,7 @@ func TestVideoEndpointValidationsCritical(t *testing.T) { mimes = append(mimes, "") mimes = append(mimes, "") - videoProtocols := make([]openrtb.Protocol, 0) + videoProtocols := make([]openrtb2.Protocol, 0) req := openrtb_ext.BidRequestVideo{ StoredRequestId: "", @@ -419,7 +419,7 @@ func TestVideoEndpointValidationsCritical(t *testing.T) { IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ PrimaryAdserver: 0, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: mimes, Protocols: videoProtocols, }, @@ -476,7 +476,7 @@ func TestVideoEndpointValidationsPodErrors(t *testing.T) { mimes = append(mimes, "mp4") mimes = append(mimes, "") - videoProtocols := make([]openrtb.Protocol, 0) + videoProtocols := make([]openrtb2.Protocol, 0) videoProtocols = append(videoProtocols, 15) videoProtocols = append(videoProtocols, 30) @@ -487,13 +487,13 @@ func TestVideoEndpointValidationsPodErrors(t *testing.T) { RequireExactDuration: true, Pods: pods, }, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "pbs.com", }, IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ PrimaryAdserver: 1, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: mimes, Protocols: videoProtocols, }, @@ -546,7 +546,7 @@ func TestVideoEndpointValidationsSiteAndApp(t *testing.T) { mimes = append(mimes, "mp4") mimes = append(mimes, "") - videoProtocols := make([]openrtb.Protocol, 0) + videoProtocols := make([]openrtb2.Protocol, 0) videoProtocols = append(videoProtocols, 15) videoProtocols = append(videoProtocols, 30) @@ -557,16 +557,16 @@ func TestVideoEndpointValidationsSiteAndApp(t *testing.T) { RequireExactDuration: true, Pods: pods, }, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "pbs.com", }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ ID: "pbs.com", }, IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ PrimaryAdserver: 1, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: mimes, Protocols: videoProtocols, }, @@ -604,7 +604,7 @@ func TestVideoEndpointValidationsSiteMissingRequiredField(t *testing.T) { mimes = append(mimes, "mp4") mimes = append(mimes, "") - videoProtocols := make([]openrtb.Protocol, 0) + videoProtocols := make([]openrtb2.Protocol, 0) videoProtocols = append(videoProtocols, 15) videoProtocols = append(videoProtocols, 30) @@ -615,13 +615,13 @@ func TestVideoEndpointValidationsSiteMissingRequiredField(t *testing.T) { RequireExactDuration: true, Pods: pods, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ Domain: "pbs.com", }, IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ PrimaryAdserver: 1, }, - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: mimes, Protocols: videoProtocols, }, @@ -655,7 +655,7 @@ func TestVideoEndpointValidationsMissingVideo(t *testing.T) { }, }, }, - App: &openrtb.App{ + App: &openrtb2.App{ Bundle: "pbs.com", }, IncludeBrandCategory: &openrtb_ext.IncludeBrandCategory{ @@ -670,16 +670,16 @@ func TestVideoEndpointValidationsMissingVideo(t *testing.T) { } func TestVideoBuildVideoResponseMissedCacheForOneBid(t *testing.T) { - openRtbBidResp := openrtb.BidResponse{} + openRtbBidResp := openrtb2.BidResponse{} podErrors := make([]PodError, 0) - seatBids := make([]openrtb.SeatBid, 0) - seatBid := openrtb.SeatBid{} + seatBids := make([]openrtb2.SeatBid, 0) + seatBid := openrtb2.SeatBid{} - bids := make([]openrtb.Bid, 0) - bid1 := openrtb.Bid{} - bid2 := openrtb.Bid{} - bid3 := openrtb.Bid{} + bids := make([]openrtb2.Bid, 0) + bid1 := openrtb2.Bid{} + bid2 := openrtb2.Bid{} + bid3 := openrtb2.Bid{} extBid1 := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"17.00","hb_pb_cat_dur_appnex":"17.00_123_30s","hb_size":"1x1","hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"}}}`) extBid2 := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"17.00","hb_pb_cat_dur_appnex":"17.00_456_30s","hb_size":"1x1","hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"}}}`) @@ -708,16 +708,16 @@ func TestVideoBuildVideoResponseMissedCacheForOneBid(t *testing.T) { } func TestVideoBuildVideoResponseMissedCacheForAllBids(t *testing.T) { - openRtbBidResp := openrtb.BidResponse{} + openRtbBidResp := openrtb2.BidResponse{} podErrors := make([]PodError, 0) - seatBids := make([]openrtb.SeatBid, 0) - seatBid := openrtb.SeatBid{} + seatBids := make([]openrtb2.SeatBid, 0) + seatBid := openrtb2.SeatBid{} - bids := make([]openrtb.Bid, 0) - bid1 := openrtb.Bid{} - bid2 := openrtb.Bid{} - bid3 := openrtb.Bid{} + bids := make([]openrtb2.Bid, 0) + bid1 := openrtb2.Bid{} + bid2 := openrtb2.Bid{} + bid3 := openrtb2.Bid{} extBid1 := []byte(`{"prebid":{"targeting":{"hb_bidder":"appnexus","hb_pb":"17.00","hb_pb_cat_dur":"17.00_123_30s","hb_size":"1x1"}}}`) extBid2 := []byte(`{"prebid":{"targeting":{"hb_bidder":"appnexus","hb_pb":"17.00","hb_pb_cat_dur":"17.00_456_30s","hb_size":"1x1"}}}`) @@ -742,15 +742,15 @@ func TestVideoBuildVideoResponseMissedCacheForAllBids(t *testing.T) { } func TestVideoBuildVideoResponsePodErrors(t *testing.T) { - openRtbBidResp := openrtb.BidResponse{} + openRtbBidResp := openrtb2.BidResponse{} podErrors := make([]PodError, 0, 2) - seatBids := make([]openrtb.SeatBid, 0) - seatBid := openrtb.SeatBid{} + seatBids := make([]openrtb2.SeatBid, 0) + seatBid := openrtb2.SeatBid{} - bids := make([]openrtb.Bid, 0) - bid1 := openrtb.Bid{} - bid2 := openrtb.Bid{} + bids := make([]openrtb2.Bid, 0) + bid1 := openrtb2.Bid{} + bid2 := openrtb2.Bid{} extBid1 := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"17.00","hb_pb_cat_dur_appnex":"17.00_123_30s","hb_size":"1x1","hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"}}}`) extBid2 := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"17.00","hb_pb_cat_dur_appnex":"17.00_456_30s","hb_size":"1x1","hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"}}}`) @@ -785,30 +785,30 @@ func TestVideoBuildVideoResponsePodErrors(t *testing.T) { } func TestVideoBuildVideoResponseNoBids(t *testing.T) { - openRtbBidResp := openrtb.BidResponse{} + openRtbBidResp := openrtb2.BidResponse{} podErrors := make([]PodError, 0, 0) - openRtbBidResp.SeatBid = make([]openrtb.SeatBid, 0) + openRtbBidResp.SeatBid = make([]openrtb2.SeatBid, 0) bidRespVideo, err := buildVideoResponse(&openRtbBidResp, podErrors) assert.NoError(t, err, "Error should be nil") assert.Len(t, bidRespVideo.AdPods, 0, "AdPods length should be 0") } func TestMergeOpenRTBToVideoRequest(t *testing.T) { - var bidReq = &openrtb.BidRequest{} + var bidReq = &openrtb2.BidRequest{} var videoReq = &openrtb_ext.BidRequestVideo{} - videoReq.App = &openrtb.App{ + videoReq.App = &openrtb2.App{ Domain: "test.com", Bundle: "test.bundle", } - videoReq.Site = &openrtb.Site{ + videoReq.Site = &openrtb2.Site{ Page: "site.com/index", } var dnt int8 = 4 var lmt int8 = 5 - videoReq.Device = openrtb.Device{ + videoReq.Device = openrtb2.Device{ DNT: &dnt, Lmt: &lmt, } @@ -816,11 +816,11 @@ func TestMergeOpenRTBToVideoRequest(t *testing.T) { videoReq.BCat = []string{"test1", "test2"} videoReq.BAdv = []string{"test3", "test4"} - videoReq.Regs = &openrtb.Regs{ + videoReq.Regs = &openrtb2.Regs{ Ext: json.RawMessage(`{"gdpr":1,"us_privacy":"1NYY","existing":"any","consent":"anyConsent"}`), } - videoReq.User = &openrtb.User{ + videoReq.User = &openrtb2.User{ BuyerUID: "test UID", Yob: 1980, Keywords: "test keywords", @@ -1057,27 +1057,27 @@ func TestHandleErrorDebugLog(t *testing.T) { func TestCreateImpressionTemplate(t *testing.T) { - imp := openrtb.Imp{} - imp.Video = &openrtb.Video{} - imp.Video.Protocols = []openrtb.Protocol{1, 2} + imp := openrtb2.Imp{} + imp.Video = &openrtb2.Video{} + imp.Video.Protocols = []openrtb2.Protocol{1, 2} imp.Video.MIMEs = []string{"video/mp4"} imp.Video.H = 200 imp.Video.W = 400 - imp.Video.PlaybackMethod = []openrtb.PlaybackMethod{5, 6} + imp.Video.PlaybackMethod = []openrtb2.PlaybackMethod{5, 6} - video := openrtb.Video{} - video.Protocols = []openrtb.Protocol{3, 4} + video := openrtb2.Video{} + video.Protocols = []openrtb2.Protocol{3, 4} video.MIMEs = []string{"video/flv"} video.H = 300 video.W = 0 - video.PlaybackMethod = []openrtb.PlaybackMethod{7, 8} + video.PlaybackMethod = []openrtb2.PlaybackMethod{7, 8} res := createImpressionTemplate(imp, &video) - assert.Equal(t, res.Video.Protocols, []openrtb.Protocol{3, 4}, "Incorrect video protocols") + assert.Equal(t, res.Video.Protocols, []openrtb2.Protocol{3, 4}, "Incorrect video protocols") assert.Equal(t, res.Video.MIMEs, []string{"video/flv"}, "Incorrect video MIMEs") assert.Equal(t, int(res.Video.H), 300, "Incorrect video height") assert.Equal(t, int(res.Video.W), 0, "Incorrect video width") - assert.Equal(t, res.Video.PlaybackMethod, []openrtb.PlaybackMethod{7, 8}, "Incorrect video playback method") + assert.Equal(t, res.Video.PlaybackMethod, []openrtb2.PlaybackMethod{7, 8}, "Incorrect video playback method") } func TestCCPA(t *testing.T) { @@ -1331,20 +1331,20 @@ func (cf mockVideoStoredReqFetcher) FetchRequests(ctx context.Context, requestID } type mockExchangeVideo struct { - lastRequest *openrtb.BidRequest + lastRequest *openrtb2.BidRequest cache *mockCacheClient } -func (m *mockExchangeVideo) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (m *mockExchangeVideo) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { m.lastRequest = r.BidRequest if debugLog != nil && debugLog.Enabled { m.cache.called = true } ext := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"20.00","hb_pb_cat_dur_appnex":"20.00_395_30s","hb_size":"1x1", "hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"},"type":"video","dealpriority":0,"dealtiersatisfied":false},"bidder":{"appnexus":{"brand_id":1,"auction_id":7840037870526938650,"bidder_id":2,"bid_ad_type":1,"creative_info":{"video":{"duration":30,"mimes":["video\/mp4"]}}}}}`) - return &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ + return &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ Seat: "appnexus", - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ {ID: "01", ImpID: "1_0", Ext: ext}, {ID: "02", ImpID: "1_1", Ext: ext}, {ID: "03", ImpID: "1_2", Ext: ext}, @@ -1367,20 +1367,20 @@ func (m *mockExchangeVideo) HoldAuction(ctx context.Context, r exchange.AuctionR } type mockExchangeAppendBidderNames struct { - lastRequest *openrtb.BidRequest + lastRequest *openrtb2.BidRequest cache *mockCacheClient } -func (m *mockExchangeAppendBidderNames) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (m *mockExchangeAppendBidderNames) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { m.lastRequest = r.BidRequest if debugLog != nil && debugLog.Enabled { m.cache.called = true } ext := []byte(`{"prebid":{"targeting":{"hb_bidder_appnexus":"appnexus","hb_pb_appnexus":"20.00","hb_pb_cat_dur_appnex":"20.00_395_30s_appnexus","hb_size":"1x1", "hb_uuid_appnexus":"837ea3b7-5598-4958-8c45-8e9ef2bf7cc1"},"type":"video"},"bidder":{"appnexus":{"brand_id":1,"auction_id":7840037870526938650,"bidder_id":2,"bid_ad_type":1,"creative_info":{"video":{"duration":30,"mimes":["video\/mp4"]}}}}}`) - return &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{ + return &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{ Seat: "appnexus", - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ {ID: "01", ImpID: "1_0", Ext: ext}, {ID: "02", ImpID: "1_1", Ext: ext}, {ID: "03", ImpID: "1_2", Ext: ext}, @@ -1403,14 +1403,14 @@ func (m *mockExchangeAppendBidderNames) HoldAuction(ctx context.Context, r excha } type mockExchangeVideoNoBids struct { - lastRequest *openrtb.BidRequest + lastRequest *openrtb2.BidRequest cache *mockCacheClient } -func (m *mockExchangeVideoNoBids) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb.BidResponse, error) { +func (m *mockExchangeVideoNoBids) HoldAuction(ctx context.Context, r exchange.AuctionRequest, debugLog *exchange.DebugLog) (*openrtb2.BidResponse, error) { m.lastRequest = r.BidRequest - return &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{{}}, + return &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{{}}, }, nil } diff --git a/exchange/adapter_util_test.go b/exchange/adapter_util_test.go index 7420779f787..73a456f54b1 100644 --- a/exchange/adapter_util_test.go +++ b/exchange/adapter_util_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/adapters/appnexus" "github.com/prebid/prebid-server/adapters/lifestreet" @@ -371,7 +371,7 @@ func TestGetDisabledBiddersErrorMessages(t *testing.T) { type fakeAdaptedBidder struct{} -func (fakeAdaptedBidder) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { +func (fakeAdaptedBidder) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { return nil, nil } @@ -379,11 +379,11 @@ type fakeBidder struct { name string } -func (fakeBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (fakeBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { return nil, nil } -func (fakeBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (fakeBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { return nil, nil } diff --git a/exchange/auction.go b/exchange/auction.go index 97f82d3c6eb..b3878709c29 100644 --- a/exchange/auction.go +++ b/exchange/auction.go @@ -11,7 +11,7 @@ import ( "time" uuid "github.com/gofrs/uuid" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/prebid_cache_client" @@ -125,7 +125,7 @@ func newAuction(seatBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, numImps int } // isNewWinningBid calculates if the new bid (nbid) will win against the current winning bid (wbid) given preferDeals. -func isNewWinningBid(bid, wbid *openrtb.Bid, preferDeals bool) bool { +func isNewWinningBid(bid, wbid *openrtb2.Bid, preferDeals bool) bool { if preferDeals { if len(wbid.DealID) > 0 && len(bid.DealID) == 0 { return false @@ -147,7 +147,7 @@ func (a *auction) setRoundedPrices(priceGranularity openrtb_ext.PriceGranularity a.roundedPrices = roundedPrices } -func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, targData *targetData, evTracking *eventTracking, bidRequest *openrtb.BidRequest, ttlBuffer int64, defaultTTLs *config.DefaultTTLs, bidCategory map[string]string, debugLog *DebugLog) []error { +func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, targData *targetData, evTracking *eventTracking, bidRequest *openrtb2.BidRequest, ttlBuffer int64, defaultTTLs *config.DefaultTTLs, bidCategory map[string]string, debugLog *DebugLog) []error { var bids, vast, includeBidderKeys, includeWinners bool = targData.includeCacheBids, targData.includeCacheVast, targData.includeBidderKeys, targData.includeWinners if !((bids || vast) && (includeBidderKeys || includeWinners)) { return nil @@ -155,8 +155,8 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, var errs []error expectNumBids := valOrZero(bids, len(a.roundedPrices)) expectNumVast := valOrZero(vast, len(a.roundedPrices)) - bidIndices := make(map[int]*openrtb.Bid, expectNumBids) - vastIndices := make(map[int]*openrtb.Bid, expectNumVast) + bidIndices := make(map[int]*openrtb2.Bid, expectNumBids) + vastIndices := make(map[int]*openrtb2.Bid, expectNumVast) toCache := make([]prebid_cache_client.Cacheable, 0, expectNumBids+expectNumVast) expByImp := make(map[string]int64) competitiveExclusion := false @@ -257,7 +257,7 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, } if bids { - a.cacheIds = make(map[*openrtb.Bid]string, len(bidIndices)) + a.cacheIds = make(map[*openrtb2.Bid]string, len(bidIndices)) for index, bid := range bidIndices { if ids[index] != "" { a.cacheIds[bid] = ids[index] @@ -265,7 +265,7 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, } } if vast { - a.vastCacheIds = make(map[*openrtb.Bid]string, len(vastIndices)) + a.vastCacheIds = make(map[*openrtb2.Bid]string, len(vastIndices)) for index, bid := range vastIndices { if ids[index] != "" { if competitiveExclusion && strings.HasSuffix(ids[index], hbCacheID) { @@ -282,7 +282,7 @@ func (a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, // makeVAST returns some VAST XML for the given bid. If AdM is defined, // it takes precedence. Otherwise the Nurl will be wrapped in a redirect tag. -func makeVAST(bid *openrtb.Bid) string { +func makeVAST(bid *openrtb2.Bid) string { if bid.AdM == "" { return `` + `prebid.org wrapper` + @@ -355,7 +355,7 @@ type auction struct { // roundedPrices stores the price strings rounded for each bid according to the price granularity. roundedPrices map[*pbsOrtbBid]string // cacheIds stores the UUIDs from Prebid Cache for fetching the full bid JSON. - cacheIds map[*openrtb.Bid]string + cacheIds map[*openrtb2.Bid]string // vastCacheIds stores UUIDS from Prebid cache for fetching the VAST markup to video bids. - vastCacheIds map[*openrtb.Bid]string + vastCacheIds map[*openrtb2.Bid]string } diff --git a/exchange/auction_test.go b/exchange/auction_test.go index 7e8a8a8cec9..bd32607bdf3 100644 --- a/exchange/auction_test.go +++ b/exchange/auction_test.go @@ -11,17 +11,17 @@ import ( "strconv" "testing" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/prebid_cache_client" - "github.com/mxmCherry/openrtb" "github.com/stretchr/testify/assert" ) func TestMakeVASTGiven(t *testing.T) { const expect = `` - bid := &openrtb.Bid{ + bid := &openrtb2.Bid{ AdM: expect, } vast := makeVAST(bid) @@ -35,7 +35,7 @@ func TestMakeVASTNurl(t *testing.T) { `` + `` + `` - bid := &openrtb.Bid{ + bid := &openrtb2.Bid{ NURL: url, } vast := makeVAST(bid) @@ -268,45 +268,45 @@ func runCacheSpec(t *testing.T, fileDisplayName string, specData *cacheSpec) { func TestNewAuction(t *testing.T) { bid1p077 := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp1", Price: 0.77, }, } bid1p123 := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp1", Price: 1.23, }, } bid1p230 := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp1", Price: 2.30, }, } bid1p088d := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp1", Price: 0.88, DealID: "SpecialDeal", }, } bid1p166d := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp1", Price: 1.66, DealID: "BigDeal", }, } bid2p123 := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp2", Price: 1.23, }, } bid2p144 := pbsOrtbBid{ - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "imp2", Price: 1.44, }, @@ -486,7 +486,7 @@ func TestNewAuction(t *testing.T) { } type cacheSpec struct { - BidRequest openrtb.BidRequest `json:"bidRequest"` + BidRequest openrtb2.BidRequest `json:"bidRequest"` PbsBids []pbsBid `json:"pbsBids"` ExpectedCacheables []prebid_cache_client.Cacheable `json:"expectedCacheables"` DefaultTTLs config.DefaultTTLs `json:"defaultTTLs"` @@ -500,7 +500,7 @@ type cacheSpec struct { } type pbsBid struct { - Bid *openrtb.Bid `json:"bid"` + Bid *openrtb2.Bid `json:"bid"` BidType openrtb_ext.BidType `json:"bidType"` Bidder openrtb_ext.BidderName `json:"bidder"` } diff --git a/exchange/bidder.go b/exchange/bidder.go index b0818dfdbe3..d6b8028c2e9 100644 --- a/exchange/bidder.go +++ b/exchange/bidder.go @@ -16,9 +16,9 @@ import ( "github.com/prebid/prebid-server/config/util" "github.com/prebid/prebid-server/currency" - "github.com/mxmCherry/openrtb" - nativeRequests "github.com/mxmCherry/openrtb/native/request" - nativeResponse "github.com/mxmCherry/openrtb/native/response" + nativeRequests "github.com/mxmCherry/openrtb/v14/native1/request" + nativeResponse "github.com/mxmCherry/openrtb/v14/native1/response" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" @@ -49,7 +49,7 @@ type adaptedBidder interface { // // Any errors will be user-facing in the API. // Error messages should help publishers understand what might account for "bad" bids. - requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) + requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) } // pbsOrtbBid is a Bid returned by an adaptedBidder. @@ -62,7 +62,7 @@ type adaptedBidder interface { // pbsOrtbBid.dealPriority is optionally provided by adapters and used internally by the exchange to support deal targeted campaigns. // pbsOrtbBid.dealTierSatisfied is set to true by exchange.updateHbPbCatDur if deal tier satisfied otherwise it will be set to false type pbsOrtbBid struct { - bid *openrtb.Bid + bid *openrtb2.Bid bidType openrtb_ext.BidType bidTargets map[string]string bidVideo *openrtb_ext.ExtBidPrebidVideo @@ -73,7 +73,7 @@ type pbsOrtbBid struct { // pbsOrtbSeatBid is a SeatBid returned by an adaptedBidder. // -// This is distinct from the openrtb.SeatBid so that the prebid-server ext can be passed back with typesafety. +// This is distinct from the openrtb2.SeatBid so that the prebid-server ext can be passed back with typesafety. type pbsOrtbSeatBid struct { // bids is the list of bids which this adaptedBidder wishes to make. bids []*pbsOrtbBid @@ -124,7 +124,7 @@ type bidderAdapterConfig struct { DebugInfo config.DebugInfo } -func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { +func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { reqData, errs := bidder.Bidder.MakeRequests(request, reqInfo) if len(reqData) == 0 { @@ -248,7 +248,7 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi return seatBid, errs } -func addNativeTypes(bid *openrtb.Bid, request *openrtb.BidRequest) (*nativeResponse.Response, []error) { +func addNativeTypes(bid *openrtb2.Bid, request *openrtb2.BidRequest) (*nativeResponse.Response, []error) { var errs []error var nativeMarkup *nativeResponse.Response if err := json.Unmarshal(json.RawMessage(bid.AdM), &nativeMarkup); err != nil || len(nativeMarkup.Assets) == 0 { @@ -307,7 +307,7 @@ func setAssetTypes(asset nativeResponse.Asset, nativePayload nativeRequests.Requ return nil } -func getNativeImpByImpID(impID string, request *openrtb.BidRequest) (*openrtb.Native, error) { +func getNativeImpByImpID(impID string, request *openrtb2.BidRequest) (*openrtb2.Native, error) { for _, impInRequest := range request.Imp { if impInRequest.ID == impID && impInRequest.Native != nil { return impInRequest.Native, nil diff --git a/exchange/bidder_test.go b/exchange/bidder_test.go index e4eb7b9574e..8cc5b5e9383 100644 --- a/exchange/bidder_test.go +++ b/exchange/bidder_test.go @@ -16,7 +16,9 @@ import ( "time" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" + nativeRequests "github.com/mxmCherry/openrtb/v14/native1/request" + nativeResponse "github.com/mxmCherry/openrtb/v14/native1/response" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/currency" @@ -26,9 +28,6 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - - nativeRequests "github.com/mxmCherry/openrtb/native/request" - nativeResponse "github.com/mxmCherry/openrtb/native/response" ) // TestSingleBidder makes sure that the following things work if the Bidder needs only one request. @@ -76,14 +75,14 @@ func TestSingleBidder(t *testing.T) { mockBidderResponse := &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ Price: firstInitialPrice, }, BidType: openrtb_ext.BidTypeBanner, DealPriority: 4, }, { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ Price: secondInitialPrice, }, BidType: openrtb_ext.BidTypeVideo, @@ -96,7 +95,7 @@ func TestSingleBidder(t *testing.T) { bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, test.debugInfo) currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) - seatBid, errs := bidder.requestBid(ctx, &openrtb.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) + seatBid, errs := bidder.requestBid(ctx, &openrtb2.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) // Make sure the goodSingleBidder was called with the expected arguments. if bidderImpl.httpResponse == nil { @@ -158,11 +157,11 @@ func TestMultiBidder(t *testing.T) { mockBidderResponse := &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeBanner, }, { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeVideo, }, }, @@ -185,7 +184,7 @@ func TestMultiBidder(t *testing.T) { } bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) - seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) + seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) if seatBid == nil { t.Fatalf("SeatBid should exist, because bids exist.") @@ -515,7 +514,7 @@ func TestMultiCurrencies(t *testing.T) { mockBidderResponses[i] = &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ Price: bid.price, }, BidType: openrtb_ext.BidTypeBanner, @@ -556,7 +555,7 @@ func TestMultiCurrencies(t *testing.T) { seatBid, errs := bidder.requestBid( context.Background(), - &openrtb.BidRequest{}, + &openrtb2.BidRequest{}, "test", 1, currencyConverter.Rates(), @@ -681,7 +680,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) { mockBidderResponses[i] = &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeBanner, }, }, @@ -701,7 +700,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) { currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) seatBid, errs := bidder.requestBid( context.Background(), - &openrtb.BidRequest{}, + &openrtb2.BidRequest{}, "test", 1, currencyConverter.Rates(), @@ -844,7 +843,7 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { { Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeBanner, }, }, @@ -872,7 +871,7 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { ) seatBid, errs := bidder.requestBid( context.Background(), - &openrtb.BidRequest{ + &openrtb2.BidRequest{ Cur: tc.bidRequestCurrencies, }, "test", @@ -984,27 +983,27 @@ func TestMobileNativeTypes(t *testing.T) { reqURL := server.URL testCases := []struct { - mockBidderRequest *openrtb.BidRequest + mockBidderRequest *openrtb2.BidRequest mockBidderResponse *adapters.BidderResponse expectedValue string description string }{ { - mockBidderRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{ + mockBidderRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ { ID: "some-imp-id", - Native: &openrtb.Native{ + Native: &openrtb2.Native{ Request: "{\"ver\":\"1.1\",\"context\":1,\"contextsubtype\":11,\"plcmttype\":4,\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":500}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1,\"hmin\":1}},{\"id\":3,\"required\":0,\"data\":{\"type\":1,\"len\":200}},{\"id\":4,\"required\":0,\"data\":{\"type\":2,\"len\":15000}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"len\":40}}]}", }, }, }, - App: &openrtb.App{}, + App: &openrtb2.App{}, }, mockBidderResponse: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ ImpID: "some-imp-id", AdM: "{\"assets\":[{\"id\":2,\"img\":{\"url\":\"http://vcdn.adnxs.com/p/creative-image/f8/7f/0f/13/f87f0f13-230c-4f05-8087-db9216e393de.jpg\",\"w\":989,\"h\":742,\"ext\":{\"appnexus\":{\"prevent_crop\":0}}}},{\"id\":1,\"title\":{\"text\":\"This is a Prebid Native Creative\"}},{\"id\":3,\"data\":{\"value\":\"Prebid.org\"}},{\"id\":4,\"data\":{\"value\":\"This is a Prebid Native Creative. There are many like it, but this one is mine.\"}}],\"link\":{\"url\":\"http://some-url.com\"},\"imptrackers\":[\"http://someimptracker.com\"],\"jstracker\":\"some-js-tracker\"}", Price: 10, @@ -1017,21 +1016,21 @@ func TestMobileNativeTypes(t *testing.T) { description: "Checks types in response", }, { - mockBidderRequest: &openrtb.BidRequest{ - Imp: []openrtb.Imp{ + mockBidderRequest: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ { ID: "some-imp-id", - Native: &openrtb.Native{ + Native: &openrtb2.Native{ Request: "{\"ver\":\"1.1\",\"context\":1,\"contextsubtype\":11,\"plcmttype\":4,\"plcmtcnt\":1,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":500}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":1,\"hmin\":1}},{\"id\":3,\"required\":0,\"data\":{\"type\":1,\"len\":200}},{\"id\":4,\"required\":0,\"data\":{\"type\":2,\"len\":15000}},{\"id\":5,\"required\":0,\"data\":{\"type\":6,\"len\":40}}]}", }, }, }, - App: &openrtb.App{}, + App: &openrtb2.App{}, }, mockBidderResponse: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ ImpID: "some-imp-id", AdM: "{\"some-diff-markup\":\"creative\"}", Price: 10, @@ -1079,7 +1078,7 @@ func TestMobileNativeTypes(t *testing.T) { func TestErrorReporting(t *testing.T) { bidder := adaptBidder(&bidRejector{}, nil, &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, nil) currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) - bids, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) + bids, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, "test", 1.0, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) if bids != nil { t.Errorf("There should be no seatbid if no http requests are returned.") } @@ -1262,7 +1261,7 @@ func TestCallRecordAdapterConnections(t *testing.T) { // Run requestBid using an http.Client with a mock handler bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, metrics, openrtb_ext.BidderAppnexus, nil) currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) - _, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) + _, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, "test", bidAdjustment, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) // Assert no errors assert.Equal(t, 0, len(errs), "bidder.requestBid returned errors %v \n", errs) @@ -1467,31 +1466,31 @@ func wrapWithBidderInfo(bidder adapters.Bidder) adapters.Bidder { } type goodSingleBidder struct { - bidRequest *openrtb.BidRequest + bidRequest *openrtb2.BidRequest httpRequest *adapters.RequestData httpResponse *adapters.ResponseData bidResponse *adapters.BidderResponse } -func (bidder *goodSingleBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (bidder *goodSingleBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { bidder.bidRequest = request return []*adapters.RequestData{bidder.httpRequest}, nil } -func (bidder *goodSingleBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (bidder *goodSingleBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { bidder.httpResponse = response return bidder.bidResponse, nil } type goodMultiHTTPCallsBidder struct { - bidRequest *openrtb.BidRequest + bidRequest *openrtb2.BidRequest httpRequest []*adapters.RequestData httpResponses []*adapters.ResponseData bidResponses []*adapters.BidderResponse bidResponseNumber int } -func (bidder *goodMultiHTTPCallsBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (bidder *goodMultiHTTPCallsBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { bidder.bidRequest = request response := make([]*adapters.RequestData, len(bidder.httpRequest)) @@ -1501,7 +1500,7 @@ func (bidder *goodMultiHTTPCallsBidder) MakeRequests(request *openrtb.BidRequest return response, nil } -func (bidder *goodMultiHTTPCallsBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (bidder *goodMultiHTTPCallsBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { br := bidder.bidResponses[bidder.bidResponseNumber] bidder.bidResponseNumber++ bidder.httpResponses = append(bidder.httpResponses, response) @@ -1510,18 +1509,18 @@ func (bidder *goodMultiHTTPCallsBidder) MakeBids(internalRequest *openrtb.BidReq } type mixedMultiBidder struct { - bidRequest *openrtb.BidRequest + bidRequest *openrtb2.BidRequest httpRequests []*adapters.RequestData httpResponses []*adapters.ResponseData bidResponse *adapters.BidderResponse } -func (bidder *mixedMultiBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (bidder *mixedMultiBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { bidder.bidRequest = request return bidder.httpRequests, []error{errors.New("The requests weren't ideal.")} } -func (bidder *mixedMultiBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (bidder *mixedMultiBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { bidder.httpResponses = append(bidder.httpResponses, response) return bidder.bidResponse, []error{errors.New("The bidResponse weren't ideal.")} } @@ -1531,11 +1530,11 @@ type bidRejector struct { httpResponse *adapters.ResponseData } -func (bidder *bidRejector) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (bidder *bidRejector) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { return nil, []error{errors.New("Invalid params on BidRequest.")} } -func (bidder *bidRejector) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (bidder *bidRejector) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { bidder.httpResponse = response return nil, []error{errors.New("Can't make a response.")} } @@ -1545,11 +1544,11 @@ type notifyingBidder struct { notifyRequest adapters.RequestData } -func (bidder *notifyingBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (bidder *notifyingBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { return bidder.requests, nil } -func (bidder *notifyingBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (bidder *notifyingBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { return nil, nil } diff --git a/exchange/bidder_validate_bids.go b/exchange/bidder_validate_bids.go index cf74dfb1dd5..ad387cf4fcc 100644 --- a/exchange/bidder_validate_bids.go +++ b/exchange/bidder_validate_bids.go @@ -6,7 +6,7 @@ import ( "fmt" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/currency" "github.com/prebid/prebid-server/openrtb_ext" @@ -28,7 +28,7 @@ type validatedBidder struct { bidder adaptedBidder } -func (v *validatedBidder) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { +func (v *validatedBidder) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { seatBid, errs := v.bidder.requestBid(ctx, request, name, bidAdjustment, conversions, reqInfo, accountDebugAllowed) if validationErrors := removeInvalidBids(request, seatBid); len(validationErrors) > 0 { errs = append(errs, validationErrors...) @@ -37,7 +37,7 @@ func (v *validatedBidder) requestBid(ctx context.Context, request *openrtb.BidRe } // validateBids will run some validation checks on the returned bids and excise any invalid bids -func removeInvalidBids(request *openrtb.BidRequest, seatBid *pbsOrtbSeatBid) []error { +func removeInvalidBids(request *openrtb2.BidRequest, seatBid *pbsOrtbSeatBid) []error { // Exit early if there is nothing to do. if seatBid == nil || len(seatBid.bids) == 0 { return nil diff --git a/exchange/bidder_validate_bids_test.go b/exchange/bidder_validate_bids_test.go index e7fc0b046dd..97a11a6b743 100644 --- a/exchange/bidder_validate_bids_test.go +++ b/exchange/bidder_validate_bids_test.go @@ -4,7 +4,7 @@ import ( "context" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/currency" "github.com/prebid/prebid-server/openrtb_ext" @@ -16,7 +16,7 @@ func TestAllValidBids(t *testing.T) { bidResponse: &pbsOrtbSeatBid{ bids: []*pbsOrtbBid{ { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "one-bid", ImpID: "thisImp", Price: 0.45, @@ -24,7 +24,7 @@ func TestAllValidBids(t *testing.T) { }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "thatBid", ImpID: "thatImp", Price: 0.40, @@ -32,7 +32,7 @@ func TestAllValidBids(t *testing.T) { }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "123", ImpID: "456", Price: 0.44, @@ -42,7 +42,7 @@ func TestAllValidBids(t *testing.T) { }, }, }) - seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) + seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) assert.Len(t, seatBid.bids, 3) assert.Len(t, errs, 0) } @@ -52,28 +52,28 @@ func TestAllBadBids(t *testing.T) { bidResponse: &pbsOrtbSeatBid{ bids: []*pbsOrtbBid{ { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "one-bid", Price: 0.45, CrID: "thisCreative", }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "thatBid", ImpID: "thatImp", CrID: "thatCreative", }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "123", ImpID: "456", Price: 0.44, }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "456", Price: 0.44, CrID: "blah", @@ -83,7 +83,7 @@ func TestAllBadBids(t *testing.T) { }, }, }) - seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) + seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) assert.Len(t, seatBid.bids, 0) assert.Len(t, errs, 5) } @@ -93,7 +93,7 @@ func TestMixedBids(t *testing.T) { bidResponse: &pbsOrtbSeatBid{ bids: []*pbsOrtbBid{ { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "one-bid", ImpID: "thisImp", Price: 0.45, @@ -101,14 +101,14 @@ func TestMixedBids(t *testing.T) { }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "thatBid", ImpID: "thatImp", CrID: "thatCreative", }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "123", ImpID: "456", Price: 0.44, @@ -116,7 +116,7 @@ func TestMixedBids(t *testing.T) { }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ImpID: "456", Price: 0.44, CrID: "blah", @@ -126,7 +126,7 @@ func TestMixedBids(t *testing.T) { }, }, }) - seatBid, errs := bidder.requestBid(context.Background(), &openrtb.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) + seatBid, errs := bidder.requestBid(context.Background(), &openrtb2.BidRequest{}, openrtb_ext.BidderAppnexus, 1.0, currency.NewConstantRates(), &adapters.ExtraRequestInfo{}, true) assert.Len(t, seatBid.bids, 2) assert.Len(t, errs, 3) } @@ -210,7 +210,7 @@ func TestCurrencyBids(t *testing.T) { for _, tc := range currencyTestCases { bids := []*pbsOrtbBid{ { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "one-bid", ImpID: "thisImp", Price: 0.45, @@ -218,7 +218,7 @@ func TestCurrencyBids(t *testing.T) { }, }, { - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ ID: "thatBid", ImpID: "thatImp", Price: 0.44, @@ -242,7 +242,7 @@ func TestCurrencyBids(t *testing.T) { expectedValidBids = 0 } - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ Cur: tc.brqCur, } @@ -257,6 +257,6 @@ type mockAdaptedBidder struct { errorResponse []error } -func (b *mockAdaptedBidder) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { +func (b *mockAdaptedBidder) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { return b.bidResponse, b.errorResponse } diff --git a/exchange/events_test.go b/exchange/events_test.go index 1d72739d873..6685918ee6e 100644 --- a/exchange/events_test.go +++ b/exchange/events_test.go @@ -3,7 +3,7 @@ package exchange import ( "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -60,7 +60,7 @@ func Test_eventsData_makeBidExtEvents(t *testing.T) { auctionTimestampMs: 1234567890, externalURL: "http://localhost", } - bid := &pbsOrtbBid{bid: &openrtb.Bid{ID: "BID-1"}, bidType: tt.args.bidType} + bid := &pbsOrtbBid{bid: &openrtb2.Bid{ID: "BID-1"}, bidType: tt.args.bidType} assert.Equal(t, tt.want, evData.makeBidExtEvents(bid, openrtb_ext.BidderOpenx)) }) } @@ -124,7 +124,7 @@ func Test_eventsData_modifyBidJSON(t *testing.T) { auctionTimestampMs: 1234567890, externalURL: "http://localhost", } - bid := &pbsOrtbBid{bid: &openrtb.Bid{ID: "BID-1"}, bidType: tt.args.bidType} + bid := &pbsOrtbBid{bid: &openrtb2.Bid{ID: "BID-1"}, bidType: tt.args.bidType} modifiedJSON, err := evData.modifyBidJSON(bid, openrtb_ext.BidderOpenx, tt.jsonBytes) if tt.want != nil { assert.NoError(t, err, "Unexpected error") diff --git a/exchange/exchange.go b/exchange/exchange.go index d8ac60ba46a..e06f87bf677 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -14,10 +14,10 @@ import ( "strings" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/stored_requests" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/currency" @@ -39,7 +39,7 @@ type extCacheInstructions struct { // Exchange runs Auctions. Implementations must be threadsafe, and will be shared across many goroutines. type Exchange interface { // HoldAuction executes an OpenRTB v2.5 Auction. - HoldAuction(ctx context.Context, r AuctionRequest, debugLog *DebugLog) (*openrtb.BidResponse, error) + HoldAuction(ctx context.Context, r AuctionRequest, debugLog *DebugLog) (*openrtb2.BidResponse, error) } // IdFetcher can find the user's ID for a specific Bidder. @@ -102,7 +102,7 @@ func NewExchange(adapters map[openrtb_ext.BidderName]adaptedBidder, cache prebid // AuctionRequest holds the bid request for the auction // and all other information needed to process that request type AuctionRequest struct { - BidRequest *openrtb.BidRequest + BidRequest *openrtb2.BidRequest Account config.Account UserSyncs IdFetcher RequestType metrics.RequestType @@ -117,13 +117,13 @@ type AuctionRequest struct { // BidderRequest holds the bidder specific request and all other // information needed to process that bidder request. type BidderRequest struct { - BidRequest *openrtb.BidRequest + BidRequest *openrtb2.BidRequest BidderName openrtb_ext.BidderName BidderCoreName openrtb_ext.BidderName BidderLabels metrics.AdapterLabels } -func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog *DebugLog) (*openrtb.BidResponse, error) { +func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog *DebugLog) (*openrtb2.BidResponse, error) { var err error requestExt, err := extractBidRequestExt(r.BidRequest) if err != nil { @@ -258,9 +258,9 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * return e.buildBidResponse(ctx, liveAdapters, adapterBids, r.BidRequest, adapterExtra, auc, bidResponseExt, cacheInstructions.returnCreative, errs) } -func (e *exchange) parseUsersyncIfAmbiguous(bidRequest *openrtb.BidRequest) bool { +func (e *exchange) parseUsersyncIfAmbiguous(bidRequest *openrtb2.BidRequest) bool { usersyncIfAmbiguous := e.UsersyncIfAmbiguous - var geo *openrtb.Geo = nil + var geo *openrtb2.Geo = nil if bidRequest.User != nil && bidRequest.User.Geo != nil { geo = bidRequest.User.Geo @@ -281,7 +281,7 @@ func (e *exchange) parseUsersyncIfAmbiguous(bidRequest *openrtb.BidRequest) bool return usersyncIfAmbiguous } -func recordImpMetrics(bidRequest *openrtb.BidRequest, metricsEngine metrics.MetricsEngine) { +func recordImpMetrics(bidRequest *openrtb2.BidRequest, metricsEngine metrics.MetricsEngine) { for _, impInRequest := range bidRequest.Imp { var impLabels metrics.ImpLabels = metrics.ImpLabels{ BannerImps: impInRequest.Banner != nil, @@ -294,7 +294,7 @@ func recordImpMetrics(bidRequest *openrtb.BidRequest, metricsEngine metrics.Metr } // applyDealSupport updates targeting keys with deal prefixes if minimum deal tier exceeded -func applyDealSupport(bidRequest *openrtb.BidRequest, auc *auction, bidCategory map[string]string) []error { +func applyDealSupport(bidRequest *openrtb2.BidRequest, auc *auction, bidCategory map[string]string) []error { errs := []error{} impDealMap := getDealTiers(bidRequest) @@ -315,7 +315,7 @@ func applyDealSupport(bidRequest *openrtb.BidRequest, auc *auction, bidCategory } // getDealTiers creates map of impression to bidder deal tier configuration -func getDealTiers(bidRequest *openrtb.BidRequest) map[string]openrtb_ext.DealTierBidderMap { +func getDealTiers(bidRequest *openrtb2.BidRequest) map[string]openrtb_ext.DealTierBidderMap { impDealMap := make(map[string]openrtb_ext.DealTierBidderMap) for _, imp := range bidRequest.Imp { @@ -538,19 +538,19 @@ func errsToBidderWarnings(errs []error) []openrtb_ext.ExtBidderMessage { } // This piece takes all the bids supplied by the adapters and crafts an openRTB response to send back to the requester -func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_ext.BidderName, adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, bidRequest *openrtb.BidRequest, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, bidResponseExt *openrtb_ext.ExtBidResponse, returnCreative bool, errList []error) (*openrtb.BidResponse, error) { - bidResponse := new(openrtb.BidResponse) +func (e *exchange) buildBidResponse(ctx context.Context, liveAdapters []openrtb_ext.BidderName, adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, bidRequest *openrtb2.BidRequest, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, bidResponseExt *openrtb_ext.ExtBidResponse, returnCreative bool, errList []error) (*openrtb2.BidResponse, error) { + bidResponse := new(openrtb2.BidResponse) var err error bidResponse.ID = bidRequest.ID if len(liveAdapters) == 0 { // signal "Invalid Request" if no valid bidders. - bidResponse.NBR = openrtb.NoBidReasonCode.Ptr(openrtb.NoBidReasonCodeInvalidRequest) + bidResponse.NBR = openrtb2.NoBidReasonCode.Ptr(openrtb2.NoBidReasonCodeInvalidRequest) } // Create the SeatBids. We use a zero sized slice so that we can append non-zero seat bids, and not include seatBid // objects for seatBids without any bids. Preallocate the max possible size to avoid reallocating the array as we go. - seatBids := make([]openrtb.SeatBid, 0, len(liveAdapters)) + seatBids := make([]openrtb2.SeatBid, 0, len(liveAdapters)) for _, a := range liveAdapters { //while processing every single bib, do we need to handle categories here? if adapterBids[a] != nil && len(adapterBids[a].bids) > 0 { @@ -825,8 +825,8 @@ func (e *exchange) makeExtBidResponse(adapterBids map[openrtb_ext.BidderName]*pb // Return an openrtb seatBid for a bidder // BuildBidResponse is responsible for ensuring nil bid seatbids are not included -func (e *exchange) makeSeatBid(adapterBid *pbsOrtbSeatBid, adapter openrtb_ext.BidderName, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, returnCreative bool) *openrtb.SeatBid { - seatBid := &openrtb.SeatBid{ +func (e *exchange) makeSeatBid(adapterBid *pbsOrtbSeatBid, adapter openrtb_ext.BidderName, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, auc *auction, returnCreative bool) *openrtb2.SeatBid { + seatBid := &openrtb2.SeatBid{ Seat: adapter.String(), Group: 0, // Prebid cannot support roadblocking } @@ -840,8 +840,8 @@ func (e *exchange) makeSeatBid(adapterBid *pbsOrtbSeatBid, adapter openrtb_ext.B return seatBid } -func (e *exchange) makeBid(bids []*pbsOrtbBid, auc *auction, returnCreative bool) ([]openrtb.Bid, []error) { - result := make([]openrtb.Bid, 0, len(bids)) +func (e *exchange) makeBid(bids []*pbsOrtbBid, auc *auction, returnCreative bool) ([]openrtb2.Bid, []error) { + result := make([]openrtb2.Bid, 0, len(bids)) errs := make([]error, 0, 1) for _, bid := range bids { @@ -890,7 +890,7 @@ func makeBidExtJSON(ext json.RawMessage, prebid *openrtb_ext.ExtBidPrebid) (json return json.Marshal(extMap) } -// If bid got cached inside `(a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, targData *targetData, bidRequest *openrtb.BidRequest, ttlBuffer int64, defaultTTLs *config.DefaultTTLs, bidCategory map[string]string)`, +// If bid got cached inside `(a *auction) doCache(ctx context.Context, cache prebid_cache_client.Client, targData *targetData, bidRequest *openrtb2.BidRequest, ttlBuffer int64, defaultTTLs *config.DefaultTTLs, bidCategory map[string]string)`, // a UUID should be found inside `a.cacheIds` or `a.vastCacheIds`. This function returns the UUID along with the internal cache URL func (e *exchange) getBidCacheInfo(bid *pbsOrtbBid, auction *auction) (cacheInfo openrtb_ext.ExtBidPrebidCacheBids, found bool) { uuid, found := findCacheID(bid, auction) diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index 3eaa625f74f..1cffa79b127 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -16,6 +16,7 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/currency" @@ -29,7 +30,6 @@ import ( "github.com/prebid/prebid-server/stored_requests/backends/file_fetcher" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" "github.com/stretchr/testify/assert" "github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff/formatter" @@ -75,7 +75,7 @@ func TestNewExchange(t *testing.T) { } } -// The objective is to get to execute e.buildBidResponse(ctx.Background(), liveA... ) (*openrtb.BidResponse, error) +// The objective is to get to execute e.buildBidResponse(ctx.Background(), liveA... ) (*openrtb2.BidResponse, error) // and check whether the returned request successfully prints any '&' characters as it should // To do so, we: // 1) Write the endpoint adapter URL with an '&' character into a new config,Configuration struct @@ -123,16 +123,16 @@ func TestCharacterEscape(t *testing.T) { adapterBids := make(map[openrtb_ext.BidderName]*pbsOrtbSeatBid, 1) adapterBids["appnexus"] = &pbsOrtbSeatBid{currency: "USD"} - //An openrtb.BidRequest struct as specified in https://github.com/prebid/prebid-server/issues/465 - bidRequest := &openrtb.BidRequest{ + //An openrtb2.BidRequest struct as specified in https://github.com/prebid/prebid-server/issues/465 + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-impression-id", - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, Ext: json.RawMessage(`{"appnexus": {"placementId": 1}}`), }}, - Site: &openrtb.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, - Device: &openrtb.Device{UA: "curl/7.54.0", IP: "::1"}, + Site: &openrtb2.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, + Device: &openrtb2.Device{UA: "curl/7.54.0", IP: "::1"}, AT: 1, TMax: 500, Ext: json.RawMessage(`{"id": "some-request-id","site": {"page": "prebid.org"},"imp": [{"id": "some-impression-id","banner": {"format": [{"w": 300,"h": 250},{"w": 300,"h": 600}]},"ext": {"appnexus": {"placementId": 1}}}],"tmax": 500}`), @@ -163,7 +163,7 @@ func TestCharacterEscape(t *testing.T) { } // TestDebugBehaviour asserts the HttpCalls object is included inside the json "debug" field of the bidResponse extension when the -// openrtb.BidRequest "Test" value is set to 1 or the openrtb.BidRequest.Ext.Debug boolean field is set to true +// openrtb2.BidRequest "Test" value is set to 1 or the openrtb2.BidRequest.Ext.Debug boolean field is set to true func TestDebugBehaviour(t *testing.T) { // Define test cases @@ -258,15 +258,15 @@ func TestDebugBehaviour(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", err) } - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-impression-id", - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, Ext: json.RawMessage(`{"appnexus": {"placementId": 1}}`), }}, - Site: &openrtb.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, - Device: &openrtb.Device{UA: "curl/7.54.0", IP: "::1"}, + Site: &openrtb2.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, + Device: &openrtb2.Device{UA: "curl/7.54.0", IP: "::1"}, AT: 1, TMax: 500, } @@ -442,15 +442,15 @@ func TestTwoBiddersDebugDisabledAndEnabled(t *testing.T) { debugLog := DebugLog{Enabled: true} for _, testCase := range testCases { - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-impression-id", - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, Ext: json.RawMessage(`{"telaria": {"placementId": 1}, "appnexus": {"placementid": 2}}`), }}, - Site: &openrtb.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, - Device: &openrtb.Device{UA: "curl/7.54.0", IP: "::1"}, + Site: &openrtb2.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, + Device: &openrtb2.Device{UA: "curl/7.54.0", IP: "::1"}, AT: 1, TMax: 500, } @@ -637,7 +637,7 @@ func TestReturnCreativeEndToEnd(t *testing.T) { bidResponse: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{AdM: sampleAd}, + Bid: &openrtb2.Bid{AdM: sampleAd}, }, }, }, @@ -654,14 +654,14 @@ func TestReturnCreativeEndToEnd(t *testing.T) { e.categoriesFetcher = categoriesFetcher // Define mock incoming bid requeset - mockBidRequest := &openrtb.BidRequest{ + mockBidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-impression-id", - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, Ext: json.RawMessage(`{"appnexus": {"placementId": 1}}`), }}, - Site: &openrtb.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, + Site: &openrtb2.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, } // Run tests @@ -750,7 +750,7 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { liveAdapters := []openrtb_ext.BidderName{bidderName} //adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, - bids := []*openrtb.Bid{ + bids := []*openrtb2.Bid{ { ID: "some-imp-id", ImpID: "", @@ -782,7 +782,7 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { }, } auc := &auction{ - cacheIds: map[*openrtb.Bid]string{ + cacheIds: map[*openrtb2.Bid]string{ bids[0]: testUUID, }, } @@ -816,14 +816,14 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { }, }, } - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", TMax: 1000, - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "test-div", - Secure: openrtb.Int8Ptr(0), - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}}}, + Secure: openrtb2.Int8Ptr(0), + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}}}, Ext: json.RawMessage(` { "rubicon": { "accountId": 1001, @@ -838,9 +838,9 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { }`), }, }, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ Page: "http://rubitest.com/index.html", - Publisher: &openrtb.Publisher{ID: "1001"}, + Publisher: &openrtb2.Publisher{ID: "1001"}, }, Test: 1, Ext: json.RawMessage(`{"prebid": { "cache": { "bids": {}, "vastxml": {} }, "targeting": { "pricegranularity": "med", "includewinners": true, "includebidderkeys": false } }}`), @@ -854,11 +854,11 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { /* 5) Assert we have no errors and the bid response we expected*/ assert.NoError(t, err, "[TestGetBidCacheInfo] buildBidResponse() threw an error") - expectedBidResponse := &openrtb.BidResponse{ - SeatBid: []openrtb.SeatBid{ + expectedBidResponse := &openrtb2.BidResponse{ + SeatBid: []openrtb2.SeatBid{ { Seat: string(bidderName), - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ { Ext: json.RawMessage(`{ "prebid": { "cache": { "bids": { "cacheId": "` + testUUID + `", "url": "` + testExternalCacheScheme + `://` + testExternalCacheHost + `/` + testExternalCachePath + `?uuid=` + testUUID + `" }, "key": "", "url": "" }`), }, @@ -887,7 +887,7 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { func TestBidReturnsCreative(t *testing.T) { sampleAd := "" - sampleOpenrtbBid := &openrtb.Bid{ID: "some-bid-id", AdM: sampleAd} + sampleOpenrtbBid := &openrtb2.Bid{ID: "some-bid-id", AdM: sampleAd} // Define test cases testCases := []struct { @@ -915,7 +915,7 @@ func TestBidReturnsCreative(t *testing.T) { bidTargets: map[string]string{}, }, } - sampleAuction := &auction{cacheIds: map[*openrtb.Bid]string{sampleOpenrtbBid: "CACHE_UUID_1234"}} + sampleAuction := &auction{cacheIds: map[*openrtb2.Bid]string{sampleOpenrtbBid: "CACHE_UUID_1234"}} noBidHandler := func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(204) } server := httptest.NewServer(http.HandlerFunc(noBidHandler)) @@ -954,7 +954,7 @@ func TestBidReturnsCreative(t *testing.T) { } func TestGetBidCacheInfo(t *testing.T) { - bid := &openrtb.Bid{ID: "42"} + bid := &openrtb2.Bid{ID: "42"} testCases := []struct { description string scheme string @@ -972,7 +972,7 @@ func TestGetBidCacheInfo(t *testing.T) { host: "prebid.org", path: "cache", bid: &pbsOrtbBid{bid: bid}, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: true, expectedCacheID: "anyID", expectedCacheURL: "https://prebid.org/cache?uuid=anyID", @@ -983,7 +983,7 @@ func TestGetBidCacheInfo(t *testing.T) { host: "prebid.org", path: "cache", bid: &pbsOrtbBid{bid: bid}, - auction: &auction{vastCacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{vastCacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: true, expectedCacheID: "anyID", expectedCacheURL: "https://prebid.org/cache?uuid=anyID", @@ -1004,7 +1004,7 @@ func TestGetBidCacheInfo(t *testing.T) { host: "prebid.org", path: "cache", bid: &pbsOrtbBid{bid: bid}, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: true, expectedCacheID: "anyID", expectedCacheURL: "prebid.org/cache?uuid=anyID", @@ -1012,7 +1012,7 @@ func TestGetBidCacheInfo(t *testing.T) { { description: "Host And Path Not Provided - Without Scheme", bid: &pbsOrtbBid{bid: bid}, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: true, expectedCacheID: "anyID", expectedCacheURL: "", @@ -1021,7 +1021,7 @@ func TestGetBidCacheInfo(t *testing.T) { description: "Host And Path Not Provided - With Scheme", scheme: "https", bid: &pbsOrtbBid{bid: bid}, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: true, expectedCacheID: "anyID", expectedCacheURL: "", @@ -1032,7 +1032,7 @@ func TestGetBidCacheInfo(t *testing.T) { host: "prebid.org", path: "cache", bid: nil, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: false, expectedCacheID: "", expectedCacheURL: "", @@ -1043,7 +1043,7 @@ func TestGetBidCacheInfo(t *testing.T) { host: "prebid.org", path: "cache", bid: &pbsOrtbBid{bid: nil}, - auction: &auction{cacheIds: map[*openrtb.Bid]string{bid: "anyID"}}, + auction: &auction{cacheIds: map[*openrtb2.Bid]string{bid: "anyID"}}, expectedFound: false, expectedCacheID: "", expectedCacheURL: "", @@ -1103,15 +1103,15 @@ func TestBidResponseCurrency(t *testing.T) { liveAdapters := make([]openrtb_ext.BidderName, 1) liveAdapters[0] = "appnexus" - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-impression-id", - Banner: &openrtb.Banner{Format: []openrtb.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, + Banner: &openrtb2.Banner{Format: []openrtb2.Format{{W: 300, H: 250}, {W: 300, H: 600}}}, Ext: json.RawMessage(`{"appnexus": {"placementId": 10433394}}`), }}, - Site: &openrtb.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, - Device: &openrtb.Device{UA: "curl/7.54.0", IP: "::1"}, + Site: &openrtb2.Site{Page: "prebid.org", Ext: json.RawMessage(`{"amp":0}`)}, + Device: &openrtb2.Device{UA: "curl/7.54.0", IP: "::1"}, AT: 1, TMax: 500, Ext: json.RawMessage(`{"id": "some-request-id","site": {"page": "prebid.org"},"imp": [{"id": "some-impression-id","banner": {"format": [{"w": 300,"h": 250},{"w": 300,"h": 600}]},"ext": {"appnexus": {"placementId": 10433394}}}],"tmax": 500}`), @@ -1123,7 +1123,7 @@ func TestBidResponseCurrency(t *testing.T) { var errList []error - sampleBid := &openrtb.Bid{ + sampleBid := &openrtb2.Bid{ ID: "some-imp-id", Price: 9.517803, W: 300, @@ -1131,10 +1131,10 @@ func TestBidResponseCurrency(t *testing.T) { Ext: nil, } aPbsOrtbBidArr := []*pbsOrtbBid{{bid: sampleBid, bidType: openrtb_ext.BidTypeBanner}} - sampleSeatBid := []openrtb.SeatBid{ + sampleSeatBid := []openrtb2.SeatBid{ { Seat: "appnexus", - Bid: []openrtb.Bid{ + Bid: []openrtb2.Bid{ { ID: "some-imp-id", Price: 9.517803, @@ -1145,13 +1145,13 @@ func TestBidResponseCurrency(t *testing.T) { }, }, } - emptySeatBid := []openrtb.SeatBid{} + emptySeatBid := []openrtb2.SeatBid{} // Test cases type aTest struct { description string adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid - expectedBidResponse *openrtb.BidResponse + expectedBidResponse *openrtb2.BidResponse } testCases := []aTest{ { @@ -1162,7 +1162,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "USD", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: sampleSeatBid, Cur: "USD", @@ -1178,7 +1178,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "USD", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: emptySeatBid, Cur: "", @@ -1194,7 +1194,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: sampleSeatBid, Cur: "", @@ -1210,7 +1210,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: emptySeatBid, Cur: "", @@ -1305,39 +1305,39 @@ func newCategoryFetcher(directory string) (stored_requests.CategoryFetcher, erro // newRaceCheckingRequest builds a BidRequest from all the params in the // adapters/{bidder}/{bidder}test/params/race/*.json files -func newRaceCheckingRequest(t *testing.T) *openrtb.BidRequest { +func newRaceCheckingRequest(t *testing.T) *openrtb2.BidRequest { dnt := int8(1) - return &openrtb.BidRequest{ - Site: &openrtb.Site{ + return &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "www.some.domain.com", Domain: "domain.com", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "some-publisher-id", }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ UA: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", IFA: "ifa", IP: "132.173.230.74", DNT: &dnt, Language: "EN", }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "61018dc9-fa61-4c41-b7dc-f90b9ae80e87", }, - User: &openrtb.User{ + User: &openrtb2.User{ ID: "our-id", BuyerUID: "their-id", Ext: json.RawMessage(`{"consent":"BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw","digitrust":{"id":"digi-id","keyv":1,"pref":1}}`), }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ COPPA: 1, Ext: json.RawMessage(`{"gdpr":1}`), }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }, { @@ -1347,7 +1347,7 @@ func newRaceCheckingRequest(t *testing.T) *openrtb.BidRequest { }, Ext: buildImpExt(t, "banner"), }, { - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: []string{"video/mp4"}, MinDuration: 1, MaxDuration: 300, @@ -1399,14 +1399,14 @@ func TestPanicRecovery(t *testing.T) { BidderName: "bidder1", BidderCoreName: "appnexus", BidderLabels: apnLabels, - BidRequest: &openrtb.BidRequest{ + BidRequest: &openrtb2.BidRequest{ ID: "b-1", }, }, { BidderName: "bidder2", BidderCoreName: "bidder2", - BidRequest: &openrtb.BidRequest{ + BidRequest: &openrtb2.BidRequest{ ID: "b-2", }, }, @@ -1479,23 +1479,23 @@ func TestPanicRecoveryHighLevel(t *testing.T) { e.adapterMap[openrtb_ext.BidderBeachfront] = panicingAdapter{} e.adapterMap[openrtb_ext.BidderAppnexus] = panicingAdapter{} - request := &openrtb.BidRequest{ - Site: &openrtb.Site{ + request := &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "www.some.domain.com", Domain: "domain.com", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "some-publisher-id", }, }, - User: &openrtb.User{ + User: &openrtb2.User{ ID: "our-id", BuyerUID: "their-id", Ext: json.RawMessage(`{"consent":"BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw","digitrust":{"id":"digi-id","keyv":1,"pref":1}}`), }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }, { @@ -1685,7 +1685,7 @@ func runSpec(t *testing.T, filename string, spec *exchangeSpec) { } } -func findBiddersInAuction(t *testing.T, context string, req *openrtb.BidRequest) []string { +func findBiddersInAuction(t *testing.T, context string, req *openrtb2.BidRequest) []string { if splitImps, err := splitImps(req.Imp); err != nil { t.Errorf("%s: Failed to parse Bidders from request: %v", context, err) return nil @@ -1701,7 +1701,7 @@ func findBiddersInAuction(t *testing.T, context string, req *openrtb.BidRequest) // extractResponseTimes validates the format of bid.ext.responsetimemillis, and then removes it. // This is done because the response time will change from run to run, so it's impossible to hardcode a value // into the JSON. The best we can do is make sure that the property exists. -func extractResponseTimes(t *testing.T, context string, bid *openrtb.BidResponse) map[string]int { +func extractResponseTimes(t *testing.T, context string, bid *openrtb2.BidResponse) map[string]int { if data, dataType, _, err := jsonparser.Get(bid.Ext, "responsetimemillis"); err != nil || dataType != jsonparser.Object { t.Errorf("%s: Exchange did not return ext.responsetimemillis object: %v", context, err) return nil @@ -1852,10 +1852,10 @@ func TestCategoryMapping(t *testing.T) { cats2 := []string{"IAB1-4"} cats3 := []string{"IAB1-1000"} cats4 := []string{"IAB1-2000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} - bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} + bid4 := openrtb2.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, nil, 0, false} @@ -1907,10 +1907,10 @@ func TestCategoryMappingNoIncludeBrandCategory(t *testing.T) { cats2 := []string{"IAB1-4"} cats3 := []string{"IAB1-1000"} cats4 := []string{"IAB1-2000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} - bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} + bid4 := openrtb2.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 40.0000, Cat: cats4, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, nil, 0, false} @@ -1962,9 +1962,9 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) { cats1 := []string{"IAB1-3"} cats2 := []string{"IAB1-4"} cats3 := []string{"IAB1-1000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, nil, 0, false} @@ -2044,9 +2044,9 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) { cats1 := []string{"IAB1-3"} cats2 := []string{"IAB1-4"} cats3 := []string{"IAB1-1000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 20.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 30.0000, Cat: cats3, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 40}, nil, 0, false} @@ -2094,11 +2094,11 @@ func TestCategoryDedupe(t *testing.T) { cats2 := []string{"IAB1-4"} // bid3 will be same price, category, and duration as bid1 so one of them should get removed cats4 := []string{"IAB1-2000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 15.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 20.0000, Cat: cats1, W: 1, H: 1} - bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} - bid5 := openrtb.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 20.0000, Cat: cats1, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 15.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 20.0000, Cat: cats1, W: 1, H: 1} + bid4 := openrtb2.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} + bid5 := openrtb2.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 20.0000, Cat: cats1, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, nil, 0, false} @@ -2173,11 +2173,11 @@ func TestNoCategoryDedupe(t *testing.T) { cats1 := []string{"IAB1-3"} cats2 := []string{"IAB1-4"} cats4 := []string{"IAB1-2000"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 14.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 14.0000, Cat: cats2, W: 1, H: 1} - bid3 := openrtb.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 20.0000, Cat: cats1, W: 1, H: 1} - bid4 := openrtb.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} - bid5 := openrtb.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 14.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 14.0000, Cat: cats2, W: 1, H: 1} + bid3 := openrtb2.Bid{ID: "bid_id3", ImpID: "imp_id3", Price: 20.0000, Cat: cats1, W: 1, H: 1} + bid4 := openrtb2.Bid{ID: "bid_id4", ImpID: "imp_id4", Price: 20.0000, Cat: cats4, W: 1, H: 1} + bid5 := openrtb2.Bid{ID: "bid_id5", ImpID: "imp_id5", Price: 10.0000, Cat: cats1, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} @@ -2256,8 +2256,8 @@ func TestCategoryMappingBidderName(t *testing.T) { cats1 := []string{"IAB1-1"} cats2 := []string{"IAB1-2"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 10.0000, Cat: cats2, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 10.0000, Cat: cats2, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} @@ -2310,8 +2310,8 @@ func TestCategoryMappingBidderNameNoCategories(t *testing.T) { cats1 := []string{"IAB1-1"} cats2 := []string{"IAB1-2"} - bid1 := openrtb.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bid2 := openrtb.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 12.0000, Cat: cats2, W: 1, H: 1} + bid1 := openrtb2.Bid{ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bid2 := openrtb2.Bid{ID: "bid_id2", ImpID: "imp_id2", Price: 12.0000, Cat: cats2, W: 1, H: 1} bid1_1 := pbsOrtbBid{&bid1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_2 := pbsOrtbBid{&bid2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} @@ -2368,7 +2368,7 @@ func TestBidRejectionErrors(t *testing.T) { testCases := []struct { description string reqExt openrtb_ext.ExtRequest - bids []*openrtb.Bid + bids []*openrtb2.Bid duration int expectedRejections []string expectedCatDur string @@ -2376,7 +2376,7 @@ func TestBidRejectionErrors(t *testing.T) { { description: "Bid should be rejected due to not containing a category", reqExt: requestExt, - bids: []*openrtb.Bid{ + bids: []*openrtb2.Bid{ {ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: []string{}, W: 1, H: 1}, }, duration: 30, @@ -2387,7 +2387,7 @@ func TestBidRejectionErrors(t *testing.T) { { description: "Bid should be rejected due to missing category mapping file", reqExt: invalidReqExt, - bids: []*openrtb.Bid{ + bids: []*openrtb2.Bid{ {ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: []string{"IAB1-1"}, W: 1, H: 1}, }, duration: 30, @@ -2398,7 +2398,7 @@ func TestBidRejectionErrors(t *testing.T) { { description: "Bid should be rejected due to duration exceeding maximum", reqExt: requestExt, - bids: []*openrtb.Bid{ + bids: []*openrtb2.Bid{ {ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: []string{"IAB1-1"}, W: 1, H: 1}, }, duration: 70, @@ -2409,7 +2409,7 @@ func TestBidRejectionErrors(t *testing.T) { { description: "Bid should be rejected due to duplicate bid", reqExt: requestExt, - bids: []*openrtb.Bid{ + bids: []*openrtb2.Bid{ {ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: []string{"IAB1-1"}, W: 1, H: 1}, {ID: "bid_id1", ImpID: "imp_id1", Price: 10.0000, Cat: []string{"IAB1-1"}, W: 1, H: 1}, }, @@ -2471,8 +2471,8 @@ func TestCategoryMappingTwoBiddersOneBidEachNoCategorySamePrice(t *testing.T) { cats1 := []string{"IAB1-3"} cats2 := []string{"IAB1-4"} - bidApn1 := openrtb.Bid{ID: "bid_idApn1", ImpID: "imp_idApn1", Price: 10.0000, Cat: cats1, W: 1, H: 1} - bidApn2 := openrtb.Bid{ID: "bid_idApn2", ImpID: "imp_idApn2", Price: 10.0000, Cat: cats2, W: 1, H: 1} + bidApn1 := openrtb2.Bid{ID: "bid_idApn1", ImpID: "imp_idApn1", Price: 10.0000, Cat: cats1, W: 1, H: 1} + bidApn2 := openrtb2.Bid{ID: "bid_idApn2", ImpID: "imp_idApn2", Price: 10.0000, Cat: cats2, W: 1, H: 1} bid1_Apn1 := pbsOrtbBid{&bidApn1, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} bid1_Apn2 := pbsOrtbBid{&bidApn2, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} @@ -2592,9 +2592,9 @@ func TestApplyDealSupport(t *testing.T) { bidderName := openrtb_ext.BidderName("appnexus") for _, test := range testCases { - bidRequest := &openrtb.BidRequest{ + bidRequest := &openrtb2.BidRequest{ ID: "some-request-id", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "imp_id1", Ext: test.impExt, @@ -2602,7 +2602,7 @@ func TestApplyDealSupport(t *testing.T) { }, } - bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, nil, test.dealPriority, false} + bid := pbsOrtbBid{&openrtb2.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, nil, test.dealPriority, false} bidCategory := map[string]string{ bid.bid.ID: test.targ["hb_pb_cat_dur"], } @@ -2628,20 +2628,20 @@ func TestApplyDealSupport(t *testing.T) { func TestGetDealTiers(t *testing.T) { testCases := []struct { description string - request openrtb.BidRequest + request openrtb2.BidRequest expected map[string]openrtb_ext.DealTierBidderMap }{ { description: "None", - request: openrtb.BidRequest{ - Imp: []openrtb.Imp{}, + request: openrtb2.BidRequest{ + Imp: []openrtb2.Imp{}, }, expected: map[string]openrtb_ext.DealTierBidderMap{}, }, { description: "One", - request: openrtb.BidRequest{ - Imp: []openrtb.Imp{ + request: openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"appnexus": {"dealTier": {"minDealTier": 5, "prefix": "tier"}}}`)}, }, }, @@ -2651,8 +2651,8 @@ func TestGetDealTiers(t *testing.T) { }, { description: "Many", - request: openrtb.BidRequest{ - Imp: []openrtb.Imp{ + request: openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"appnexus": {"dealTier": {"minDealTier": 5, "prefix": "tier1"}}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"appnexus": {"dealTier": {"minDealTier": 8, "prefix": "tier2"}}}`)}, }, @@ -2664,8 +2664,8 @@ func TestGetDealTiers(t *testing.T) { }, { description: "Many - Skips Malformed", - request: openrtb.BidRequest{ - Imp: []openrtb.Imp{ + request: openrtb2.BidRequest{ + Imp: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"appnexus": {"dealTier": {"minDealTier": 5, "prefix": "tier1"}}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"appnexus": {"dealTier": "wrong type"}}`)}, }, @@ -2769,7 +2769,7 @@ func TestUpdateHbPbCatDur(t *testing.T) { } for _, test := range testCases { - bid := pbsOrtbBid{&openrtb.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, nil, test.dealPriority, false} + bid := pbsOrtbBid{&openrtb2.Bid{ID: "123456"}, "video", map[string]string{}, &openrtb_ext.ExtBidPrebidVideo{}, nil, test.dealPriority, false} bidCategory := map[string]string{ bid.bid.ID: test.targ["hb_pb_cat_dur"], } @@ -2795,14 +2795,14 @@ type exchangeSpec struct { } type exchangeRequest struct { - OrtbRequest openrtb.BidRequest `json:"ortbRequest"` - Usersyncs map[string]string `json:"usersyncs"` + OrtbRequest openrtb2.BidRequest `json:"ortbRequest"` + Usersyncs map[string]string `json:"usersyncs"` } type exchangeResponse struct { - Bids *openrtb.BidResponse `json:"bids"` - Error string `json:"error,omitempty"` - Ext json.RawMessage `json:"ext,omitempty"` + Bids *openrtb2.BidResponse `json:"bids"` + Error string `json:"error,omitempty"` + Ext json.RawMessage `json:"ext,omitempty"` } type bidderSpec struct { @@ -2812,8 +2812,8 @@ type bidderSpec struct { } type bidderRequest struct { - OrtbRequest openrtb.BidRequest `json:"ortbRequest"` - BidAdjustment float64 `json:"bidAdjustment"` + OrtbRequest openrtb2.BidRequest `json:"ortbRequest"` + BidAdjustment float64 `json:"bidAdjustment"` } type bidderResponse struct { @@ -2832,8 +2832,8 @@ type bidderSeatBid struct { // bidderBid is basically a subset of pbsOrtbBid from exchange/bidder.go. // See the comment on bidderSeatBid for more info. type bidderBid struct { - Bid *openrtb.Bid `json:"ortbBid,omitempty"` - Type string `json:"bidType,omitempty"` + Bid *openrtb2.Bid `json:"ortbBid,omitempty"` + Type string `json:"bidType,omitempty"` } type mockIdFetcher map[string]string @@ -2857,7 +2857,7 @@ type validatingBidder struct { mockResponses map[string]bidderResponse } -func (b *validatingBidder) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (seatBid *pbsOrtbSeatBid, errs []error) { +func (b *validatingBidder) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (seatBid *pbsOrtbSeatBid, errs []error) { if expectedRequest, ok := b.expectations[string(name)]; ok { if expectedRequest != nil { if expectedRequest.BidAdjustment != bidAdjustment { @@ -2900,7 +2900,7 @@ func (b *validatingBidder) requestBid(ctx context.Context, request *openrtb.BidR return } -func diffOrtbRequests(t *testing.T, description string, expected *openrtb.BidRequest, actual *openrtb.BidRequest) { +func diffOrtbRequests(t *testing.T, description string, expected *openrtb2.BidRequest, actual *openrtb2.BidRequest) { t.Helper() actualJSON, err := json.Marshal(actual) if err != nil { @@ -2915,7 +2915,7 @@ func diffOrtbRequests(t *testing.T, description string, expected *openrtb.BidReq diffJson(t, description, actualJSON, expectedJSON) } -func diffOrtbResponses(t *testing.T, description string, expected *openrtb.BidResponse, actual *openrtb.BidResponse) { +func diffOrtbResponses(t *testing.T, description string, expected *openrtb2.BidResponse, actual *openrtb2.BidResponse) { t.Helper() // The OpenRTB spec is wonky here. Since "bidresponse.seatbid" is an array, order technically matters to any JSON diff or // deep equals method. However, for all intents and purposes it really *doesn't* matter. ...so this nasty logic makes compares @@ -2938,8 +2938,8 @@ func diffOrtbResponses(t *testing.T, description string, expected *openrtb.BidRe diffJson(t, description, actualJSON, expectedJSON) } -func mapifySeatBids(t *testing.T, context string, seatBids []openrtb.SeatBid) map[string]*openrtb.SeatBid { - seatMap := make(map[string]*openrtb.SeatBid, len(seatBids)) +func mapifySeatBids(t *testing.T, context string, seatBids []openrtb2.SeatBid) map[string]*openrtb2.SeatBid { + seatMap := make(map[string]*openrtb2.SeatBid, len(seatBids)) for i := 0; i < len(seatBids); i++ { seatName := seatBids[i].Seat if _, ok := seatMap[seatName]; ok { @@ -3036,7 +3036,7 @@ func (e *mockUsersync) LiveSyncCount() int { type panicingAdapter struct{} -func (panicingAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (posb *pbsOrtbSeatBid, errs []error) { +func (panicingAdapter) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (posb *pbsOrtbSeatBid, errs []error) { panic("Panic! Panic! The world is ending!") } diff --git a/exchange/gdpr.go b/exchange/gdpr.go index e861f948773..a6b4a22dc8f 100644 --- a/exchange/gdpr.go +++ b/exchange/gdpr.go @@ -3,12 +3,12 @@ package exchange import ( "encoding/json" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/gdpr" ) // ExtractGDPR will pull the gdpr flag from an openrtb request -func extractGDPR(bidRequest *openrtb.BidRequest) (gdpr.Signal, error) { +func extractGDPR(bidRequest *openrtb2.BidRequest) (gdpr.Signal, error) { var re regsExt var err error if bidRequest.Regs != nil && bidRequest.Regs.Ext != nil { @@ -21,7 +21,7 @@ func extractGDPR(bidRequest *openrtb.BidRequest) (gdpr.Signal, error) { } // ExtractConsent will pull the consent string from an openrtb request -func extractConsent(bidRequest *openrtb.BidRequest) (consent string, err error) { +func extractConsent(bidRequest *openrtb2.BidRequest) (consent string, err error) { var ue userExt if bidRequest.User != nil && bidRequest.User.Ext != nil { err = json.Unmarshal(bidRequest.User.Ext, &ue) diff --git a/exchange/gdpr_test.go b/exchange/gdpr_test.go index 351939091da..420b299f2cc 100644 --- a/exchange/gdpr_test.go +++ b/exchange/gdpr_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/gdpr" "github.com/stretchr/testify/assert" ) @@ -12,23 +12,23 @@ import ( func TestExtractGDPR(t *testing.T) { tests := []struct { description string - giveRegs *openrtb.Regs + giveRegs *openrtb2.Regs wantGDPR gdpr.Signal wantError bool }{ { description: "Regs Ext GDPR = 0", - giveRegs: &openrtb.Regs{Ext: json.RawMessage(`{"gdpr": 0}`)}, + giveRegs: &openrtb2.Regs{Ext: json.RawMessage(`{"gdpr": 0}`)}, wantGDPR: gdpr.SignalNo, }, { description: "Regs Ext GDPR = 1", - giveRegs: &openrtb.Regs{Ext: json.RawMessage(`{"gdpr": 1}`)}, + giveRegs: &openrtb2.Regs{Ext: json.RawMessage(`{"gdpr": 1}`)}, wantGDPR: gdpr.SignalYes, }, { description: "Regs Ext GDPR = null", - giveRegs: &openrtb.Regs{Ext: json.RawMessage(`{"gdpr": null}`)}, + giveRegs: &openrtb2.Regs{Ext: json.RawMessage(`{"gdpr": null}`)}, wantGDPR: gdpr.SignalAmbiguous, }, { @@ -38,19 +38,19 @@ func TestExtractGDPR(t *testing.T) { }, { description: "Regs Ext is nil", - giveRegs: &openrtb.Regs{Ext: nil}, + giveRegs: &openrtb2.Regs{Ext: nil}, wantGDPR: gdpr.SignalAmbiguous, }, { description: "JSON unmarshal error", - giveRegs: &openrtb.Regs{Ext: json.RawMessage(`{"`)}, + giveRegs: &openrtb2.Regs{Ext: json.RawMessage(`{"`)}, wantGDPR: gdpr.SignalAmbiguous, wantError: true, }, } for _, tt := range tests { - bidReq := openrtb.BidRequest{ + bidReq := openrtb2.BidRequest{ Regs: tt.giveRegs, } @@ -68,23 +68,23 @@ func TestExtractGDPR(t *testing.T) { func TestExtractConsent(t *testing.T) { tests := []struct { description string - giveUser *openrtb.User + giveUser *openrtb2.User wantConsent string wantError bool }{ { description: "User Ext Consent is not empty", - giveUser: &openrtb.User{Ext: json.RawMessage(`{"consent": "BOS2bx5OS2bx5ABABBAAABoAAAAAFA"}`)}, + giveUser: &openrtb2.User{Ext: json.RawMessage(`{"consent": "BOS2bx5OS2bx5ABABBAAABoAAAAAFA"}`)}, wantConsent: "BOS2bx5OS2bx5ABABBAAABoAAAAAFA", }, { description: "User Ext Consent is empty", - giveUser: &openrtb.User{Ext: json.RawMessage(`{"consent": ""}`)}, + giveUser: &openrtb2.User{Ext: json.RawMessage(`{"consent": ""}`)}, wantConsent: "", }, { description: "User Ext is nil", - giveUser: &openrtb.User{Ext: nil}, + giveUser: &openrtb2.User{Ext: nil}, wantConsent: "", }, { @@ -94,14 +94,14 @@ func TestExtractConsent(t *testing.T) { }, { description: "JSON unmarshal error", - giveUser: &openrtb.User{Ext: json.RawMessage(`{`)}, + giveUser: &openrtb2.User{Ext: json.RawMessage(`{`)}, wantConsent: "", wantError: true, }, } for _, tt := range tests { - bidReq := openrtb.BidRequest{ + bidReq := openrtb2.BidRequest{ User: tt.giveUser, } diff --git a/exchange/legacy.go b/exchange/legacy.go index b4845b76c69..ea8b65c28f0 100644 --- a/exchange/legacy.go +++ b/exchange/legacy.go @@ -6,7 +6,7 @@ import ( "errors" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/currency" "github.com/prebid/prebid-server/openrtb_ext" @@ -33,7 +33,7 @@ type adaptedAdapter struct { // // This is not ideal. OpenRTB provides a superset of the legacy data structures. // For requests which use those features, the best we can do is respond with "no bid". -func (bidder *adaptedAdapter) requestBid(ctx context.Context, request *openrtb.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { +func (bidder *adaptedAdapter) requestBid(ctx context.Context, request *openrtb2.BidRequest, name openrtb_ext.BidderName, bidAdjustment float64, conversions currency.Conversions, reqInfo *adapters.ExtraRequestInfo, accountDebugAllowed bool) (*pbsOrtbSeatBid, []error) { legacyRequest, legacyBidder, errs := bidder.toLegacyAdapterInputs(request, name) if legacyRequest == nil || legacyBidder == nil { return nil, errs @@ -58,7 +58,7 @@ func (bidder *adaptedAdapter) requestBid(ctx context.Context, request *openrtb.B // toLegacyAdapterInputs is a best-effort transformation of an OpenRTB BidRequest into the args needed to run a legacy Adapter. // If the OpenRTB request is too complex, it fails with an error. // If the error is nil, then the PBSRequest and PBSBidder are valid. -func (bidder *adaptedAdapter) toLegacyAdapterInputs(req *openrtb.BidRequest, name openrtb_ext.BidderName) (*pbs.PBSRequest, *pbs.PBSBidder, []error) { +func (bidder *adaptedAdapter) toLegacyAdapterInputs(req *openrtb2.BidRequest, name openrtb_ext.BidderName) (*pbs.PBSRequest, *pbs.PBSBidder, []error) { legacyReq, err := bidder.toLegacyRequest(req) if err != nil { return nil, nil, []error{err} @@ -72,7 +72,7 @@ func (bidder *adaptedAdapter) toLegacyAdapterInputs(req *openrtb.BidRequest, nam return legacyReq, legacyBidder, errs } -func (bidder *adaptedAdapter) toLegacyRequest(req *openrtb.BidRequest) (*pbs.PBSRequest, error) { +func (bidder *adaptedAdapter) toLegacyRequest(req *openrtb2.BidRequest) (*pbs.PBSRequest, error) { acctId, err := toAccountId(req) if err != nil { return nil, err @@ -126,7 +126,7 @@ func (bidder *adaptedAdapter) toLegacyRequest(req *openrtb.BidRequest) (*pbs.PBS App: req.App, Device: req.Device, // PBSUser is excluded because rubicon is the only adapter which reads from it, and they're supporting OpenRTB directly - // SDK is excluded because that information doesn't exist in OpenRTB. + // SDK is excluded because that information doesn't exist in openrtb2. // Bidders is excluded because no legacy adapters read from it User: req.User, Cookie: cookie, @@ -137,7 +137,7 @@ func (bidder *adaptedAdapter) toLegacyRequest(req *openrtb.BidRequest) (*pbs.PBS }, nil } -func toAccountId(req *openrtb.BidRequest) (string, error) { +func toAccountId(req *openrtb2.BidRequest) (string, error) { if req.Site != nil && req.Site.Publisher != nil { return req.Site.Publisher.ID, nil } @@ -147,14 +147,14 @@ func toAccountId(req *openrtb.BidRequest) (string, error) { return "", errors.New("bidrequest.site.publisher.id or bidrequest.app.publisher.id required for legacy bidders.") } -func toTransactionId(req *openrtb.BidRequest) (string, error) { +func toTransactionId(req *openrtb2.BidRequest) (string, error) { if req.Source != nil { return req.Source.TID, nil } return "", errors.New("bidrequest.source.tid required for legacy bidders.") } -func toSecure(req *openrtb.BidRequest) (secure int8, err error) { +func toSecure(req *openrtb2.BidRequest) (secure int8, err error) { secure = -1 for _, imp := range req.Imp { if imp.Secure != nil { @@ -181,7 +181,7 @@ func toSecure(req *openrtb.BidRequest) (secure int8, err error) { return } -func toLegacyBidder(req *openrtb.BidRequest, name openrtb_ext.BidderName) (*pbs.PBSBidder, []error) { +func toLegacyBidder(req *openrtb2.BidRequest, name openrtb_ext.BidderName) (*pbs.PBSBidder, []error) { adUnits, errs := toPBSAdUnits(req) if len(adUnits) > 0 { return &pbs.PBSBidder{ @@ -202,7 +202,7 @@ func toLegacyBidder(req *openrtb.BidRequest, name openrtb_ext.BidderName) (*pbs. } } -func toPBSAdUnits(req *openrtb.BidRequest) ([]pbs.PBSAdUnit, []error) { +func toPBSAdUnits(req *openrtb2.BidRequest) ([]pbs.PBSAdUnit, []error) { adUnits := make([]pbs.PBSAdUnit, len(req.Imp)) var errs []error = nil nextAdUnit := 0 @@ -217,8 +217,8 @@ func toPBSAdUnits(req *openrtb.BidRequest) ([]pbs.PBSAdUnit, []error) { return adUnits[:nextAdUnit], errs } -func initPBSAdUnit(imp *openrtb.Imp, adUnit *pbs.PBSAdUnit) error { - var sizes []openrtb.Format = nil +func initPBSAdUnit(imp *openrtb2.Imp, adUnit *pbs.PBSAdUnit) error { + var sizes []openrtb2.Format = nil video := pbs.PBSVideo{} if imp.Video != nil { @@ -242,7 +242,7 @@ func initPBSAdUnit(imp *openrtb.Imp, adUnit *pbs.PBSAdUnit) error { } // Fixes #360 if imp.Video.W != 0 && imp.Video.H != 0 { - sizes = append(sizes, openrtb.Format{ + sizes = append(sizes, openrtb2.Format{ W: imp.Video.W, H: imp.Video.H, }) @@ -324,12 +324,12 @@ func transformBid(legacyBid *pbs.PBSBid) (*pbsOrtbBid, error) { }, nil } -func transformBidToOrtb(legacyBid *pbs.PBSBid) *openrtb.Bid { - return &openrtb.Bid{ +func transformBidToOrtb(legacyBid *pbs.PBSBid) *openrtb2.Bid { + return &openrtb2.Bid{ ID: legacyBid.BidID, ImpID: legacyBid.AdUnitCode, CrID: legacyBid.Creative_id, - // legacyBid.CreativeMediaType is handled by transformBid(), because it doesn't exist on the openrtb.Bid + // legacyBid.CreativeMediaType is handled by transformBid(), because it doesn't exist on the openrtb2.Bid // legacyBid.BidderCode is handled by the exchange, which already knows which bidder we are. // legacyBid.BidHash is ignored, because it doesn't get sent in the response anyway Price: legacyBid.Price, diff --git a/exchange/legacy_test.go b/exchange/legacy_test.go index 2cef4feae40..aa684287997 100644 --- a/exchange/legacy_test.go +++ b/exchange/legacy_test.go @@ -11,7 +11,7 @@ import ( "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/currency" "github.com/prebid/prebid-server/openrtb_ext" @@ -20,35 +20,35 @@ import ( ) func TestSiteVideo(t *testing.T) { - ortbRequest := &openrtb.BidRequest{ + ortbRequest := &openrtb2.BidRequest{ ID: "request-id", TMax: 1000, - Site: &openrtb.Site{ + Site: &openrtb2.Site{ Page: "http://www.site.com", Domain: "site.com", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "b1c81a38-1415-42b7-8238-0d2d64016c27", }, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "transaction-id", }, - User: &openrtb.User{ + User: &openrtb2.User{ ID: "host-id", BuyerUID: "bidder-id", }, Test: 1, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "imp-id", - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: []string{"video/mp4"}, MinDuration: 20, MaxDuration: 40, - Protocols: []openrtb.Protocol{openrtb.ProtocolVAST10}, - StartDelay: openrtb.StartDelayGenericMidRoll.Ptr(), + Protocols: []openrtb2.Protocol{openrtb2.ProtocolVAST10}, + StartDelay: openrtb2.StartDelayGenericMidRoll.Ptr(), }, - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }}, @@ -85,7 +85,7 @@ func TestSiteVideo(t *testing.T) { func TestAppBanner(t *testing.T) { ortbRequest := newAppOrtbRequest() ortbRequest.TMax = 1000 - ortbRequest.User = &openrtb.User{ + ortbRequest.User = &openrtb2.User{ ID: "host-id", BuyerUID: "bidder-id", } @@ -187,8 +187,8 @@ func TestBidTransforms(t *testing.T) { func TestInsecureImps(t *testing.T) { insecure := int8(0) - bidReq := &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ + bidReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ Secure: &insecure, }, { Secure: &insecure, @@ -205,8 +205,8 @@ func TestInsecureImps(t *testing.T) { func TestSecureImps(t *testing.T) { secure := int8(1) - bidReq := &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ + bidReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ Secure: &secure, }, { Secure: &secure, @@ -224,8 +224,8 @@ func TestSecureImps(t *testing.T) { func TestMixedSecureImps(t *testing.T) { insecure := int8(0) secure := int8(1) - bidReq := &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ + bidReq := &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ Secure: &insecure, }, { Secure: &secure, @@ -237,21 +237,21 @@ func TestMixedSecureImps(t *testing.T) { } } -func newAppOrtbRequest() *openrtb.BidRequest { - return &openrtb.BidRequest{ +func newAppOrtbRequest() *openrtb2.BidRequest { + return &openrtb2.BidRequest{ ID: "request-id", - App: &openrtb.App{ - Publisher: &openrtb.Publisher{ + App: &openrtb2.App{ + Publisher: &openrtb2.Publisher{ ID: "b1c81a38-1415-42b7-8238-0d2d64016c27", }, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "transaction-id", }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }}, @@ -262,20 +262,20 @@ func newAppOrtbRequest() *openrtb.BidRequest { } func TestErrorResponse(t *testing.T) { - ortbRequest := &openrtb.BidRequest{ + ortbRequest := &openrtb2.BidRequest{ ID: "request-id", - App: &openrtb.App{ - Publisher: &openrtb.Publisher{ + App: &openrtb2.App{ + Publisher: &openrtb2.Publisher{ ID: "b1c81a38-1415-42b7-8238-0d2d64016c27", }, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "transaction-id", }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }}, @@ -300,20 +300,20 @@ func TestErrorResponse(t *testing.T) { } func TestWithTargeting(t *testing.T) { - ortbRequest := &openrtb.BidRequest{ + ortbRequest := &openrtb2.BidRequest{ ID: "request-id", - App: &openrtb.App{ - Publisher: &openrtb.Publisher{ + App: &openrtb2.App{ + Publisher: &openrtb2.Publisher{ ID: "b1c81a38-1415-42b7-8238-0d2d64016c27", }, }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "transaction-id", }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }}, @@ -343,7 +343,7 @@ func TestWithTargeting(t *testing.T) { // assertEquivalentFields compares the OpenRTB request with the legacy request, using the mappings defined here: // https://gist.github.com/dbemiller/68aa3387189fa17d3addfb9818dd4d97 -func assertEquivalentRequests(t *testing.T, req *openrtb.BidRequest, legacy *pbs.PBSRequest) { +func assertEquivalentRequests(t *testing.T, req *openrtb2.BidRequest, legacy *pbs.PBSRequest) { if req.Site != nil { if req.Site.Publisher.ID != legacy.AccountID { t.Errorf("Account ID did not translate. OpenRTB: %s, Legacy: %s.", req.Site.Publisher.ID, legacy.AccountID) @@ -399,7 +399,7 @@ func assertEquivalentRequests(t *testing.T, req *openrtb.BidRequest, legacy *pbs } } -func assertEquivalentBidder(t *testing.T, req *openrtb.BidRequest, legacy *pbs.PBSBidder) { +func assertEquivalentBidder(t *testing.T, req *openrtb2.BidRequest, legacy *pbs.PBSBidder) { if len(req.Imp) != len(legacy.AdUnits) { t.Errorf("Wrong number of Imps. Expected %d, got %d", len(req.Imp), len(legacy.AdUnits)) return @@ -409,7 +409,7 @@ func assertEquivalentBidder(t *testing.T, req *openrtb.BidRequest, legacy *pbs.P } } -func assertEquivalentImp(t *testing.T, index int, imp *openrtb.Imp, legacy *pbs.PBSAdUnit) { +func assertEquivalentImp(t *testing.T, index int, imp *openrtb2.Imp, legacy *pbs.PBSAdUnit) { if imp.ID != legacy.BidID { t.Errorf("imp[%d].id did not translate. OpenRTB %s, legacy %s", index, imp.ID, legacy.BidID) } diff --git a/exchange/targeting.go b/exchange/targeting.go index 87bec6f3077..f79e05be930 100644 --- a/exchange/targeting.go +++ b/exchange/targeting.go @@ -3,7 +3,7 @@ package exchange import ( "strconv" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" ) @@ -91,9 +91,9 @@ func (targData *targetData) addKeys(keys map[string]string, key openrtb_ext.Targ } } -func makeHbSize(bid *openrtb.Bid) string { +func makeHbSize(bid *openrtb2.Bid) string { if bid.W != 0 && bid.H != 0 { - return strconv.FormatUint(bid.W, 10) + "x" + strconv.FormatUint(bid.H, 10) + return strconv.FormatInt(bid.W, 10) + "x" + strconv.FormatInt(bid.H, 10) } return "" } diff --git a/exchange/targeting_test.go b/exchange/targeting_test.go index 2a77c4f7517..2cdf403439f 100644 --- a/exchange/targeting_test.go +++ b/exchange/targeting_test.go @@ -8,6 +8,7 @@ import ( "testing" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/currency" @@ -16,14 +17,13 @@ import ( metricsConf "github.com/prebid/prebid-server/metrics/config" metricsConfig "github.com/prebid/prebid-server/metrics/config" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) // Using this set of bids in more than one test -var mockBids = map[openrtb_ext.BidderName][]*openrtb.Bid{ +var mockBids = map[openrtb_ext.BidderName][]*openrtb2.Bid{ openrtb_ext.BidderAppnexus: {{ ID: "losing-bid", ImpID: "some-imp", @@ -67,7 +67,7 @@ func TestTargetingCache(t *testing.T) { } -func assertKeyExists(t *testing.T, bid *openrtb.Bid, key string, expected bool) { +func assertKeyExists(t *testing.T, bid *openrtb2.Bid, key string, expected bool) { t.Helper() targets := parseTargets(t, bid) if _, ok := targets[key]; ok != expected { @@ -77,7 +77,7 @@ func assertKeyExists(t *testing.T, bid *openrtb.Bid, key string, expected bool) // runAuction takes a bunch of mock bids by Bidder and runs an auction. It returns a map of Bids indexed by their ImpID. // If includeCache is true, the auction will be run with cacheing as well, so the cache targeting keys should exist. -func runTargetingAuction(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bid, includeCache bool, includeWinners bool, includeBidderKeys bool, isApp bool) map[string]*openrtb.Bid { +func runTargetingAuction(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb2.Bid, includeCache bool, includeWinners bool, includeBidderKeys bool, isApp bool) map[string]*openrtb2.Bid { server := httptest.NewServer(http.HandlerFunc(mockServer)) defer server.Close() @@ -99,14 +99,14 @@ func runTargetingAuction(t *testing.T, mockBids map[openrtb_ext.BidderName][]*op imps := buildImps(t, mockBids) - req := &openrtb.BidRequest{ + req := &openrtb2.BidRequest{ Imp: imps, Ext: buildTargetingExt(includeCache, includeWinners, includeBidderKeys), } if isApp { - req.App = &openrtb.App{} + req.App = &openrtb2.App{} } else { - req.Site = &openrtb.Site{} + req.Site = &openrtb2.Site{} } auctionRequest := AuctionRequest{ @@ -128,7 +128,7 @@ func runTargetingAuction(t *testing.T, mockBids map[openrtb_ext.BidderName][]*op return buildBidMap(bidResp.SeatBid, len(mockBids)) } -func buildBidderList(bids map[openrtb_ext.BidderName][]*openrtb.Bid) []openrtb_ext.BidderName { +func buildBidderList(bids map[openrtb_ext.BidderName][]*openrtb2.Bid) []openrtb_ext.BidderName { bidders := make([]openrtb_ext.BidderName, 0, len(bids)) for name := range bids { bidders = append(bidders, name) @@ -136,7 +136,7 @@ func buildBidderList(bids map[openrtb_ext.BidderName][]*openrtb.Bid) []openrtb_e return bidders } -func buildAdapterMap(bids map[openrtb_ext.BidderName][]*openrtb.Bid, mockServerURL string, client *http.Client) map[openrtb_ext.BidderName]adaptedBidder { +func buildAdapterMap(bids map[openrtb_ext.BidderName][]*openrtb2.Bid, mockServerURL string, client *http.Client) map[openrtb_ext.BidderName]adaptedBidder { adapterMap := make(map[openrtb_ext.BidderName]adaptedBidder, len(bids)) for bidder, bids := range bids { adapterMap[bidder] = adaptBidder(&mockTargetingBidder{ @@ -166,7 +166,7 @@ func buildTargetingExt(includeCache bool, includeWinners bool, includeBidderKeys return json.RawMessage(`{"prebid":{"targeting":` + targeting + `}}`) } -func buildParams(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bid) json.RawMessage { +func buildParams(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb2.Bid) json.RawMessage { params := make(map[string]json.RawMessage) for bidder := range mockBids { params[string(bidder)] = json.RawMessage(`{"whatever":true}`) @@ -178,7 +178,7 @@ func buildParams(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bi return ext } -func buildImps(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bid) []openrtb.Imp { +func buildImps(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb2.Bid) []openrtb2.Imp { impExt := buildParams(t, mockBids) var s struct{} @@ -189,9 +189,9 @@ func buildImps(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bid) } } - imps := make([]openrtb.Imp, 0, len(impIds)) + imps := make([]openrtb2.Imp, 0, len(impIds)) for impId := range impIds { - imps = append(imps, openrtb.Imp{ + imps = append(imps, openrtb2.Imp{ ID: impId, Ext: impExt, }) @@ -199,8 +199,8 @@ func buildImps(t *testing.T, mockBids map[openrtb_ext.BidderName][]*openrtb.Bid) return imps } -func buildBidMap(seatBids []openrtb.SeatBid, numBids int) map[string]*openrtb.Bid { - bids := make(map[string]*openrtb.Bid, numBids) +func buildBidMap(seatBids []openrtb2.SeatBid, numBids int) map[string]*openrtb2.Bid { + bids := make(map[string]*openrtb2.Bid, numBids) for _, seatBid := range seatBids { for i := 0; i < len(seatBid.Bid); i++ { bid := seatBid.Bid[i] @@ -210,7 +210,7 @@ func buildBidMap(seatBids []openrtb.SeatBid, numBids int) map[string]*openrtb.Bi return bids } -func parseTargets(t *testing.T, bid *openrtb.Bid) map[string]string { +func parseTargets(t *testing.T, bid *openrtb2.Bid) map[string]string { t.Helper() var parsed openrtb_ext.ExtBid if err := json.Unmarshal(bid.Ext, &parsed); err != nil { @@ -221,10 +221,10 @@ func parseTargets(t *testing.T, bid *openrtb.Bid) map[string]string { type mockTargetingBidder struct { mockServerURL string - bids []*openrtb.Bid + bids []*openrtb2.Bid } -func (m *mockTargetingBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (m *mockTargetingBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { return []*adapters.RequestData{{ Method: "POST", Uri: m.mockServerURL, @@ -233,7 +233,7 @@ func (m *mockTargetingBidder) MakeRequests(request *openrtb.BidRequest, reqInfo }}, nil } -func (m *mockTargetingBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (m *mockTargetingBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { bidResponse := &adapters.BidderResponse{ Bids: make([]*adapters.TypedBid, len(m.bids)), } @@ -259,15 +259,15 @@ type TargetingTestData struct { ExpectedBidTargetsByBidder map[string]map[openrtb_ext.BidderName]map[string]string } -var bid123 *openrtb.Bid = &openrtb.Bid{ +var bid123 *openrtb2.Bid = &openrtb2.Bid{ Price: 1.23, } -var bid111 *openrtb.Bid = &openrtb.Bid{ +var bid111 *openrtb2.Bid = &openrtb2.Bid{ Price: 1.11, DealID: "mydeal", } -var bid084 *openrtb.Bid = &openrtb.Bid{ +var bid084 *openrtb2.Bid = &openrtb2.Bid{ Price: 0.84, } @@ -396,7 +396,7 @@ var TargetingTests []TargetingTestData = []TargetingTestData{ }, }, }, - cacheIds: map[*openrtb.Bid]string{ + cacheIds: map[*openrtb2.Bid]string{ bid123: "55555", bid111: "cacheme", }, diff --git a/exchange/utils.go b/exchange/utils.go index 0d9d0e3ced8..f011669e1f2 100644 --- a/exchange/utils.go +++ b/exchange/utils.go @@ -6,10 +6,10 @@ import ( "fmt" "math/rand" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/go-gdpr/vendorconsent" "github.com/buger/jsonparser" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/gdpr" "github.com/prebid/prebid-server/metrics" @@ -153,7 +153,7 @@ func ccpaEnabled(account *config.Account, privacyConfig config.Privacy, requestT return privacyConfig.CCPA.Enforce } -func extractCCPA(orig *openrtb.BidRequest, privacyConfig config.Privacy, account *config.Account, aliases map[string]string, requestType config.IntegrationType) (privacy.PolicyEnforcer, error) { +func extractCCPA(orig *openrtb2.BidRequest, privacyConfig config.Privacy, account *config.Account, aliases map[string]string, requestType config.IntegrationType) (privacy.PolicyEnforcer, error) { ccpaPolicy, err := ccpa.ReadFromRequest(orig) if err != nil { return privacy.NilPolicyEnforcer{}, err @@ -172,7 +172,7 @@ func extractCCPA(orig *openrtb.BidRequest, privacyConfig config.Privacy, account return ccpaEnforcer, nil } -func extractLMT(orig *openrtb.BidRequest, privacyConfig config.Privacy) privacy.PolicyEnforcer { +func extractLMT(orig *openrtb2.BidRequest, privacyConfig config.Privacy) privacy.PolicyEnforcer { return privacy.EnabledPolicyEnforcer{ Enabled: privacyConfig.LMT.Enforce, PolicyEnforcer: lmt.ReadFromRequest(orig), @@ -181,7 +181,7 @@ func extractLMT(orig *openrtb.BidRequest, privacyConfig config.Privacy) privacy. func getAuctionBidderRequests(req AuctionRequest, requestExt *openrtb_ext.ExtRequest, - impsByBidder map[string][]openrtb.Imp, + impsByBidder map[string][]openrtb2.Imp, aliases map[string]string) ([]BidderRequest, []error) { bidderRequests := make([]BidderRequest, 0, len(impsByBidder)) @@ -243,7 +243,7 @@ func getAuctionBidderRequests(req AuctionRequest, return bidderRequests, errs } -func getExtJson(req *openrtb.BidRequest, unpackedExt *openrtb_ext.ExtRequest) (json.RawMessage, error) { +func getExtJson(req *openrtb2.BidRequest, unpackedExt *openrtb_ext.ExtRequest) (json.RawMessage, error) { if len(req.Ext) == 0 || unpackedExt == nil { return json.RawMessage(``), nil } @@ -253,7 +253,7 @@ func getExtJson(req *openrtb.BidRequest, unpackedExt *openrtb_ext.ExtRequest) (j return json.Marshal(extCopy) } -func prepareSource(req *openrtb.BidRequest, bidder string, sChainsByBidder map[string]*openrtb_ext.ExtRequestPrebidSChainSChain) { +func prepareSource(req *openrtb2.BidRequest, bidder string, sChainsByBidder map[string]*openrtb_ext.ExtRequestPrebidSChainSChain) { const sChainWildCard = "*" var selectedSChain *openrtb_ext.ExtRequestPrebidSChainSChain @@ -273,7 +273,7 @@ func prepareSource(req *openrtb.BidRequest, bidder string, sChainsByBidder map[s // set source if req.Source == nil { - req.Source = &openrtb.Source{} + req.Source = &openrtb2.Source{} } schain := openrtb_ext.ExtRequestPrebidSChain{ SChain: *selectedSChain, @@ -286,7 +286,7 @@ func prepareSource(req *openrtb.BidRequest, bidder string, sChainsByBidder map[s // extractBuyerUIDs parses the values from user.ext.prebid.buyeruids, and then deletes those values from the ext. // This prevents a Bidder from using these values to figure out who else is involved in the Auction. -func extractBuyerUIDs(user *openrtb.User) (map[string]string, error) { +func extractBuyerUIDs(user *openrtb2.User) (map[string]string, error) { if user == nil { return nil, nil } @@ -328,8 +328,8 @@ func extractBuyerUIDs(user *openrtb.User) (map[string]string, error) { // The "imp.ext" value of the rubicon Imp will only contain the "prebid" values, and "rubicon" value at the "bidder" key. // // The goal here is so that Bidders only get Imps and Imp.Ext values which are intended for them. -func splitImps(imps []openrtb.Imp) (map[string][]openrtb.Imp, error) { - bidderImps := make(map[string][]openrtb.Imp) +func splitImps(imps []openrtb2.Imp) (map[string][]openrtb2.Imp, error) { + bidderImps := make(map[string][]openrtb2.Imp) for i, imp := range imps { var impExt map[string]json.RawMessage @@ -433,7 +433,7 @@ func isSpecialField(bidder string) bool { // // In this function, "givenBidder" may or may not be an alias. "coreBidder" must *not* be an alias. // It returns true if a Cookie User Sync existed, and false otherwise. -func prepareUser(req *openrtb.BidRequest, givenBidder string, coreBidder openrtb_ext.BidderName, explicitBuyerUIDs map[string]string, usersyncs IdFetcher) bool { +func prepareUser(req *openrtb2.BidRequest, givenBidder string, coreBidder openrtb_ext.BidderName, explicitBuyerUIDs map[string]string, usersyncs IdFetcher) bool { cookieId, hadCookie := usersyncs.GetId(coreBidder) if id, ok := explicitBuyerUIDs[givenBidder]; ok { @@ -447,9 +447,9 @@ func prepareUser(req *openrtb.BidRequest, givenBidder string, coreBidder openrtb // copyWithBuyerUID either overwrites the BuyerUID property on user with the argument, or returns // a new (empty) User with the BuyerUID already set. -func copyWithBuyerUID(user *openrtb.User, buyerUID string) *openrtb.User { +func copyWithBuyerUID(user *openrtb2.User, buyerUID string) *openrtb2.User { if user == nil { - return &openrtb.User{ + return &openrtb2.User{ BuyerUID: buyerUID, } } @@ -462,7 +462,7 @@ func copyWithBuyerUID(user *openrtb.User, buyerUID string) *openrtb.User { } // removeUnpermissionedEids modifies the request to remove any request.user.ext.eids not permissions for the specific bidder -func removeUnpermissionedEids(request *openrtb.BidRequest, bidder string, requestExt *openrtb_ext.ExtRequest) error { +func removeUnpermissionedEids(request *openrtb2.BidRequest, bidder string, requestExt *openrtb_ext.ExtRequest) error { // ensure request might have eids (as much as we can check before unmarshalling) if request.User == nil || len(request.User.Ext) == 0 { return nil @@ -549,7 +549,7 @@ func removeUnpermissionedEids(request *openrtb.BidRequest, bidder string, reques return nil } -func setUserExtWithCopy(request *openrtb.BidRequest, userExtJSON json.RawMessage) { +func setUserExtWithCopy(request *openrtb2.BidRequest, userExtJSON json.RawMessage) { userCopy := *request.User userCopy.Ext = userExtJSON request.User = &userCopy @@ -564,7 +564,7 @@ func resolveBidder(bidder string, aliases map[string]string) openrtb_ext.BidderN } // parseAliases parses the aliases from the BidRequest -func parseAliases(orig *openrtb.BidRequest) (map[string]string, []error) { +func parseAliases(orig *openrtb2.BidRequest) (map[string]string, []error) { var aliases map[string]string if value, dataType, _, err := jsonparser.Get(orig.Ext, openrtb_ext.PrebidExtKey, "aliases"); dataType == jsonparser.Object && err == nil { if err := json.Unmarshal(value, &aliases); err != nil { @@ -597,7 +597,7 @@ func randomizeList(list []openrtb_ext.BidderName) { } } -func extractBidRequestExt(bidRequest *openrtb.BidRequest) (*openrtb_ext.ExtRequest, error) { +func extractBidRequestExt(bidRequest *openrtb2.BidRequest) (*openrtb_ext.ExtRequest, error) { requestExt := &openrtb_ext.ExtRequest{} if bidRequest == nil { @@ -660,7 +660,7 @@ func getExtTargetData(requestExt *openrtb_ext.ExtRequest, cacheInstructions *ext return targData } -func getDebugInfo(bidRequest *openrtb.BidRequest, requestExt *openrtb_ext.ExtRequest) bool { +func getDebugInfo(bidRequest *openrtb2.BidRequest, requestExt *openrtb_ext.ExtRequest) bool { return (bidRequest != nil && bidRequest.Test == 1) || (requestExt != nil && requestExt.Prebid.Debug) } diff --git a/exchange/utils_test.go b/exchange/utils_test.go index f8603f18f4f..05e22548639 100644 --- a/exchange/utils_test.go +++ b/exchange/utils_test.go @@ -7,7 +7,7 @@ import ( "fmt" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/gdpr" @@ -58,28 +58,28 @@ func assertReq(t *testing.T, bidderRequests []BidderRequest, func TestSplitImps(t *testing.T) { testCases := []struct { description string - givenImps []openrtb.Imp - expectedImps map[string][]openrtb.Imp + givenImps []openrtb2.Imp + expectedImps map[string][]openrtb2.Imp expectedError string }{ { description: "Nil", givenImps: nil, - expectedImps: map[string][]openrtb.Imp{}, + expectedImps: map[string][]openrtb2.Imp{}, expectedError: "", }, { description: "Empty", - givenImps: []openrtb.Imp{}, - expectedImps: map[string][]openrtb.Imp{}, + givenImps: []openrtb2.Imp{}, + expectedImps: map[string][]openrtb2.Imp{}, expectedError: "", }, { description: "1 Imp, 1 Bidder", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1ParamA":"imp1ValueA"}}}}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, }, @@ -88,10 +88,10 @@ func TestSplitImps(t *testing.T) { }, { description: "1 Imp, 2 Bidders", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1ParamA":"imp1ValueA"},"bidderB":{"imp1ParamB":"imp1ValueB"}}}}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, }, @@ -103,11 +103,11 @@ func TestSplitImps(t *testing.T) { }, { description: "2 Imps, 1 Bidders Each", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1ParamA":"imp1ValueA"}}}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp2ParamA":"imp2ValueA"}}}}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2ParamA":"imp2ValueA"}}`)}, @@ -117,11 +117,11 @@ func TestSplitImps(t *testing.T) { }, { description: "2 Imps, 2 Bidders Each", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1paramA":"imp1valueA"},"bidderB":{"imp1paramB":"imp1valueB"}}}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp2paramA":"imp2valueA"},"bidderB":{"imp2paramB":"imp2valueB"}}}}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"}}`)}, @@ -136,11 +136,11 @@ func TestSplitImps(t *testing.T) { { // This is a "happy path" integration test. Functionality is covered in detail by TestCreateSanitizedImpExt. description: "Other Fields - 2 Imps, 2 Bidders Each", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1paramA":"imp1valueA"},"bidderB":{"imp1paramB":"imp1valueB"}}},"skadn":"imp1SkAdN"}`)}, {ID: "imp2", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp2paramA":"imp2valueA"},"bidderB":{"imp2paramB":"imp2valueB"}}},"skadn":"imp2SkAdN"}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"},"skadn":"imp1SkAdN"}`)}, {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"},"skadn":"imp2SkAdN"}`)}, @@ -155,11 +155,11 @@ func TestSplitImps(t *testing.T) { { // This is a "happy path" integration test. Functionality is covered in detail by TestExtractBidderExts. description: "Legacy imp.ext.BIDDER - 2 Imps, 2 Bidders Each", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"bidderA":{"imp1paramA":"imp1valueA"},"bidderB":{"imp1paramB":"imp1valueB"}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"bidderA":{"imp2paramA":"imp2valueA"},"bidderB":{"imp2paramB":"imp2valueB"}}`)}, }, - expectedImps: map[string][]openrtb.Imp{ + expectedImps: map[string][]openrtb2.Imp{ "bidderA": { {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"}}`)}, {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"}}`)}, @@ -173,21 +173,21 @@ func TestSplitImps(t *testing.T) { }, { description: "Malformed imp.ext", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`malformed`)}, }, expectedError: "invalid json for imp[0]: invalid character 'm' looking for beginning of value", }, { description: "Malformed imp.ext.prebid", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid": malformed}`)}, }, expectedError: "invalid json for imp[0]: invalid character 'm' looking for beginning of value", }, { description: "Malformed imp.ext.prebid.bidder", - givenImps: []openrtb.Imp{ + givenImps: []openrtb2.Imp{ {ID: "imp1", Ext: json.RawMessage(`{"prebid": {"bidder": malformed}}`)}, }, expectedError: "invalid json for imp[0]: invalid character 'm' looking for beginning of value", @@ -594,7 +594,7 @@ func TestCleanOpenRTBRequestsCCPA(t *testing.T) { for _, test := range testCases { req := newBidRequest(t) req.Ext = test.reqExt - req.Regs = &openrtb.Regs{ + req.Regs = &openrtb2.Regs{ Ext: json.RawMessage(`{"us_privacy":"` + test.ccpaConsent + `"}`), } @@ -664,7 +664,7 @@ func TestCleanOpenRTBRequestsCCPAErrors(t *testing.T) { for _, test := range testCases { req := newBidRequest(t) req.Ext = test.reqExt - req.Regs = &openrtb.Regs{Ext: test.reqRegsExt} + req.Regs = &openrtb2.Regs{Ext: test.reqRegsExt} var reqExtStruct openrtb_ext.ExtRequest err := json.Unmarshal(req.Ext, &reqExtStruct) @@ -713,7 +713,7 @@ func TestCleanOpenRTBRequestsCOPPA(t *testing.T) { for _, test := range testCases { req := newBidRequest(t) - req.Regs = &openrtb.Regs{COPPA: test.coppa} + req.Regs = &openrtb2.Regs{COPPA: test.coppa} auctionReq := AuctionRequest{ BidRequest: req, @@ -847,13 +847,13 @@ func TestExtractBidRequestExt(t *testing.T) { testCases := []struct { desc string - inBidRequest *openrtb.BidRequest + inBidRequest *openrtb2.BidRequest outRequestExt *openrtb_ext.ExtRequest outError error }{ { desc: "Valid vastxml.returnCreative set to false", - inBidRequest: &openrtb.BidRequest{Ext: json.RawMessage(`{"prebid":{"debug":true,"cache":{"vastxml":{"returnCreative":false}}}}`)}, + inBidRequest: &openrtb2.BidRequest{Ext: json.RawMessage(`{"prebid":{"debug":true,"cache":{"vastxml":{"returnCreative":false}}}}`)}, outRequestExt: &openrtb_ext.ExtRequest{ Prebid: openrtb_ext.ExtRequestPrebid{ Debug: true, @@ -868,7 +868,7 @@ func TestExtractBidRequestExt(t *testing.T) { }, { desc: "Valid vastxml.returnCreative set to true", - inBidRequest: &openrtb.BidRequest{Ext: json.RawMessage(`{"prebid":{"debug":true,"cache":{"vastxml":{"returnCreative":true}}}}`)}, + inBidRequest: &openrtb2.BidRequest{Ext: json.RawMessage(`{"prebid":{"debug":true,"cache":{"vastxml":{"returnCreative":true}}}}`)}, outRequestExt: &openrtb_ext.ExtRequest{ Prebid: openrtb_ext.ExtRequestPrebid{ Debug: true, @@ -889,13 +889,13 @@ func TestExtractBidRequestExt(t *testing.T) { }, { desc: "Non-nil bidRequest with empty Ext, we expect a blank requestExt", - inBidRequest: &openrtb.BidRequest{}, + inBidRequest: &openrtb2.BidRequest{}, outRequestExt: &openrtb_ext.ExtRequest{}, outError: nil, }, { desc: "Non-nil bidRequest with non-empty, invalid Ext, we expect unmarshaling error", - inBidRequest: &openrtb.BidRequest{Ext: json.RawMessage(`invalid`)}, + inBidRequest: &openrtb2.BidRequest{Ext: json.RawMessage(`invalid`)}, outRequestExt: &openrtb_ext.ExtRequest{}, outError: fmt.Errorf("Error decoding Request.ext : invalid character 'i' looking for beginning of value"), }, @@ -1263,7 +1263,7 @@ func TestGetExtTargetData(t *testing.T) { func TestGetDebugInfo(t *testing.T) { type inTest struct { - bidRequest *openrtb.BidRequest + bidRequest *openrtb2.BidRequest requestExt *openrtb_ext.ExtRequest } testCases := []struct { @@ -1278,7 +1278,7 @@ func TestGetDebugInfo(t *testing.T) { }, { desc: "bid request test == 0, nil requestExt", - in: inTest{&openrtb.BidRequest{Test: 0}, nil}, + in: inTest{&openrtb2.BidRequest{Test: 0}, nil}, out: false, }, { @@ -1288,22 +1288,22 @@ func TestGetDebugInfo(t *testing.T) { }, { desc: "bid request test == 0, requestExt debug flag false", - in: inTest{&openrtb.BidRequest{Test: 0}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: false}}}, + in: inTest{&openrtb2.BidRequest{Test: 0}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: false}}}, out: false, }, { desc: "bid request test == 1, requestExt debug flag false", - in: inTest{&openrtb.BidRequest{Test: 1}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: false}}}, + in: inTest{&openrtb2.BidRequest{Test: 1}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: false}}}, out: true, }, { desc: "bid request test == 0, requestExt debug flag true", - in: inTest{&openrtb.BidRequest{Test: 0}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: true}}}, + in: inTest{&openrtb2.BidRequest{Test: 0}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: true}}}, out: true, }, { desc: "bid request test == 1, requestExt debug flag true", - in: inTest{&openrtb.BidRequest{Test: 1}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: true}}}, + in: inTest{&openrtb2.BidRequest{Test: 1}, &openrtb_ext.ExtRequest{Prebid: openrtb_ext.ExtRequestPrebid{Debug: true}}}, out: true, }, } @@ -1593,7 +1593,7 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) { for _, test := range testCases { req := newBidRequest(t) req.User.Ext = json.RawMessage(`{"consent":"` + test.gdprConsent + `"}`) - req.Regs = &openrtb.Regs{ + req.Regs = &openrtb2.Regs{ Ext: json.RawMessage(`{"gdpr":` + test.gdpr + `}`), } @@ -1646,17 +1646,17 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) { } // newAdapterAliasBidRequest builds a BidRequest with aliases -func newAdapterAliasBidRequest(t *testing.T) *openrtb.BidRequest { +func newAdapterAliasBidRequest(t *testing.T) *openrtb2.BidRequest { dnt := int8(1) - return &openrtb.BidRequest{ - Site: &openrtb.Site{ + return &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "www.some.domain.com", Domain: "domain.com", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "some-publisher-id", }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ DIDMD5: "some device ID hash", UA: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", IFA: "ifa", @@ -1664,21 +1664,21 @@ func newAdapterAliasBidRequest(t *testing.T) *openrtb.BidRequest { DNT: &dnt, Language: "EN", }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "61018dc9-fa61-4c41-b7dc-f90b9ae80e87", }, - User: &openrtb.User{ + User: &openrtb2.User{ ID: "our-id", BuyerUID: "their-id", Ext: json.RawMessage(`{"consent":"BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw","digitrust":{"id":"digi-id","keyv":1,"pref":1}}`), }, - Regs: &openrtb.Regs{ + Regs: &openrtb2.Regs{ Ext: json.RawMessage(`{"gdpr":1}`), }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }, { @@ -1692,35 +1692,35 @@ func newAdapterAliasBidRequest(t *testing.T) *openrtb.BidRequest { } } -func newBidRequest(t *testing.T) *openrtb.BidRequest { - return &openrtb.BidRequest{ - Site: &openrtb.Site{ +func newBidRequest(t *testing.T) *openrtb2.BidRequest { + return &openrtb2.BidRequest{ + Site: &openrtb2.Site{ Page: "www.some.domain.com", Domain: "domain.com", - Publisher: &openrtb.Publisher{ + Publisher: &openrtb2.Publisher{ ID: "some-publisher-id", }, }, - Device: &openrtb.Device{ + Device: &openrtb2.Device{ DIDMD5: "some device ID hash", UA: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36", IFA: "ifa", IP: "132.173.230.74", Language: "EN", }, - Source: &openrtb.Source{ + Source: &openrtb2.Source{ TID: "61018dc9-fa61-4c41-b7dc-f90b9ae80e87", }, - User: &openrtb.User{ + User: &openrtb2.User{ ID: "our-id", BuyerUID: "their-id", Yob: 1982, Ext: json.RawMessage(`{"digitrust":{"id":"digi-id","keyv":1,"pref":1}}`), }, - Imp: []openrtb.Imp{{ + Imp: []openrtb2.Imp{{ ID: "some-imp-id", - Banner: &openrtb.Banner{ - Format: []openrtb.Format{{ + Banner: &openrtb2.Banner{ + Format: []openrtb2.Format{{ W: 300, H: 250, }, { @@ -1969,8 +1969,8 @@ func TestRemoveUnpermissionedEids(t *testing.T) { } for _, test := range testCases { - request := &openrtb.BidRequest{ - User: &openrtb.User{Ext: test.userExt}, + request := &openrtb2.BidRequest{ + User: &openrtb2.User{Ext: test.userExt}, } requestExt := &openrtb_ext.ExtRequest{ @@ -1981,8 +1981,8 @@ func TestRemoveUnpermissionedEids(t *testing.T) { }, } - expectedRequest := &openrtb.BidRequest{ - User: &openrtb.User{Ext: test.expectedUserExt}, + expectedRequest := &openrtb2.BidRequest{ + User: &openrtb2.User{Ext: test.expectedUserExt}, } resultErr := removeUnpermissionedEids(request, bidder, requestExt) @@ -2015,8 +2015,8 @@ func TestRemoveUnpermissionedEidsUnmarshalErrors(t *testing.T) { } for _, test := range testCases { - request := &openrtb.BidRequest{ - User: &openrtb.User{Ext: test.userExt}, + request := &openrtb2.BidRequest{ + User: &openrtb2.User{Ext: test.userExt}, } requestExt := &openrtb_ext.ExtRequest{ @@ -2037,12 +2037,12 @@ func TestRemoveUnpermissionedEidsUnmarshalErrors(t *testing.T) { func TestRemoveUnpermissionedEidsEmptyValidations(t *testing.T) { testCases := []struct { description string - request *openrtb.BidRequest + request *openrtb2.BidRequest requestExt *openrtb_ext.ExtRequest }{ { description: "Nil User", - request: &openrtb.BidRequest{ + request: &openrtb2.BidRequest{ User: nil, }, requestExt: &openrtb_ext.ExtRequest{ @@ -2057,8 +2057,8 @@ func TestRemoveUnpermissionedEidsEmptyValidations(t *testing.T) { }, { description: "Empty User", - request: &openrtb.BidRequest{ - User: &openrtb.User{}, + request: &openrtb2.BidRequest{ + User: &openrtb2.User{}, }, requestExt: &openrtb_ext.ExtRequest{ Prebid: openrtb_ext.ExtRequestPrebid{ @@ -2072,15 +2072,15 @@ func TestRemoveUnpermissionedEidsEmptyValidations(t *testing.T) { }, { description: "Nil Ext", - request: &openrtb.BidRequest{ - User: &openrtb.User{Ext: json.RawMessage(`{"eids":[{"source":"source1","id":"anyID"}]}`)}, + request: &openrtb2.BidRequest{ + User: &openrtb2.User{Ext: json.RawMessage(`{"eids":[{"source":"source1","id":"anyID"}]}`)}, }, requestExt: nil, }, { description: "Nil Prebid Data", - request: &openrtb.BidRequest{ - User: &openrtb.User{Ext: json.RawMessage(`{"eids":[{"source":"source1","id":"anyID"}]}`)}, + request: &openrtb2.BidRequest{ + User: &openrtb2.User{Ext: json.RawMessage(`{"eids":[{"source":"source1","id":"anyID"}]}`)}, }, requestExt: &openrtb_ext.ExtRequest{ Prebid: openrtb_ext.ExtRequestPrebid{ diff --git a/go.mod b/go.mod index 48fc6b6479b..67f95057bee 100644 --- a/go.mod +++ b/go.mod @@ -23,19 +23,16 @@ require ( github.com/influxdata/influxdb v1.6.1 github.com/julienschmidt/httprouter v1.1.0 github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect - github.com/kr/pretty v0.2.0 // indirect github.com/lib/pq v1.0.0 github.com/magiconair/properties v1.8.0 github.com/mattn/go-colorable v0.1.2 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/mapstructure v1.0.0 // indirect - github.com/mssola/user_agent v0.4.1 // indirect - github.com/mxmCherry/openrtb v11.0.0+incompatible + github.com/mxmCherry/openrtb/v14 v14.0.0 github.com/onsi/ginkgo v1.10.1 // indirect github.com/onsi/gomega v1.7.0 // indirect github.com/pelletier/go-toml v1.2.0 // indirect github.com/prebid/go-gdpr v0.8.3 - github.com/prebid/prebid-cache v0.0.0-20200218152159-6d6d678c1caf // indirect github.com/prometheus/client_golang v0.0.0-20180623155954-77e8f2ddcfed github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect diff --git a/go.sum b/go.sum index 6da3f8898ba..f9c9bb887da 100644 --- a/go.sum +++ b/go.sum @@ -48,11 +48,6 @@ github.com/julienschmidt/httprouter v1.1.0 h1:7wLdtIiIpzOkC9u6sXOozpBauPdskj3ru4 github.com/julienschmidt/httprouter v1.1.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.0.0 h1:X5PMW56eZitiTeO7tKzZxFCSpbFZJtkMMooicw2us9A= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= @@ -65,13 +60,13 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/mapstructure v1.0.0 h1:vVpGvMXJPqSDh2VYHF7gsfQj8Ncx+Xw5Y1KHeTRY+7I= github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mssola/user_agent v0.4.1 h1:iTUaMpVrb2qWyvUw8UvK3ygWMd2lB1NGuZ1xhpBf1eg= -github.com/mssola/user_agent v0.4.1/go.mod h1:UFiKPVaShrJGW93n4uo8dpPdg1BSVpw2P9bneo0Mtp8= -github.com/mxmCherry/openrtb v11.0.0+incompatible h1:tNzh7vKwQ8lopBAadyN3QPryawXSaVXYWi1IVluXHiM= -github.com/mxmCherry/openrtb v11.0.0+incompatible/go.mod h1:zpnz6Au3bzTGplpRU0kvFPNT6g4ROAKx/GkrslFDwZk= +github.com/mxmCherry/openrtb/v14 v14.0.0 h1:7CUpdQi6Hqi9k03AaUAZVYF3Kqt6ZXryBUFQv8IA/N8= +github.com/mxmCherry/openrtb/v14 v14.0.0/go.mod h1:aAj4RuDpol+zMEVyKiDqiXPHfXevLVmyAf3f6BkRaJw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= @@ -80,12 +75,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prebid/go-gdpr v0.8.3 h1:rjCZNV0AdKygiGHpVhNB42usjEpTN3qidXUPB1yarb0= github.com/prebid/go-gdpr v0.8.3/go.mod h1:TGzgqQDGKOVUkbqmY25K4uvcwMywSddXEaY4zUFiVBQ= -github.com/prebid/prebid-cache v0.0.0-20200218152159-6d6d678c1caf h1:CcE+KN1tCtWKsUFH5IzdQxHIgP609VSIVe5Hywg2phs= -github.com/prebid/prebid-cache v0.0.0-20200218152159-6d6d678c1caf/go.mod h1:k5xrl5ZpnumN1S2x8w8cMiFYsgRuVyAeFJz+BkSi+98= github.com/prometheus/client_golang v0.0.0-20180623155954-77e8f2ddcfed h1:0dloFFFNNDG7c+8qtkYw2FdADrWy9s5cI8wHp6tK3Mg= github.com/prometheus/client_golang v0.0.0-20180623155954-77e8f2ddcfed/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A= -github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e h1:n/3MEhJQjQxrOUCzh1Y3Re6aJUUWRp2M9+Oc3eVn/54= @@ -136,7 +127,6 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200602114024-627f9648deb9 h1:pNX+40auqi2JqRfOP1akLGtYcn15TUbkhwuCO3foqqM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/openrtb_ext/bid_request_video.go b/openrtb_ext/bid_request_video.go index 09edf51d0db..16b66fc20fc 100644 --- a/openrtb_ext/bid_request_video.go +++ b/openrtb_ext/bid_request_video.go @@ -1,8 +1,6 @@ package openrtb_ext -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" type BidRequestVideo struct { // Attribute: @@ -27,7 +25,7 @@ type BidRequestVideo struct { // object; App or Site required // Description: // Application where the impression will be shown - App *openrtb.App `json:"app"` + App *openrtb2.App `json:"app"` // Attribute: // site @@ -35,7 +33,7 @@ type BidRequestVideo struct { // object; App or Site required // Description: // Site where the impression will be shown - Site *openrtb.Site `json:"site"` + Site *openrtb2.Site `json:"site"` // Attribute: // user @@ -43,7 +41,7 @@ type BidRequestVideo struct { // object; optional // Description: // Container object for the user of of the actual device - User *openrtb.User `json:"user,omitempty"` + User *openrtb2.User `json:"user,omitempty"` // Attribute: // device @@ -51,7 +49,7 @@ type BidRequestVideo struct { // object; optional // Description: // Device specific data - Device openrtb.Device `json:"device,omitempty"` + Device openrtb2.Device `json:"device,omitempty"` // Attribute: // includebrandcategory @@ -67,7 +65,7 @@ type BidRequestVideo struct { // object; required // Description: // Player container object - Video *openrtb.Video `json:"video,omitempty"` + Video *openrtb2.Video `json:"video,omitempty"` // Attribute: // content @@ -75,7 +73,7 @@ type BidRequestVideo struct { // object; optional // Description: // Misc content meta data that can be used for targeting the adPod(s) - Content openrtb.Content `json:"content,omitempty"` + Content openrtb2.Content `json:"content,omitempty"` // Attribute: // cacheconfig @@ -135,7 +133,7 @@ type BidRequestVideo struct { // object; optional // Description: // Contains the OpenRTB Regs object to be passed to OpenRTB request - Regs *openrtb.Regs `json:"regs,omitempty"` + Regs *openrtb2.Regs `json:"regs,omitempty"` // Attribute: // supportdeals diff --git a/openrtb_ext/deal_tier.go b/openrtb_ext/deal_tier.go index 8583c053e8f..66236e9477d 100644 --- a/openrtb_ext/deal_tier.go +++ b/openrtb_ext/deal_tier.go @@ -3,7 +3,7 @@ package openrtb_ext import ( "encoding/json" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" ) // DealTier defines the configuration of a deal tier. @@ -20,7 +20,7 @@ type DealTier struct { type DealTierBidderMap map[BidderName]DealTier // ReadDealTiersFromImp returns a map of bidder deal tiers read from the impression of an original request (not split / cleaned). -func ReadDealTiersFromImp(imp openrtb.Imp) (DealTierBidderMap, error) { +func ReadDealTiersFromImp(imp openrtb2.Imp) (DealTierBidderMap, error) { dealTiers := make(DealTierBidderMap) if len(imp.Ext) == 0 { diff --git a/openrtb_ext/deal_tier_test.go b/openrtb_ext/deal_tier_test.go index 1bb4d5648f0..607956ecb38 100644 --- a/openrtb_ext/deal_tier_test.go +++ b/openrtb_ext/deal_tier_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) @@ -83,7 +83,7 @@ func TestReadDealTiersFromImp(t *testing.T) { } for _, test := range testCases { - imp := openrtb.Imp{Ext: test.impExt} + imp := openrtb2.Imp{Ext: test.impExt} result, err := ReadDealTiersFromImp(imp) diff --git a/openrtb_ext/response.go b/openrtb_ext/response.go index d517704f44d..d61ec54a887 100644 --- a/openrtb_ext/response.go +++ b/openrtb_ext/response.go @@ -1,8 +1,6 @@ package openrtb_ext -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" // ExtBidResponse defines the contract for bidresponse.ext type ExtBidResponse struct { @@ -27,7 +25,7 @@ type ExtResponseDebug struct { // HttpCalls defines the contract for bidresponse.ext.debug.httpcalls HttpCalls map[BidderName][]*ExtHttpCall `json:"httpcalls,omitempty"` // Request after resolution of stored requests and debug overrides - ResolvedRequest *openrtb.BidRequest `json:"resolvedrequest,omitempty"` + ResolvedRequest *openrtb2.BidRequest `json:"resolvedrequest,omitempty"` } // ExtResponseSyncData defines the contract for bidresponse.ext.usersync.{bidder} diff --git a/pbs/pbsrequest.go b/pbs/pbsrequest.go index 30f8bd25c0d..795cfaf9533 100644 --- a/pbs/pbsrequest.go +++ b/pbs/pbsrequest.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/cache" "github.com/prebid/prebid-server/config" "github.com/prebid/prebid-server/stored_requests" @@ -20,7 +21,6 @@ import ( "github.com/blang/semver" "github.com/buger/jsonparser" "github.com/golang/glog" - "github.com/mxmCherry/openrtb" "golang.org/x/net/publicsuffix" ) @@ -84,18 +84,18 @@ type PBSVideo struct { } type AdUnit struct { - Code string `json:"code"` - TopFrame int8 `json:"is_top_frame"` - Sizes []openrtb.Format `json:"sizes"` - Bids []Bids `json:"bids"` - ConfigID string `json:"config_id"` - MediaTypes []string `json:"media_types"` - Instl int8 `json:"instl"` - Video PBSVideo `json:"video"` + Code string `json:"code"` + TopFrame int8 `json:"is_top_frame"` + Sizes []openrtb2.Format `json:"sizes"` + Bids []Bids `json:"bids"` + ConfigID string `json:"config_id"` + MediaTypes []string `json:"media_types"` + Instl int8 `json:"instl"` + Video PBSVideo `json:"video"` } type PBSAdUnit struct { - Sizes []openrtb.Format + Sizes []openrtb2.Format TopFrame int8 Code string BidID string @@ -153,27 +153,27 @@ func (bidder *PBSBidder) LookupAdUnit(Code string) (unit *PBSAdUnit) { } type PBSRequest struct { - AccountID string `json:"account_id"` - Tid string `json:"tid"` - CacheMarkup int8 `json:"cache_markup"` - SortBids int8 `json:"sort_bids"` - MaxKeyLength int8 `json:"max_key_length"` - Secure int8 `json:"secure"` - TimeoutMillis int64 `json:"timeout_millis"` - AdUnits []AdUnit `json:"ad_units"` - IsDebug bool `json:"is_debug"` - App *openrtb.App `json:"app"` - Device *openrtb.Device `json:"device"` - PBSUser json.RawMessage `json:"user"` - SDK *SDK `json:"sdk"` + AccountID string `json:"account_id"` + Tid string `json:"tid"` + CacheMarkup int8 `json:"cache_markup"` + SortBids int8 `json:"sort_bids"` + MaxKeyLength int8 `json:"max_key_length"` + Secure int8 `json:"secure"` + TimeoutMillis int64 `json:"timeout_millis"` + AdUnits []AdUnit `json:"ad_units"` + IsDebug bool `json:"is_debug"` + App *openrtb2.App `json:"app"` + Device *openrtb2.Device `json:"device"` + PBSUser json.RawMessage `json:"user"` + SDK *SDK `json:"sdk"` // internal Bidders []*PBSBidder `json:"-"` - User *openrtb.User `json:"-"` + User *openrtb2.User `json:"-"` Cookie *usersync.PBSCookie `json:"-"` Url string `json:"-"` Domain string `json:"-"` - Regs *openrtb.Regs `json:"-"` + Regs *openrtb2.Regs `json:"-"` Start time.Time } @@ -236,7 +236,7 @@ func ParsePBSRequest(r *http.Request, cfg *config.AuctionTimeouts, cache cache.C pbsReq.TimeoutMillis = int64(cfg.LimitAuctionTimeout(time.Duration(pbsReq.TimeoutMillis)*time.Millisecond) / time.Millisecond) if pbsReq.Device == nil { - pbsReq.Device = &openrtb.Device{} + pbsReq.Device = &openrtb2.Device{} } if ip, _ := httputil.FindIP(r, ipv4Validator); ip != nil { pbsReq.Device.IP = ip.String() @@ -259,7 +259,7 @@ func ParsePBSRequest(r *http.Request, cfg *config.AuctionTimeouts, cache cache.C } if pbsReq.User == nil { - pbsReq.User = &openrtb.User{} + pbsReq.User = &openrtb2.User{} } // use client-side data for web requests diff --git a/pbs/pbsresponse.go b/pbs/pbsresponse.go index 7c6cea31261..b8cf2c19ff7 100644 --- a/pbs/pbsresponse.go +++ b/pbs/pbsresponse.go @@ -32,9 +32,9 @@ type PBSBid struct { // If NURL and Adm are both defined, then Adm takes precedence. Adm string `json:"adm,omitempty"` // Width is the intended width which Adm should be shown, in pixels. - Width uint64 `json:"width,omitempty"` + Width int64 `json:"width,omitempty"` // Height is the intended width which Adm should be shown, in pixels. - Height uint64 `json:"height,omitempty"` + Height int64 `json:"height,omitempty"` // DealId is not used by prebid-server, but may be used by buyers and sellers who make special // deals with each other. We simply pass this information along with the bid. DealId string `json:"deal_id,omitempty"` diff --git a/prebid_cache_client/client.go b/prebid_cache_client/client.go index 88c197cd0b8..730d54b0acb 100644 --- a/prebid_cache_client/client.go +++ b/prebid_cache_client/client.go @@ -22,7 +22,7 @@ import ( // Client stores values in Prebid Cache. For more info, see https://github.com/prebid/prebid-cache type Client interface { - // PutJson stores JSON values for the given openrtb.Bids in the cache. Null values will be + // PutJson stores JSON values for the given openrtb2.Bids in the cache. Null values will be // // The returned string slice will always have the same number of elements as the values argument. If a // value could not be saved, the element will be an empty string. Implementations are responsible for diff --git a/prebid_cache_client/prebid_cache.go b/prebid_cache_client/prebid_cache.go index c2f682c6129..cde7ec8d951 100644 --- a/prebid_cache_client/prebid_cache.go +++ b/prebid_cache_client/prebid_cache.go @@ -22,8 +22,8 @@ type CacheObject struct { type BidCache struct { Adm string `json:"adm,omitempty"` NURL string `json:"nurl,omitempty"` - Width uint64 `json:"width,omitempty"` - Height uint64 `json:"height,omitempty"` + Width int64 `json:"width,omitempty"` + Height int64 `json:"height,omitempty"` } // internal protocol objects diff --git a/privacy/ccpa/consentwriter.go b/privacy/ccpa/consentwriter.go index 4856655402b..67b5681deca 100644 --- a/privacy/ccpa/consentwriter.go +++ b/privacy/ccpa/consentwriter.go @@ -1,8 +1,6 @@ package ccpa -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" // ConsentWriter implements the PolicyWriter interface for CCPA. type ConsentWriter struct { @@ -10,7 +8,7 @@ type ConsentWriter struct { } // Write mutates an OpenRTB bid request with the CCPA consent string. -func (c ConsentWriter) Write(req *openrtb.BidRequest) error { +func (c ConsentWriter) Write(req *openrtb2.BidRequest) error { if req == nil { return nil } diff --git a/privacy/ccpa/consentwriter_test.go b/privacy/ccpa/consentwriter_test.go index 57a7f8f4ddf..d805936cf72 100644 --- a/privacy/ccpa/consentwriter_test.go +++ b/privacy/ccpa/consentwriter_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) @@ -12,8 +12,8 @@ func TestConsentWriter(t *testing.T) { consent := "anyConsent" testCases := []struct { description string - request *openrtb.BidRequest - expected *openrtb.BidRequest + request *openrtb2.BidRequest + expected *openrtb2.BidRequest expectedError bool }{ { @@ -23,19 +23,19 @@ func TestConsentWriter(t *testing.T) { }, { description: "Success", - request: &openrtb.BidRequest{}, - expected: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + request: &openrtb2.BidRequest{}, + expected: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, }, { description: "Error With Regs.Ext - Does Not Mutate", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`malformed}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed}`)}, }, expectedError: true, - expected: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`malformed}`)}, + expected: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed}`)}, }, }, } diff --git a/privacy/ccpa/parsedpolicy_test.go b/privacy/ccpa/parsedpolicy_test.go index 2f7e8bfd683..183a774363c 100644 --- a/privacy/ccpa/parsedpolicy_test.go +++ b/privacy/ccpa/parsedpolicy_test.go @@ -3,7 +3,7 @@ package ccpa import ( "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -385,7 +385,7 @@ type mockPolicWriter struct { mock.Mock } -func (m *mockPolicWriter) Write(req *openrtb.BidRequest) error { +func (m *mockPolicWriter) Write(req *openrtb2.BidRequest) error { args := m.Called(req) return args.Error(0) } diff --git a/privacy/ccpa/policy.go b/privacy/ccpa/policy.go index a9f1c49e47d..64250375106 100644 --- a/privacy/ccpa/policy.go +++ b/privacy/ccpa/policy.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" ) @@ -16,7 +16,7 @@ type Policy struct { } // ReadFromRequest extracts the CCPA regulatory information from an OpenRTB bid request. -func ReadFromRequest(req *openrtb.BidRequest) (Policy, error) { +func ReadFromRequest(req *openrtb2.BidRequest) (Policy, error) { var consent string var noSaleBidders []string @@ -46,7 +46,7 @@ func ReadFromRequest(req *openrtb.BidRequest) (Policy, error) { } // Write mutates an OpenRTB bid request with the CCPA regulatory information. -func (p Policy) Write(req *openrtb.BidRequest) error { +func (p Policy) Write(req *openrtb2.BidRequest) error { if req == nil { return nil } @@ -65,14 +65,14 @@ func (p Policy) Write(req *openrtb.BidRequest) error { return nil } -func buildRegs(consent string, regs *openrtb.Regs) (*openrtb.Regs, error) { +func buildRegs(consent string, regs *openrtb2.Regs) (*openrtb2.Regs, error) { if consent == "" { return buildRegsClear(regs) } return buildRegsWrite(consent, regs) } -func buildRegsClear(regs *openrtb.Regs) (*openrtb.Regs, error) { +func buildRegsClear(regs *openrtb2.Regs) (*openrtb2.Regs, error) { if regs == nil || len(regs.Ext) == 0 { return regs, nil } @@ -92,7 +92,7 @@ func buildRegsClear(regs *openrtb.Regs) (*openrtb.Regs, error) { } // Marshal ext if there are still other fields - var regsResult openrtb.Regs + var regsResult openrtb2.Regs ext, err := json.Marshal(extMap) if err == nil { regsResult = *regs @@ -101,9 +101,9 @@ func buildRegsClear(regs *openrtb.Regs) (*openrtb.Regs, error) { return ®sResult, err } -func buildRegsWrite(consent string, regs *openrtb.Regs) (*openrtb.Regs, error) { +func buildRegsWrite(consent string, regs *openrtb2.Regs) (*openrtb2.Regs, error) { if regs == nil { - return marshalRegsExt(openrtb.Regs{}, openrtb_ext.ExtRegs{USPrivacy: consent}) + return marshalRegsExt(openrtb2.Regs{}, openrtb_ext.ExtRegs{USPrivacy: consent}) } if regs.Ext == nil { @@ -119,7 +119,7 @@ func buildRegsWrite(consent string, regs *openrtb.Regs) (*openrtb.Regs, error) { return marshalRegsExt(*regs, extMap) } -func marshalRegsExt(regs openrtb.Regs, ext interface{}) (*openrtb.Regs, error) { +func marshalRegsExt(regs openrtb2.Regs, ext interface{}) (*openrtb2.Regs, error) { extJSON, err := json.Marshal(ext) if err == nil { regs.Ext = extJSON diff --git a/privacy/ccpa/policy_test.go b/privacy/ccpa/policy_test.go index 7ff896e9ebf..31eca2cca57 100644 --- a/privacy/ccpa/policy_test.go +++ b/privacy/ccpa/policy_test.go @@ -4,21 +4,21 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) func TestReadFromRequest(t *testing.T) { testCases := []struct { description string - request *openrtb.BidRequest + request *openrtb2.BidRequest expectedPolicy Policy expectedError bool }{ { description: "Success", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedPolicy: Policy{ @@ -36,7 +36,7 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Nil Regs", - request: &openrtb.BidRequest{ + request: &openrtb2.BidRequest{ Regs: nil, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, @@ -47,8 +47,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Nil Regs.Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedPolicy: Policy{ @@ -58,8 +58,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Empty Regs.Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{}`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedPolicy: Policy{ @@ -69,8 +69,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Missing Regs.Ext USPrivacy Value", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"anythingElse":"42"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"anythingElse":"42"}`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedPolicy: Policy{ @@ -80,24 +80,24 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Malformed Regs.Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`malformed`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedError: true, }, { description: "Invalid Regs.Ext Type", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":123`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":123`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a", "b"]}}`), }, expectedError: true, }, { description: "Nil Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: nil, }, expectedPolicy: Policy{ @@ -107,8 +107,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Empty Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: json.RawMessage(`{}`), }, expectedPolicy: Policy{ @@ -118,8 +118,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Missing Ext.Prebid No Sale Value", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: json.RawMessage(`{"anythingElse":"42"}`), }, expectedPolicy: Policy{ @@ -129,24 +129,24 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Malformed Ext", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: json.RawMessage(`malformed`), }, expectedError: true, }, { description: "Invalid Ext.Prebid.NoSale Type", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, Ext: json.RawMessage(`{"prebid":{"nosale":"wrongtype"}}`), }, expectedError: true, }, { description: "Injection Attack", - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"1YYY\"},\"oops\":\"malicious\",\"p\":{\"p\":\""}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"1YYY\"},\"oops\":\"malicious\",\"p\":{\"p\":\""}`)}, }, expectedPolicy: Policy{ Consent: "1YYY\"},\"oops\":\"malicious\",\"p\":{\"p\":\"", @@ -165,8 +165,8 @@ func TestWrite(t *testing.T) { testCases := []struct { description string policy Policy - request *openrtb.BidRequest - expected *openrtb.BidRequest + request *openrtb2.BidRequest + expected *openrtb2.BidRequest expectedError bool }{ { @@ -178,31 +178,31 @@ func TestWrite(t *testing.T) { { description: "Success", policy: Policy{Consent: "anyConsent", NoSaleBidders: []string{"a", "b"}}, - request: &openrtb.BidRequest{}, - expected: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + request: &openrtb2.BidRequest{}, + expected: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, Ext: json.RawMessage(`{"prebid":{"nosale":["a","b"]}}`), }, }, { description: "Error Regs.Ext - No Partial Update To Request", policy: Policy{Consent: "anyConsent", NoSaleBidders: []string{"a", "b"}}, - request: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`malformed}`)}, + request: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed}`)}, }, expectedError: true, - expected: &openrtb.BidRequest{ - Regs: &openrtb.Regs{Ext: json.RawMessage(`malformed}`)}, + expected: &openrtb2.BidRequest{ + Regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed}`)}, }, }, { description: "Error Ext - No Partial Update To Request", policy: Policy{Consent: "anyConsent", NoSaleBidders: []string{"a", "b"}}, - request: &openrtb.BidRequest{ + request: &openrtb2.BidRequest{ Ext: json.RawMessage(`malformed}`), }, expectedError: true, - expected: &openrtb.BidRequest{ + expected: &openrtb2.BidRequest{ Ext: json.RawMessage(`malformed}`), }, }, @@ -219,22 +219,22 @@ func TestBuildRegs(t *testing.T) { testCases := []struct { description string consent string - regs *openrtb.Regs - expected *openrtb.Regs + regs *openrtb2.Regs + expected *openrtb2.Regs expectedError bool }{ { description: "Clear", consent: "", - regs: &openrtb.Regs{ + regs: &openrtb2.Regs{ Ext: json.RawMessage(`{"us_privacy":"ABC"}`), }, - expected: &openrtb.Regs{}, + expected: &openrtb2.Regs{}, }, { description: "Clear - Error", consent: "", - regs: &openrtb.Regs{ + regs: &openrtb2.Regs{ Ext: json.RawMessage(`malformed`), }, expectedError: true, @@ -243,14 +243,14 @@ func TestBuildRegs(t *testing.T) { description: "Write", consent: "anyConsent", regs: nil, - expected: &openrtb.Regs{ + expected: &openrtb2.Regs{ Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`), }, }, { description: "Write - Error", consent: "anyConsent", - regs: &openrtb.Regs{ + regs: &openrtb2.Regs{ Ext: json.RawMessage(`malformed`), }, expectedError: true, @@ -267,8 +267,8 @@ func TestBuildRegs(t *testing.T) { func TestBuildRegsClear(t *testing.T) { testCases := []struct { description string - regs *openrtb.Regs - expected *openrtb.Regs + regs *openrtb2.Regs + expected *openrtb2.Regs expectedError bool }{ { @@ -278,32 +278,32 @@ func TestBuildRegsClear(t *testing.T) { }, { description: "Nil Regs.Ext", - regs: &openrtb.Regs{Ext: nil}, - expected: &openrtb.Regs{Ext: nil}, + regs: &openrtb2.Regs{Ext: nil}, + expected: &openrtb2.Regs{Ext: nil}, }, { description: "Empty Regs.Ext", - regs: &openrtb.Regs{Ext: json.RawMessage(`{}`)}, - expected: &openrtb.Regs{}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{}`)}, + expected: &openrtb2.Regs{}, }, { description: "Removes Regs.Ext Entirely", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, - expected: &openrtb.Regs{}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + expected: &openrtb2.Regs{}, }, { description: "Leaves Other Regs.Ext Values", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC", "other":"any"}`)}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"other":"any"}`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC", "other":"any"}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"other":"any"}`)}, }, { description: "Invalid Regs.Ext Type - Still Cleared", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":123}`)}, - expected: &openrtb.Regs{}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":123}`)}, + expected: &openrtb2.Regs{}, }, { description: "Malformed Regs.Ext", - regs: &openrtb.Regs{Ext: json.RawMessage(`malformed`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed`)}, expectedError: true, }, } @@ -319,50 +319,50 @@ func TestBuildRegsWrite(t *testing.T) { testCases := []struct { description string consent string - regs *openrtb.Regs - expected *openrtb.Regs + regs *openrtb2.Regs + expected *openrtb2.Regs expectedError bool }{ { description: "Nil Regs", consent: "anyConsent", regs: nil, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, { description: "Nil Regs.Ext", consent: "anyConsent", - regs: &openrtb.Regs{Ext: nil}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + regs: &openrtb2.Regs{Ext: nil}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, { description: "Empty Regs.Ext", consent: "anyConsent", - regs: &openrtb.Regs{Ext: json.RawMessage(`{}`)}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, { description: "Overwrites Existing", consent: "anyConsent", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"ABC"}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, { description: "Leaves Other Ext Values", consent: "anyConsent", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"other":"any"}`)}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"other":"any","us_privacy":"anyConsent"}`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"other":"any"}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"other":"any","us_privacy":"anyConsent"}`)}, }, { description: "Invalid Regs.Ext Type - Still Overwrites", consent: "anyConsent", - regs: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":123}`)}, - expected: &openrtb.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":123}`)}, + expected: &openrtb2.Regs{Ext: json.RawMessage(`{"us_privacy":"anyConsent"}`)}, }, { description: "Malformed Regs.Ext", consent: "anyConsent", - regs: &openrtb.Regs{Ext: json.RawMessage(`malformed`)}, + regs: &openrtb2.Regs{Ext: json.RawMessage(`malformed`)}, expectedError: true, }, } diff --git a/privacy/enforcement.go b/privacy/enforcement.go index 64070ae3a6a..4b946966206 100644 --- a/privacy/enforcement.go +++ b/privacy/enforcement.go @@ -1,8 +1,6 @@ package privacy -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" // Enforcement represents the privacy policies to enforce for an OpenRTB bid request. type Enforcement struct { @@ -19,11 +17,11 @@ func (e Enforcement) Any() bool { } // Apply cleans personally identifiable information from an OpenRTB bid request. -func (e Enforcement) Apply(bidRequest *openrtb.BidRequest) { +func (e Enforcement) Apply(bidRequest *openrtb2.BidRequest) { e.apply(bidRequest, NewScrubber()) } -func (e Enforcement) apply(bidRequest *openrtb.BidRequest, scrubber Scrubber) { +func (e Enforcement) apply(bidRequest *openrtb2.BidRequest, scrubber Scrubber) { if bidRequest != nil && e.Any() { bidRequest.Device = scrubber.ScrubDevice(bidRequest.Device, e.getDeviceIDScrubStrategy(), e.getIPv4ScrubStrategy(), e.getIPv6ScrubStrategy(), e.getGeoScrubStrategy()) bidRequest.User = scrubber.ScrubUser(bidRequest.User, e.getUserScrubStrategy(), e.getGeoScrubStrategy()) diff --git a/privacy/enforcement_test.go b/privacy/enforcement_test.go index 9240aafc2c3..5080709f2cb 100644 --- a/privacy/enforcement_test.go +++ b/privacy/enforcement_test.go @@ -3,7 +3,7 @@ package privacy import ( "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -197,12 +197,12 @@ func TestApply(t *testing.T) { } for _, test := range testCases { - req := &openrtb.BidRequest{ - Device: &openrtb.Device{}, - User: &openrtb.User{}, + req := &openrtb2.BidRequest{ + Device: &openrtb2.Device{}, + User: &openrtb2.User{}, } - replacedDevice := &openrtb.Device{} - replacedUser := &openrtb.User{} + replacedDevice := &openrtb2.Device{} + replacedUser := &openrtb2.User{} m := &mockScrubber{} m.On("ScrubDevice", req.Device, test.expectedDeviceID, test.expectedDeviceIPv4, test.expectedDeviceIPv6, test.expectedDeviceGeo).Return(replacedDevice).Once() @@ -217,7 +217,7 @@ func TestApply(t *testing.T) { } func TestApplyNoneApplicable(t *testing.T) { - req := &openrtb.BidRequest{} + req := &openrtb2.BidRequest{} m := &mockScrubber{} @@ -248,12 +248,12 @@ type mockScrubber struct { mock.Mock } -func (m *mockScrubber) ScrubDevice(device *openrtb.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb.Device { +func (m *mockScrubber) ScrubDevice(device *openrtb2.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb2.Device { args := m.Called(device, id, ipv4, ipv6, geo) - return args.Get(0).(*openrtb.Device) + return args.Get(0).(*openrtb2.Device) } -func (m *mockScrubber) ScrubUser(user *openrtb.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb.User { +func (m *mockScrubber) ScrubUser(user *openrtb2.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb2.User { args := m.Called(user, strategy, geo) - return args.Get(0).(*openrtb.User) + return args.Get(0).(*openrtb2.User) } diff --git a/privacy/gdpr/consentwriter.go b/privacy/gdpr/consentwriter.go index 040bbd6c94b..53885e51d49 100644 --- a/privacy/gdpr/consentwriter.go +++ b/privacy/gdpr/consentwriter.go @@ -3,9 +3,8 @@ package gdpr import ( "encoding/json" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" - - "github.com/mxmCherry/openrtb" ) // ConsentWriter implements the PolicyWriter interface for GDPR TCF. @@ -14,13 +13,13 @@ type ConsentWriter struct { } // Write mutates an OpenRTB bid request with the GDPR TCF consent. -func (c ConsentWriter) Write(req *openrtb.BidRequest) error { +func (c ConsentWriter) Write(req *openrtb2.BidRequest) error { if c.Consent == "" { return nil } if req.User == nil { - req.User = &openrtb.User{} + req.User = &openrtb2.User{} } if req.User.Ext == nil { diff --git a/privacy/gdpr/consentwriter_test.go b/privacy/gdpr/consentwriter_test.go index 77fbdf88d92..9b23dccc6e4 100644 --- a/privacy/gdpr/consentwriter_test.go +++ b/privacy/gdpr/consentwriter_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) @@ -12,76 +12,76 @@ func TestConsentWriter(t *testing.T) { testCases := []struct { description string consent string - request *openrtb.BidRequest - expected *openrtb.BidRequest + request *openrtb2.BidRequest + expected *openrtb2.BidRequest expectedError bool }{ { description: "Empty", consent: "", - request: &openrtb.BidRequest{}, - expected: &openrtb.BidRequest{}, + request: &openrtb2.BidRequest{}, + expected: &openrtb2.BidRequest{}, }, { description: "Enabled With Nil Request User Object", consent: "anyConsent", - request: &openrtb.BidRequest{}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{}, + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"anyConsent"}`)}}, }, { description: "Enabled With Nil Request User Ext Object", consent: "anyConsent", - request: &openrtb.BidRequest{User: &openrtb.User{}}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{}}, + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"anyConsent"}`)}}, }, { description: "Enabled With Existing Request User Ext Object - Doesn't Overwrite", consent: "anyConsent", - request: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"existing":"any"}`)}}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"anyConsent","existing":"any"}`)}}, }, { description: "Enabled With Existing Request User Ext Object - Overwrites", consent: "anyConsent", - request: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"existing":"any","consent":"toBeOverwritten"}`)}}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"anyConsent","existing":"any"}`)}}, }, { description: "Enabled With Existing Malformed Request User Ext Object", consent: "anyConsent", - request: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`malformed`)}}, expectedError: true, }, { description: "Injection Attack With Nil Request User Object", consent: "BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\"", - request: &openrtb.BidRequest{}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{}, + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\""}`), }}, }, { description: "Injection Attack With Nil Request User Ext Object", consent: "BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\"", - request: &openrtb.BidRequest{User: &openrtb.User{}}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{}}, + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\""}`), }}, }, { description: "Injection Attack With Existing Request User Ext Object", consent: "BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\"", - request: &openrtb.BidRequest{User: &openrtb.User{ + request: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"existing":"any"}`), }}, - expected: &openrtb.BidRequest{User: &openrtb.User{ + expected: &openrtb2.BidRequest{User: &openrtb2.User{ Ext: json.RawMessage(`{"consent":"BONV8oqONXwgmADACHENAO7pqzAAppY\"},\"oops\":\"malicious\",\"p\":{\"p\":\"","existing":"any"}`), }}, }, diff --git a/privacy/lmt/ios.go b/privacy/lmt/ios.go index cac9418643e..07bd7ce0a70 100644 --- a/privacy/lmt/ios.go +++ b/privacy/lmt/ios.go @@ -3,7 +3,7 @@ package lmt import ( "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/prebid-server/util/iosutil" ) @@ -14,7 +14,7 @@ var ( ) // ModifyForIOS modifies the request's LMT flag based on iOS version and identity. -func ModifyForIOS(req *openrtb.BidRequest) { +func ModifyForIOS(req *openrtb2.BidRequest) { modifiers := map[iosutil.VersionClassification]modifier{ iosutil.Version140: modifyForIOS14X, iosutil.Version141: modifyForIOS14X, @@ -23,7 +23,7 @@ func ModifyForIOS(req *openrtb.BidRequest) { modifyForIOS(req, modifiers) } -func modifyForIOS(req *openrtb.BidRequest, modifiers map[iosutil.VersionClassification]modifier) { +func modifyForIOS(req *openrtb2.BidRequest, modifiers map[iosutil.VersionClassification]modifier) { if !isRequestForIOS(req) { return } @@ -34,13 +34,13 @@ func modifyForIOS(req *openrtb.BidRequest, modifiers map[iosutil.VersionClassifi } } -func isRequestForIOS(req *openrtb.BidRequest) bool { +func isRequestForIOS(req *openrtb2.BidRequest) bool { return req != nil && req.App != nil && req.Device != nil && strings.EqualFold(req.Device.OS, "ios") } -type modifier func(req *openrtb.BidRequest) +type modifier func(req *openrtb2.BidRequest) -func modifyForIOS14X(req *openrtb.BidRequest) { +func modifyForIOS14X(req *openrtb2.BidRequest) { if req.Device.IFA == "" || req.Device.IFA == "00000000-0000-0000-0000-000000000000" { req.Device.Lmt = &int8One } else { @@ -48,7 +48,7 @@ func modifyForIOS14X(req *openrtb.BidRequest) { } } -func modifyForIOS142OrGreater(req *openrtb.BidRequest) { +func modifyForIOS142OrGreater(req *openrtb2.BidRequest) { atts, err := openrtb_ext.ParseDeviceExtATTS(req.Device.Ext) if err != nil || atts == nil { return diff --git a/privacy/lmt/ios_test.go b/privacy/lmt/ios_test.go index 1c860be33bd..5071adf4d04 100644 --- a/privacy/lmt/ios_test.go +++ b/privacy/lmt/ios_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/prebid/prebid-server/util/iosutil" "github.com/stretchr/testify/assert" ) @@ -13,24 +13,24 @@ import ( func TestModifyForIOS(t *testing.T) { testCases := []struct { description string - givenRequest *openrtb.BidRequest + givenRequest *openrtb2.BidRequest expectedLMT *int8 }{ { description: "13.0", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS", OSV: "13.0", IFA: "", Lmt: nil}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "13.0", IFA: "", Lmt: nil}, }, expectedLMT: nil, }, { description: "14.0", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS", OSV: "14.0", IFA: "", Lmt: nil}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "14.0", IFA: "", Lmt: nil}, }, - expectedLMT: openrtb.Int8Ptr(1), + expectedLMT: openrtb2.Int8Ptr(1), }, } @@ -43,50 +43,50 @@ func TestModifyForIOS(t *testing.T) { func TestModifyForIOSHelper(t *testing.T) { testCases := []struct { description string - givenRequest *openrtb.BidRequest + givenRequest *openrtb2.BidRequest expectedModifier140Called bool expectedModifier142Called bool }{ { description: "Valid 14.0", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS", OSV: "14.0"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "14.0"}, }, expectedModifier140Called: true, expectedModifier142Called: false, }, { description: "Valid 14.2 Or Greater", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS", OSV: "14.2"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "14.2"}, }, expectedModifier140Called: false, expectedModifier142Called: true, }, { description: "Invalid Version", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS", OSV: "invalid"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "invalid"}, }, expectedModifier140Called: false, expectedModifier142Called: false, }, { description: "Invalid OS", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "invalid", OSV: "14.0"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "invalid", OSV: "14.0"}, }, expectedModifier140Called: false, expectedModifier142Called: false, }, { description: "Invalid Nil Device", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, Device: nil, }, expectedModifier140Called: false, @@ -96,10 +96,10 @@ func TestModifyForIOSHelper(t *testing.T) { for _, test := range testCases { modifierIOS140Called := false - modifierIOS140 := func(req *openrtb.BidRequest) { modifierIOS140Called = true } + modifierIOS140 := func(req *openrtb2.BidRequest) { modifierIOS140Called = true } modifierIOS142Called := false - modifierIOS142 := func(req *openrtb.BidRequest) { modifierIOS142Called = true } + modifierIOS142 := func(req *openrtb2.BidRequest) { modifierIOS142Called = true } modifiers := map[iosutil.VersionClassification]modifier{ iosutil.Version140: modifierIOS140, @@ -116,22 +116,22 @@ func TestModifyForIOSHelper(t *testing.T) { func TestIsRequestForIOS(t *testing.T) { testCases := []struct { description string - givenRequest *openrtb.BidRequest + givenRequest *openrtb2.BidRequest expected bool }{ { description: "Valid", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "iOS"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS"}, }, expected: true, }, { description: "Valid - OS Case Insensitive", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "IOS"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "IOS"}, }, expected: true, }, @@ -142,33 +142,33 @@ func TestIsRequestForIOS(t *testing.T) { }, { description: "Invalid - Nil App", - givenRequest: &openrtb.BidRequest{ + givenRequest: &openrtb2.BidRequest{ App: nil, - Device: &openrtb.Device{OS: "iOS"}, + Device: &openrtb2.Device{OS: "iOS"}, }, expected: false, }, { description: "Invalid - Nil Device", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, Device: nil, }, expected: false, }, { description: "Invalid - Empty OS", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: ""}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: ""}, }, expected: false, }, { description: "Invalid - Wrong OS", - givenRequest: &openrtb.BidRequest{ - App: &openrtb.App{}, - Device: &openrtb.Device{OS: "Android"}, + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "Android"}, }, expected: false, }, @@ -183,33 +183,33 @@ func TestIsRequestForIOS(t *testing.T) { func TestModifyForIOS14X(t *testing.T) { testCases := []struct { description string - givenDevice openrtb.Device + givenDevice openrtb2.Device expectedLMT *int8 }{ { description: "IFA Empty", - givenDevice: openrtb.Device{IFA: "", Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{IFA: "", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), }, { description: "IFA Zero UUID", - givenDevice: openrtb.Device{IFA: "00000000-0000-0000-0000-000000000000", Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{IFA: "00000000-0000-0000-0000-000000000000", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), }, { description: "IFA Populated", - givenDevice: openrtb.Device{IFA: "any-real-value", Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(0), + givenDevice: openrtb2.Device{IFA: "any-real-value", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), }, { description: "Overwrites Existing", - givenDevice: openrtb.Device{IFA: "", Lmt: openrtb.Int8Ptr(0)}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{IFA: "", Lmt: openrtb2.Int8Ptr(0)}, + expectedLMT: openrtb2.Int8Ptr(1), }, } for _, test := range testCases { - request := &openrtb.BidRequest{Device: &test.givenDevice} + request := &openrtb2.BidRequest{Device: &test.givenDevice} modifyForIOS14X(request) assert.Equal(t, test.expectedLMT, request.Device.Lmt, test.description) } @@ -218,58 +218,58 @@ func TestModifyForIOS14X(t *testing.T) { func TestModifyForIOS142OrGreater(t *testing.T) { testCases := []struct { description string - givenDevice openrtb.Device + givenDevice openrtb2.Device expectedLMT *int8 }{ { description: "Not Determined", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":0}`), Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(0), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":0}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), }, { description: "Restricted", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":1}`), Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":1}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), }, { description: "Denied", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":2}`), Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":2}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), }, { description: "Authorized", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: nil}, - expectedLMT: openrtb.Int8Ptr(0), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), }, { description: "Overwrites Existing", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: openrtb.Int8Ptr(1)}, - expectedLMT: openrtb.Int8Ptr(0), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: openrtb2.Int8Ptr(1)}, + expectedLMT: openrtb2.Int8Ptr(0), }, { description: "Invalid Value - Unknown", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: nil}, + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: nil}, expectedLMT: nil, }, { description: "Invalid Value - Unknown - Does Not Overwrite Existing", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: openrtb.Int8Ptr(1)}, - expectedLMT: openrtb.Int8Ptr(1), + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: openrtb2.Int8Ptr(1)}, + expectedLMT: openrtb2.Int8Ptr(1), }, { description: "Invalid Value - Missing", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{}`), Lmt: nil}, + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{}`), Lmt: nil}, expectedLMT: nil, }, { description: "Invalid Value - Wrong Type", - givenDevice: openrtb.Device{Ext: json.RawMessage(`{"atts":"wrong type"}`), Lmt: nil}, + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":"wrong type"}`), Lmt: nil}, expectedLMT: nil, }, } for _, test := range testCases { - request := &openrtb.BidRequest{Device: &test.givenDevice} + request := &openrtb2.BidRequest{Device: &test.givenDevice} modifyForIOS142OrGreater(request) assert.Equal(t, test.expectedLMT, request.Device.Lmt, test.description) } diff --git a/privacy/lmt/policy.go b/privacy/lmt/policy.go index 295dcc46469..e115dc3802f 100644 --- a/privacy/lmt/policy.go +++ b/privacy/lmt/policy.go @@ -1,8 +1,6 @@ package lmt -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" const ( trackingUnrestricted = 0 @@ -16,7 +14,7 @@ type Policy struct { } // ReadFromRequest extracts the LMT (Limit Ad Tracking) policy from an OpenRTB bid request. -func ReadFromRequest(req *openrtb.BidRequest) (policy Policy) { +func ReadFromRequest(req *openrtb2.BidRequest) (policy Policy) { if req != nil && req.Device != nil && req.Device.Lmt != nil { policy.Signal = int(*req.Device.Lmt) policy.SignalProvided = true diff --git a/privacy/lmt/policy_test.go b/privacy/lmt/policy_test.go index 3027414fd02..e36f30230d8 100644 --- a/privacy/lmt/policy_test.go +++ b/privacy/lmt/policy_test.go @@ -3,7 +3,7 @@ package lmt import ( "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) @@ -12,7 +12,7 @@ func TestReadFromRequest(t *testing.T) { testCases := []struct { description string - request *openrtb.BidRequest + request *openrtb2.BidRequest expectedPolicy Policy }{ { @@ -25,7 +25,7 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Nil Device", - request: &openrtb.BidRequest{ + request: &openrtb2.BidRequest{ Device: nil, }, expectedPolicy: Policy{ @@ -35,8 +35,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Nil Device.Lmt", - request: &openrtb.BidRequest{ - Device: &openrtb.Device{ + request: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ Lmt: nil, }, }, @@ -47,8 +47,8 @@ func TestReadFromRequest(t *testing.T) { }, { description: "Enabled", - request: &openrtb.BidRequest{ - Device: &openrtb.Device{ + request: &openrtb2.BidRequest{ + Device: &openrtb2.Device{ Lmt: &one, }, }, diff --git a/privacy/scrubber.go b/privacy/scrubber.go index 8771c8b3282..d656168ae12 100644 --- a/privacy/scrubber.go +++ b/privacy/scrubber.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strings" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" ) // ScrubStrategyIPV4 defines the approach to scrub PII from an IPV4 address. @@ -73,8 +73,8 @@ const ( // Scrubber removes PII from parts of an OpenRTB request. type Scrubber interface { - ScrubDevice(device *openrtb.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb.Device - ScrubUser(user *openrtb.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb.User + ScrubDevice(device *openrtb2.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb2.Device + ScrubUser(user *openrtb2.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb2.User } type scrubber struct{} @@ -84,7 +84,7 @@ func NewScrubber() Scrubber { return scrubber{} } -func (scrubber) ScrubDevice(device *openrtb.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb.Device { +func (scrubber) ScrubDevice(device *openrtb2.Device, id ScrubStrategyDeviceID, ipv4 ScrubStrategyIPV4, ipv6 ScrubStrategyIPV6, geo ScrubStrategyGeo) *openrtb2.Device { if device == nil { return nil } @@ -124,7 +124,7 @@ func (scrubber) ScrubDevice(device *openrtb.Device, id ScrubStrategyDeviceID, ip return &deviceCopy } -func (scrubber) ScrubUser(user *openrtb.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb.User { +func (scrubber) ScrubUser(user *openrtb2.User, strategy ScrubStrategyUser, geo ScrubStrategyGeo) *openrtb2.User { if user == nil { return nil } @@ -194,15 +194,15 @@ func removeLowestIPV6Segment(ip string) string { return ip[0:i] } -func scrubGeoFull(geo *openrtb.Geo) *openrtb.Geo { +func scrubGeoFull(geo *openrtb2.Geo) *openrtb2.Geo { if geo == nil { return nil } - return &openrtb.Geo{} + return &openrtb2.Geo{} } -func scrubGeoPrecision(geo *openrtb.Geo) *openrtb.Geo { +func scrubGeoPrecision(geo *openrtb2.Geo) *openrtb2.Geo { if geo == nil { return nil } diff --git a/privacy/scrubber_test.go b/privacy/scrubber_test.go index e0a2cb86f64..2d352e71821 100644 --- a/privacy/scrubber_test.go +++ b/privacy/scrubber_test.go @@ -4,12 +4,12 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) func TestScrubDevice(t *testing.T) { - device := &openrtb.Device{ + device := &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -19,7 +19,7 @@ func TestScrubDevice(t *testing.T) { IFA: "anyIFA", IP: "1.2.3.4", IPv6: "2001:0db8:0000:0000:0000:ff00:0042:8329", - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", @@ -30,7 +30,7 @@ func TestScrubDevice(t *testing.T) { testCases := []struct { description string - expected *openrtb.Device + expected *openrtb2.Device id ScrubStrategyDeviceID ipv4 ScrubStrategyIPV4 ipv6 ScrubStrategyIPV6 @@ -46,7 +46,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "All Strageties - Strictest", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "", DIDSHA1: "", DPIDMD5: "", @@ -56,7 +56,7 @@ func TestScrubDevice(t *testing.T) { IFA: "", IP: "1.2.3.0", IPv6: "2001:0db8:0000:0000:0000:ff00:0:0", - Geo: &openrtb.Geo{}, + Geo: &openrtb2.Geo{}, }, id: ScrubStrategyDeviceIDAll, ipv4: ScrubStrategyIPV4Lowest8, @@ -65,7 +65,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - ID - All", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "", DIDSHA1: "", DPIDMD5: "", @@ -84,7 +84,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - IPv4 - Lowest 8", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -103,7 +103,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - IPv6 - Lowest 16", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -122,7 +122,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - IPv6 - Lowest 32", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -141,7 +141,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - Geo - Reduced Precision", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -151,7 +151,7 @@ func TestScrubDevice(t *testing.T) { IFA: "anyIFA", IP: "1.2.3.4", IPv6: "2001:0db8:0000:0000:0000:ff00:0042:8329", - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.46, Lon: 678.89, Metro: "some metro", @@ -166,7 +166,7 @@ func TestScrubDevice(t *testing.T) { }, { description: "Isolated - Geo - Full", - expected: &openrtb.Device{ + expected: &openrtb2.Device{ DIDMD5: "anyDIDMD5", DIDSHA1: "anyDIDSHA1", DPIDMD5: "anyDPIDMD5", @@ -176,7 +176,7 @@ func TestScrubDevice(t *testing.T) { IFA: "anyIFA", IP: "1.2.3.4", IPv6: "2001:0db8:0000:0000:0000:ff00:0042:8329", - Geo: &openrtb.Geo{}, + Geo: &openrtb2.Geo{}, }, id: ScrubStrategyDeviceIDNone, ipv4: ScrubStrategyIPV4None, @@ -197,13 +197,13 @@ func TestScrubDeviceNil(t *testing.T) { } func TestScrubUser(t *testing.T) { - user := &openrtb.User{ + user := &openrtb2.User{ ID: "anyID", BuyerUID: "anyBuyerUID", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{"digitrust":{"id":"anyId","keyv":4,"pref":8}}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", @@ -214,32 +214,32 @@ func TestScrubUser(t *testing.T) { testCases := []struct { description string - expected *openrtb.User + expected *openrtb2.User scrubUser ScrubStrategyUser scrubGeo ScrubStrategyGeo }{ { description: "User ID And Demographic & Geo Full", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 0, Gender: "", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{}, + Geo: &openrtb2.Geo{}, }, scrubUser: ScrubStrategyUserIDAndDemographic, scrubGeo: ScrubStrategyGeoFull, }, { description: "User ID And Demographic & Geo Reduced", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 0, Gender: "", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.46, Lon: 678.89, Metro: "some metro", @@ -252,13 +252,13 @@ func TestScrubUser(t *testing.T) { }, { description: "User ID And Demographic & Geo None", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 0, Gender: "", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", @@ -271,26 +271,26 @@ func TestScrubUser(t *testing.T) { }, { description: "User ID & Geo Full", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{}, + Geo: &openrtb2.Geo{}, }, scrubUser: ScrubStrategyUserID, scrubGeo: ScrubStrategyGeoFull, }, { description: "User ID & Geo Reduced", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.46, Lon: 678.89, Metro: "some metro", @@ -303,13 +303,13 @@ func TestScrubUser(t *testing.T) { }, { description: "User ID & Geo None", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "", BuyerUID: "", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", @@ -322,26 +322,26 @@ func TestScrubUser(t *testing.T) { }, { description: "User None & Geo Full", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "anyID", BuyerUID: "anyBuyerUID", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{"digitrust":{"id":"anyId","keyv":4,"pref":8}}`), - Geo: &openrtb.Geo{}, + Geo: &openrtb2.Geo{}, }, scrubUser: ScrubStrategyUserNone, scrubGeo: ScrubStrategyGeoFull, }, { description: "User None & Geo Reduced", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "anyID", BuyerUID: "anyBuyerUID", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{"digitrust":{"id":"anyId","keyv":4,"pref":8}}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.46, Lon: 678.89, Metro: "some metro", @@ -354,13 +354,13 @@ func TestScrubUser(t *testing.T) { }, { description: "User None & Geo None", - expected: &openrtb.User{ + expected: &openrtb2.User{ ID: "anyID", BuyerUID: "anyBuyerUID", Yob: 42, Gender: "anyGender", Ext: json.RawMessage(`{"digitrust":{"id":"anyId","keyv":4,"pref":8}}`), - Geo: &openrtb.Geo{ + Geo: &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", @@ -503,14 +503,14 @@ func TestScrubIPV6Lowest32Bits(t *testing.T) { } func TestScrubGeoFull(t *testing.T) { - geo := &openrtb.Geo{ + geo := &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", City: "some city", ZIP: "some zip", } - geoExpected := &openrtb.Geo{ + geoExpected := &openrtb2.Geo{ Lat: 0, Lon: 0, Metro: "", @@ -529,14 +529,14 @@ func TestScrubGeoFullWhenNil(t *testing.T) { } func TestScrubGeoPrecision(t *testing.T) { - geo := &openrtb.Geo{ + geo := &openrtb2.Geo{ Lat: 123.456, Lon: 678.89, Metro: "some metro", City: "some city", ZIP: "some zip", } - geoExpected := &openrtb.Geo{ + geoExpected := &openrtb2.Geo{ Lat: 123.46, Lon: 678.89, Metro: "some metro", diff --git a/privacy/writer.go b/privacy/writer.go index c61767f16c8..610508f812c 100644 --- a/privacy/writer.go +++ b/privacy/writer.go @@ -1,18 +1,16 @@ package privacy -import ( - "github.com/mxmCherry/openrtb" -) +import "github.com/mxmCherry/openrtb/v14/openrtb2" // PolicyWriter mutates an OpenRTB bid request with a policy's regulatory information. type PolicyWriter interface { - Write(req *openrtb.BidRequest) error + Write(req *openrtb2.BidRequest) error } // NilPolicyWriter implements the PolicyWriter interface but performs no action. type NilPolicyWriter struct{} // Write is hardcoded to perform no action with the OpenRTB bid request. -func (NilPolicyWriter) Write(req *openrtb.BidRequest) error { +func (NilPolicyWriter) Write(req *openrtb2.BidRequest) error { return nil } diff --git a/privacy/writer_test.go b/privacy/writer_test.go index 79170cfc451..b419e3c6783 100644 --- a/privacy/writer_test.go +++ b/privacy/writer_test.go @@ -4,16 +4,16 @@ import ( "encoding/json" "testing" - "github.com/mxmCherry/openrtb" + "github.com/mxmCherry/openrtb/v14/openrtb2" "github.com/stretchr/testify/assert" ) func TestNilWriter(t *testing.T) { - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "anyID", Ext: json.RawMessage(`{"anyJson":"anyValue"}`), } - expectedRequest := &openrtb.BidRequest{ + expectedRequest := &openrtb2.BidRequest{ ID: "anyID", Ext: json.RawMessage(`{"anyJson":"anyValue"}`), } diff --git a/router/router.go b/router/router.go index 0920f1d61b6..3b51d0730c1 100644 --- a/router/router.go +++ b/router/router.go @@ -261,7 +261,7 @@ func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *R openrtbEndpoint, err := openrtb2.NewEndpoint(theExchange, paramsValidator, fetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders) if err != nil { - glog.Fatalf("Failed to create the openrtb endpoint handler. %v", err) + glog.Fatalf("Failed to create the openrtb2 endpoint handler. %v", err) } ampEndpoint, err := openrtb2.NewAmpEndpoint(theExchange, paramsValidator, ampFetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders)