diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 00000000000..720e2f043f0 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,9 @@ +change-template: '* $TITLE (#$NUMBER)' +template: | + ## Changes + + $CHANGES + + ## Contributors + + $CONTRIBUTORS \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..fb9b6592308 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,26 @@ +name: Release + +on: + push: + tags: + - '[0-9]+.[0-9]+.[0-9]+' + +jobs: + release: + name: Create Release + if: github.event.base_ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: Get Version + id: get_version + run: echo ::set-output name=version::${GITHUB_REF/refs\/tags\//} + + - name: Create & Publish Release + uses: release-drafter/release-drafter@v5.12.1 + with: + name: ${{ steps.get_version.outputs.version }} + tag: ${{ steps.get_version.outputs.version }} + version: ${{ steps.get_version.outputs.version }} + publish: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 79076f9be84..514e217b46c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ vendor prebid-server build debug +__debug_bin # config files pbs.* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 655ea837eae..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: go - -go: - - '1.14.2' - - '1.15' - -go_import_path: github.com/PubMatic-OpenWrap/prebid-server - -env: -- GO111MODULE=on - -script: - - "./validate.sh --nofmt --cov --race 10" - -before_deploy: - - go get github.com/mitchellh/gox - - gox -os="linux" -arch="386" -output="{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.Rev=`git rev-parse --short HEAD`" -verbose ./...; - -deploy: - provider: releases - skip_cleanup: true - api_key: - secure: TSJcbIpg2zTJuzUXwv0Un5DPztDTeIKQ2BuuO9KiWYY3Td/nKn0flTYE6B5O6iVqE96HKyj2j0W51rhnRTNDReRZv76L+YXLTJOTQEEQY/A+7XaUXRT0KIbr1EHaeU+4uPJe/8YXxq+nFNeqOjj+LY457WbvnQTIbraAmCgi4yNq4JR+J9BoCELkX0SnU7oq+brq9tJNL3V+7EHIVH6ZLa1lWOrapMnbrVils8gwzWR8XpbdaI+Sn30AGOFKZ0WE2ojZkZb8oZxyX0HKarIiykfZUUzRhlXlTJ0D81QOdc5AtPNR/2dqUXsUE8mRav9R3AJM2BCS2pnP29orCRQU/kxS/mRfx2oZhkr+OHPsNbJcGNSbqNKlM13bX2nL1ZJsJ6xL0VrkBFYlI01SWR12CT9DhZSqTmGPNEkt3fdzwuYtkJNfthb9e9obscnmJEHPSiZRv9dv/stP5LVJJHfFdrzM4+Qo3MCxLNOhmc+p93gsZPeuDGDlx8Tqv1KpN7sp0glbmOwyFAwbCVh5can/JPIAKsQi9VRyZAJvn+7sqqZCExN4TvFArq7pe0LjIVHUQZP9g/vS8HobQnPutmGxf8HqzVVEBnjMsXuiY4cVRecXVRM7crfJjLGr2e9ywIkUZMSD+bRkbRUZ0QQQPvWtcgRw5JmLKG9jDklj8BDkON8= - file: - - prebid-server_linux_386 - on: - repo: prebid/prebid-server - tags: true - branch: - - master diff --git a/Makefile b/Makefile index 8475ce8369b..8ffea91fe36 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ test: deps ifeq "$(adapter)" "" ./validate.sh else - go test github.com/PubMatic-OpenWrap/prebid-server/adapters/$(adapter) -bench=. + go test github.com/prebid/prebid-server/adapters/$(adapter) -bench=. endif # build will ensure all of our tests pass and then build the go binary diff --git a/README.md b/README.md index 529629e0e2a..9189421bd9d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -[![Build Status](https://travis-ci.org/prebid/prebid-server.svg?branch=master)](https://travis-ci.org/prebid/prebid-server) -[![Go Report Card](https://goreportcard.com/badge/github.com/PubMatic-OpenWrap/prebid-server?style=flat-square)](https://goreportcard.com/report/github.com/PubMatic-OpenWrap/prebid-server) +[![Build](https://img.shields.io/github/workflow/status/prebid/prebid-server/Validate/master?style=flat-square)](https://github.com/prebid/prebid-server/actions/workflows/validate.yml) +[![Go Report Card](https://goreportcard.com/badge/github.com/prebid/prebid-server?style=flat-square)](https://goreportcard.com/report/github.com/prebid/prebid-server) +![Go Version](https://img.shields.io/github/go-mod/go-version/prebid/prebid-server?style=flat-square) # Prebid Server @@ -16,6 +17,8 @@ For more information, see: - [Prebid Server Overview](https://docs.prebid.org/prebid-server/overview/prebid-server-overview.html) - [Current Bidders](http://prebid.org/dev-docs/pbs-bidders.html) +Please consider [registering your Prebid Server](https://docs.prebid.org/prebid-server/hosting/pbs-hosting.html#optional-registration) to get on the mailing list for updates, etc. + ## Installation First install [Go](https://golang.org/doc/install) version 1.14 or newer. diff --git a/account/account.go b/account/account.go index d5d22f4a894..25a504ca23f 100644 --- a/account/account.go +++ b/account/account.go @@ -5,11 +5,11 @@ import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" jsonpatch "github.com/evanphx/json-patch" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests" ) // GetAccount looks up the config.Account object referenced by the given accountID, with access rules applied diff --git a/account/account_test.go b/account/account_test.go index 0783ee0e134..75c48a02d89 100644 --- a/account/account_test.go +++ b/account/account_test.go @@ -6,10 +6,10 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests" "github.com/stretchr/testify/assert" ) diff --git a/adapters/33across/33across.go b/adapters/33across/33across.go index 7abd7ba72bd..fb329a76f21 100644 --- a/adapters/33across/33across.go +++ b/adapters/33across/33across.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type TtxAdapter struct { @@ -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,8 +227,8 @@ func (a *TtxAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalReque } -func validateVideoParams(video *openrtb.Video, prod string) (*openrtb.Video, error) { - videoCopy := video +func validateVideoParams(video *openrtb2.Video, prod string) (*openrtb2.Video, error) { + videoCopy := *video if videoCopy.W == 0 || videoCopy.H == 0 || videoCopy.Protocols == nil || @@ -248,11 +248,11 @@ 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) } } - return videoCopy, nil + return &videoCopy, nil } func getBidType(ext bidExt) openrtb_ext.BidType { diff --git a/adapters/33across/33across_test.go b/adapters/33across/33across_test.go index 08c2ff614e9..97703735d9c 100644 --- a/adapters/33across/33across_test.go +++ b/adapters/33across/33across_test.go @@ -3,9 +3,9 @@ package ttx import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/33across/params_test.go b/adapters/33across/params_test.go index 19dfb22198c..0c7cde18216 100644 --- a/adapters/33across/params_test.go +++ b/adapters/33across/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/33across.json diff --git a/adapters/33across/usersync.go b/adapters/33across/usersync.go index 0bed70ee60d..df26f3b6325 100644 --- a/adapters/33across/usersync.go +++ b/adapters/33across/usersync.go @@ -3,10 +3,10 @@ package ttx import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func New33AcrossSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("33across", 58, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("33across", temp, adapters.SyncTypeIframe) } diff --git a/adapters/33across/usersync_test.go b/adapters/33across/usersync_test.go index 89cae0f3f19..e99b5965746 100644 --- a/adapters/33across/usersync_test.go +++ b/adapters/33across/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func Test33AcrossSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://ic.tynt.com/r/d?m=xch&rt=html&gdpr=A&gdpr_consent=B&us_privacy=C&ru=%2Fsetuid%3Fbidder%3D33across%26uid%3D33XUSERID33X&id=zzz000000000002zzz", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 58, syncer.GDPRVendorID()) assert.False(t, syncInfo.SupportCORS) } diff --git a/adapters/acuityads/acuityads.go b/adapters/acuityads/acuityads.go index ac2c6ac7c4d..da1cda3da77 100644 --- a/adapters/acuityads/acuityads.go +++ b/adapters/acuityads/acuityads.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type AcuityAdsAdapter struct { @@ -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/acuityads/acuityads_test.go b/adapters/acuityads/acuityads_test.go index be12780a778..8cc50637374 100644 --- a/adapters/acuityads/acuityads_test.go +++ b/adapters/acuityads/acuityads_test.go @@ -3,9 +3,9 @@ package acuityads import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/acuityads/acuityadstest/exemplary/banner-app.json b/adapters/acuityads/acuityadstest/exemplary/banner-app.json index f4aedeb6788..526f1ea69ac 100644 --- a/adapters/acuityads/acuityadstest/exemplary/banner-app.json +++ b/adapters/acuityads/acuityadstest/exemplary/banner-app.json @@ -153,4 +153,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/acuityads/acuityadstest/exemplary/native-app.json b/adapters/acuityads/acuityadstest/exemplary/native-app.json index 6ada3926733..75b596f6ab7 100644 --- a/adapters/acuityads/acuityadstest/exemplary/native-app.json +++ b/adapters/acuityads/acuityadstest/exemplary/native-app.json @@ -150,4 +150,3 @@ } ] } - diff --git a/adapters/acuityads/acuityadstest/exemplary/video-web.json b/adapters/acuityads/acuityadstest/exemplary/video-web.json index 60260aa5271..2efeffec320 100644 --- a/adapters/acuityads/acuityadstest/exemplary/video-web.json +++ b/adapters/acuityads/acuityadstest/exemplary/video-web.json @@ -160,4 +160,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/acuityads/acuityadstest/supplemental/invalid-smartyads-ext-object.json b/adapters/acuityads/acuityadstest/supplemental/invalid-smartyads-ext-object.json deleted file mode 100644 index 77752d01edf..00000000000 --- a/adapters/acuityads/acuityadstest/supplemental/invalid-smartyads-ext-object.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "expectedMakeRequestsErrors": [ - { - "value": "ext.bidder not provided", - "comparison": "literal" - } - ], - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "some-impression-id", - "tagid": "my-adcode", - "video": { - "mimes": ["video/mp4"], - "w": 640, - "h": 480, - "minduration": 120, - "maxduration": 150 - }, - "ext": "Awesome" - } - ], - "site": { - "page": "test.com" - } - }, - "httpCalls": [] -} diff --git a/adapters/acuityads/params_test.go b/adapters/acuityads/params_test.go index e1a47669796..892fe9a646d 100644 --- a/adapters/acuityads/params_test.go +++ b/adapters/acuityads/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) var validParams = []string{ diff --git a/adapters/acuityads/usersync.go b/adapters/acuityads/usersync.go index 90b610bb3cd..e2fc1f41961 100644 --- a/adapters/acuityads/usersync.go +++ b/adapters/acuityads/usersync.go @@ -3,10 +3,10 @@ package acuityads import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAcuityAdsSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("acuityads", 231, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("acuityads", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/acuityads/usersync_test.go b/adapters/acuityads/usersync_test.go index 5c6f6a43677..b3ad10bdbb8 100644 --- a/adapters/acuityads/usersync_test.go +++ b/adapters/acuityads/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -29,6 +29,5 @@ func TestAcuityAdsSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://cs.admanmedia.com/sync/prebid?gdpr=0&gdpr_consent=ANDFJDS&us_privacy=1-YY&redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dacuityads%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 231, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adapterstest/adapter_test_util.go b/adapters/adapterstest/adapter_test_util.go index 269eed087ed..25d43a138fb 100644 --- a/adapters/adapterstest/adapter_test_util.go +++ b/adapters/adapterstest/adapter_test_util.go @@ -8,13 +8,13 @@ import ( "net/http" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 b8c33064fc4..95319f1e328 100644 --- a/adapters/adapterstest/test_json.go +++ b/adapters/adapterstest/test_json.go @@ -7,8 +7,8 @@ import ( "regexp" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" "github.com/yudai/gojsondiff" "github.com/yudai/gojsondiff/formatter" @@ -123,12 +123,12 @@ func runSpec(t *testing.T, filename string, spec *testSpec, bidder adapters.Bidd diffErrorLists(t, fmt.Sprintf("%s: MakeBids", filename), bidsErrs, spec.MakeBidsErrors) for i := 0; i < len(spec.BidResponses); i++ { - diffBidLists(t, filename, bidResponses[i].Bids, spec.BidResponses[i].Bids) + diffBidLists(t, filename, bidResponses[i], spec.BidResponses[i].Bids) } } 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"` @@ -227,9 +227,24 @@ func diffErrorLists(t *testing.T, description string, actual []error, expected [ } } -func diffBidLists(t *testing.T, filename string, actual []*adapters.TypedBid, expected []expectedBid) { +func diffBidLists(t *testing.T, filename string, response *adapters.BidderResponse, expected []expectedBid) { t.Helper() + if (response == nil || len(response.Bids) == 0) != (len(expected) == 0) { + if len(expected) == 0 { + t.Fatalf("%s: expectedBidResponses indicated a nil response, but mockResponses supplied a non-nil response", filename) + } + + t.Fatalf("%s: mockResponses included unexpected nil or empty response", filename) + } + + // Expected nil response - give diffBids something to work with. + if response == nil { + response = new(adapters.BidderResponse) + } + + actual := response.Bids + if len(actual) != len(expected) { t.Fatalf("%s: MakeBids returned wrong bid count. Expected %d, got %d", filename, len(expected), len(actual)) } @@ -266,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 bb3f9f4d8a3..225c7af35d4 100644 --- a/adapters/adform/adform.go +++ b/adapters/adform/adform.go @@ -13,14 +13,13 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - - "github.com/PubMatic-OpenWrap/openrtb" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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 @@ -453,7 +452,7 @@ func openRtbToAdformRequest(request *openrtb.BidRequest) (*adformRequest, []erro gdprApplies := "" var extRegs openrtb_ext.ExtRegs - if request.Regs != nil { + if request.Regs != nil && request.Regs.Ext != nil { if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { errors = append(errors, &errortypes.BadInput{ Message: err.Error(), @@ -466,7 +465,7 @@ func openRtbToAdformRequest(request *openrtb.BidRequest) (*adformRequest, []erro eids := "" consent := "" - if request.User != nil { + if request.User != nil && request.User.Ext != nil { var extUser openrtb_ext.ExtUser if err := json.Unmarshal(request.User.Ext, &extUser); err == nil { consent = extUser.Consent @@ -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 14663c32112..70cd6883a4d 100644 --- a/adapters/adform/adform_test.go +++ b/adapters/adform/adform_test.go @@ -10,17 +10,17 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -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/adform/adformtest/supplemental/regs-ext-nil.json b/adapters/adform/adformtest/supplemental/regs-ext-nil.json new file mode 100644 index 00000000000..377c48b0445 --- /dev/null +++ b/adapters/adform/adformtest/supplemental/regs-ext-nil.json @@ -0,0 +1,53 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-imp-id", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }] + }, + "ext": { + "bidder": { + "mid": 12345 + } + } + }], + "regs": {} + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "https://adx.adform.net/adx?CC=1&fd=1&gdpr=&gdpr_consent=&ip=&rp=4&stid=&bWlkPTEyMzQ1JnJjdXI9VVNE" + }, + "mockResponse": { + "status": 200, + "body": [{ + "response": "banner", + "banner": "", + "win_bid": 0.5, + "win_cur": "USD", + "width": 300, + "height": 250, + "deal_id": null, + "win_crid": "20078830" + }] + } + }], + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "id": "test-imp-id", + "impid": "test-imp-id", + "price": 0.5, + "adm": "", + "crid": "20078830", + "w": 300, + "h": 250 + }, + "type": "banner" + }] + }] +} \ No newline at end of file diff --git a/adapters/adform/params_test.go b/adapters/adform/params_test.go index c4ffb79399e..b392463f426 100644 --- a/adapters/adform/params_test.go +++ b/adapters/adform/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/adform.json diff --git a/adapters/adform/usersync.go b/adapters/adform/usersync.go index b98c1b6c0fc..6a237f794a6 100644 --- a/adapters/adform/usersync.go +++ b/adapters/adform/usersync.go @@ -3,10 +3,10 @@ package adform import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdformSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adform", 50, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adform", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/adform/usersync_test.go b/adapters/adform/usersync_test.go index 3a507331e85..f133be86583 100644 --- a/adapters/adform/usersync_test.go +++ b/adapters/adform/usersync_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" ) func TestAdformSyncer(t *testing.T) { @@ -27,6 +27,5 @@ func TestAdformSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//cm.adform.net?return_url=localhost%2Fsetuid%3Fbidder%3Dadform%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 50, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adgeneration/adgeneration.go b/adapters/adgeneration/adgeneration.go index 59a3ba5b6a2..110ec5ce98a 100644 --- a/adapters/adgeneration/adgeneration.go +++ b/adapters/adgeneration/adgeneration.go @@ -10,11 +10,11 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type AdgenerationAdapter struct { @@ -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 a4041a5a1d7..d5d93ac4e0b 100644 --- a/adapters/adgeneration/adgeneration_test.go +++ b/adapters/adgeneration/adgeneration_test.go @@ -4,11 +4,11 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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/adgeneration/adgenerationtest/supplemental/204-bid-response.json b/adapters/adgeneration/adgenerationtest/supplemental/204-bid-response.json index 8a4135c27af..b9a79688d40 100644 --- a/adapters/adgeneration/adgenerationtest/supplemental/204-bid-response.json +++ b/adapters/adgeneration/adgenerationtest/supplemental/204-bid-response.json @@ -75,4 +75,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/adgeneration/adgenerationtest/supplemental/400-bid-response.json b/adapters/adgeneration/adgenerationtest/supplemental/400-bid-response.json index ebda348fa65..9744e8d2606 100644 --- a/adapters/adgeneration/adgenerationtest/supplemental/400-bid-response.json +++ b/adapters/adgeneration/adgenerationtest/supplemental/400-bid-response.json @@ -80,4 +80,4 @@ "comparison": "literal" } ] -} +} \ No newline at end of file diff --git a/adapters/adgeneration/params_test.go b/adapters/adgeneration/params_test.go index 11a0dfe97c5..062d122ac08 100644 --- a/adapters/adgeneration/params_test.go +++ b/adapters/adgeneration/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/adhese/adhese.go b/adapters/adhese/adhese.go index 96a936c2276..8b4d8c98afe 100644 --- a/adapters/adhese/adhese.go +++ b/adapters/adhese/adhese.go @@ -10,13 +10,13 @@ import ( "strings" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type AdheseAdapter struct { @@ -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/adhese_test.go b/adapters/adhese/adhese_test.go index 40b28887c20..3a9d28ee5e9 100644 --- a/adapters/adhese/adhese_test.go +++ b/adapters/adhese/adhese_test.go @@ -3,9 +3,9 @@ package adhese import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/adhese/adhesetest/exemplary/banner-internal.json b/adapters/adhese/adhesetest/exemplary/banner-internal.json index 225b37aa2f8..50efe4a656d 100644 --- a/adapters/adhese/adhesetest/exemplary/banner-internal.json +++ b/adapters/adhese/adhesetest/exemplary/banner-internal.json @@ -103,4 +103,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/adhese/params_test.go b/adapters/adhese/params_test.go index f9c3de6212e..45024749b2d 100644 --- a/adapters/adhese/params_test.go +++ b/adapters/adhese/params_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/adhese/utils.go b/adapters/adhese/utils.go index 7b09ad02924..5a81bb83bd5 100644 --- a/adapters/adhese/utils.go +++ b/adapters/adhese/utils.go @@ -1,6 +1,6 @@ package adhese -import "github.com/PubMatic-OpenWrap/openrtb" +import "github.com/mxmCherry/openrtb/v15/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 f483ba7ce49..362307cce79 100644 --- a/adapters/adkernel/adkernel.go +++ b/adapters/adkernel/adkernel.go @@ -7,12 +7,12 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type adkernelAdapter struct { @@ -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/adkernel/adkernel_test.go b/adapters/adkernel/adkernel_test.go index a85769f5565..e9fcaef1b0e 100644 --- a/adapters/adkernel/adkernel_test.go +++ b/adapters/adkernel/adkernel_test.go @@ -3,9 +3,9 @@ package adkernel import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/adkernel/usersync.go b/adapters/adkernel/usersync.go index 7622e1da3b7..2de82a00f6e 100644 --- a/adapters/adkernel/usersync.go +++ b/adapters/adkernel/usersync.go @@ -3,12 +3,10 @@ package adkernel import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) -const adkernelGDPRVendorID = uint16(14) - func NewAdkernelSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adkernel", 14, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adkernel", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/adkernel/usersync_test.go b/adapters/adkernel/usersync_test.go index 7230fcbab9c..2ff81668d41 100644 --- a/adapters/adkernel/usersync_test.go +++ b/adapters/adkernel/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestAdkernelAdnSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://sync.adkernel.com/user-sync?t=image&gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&us_privacy=1NYN&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, adkernelGDPRVendorID, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adkernelAdn/adkernelAdn.go b/adapters/adkernelAdn/adkernelAdn.go index 491bead4e8b..f6075f865e7 100644 --- a/adapters/adkernelAdn/adkernelAdn.go +++ b/adapters/adkernelAdn/adkernelAdn.go @@ -7,12 +7,12 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) const defaultDomain string = "tag.adkernel.com" @@ -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/adkernelAdn/adkernelAdn_test.go b/adapters/adkernelAdn/adkernelAdn_test.go index a4311d3e550..687f5a946c0 100644 --- a/adapters/adkernelAdn/adkernelAdn_test.go +++ b/adapters/adkernelAdn/adkernelAdn_test.go @@ -3,9 +3,9 @@ package adkernelAdn import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/adkernelAdn/usersync.go b/adapters/adkernelAdn/usersync.go index ab60edf2dc7..5a890e1565b 100644 --- a/adapters/adkernelAdn/usersync.go +++ b/adapters/adkernelAdn/usersync.go @@ -3,12 +3,10 @@ package adkernelAdn import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) -const adkernelGDPRVendorID = uint16(14) - func NewAdkernelAdnSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adkernelAdn", 14, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adkernelAdn", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/adkernelAdn/usersync_test.go b/adapters/adkernelAdn/usersync_test.go index 9528579aa3d..17cf97ce779 100644 --- a/adapters/adkernelAdn/usersync_test.go +++ b/adapters/adkernelAdn/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestAdkernelAdnSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://tag.adkernel.com/syncr?gdpr=1&gdpr_consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&us_privacy=1NYN&r=https%3A%2F%2Flocalhost%3A8888%2Fsetuid%3Fbidder%3DadkernelAdn%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, adkernelGDPRVendorID, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adman/adman.go b/adapters/adman/adman.go index 3c0342fe24f..808951d3aba 100644 --- a/adapters/adman/adman.go +++ b/adapters/adman/adman.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // AdmanAdapter struct @@ -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/adman_test.go b/adapters/adman/adman_test.go index 5dc10df8dad..ceee5f21bd6 100644 --- a/adapters/adman/adman_test.go +++ b/adapters/adman/adman_test.go @@ -3,9 +3,9 @@ package adman import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/adman/admantest/supplemental/status-204.json b/adapters/adman/admantest/supplemental/status-204.json index a659754e8b0..05f9d030832 100644 --- a/adapters/adman/admantest/supplemental/status-204.json +++ b/adapters/adman/admantest/supplemental/status-204.json @@ -79,4 +79,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/adman/params_test.go b/adapters/adman/params_test.go index 4cea67cc098..a80c2a44b8b 100644 --- a/adapters/adman/params_test.go +++ b/adapters/adman/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // TestValidParams makes sure that the adman schema accepts all imp.ext fields which we intend to support. diff --git a/adapters/adman/usersync.go b/adapters/adman/usersync.go index f7edd8c5b70..2cb62fe7824 100644 --- a/adapters/adman/usersync.go +++ b/adapters/adman/usersync.go @@ -3,11 +3,11 @@ package adman import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) // NewAdmanSyncer returns adman syncer func NewAdmanSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adman", 149, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adman", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/adman/usersync_test.go b/adapters/adman/usersync_test.go index db67499e91d..d0dc90c8c5d 100644 --- a/adapters/adman/usersync_test.go +++ b/adapters/adman/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestAdmanSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://sync.admanmedia.com/pbs.gif?gdpr=0&gdpr_consent=ANDFJDS&us_privacy=1-YY&redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dadman%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 149, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/admixer/admixer.go b/adapters/admixer/admixer.go index b16dc0073d4..ec49950a17e 100644 --- a/adapters/admixer/admixer.go +++ b/adapters/admixer/admixer.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type AdmixerAdapter struct { @@ -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/admixer/admixer_test.go b/adapters/admixer/admixer_test.go index 629d4df83cd..d994847c1ed 100644 --- a/adapters/admixer/admixer_test.go +++ b/adapters/admixer/admixer_test.go @@ -3,9 +3,9 @@ package admixer import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/admixer/params_test.go b/adapters/admixer/params_test.go index d25bdcecd68..71cccb6a3da 100644 --- a/adapters/admixer/params_test.go +++ b/adapters/admixer/params_test.go @@ -2,7 +2,7 @@ package admixer import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/admixer/usersync.go b/adapters/admixer/usersync.go index 1df22cc276d..89e162dff32 100644 --- a/adapters/admixer/usersync.go +++ b/adapters/admixer/usersync.go @@ -1,11 +1,12 @@ package admixer import ( - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdmixerSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("admixer", 511, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("admixer", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/admixer/usersync_test.go b/adapters/admixer/usersync_test.go index 8a43b866804..6acc48453fb 100644 --- a/adapters/admixer/usersync_test.go +++ b/adapters/admixer/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,6 @@ func TestAdmixerSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://anyHost/anyPath", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 511, syncer.GDPRVendorID()) + assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adocean/adocean.go b/adapters/adocean/adocean.go index 8310626fcec..635cba8c9bc 100644 --- a/adapters/adocean/adocean.go +++ b/adapters/adocean/adocean.go @@ -13,12 +13,12 @@ import ( "strings" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) const adapterVersion = "1.1.0" @@ -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/adocean/adocean_test.go b/adapters/adocean/adocean_test.go index b75de2a9235..531204cdec3 100644 --- a/adapters/adocean/adocean_test.go +++ b/adapters/adocean/adocean_test.go @@ -3,9 +3,9 @@ package adocean import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/adocean/params_test.go b/adapters/adocean/params_test.go index 91e2fbdcb67..1a88c4716e0 100644 --- a/adapters/adocean/params_test.go +++ b/adapters/adocean/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/adocean/usersync.go b/adapters/adocean/usersync.go index 4bfe39e11e5..b189f822b46 100644 --- a/adapters/adocean/usersync.go +++ b/adapters/adocean/usersync.go @@ -3,10 +3,10 @@ package adocean import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdOceanSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adocean", 328, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adocean", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/adocean/usersync_test.go b/adapters/adocean/usersync_test.go index aa0bcb77e21..5257017adfa 100644 --- a/adapters/adocean/usersync_test.go +++ b/adapters/adocean/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,5 +30,4 @@ func TestAdOceanSyncer(t *testing.T) { syncInfo.URL, ) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 328, syncer.GDPRVendorID()) } diff --git a/adapters/adoppler/adoppler.go b/adapters/adoppler/adoppler.go index 498bb4c7cc0..015f31c7d01 100644 --- a/adapters/adoppler/adoppler.go +++ b/adapters/adoppler/adoppler.go @@ -8,12 +8,12 @@ import ( "net/url" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) const DefaultClient = "app" @@ -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/adoppler_test.go b/adapters/adoppler/adoppler_test.go index eab0ac5708d..fb5cb22bab5 100644 --- a/adapters/adoppler/adoppler_test.go +++ b/adapters/adoppler/adoppler_test.go @@ -3,9 +3,9 @@ package adoppler import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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 fcbb5a2906d..f41beed8d21 100644 --- a/adapters/adot/adot.go +++ b/adapters/adot/adot.go @@ -3,12 +3,13 @@ package adot import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "net/http" + + "github.com/mxmCherry/openrtb/v15/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" ) 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 2e6e74861d4..fbc7def4a74 100644 --- a/adapters/adot/adot_test.go +++ b/adapters/adot/adot_test.go @@ -2,13 +2,14 @@ package adot import ( "encoding/json" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/stretchr/testify/assert" "testing" + + "github.com/mxmCherry/openrtb/v15/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" ) 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/adot/params_test.go b/adapters/adot/params_test.go index 2a6dc17d916..2f7b4b9af4e 100644 --- a/adapters/adot/params_test.go +++ b/adapters/adot/params_test.go @@ -2,7 +2,7 @@ package adot import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/adpone/adpone.go b/adapters/adpone/adpone.go index ec4cba75f87..972f1576ac1 100644 --- a/adapters/adpone/adpone.go +++ b/adapters/adpone/adpone.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" ) // Builder builds a new instance of the Adpone adapter for the given bidder with the given config. @@ -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/adpone_test.go b/adapters/adpone/adpone_test.go index 69726e31d50..78ad51ba095 100644 --- a/adapters/adpone/adpone_test.go +++ b/adapters/adpone/adpone_test.go @@ -3,9 +3,9 @@ package adpone import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) const testsDir = "adponetest" 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/adpone/usersync.go b/adapters/adpone/usersync.go index 63f616091e2..38dec19bb72 100644 --- a/adapters/adpone/usersync.go +++ b/adapters/adpone/usersync.go @@ -3,17 +3,15 @@ package adpone import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) -const adponeGDPRVendorID = uint16(799) const adponeFamilyName = "adpone" func NewadponeSyncer(urlTemplate *template.Template) usersync.Usersyncer { return adapters.NewSyncer( adponeFamilyName, - adponeGDPRVendorID, urlTemplate, adapters.SyncTypeRedirect, ) diff --git a/adapters/adpone/usersync_test.go b/adapters/adpone/usersync_test.go index 7bc528b8f36..e744de5eb91 100644 --- a/adapters/adpone/usersync_test.go +++ b/adapters/adpone/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,5 +20,4 @@ func TestAdponeSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://usersync.adpone.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D%26gdpr_consent%3D%26uid%3D%7Buid%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, adponeGDPRVendorID, syncer.GDPRVendorID()) } diff --git a/adapters/adprime/adprime.go b/adapters/adprime/adprime.go index 053999fd5d1..70fbd6b399b 100644 --- a/adapters/adprime/adprime.go +++ b/adapters/adprime/adprime.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" ) // AdprimeAdapter struct @@ -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/adprime_test.go b/adapters/adprime/adprime_test.go index cfcf255a5cc..ff12381d053 100644 --- a/adapters/adprime/adprime_test.go +++ b/adapters/adprime/adprime_test.go @@ -3,9 +3,9 @@ package adprime import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/adprime/params_test.go b/adapters/adprime/params_test.go index bea13e32c13..05adad5c4ff 100644 --- a/adapters/adprime/params_test.go +++ b/adapters/adprime/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // TestValidParams makes sure that the adprime schema accepts all imp.ext fields which we intend to support. diff --git a/adapters/adtarget/adtarget.go b/adapters/adtarget/adtarget.go index 070ede40feb..24befbfec0f 100644 --- a/adapters/adtarget/adtarget.go +++ b/adapters/adtarget/adtarget.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type AdtargetAdapter struct { @@ -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/adtarget/adtarget_test.go b/adapters/adtarget/adtarget_test.go index bb20b40c286..ed21aef0828 100644 --- a/adapters/adtarget/adtarget_test.go +++ b/adapters/adtarget/adtarget_test.go @@ -3,9 +3,9 @@ package adtarget import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/adtarget/adtargettest/exemplary/simple-banner.json b/adapters/adtarget/adtargettest/exemplary/simple-banner.json index 3799612455f..0d925bacd9f 100644 --- a/adapters/adtarget/adtargettest/exemplary/simple-banner.json +++ b/adapters/adtarget/adtargettest/exemplary/simple-banner.json @@ -60,4 +60,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/adtarget/adtargettest/exemplary/simple-video.json b/adapters/adtarget/adtargettest/exemplary/simple-video.json index bf6de569496..5b47751749c 100644 --- a/adapters/adtarget/adtargettest/exemplary/simple-video.json +++ b/adapters/adtarget/adtargettest/exemplary/simple-video.json @@ -53,4 +53,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/adtarget/params_test.go b/adapters/adtarget/params_test.go index 61ed4885512..b128d11c9cf 100644 --- a/adapters/adtarget/params_test.go +++ b/adapters/adtarget/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/adtarget.json diff --git a/adapters/adtarget/usersync.go b/adapters/adtarget/usersync.go index 93e57b173f6..088de8fb2ad 100644 --- a/adapters/adtarget/usersync.go +++ b/adapters/adtarget/usersync.go @@ -3,10 +3,10 @@ package adtarget import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdtargetSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adtarget", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adtarget", temp, adapters.SyncTypeIframe) } diff --git a/adapters/adtarget/usersync_test.go b/adapters/adtarget/usersync_test.go index 419a6cb037e..e66b7b8377b 100644 --- a/adapters/adtarget/usersync_test.go +++ b/adapters/adtarget/usersync_test.go @@ -5,10 +5,10 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -32,7 +32,6 @@ func TestAdtargetSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.console.adtarget.com.tr/csync?t=p&ep=0&gdpr=0&gdpr_consent=123&us_privacy=1-YY&redir=localhost%2Fsetuid%3Fbidder%3Dadtarget%26gdpr%3D0%26gdpr_consent%3D123%26uid%3D%7Buid%7D", syncInfo.URL) - assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) + assert.Equal(t, "iframe", syncInfo.Type) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adtelligent/adtelligent.go b/adapters/adtelligent/adtelligent.go index 7d8f6099fbf..244742db504 100644 --- a/adapters/adtelligent/adtelligent.go +++ b/adapters/adtelligent/adtelligent.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type AdtelligentAdapter struct { @@ -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/adtelligent/adtelligent_test.go b/adapters/adtelligent/adtelligent_test.go index 6a104aa7463..503b30b576a 100644 --- a/adapters/adtelligent/adtelligent_test.go +++ b/adapters/adtelligent/adtelligent_test.go @@ -3,9 +3,9 @@ package adtelligent import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/adtelligent/params_test.go b/adapters/adtelligent/params_test.go index 8d8eb6d13b3..eb2aab0d437 100644 --- a/adapters/adtelligent/params_test.go +++ b/adapters/adtelligent/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/adtelligent.json diff --git a/adapters/adtelligent/usersync.go b/adapters/adtelligent/usersync.go index 387c65bb46d..9198b30fe6f 100644 --- a/adapters/adtelligent/usersync.go +++ b/adapters/adtelligent/usersync.go @@ -3,10 +3,10 @@ package adtelligent import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdtelligentSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adtelligent", 410, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adtelligent", temp, adapters.SyncTypeIframe) } diff --git a/adapters/adtelligent/usersync_test.go b/adapters/adtelligent/usersync_test.go index 7cc92eb4011..2ca0ddfc135 100644 --- a/adapters/adtelligent/usersync_test.go +++ b/adapters/adtelligent/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -24,7 +24,6 @@ func TestAdtelligentSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.adtelligent.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7Buid%7D", syncInfo.URL) - assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 410, syncer.GDPRVendorID()) + assert.Equal(t, "iframe", syncInfo.Type) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/advangelists/advangelists.go b/adapters/advangelists/advangelists.go index 249e3282481..b5b385f6c06 100644 --- a/adapters/advangelists/advangelists.go +++ b/adapters/advangelists/advangelists.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type AdvangelistsAdapter struct { @@ -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/advangelists/advangelists_test.go b/adapters/advangelists/advangelists_test.go index 49cca96a78a..4219c1a0237 100644 --- a/adapters/advangelists/advangelists_test.go +++ b/adapters/advangelists/advangelists_test.go @@ -3,9 +3,9 @@ package advangelists import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/advangelists/params_test.go b/adapters/advangelists/params_test.go index 2a94c782092..a58217a0ffd 100644 --- a/adapters/advangelists/params_test.go +++ b/adapters/advangelists/params_test.go @@ -2,7 +2,7 @@ package advangelists import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/advangelists/usersync.go b/adapters/advangelists/usersync.go index b1539d0093d..83930774773 100644 --- a/adapters/advangelists/usersync.go +++ b/adapters/advangelists/usersync.go @@ -3,10 +3,10 @@ package advangelists import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAdvangelistsSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("advangelists", 0, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("advangelists", temp, adapters.SyncTypeIframe) } diff --git a/adapters/advangelists/usersync_test.go b/adapters/advangelists/usersync_test.go index 5dae85b11a9..04ee7968d87 100644 --- a/adapters/advangelists/usersync_test.go +++ b/adapters/advangelists/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -26,6 +26,5 @@ func TestAdvangelistsSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://nep.advangelists.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=advangelists&gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&uid=$UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/adxcg/adxcg.go b/adapters/adxcg/adxcg.go new file mode 100644 index 00000000000..e9f6c94bc40 --- /dev/null +++ b/adapters/adxcg/adxcg.go @@ -0,0 +1,125 @@ +package adxcg + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb/v15/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" +) + +// Builder builds a new instance of the Adxcg adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +type adapter struct { + endpoint string +} + +// MakeRequests prepares the HTTP requests which should be made to fetch bids. +func (adapter *adapter) MakeRequests( + openRTBRequest *openrtb2.BidRequest, + reqInfo *adapters.ExtraRequestInfo, +) ( + requestsToBidder []*adapters.RequestData, + errs []error, +) { + openRTBRequestJSON, err := json.Marshal(openRTBRequest) + if err != nil { + errs = append(errs, err) + return nil, errs + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + requestToBidder := &adapters.RequestData{ + Method: "POST", + Uri: adapter.endpoint, + Body: openRTBRequestJSON, + Headers: headers, + } + requestsToBidder = append(requestsToBidder, requestToBidder) + + return requestsToBidder, errs +} + +const unexpectedStatusCodeFormat = "Unexpected status code: %d. Run with request.debug = 1 for more info" + +// MakeBids unpacks the server's response into Bids. +func (adapter *adapter) MakeBids( + openRTBRequest *openrtb2.BidRequest, + requestToBidder *adapters.RequestData, + bidderRawResponse *adapters.ResponseData, +) ( + bidderResponse *adapters.BidderResponse, + errs []error, +) { + switch bidderRawResponse.StatusCode { + case http.StatusOK: + break + case http.StatusNoContent: + return nil, nil + case http.StatusBadRequest: + err := &errortypes.BadInput{ + Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode), + } + return nil, []error{err} + default: + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode), + } + return nil, []error{err} + } + + var openRTBBidderResponse openrtb2.BidResponse + if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + return nil, []error{err} + } + + bidsCapacity := len(openRTBBidderResponse.SeatBid[0].Bid) + bidderResponse = adapters.NewBidderResponseWithBidsCapacity(bidsCapacity) + var typedBid *adapters.TypedBid + for _, seatBid := range openRTBBidderResponse.SeatBid { + for _, bid := range seatBid.Bid { + activeBid := bid + bidType, err := getMediaTypeForImp(activeBid.ImpID, openRTBRequest.Imp) + if err != nil { + errs = append(errs, err) + continue + } + + typedBid = &adapters.TypedBid{Bid: &activeBid, BidType: bidType} + bidderResponse.Bids = append(bidderResponse.Bids, typedBid) + } + } + + return bidderResponse, nil + +} + +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { + for _, imp := range imps { + if imp.ID == impID { + if imp.Native != nil { + return openrtb_ext.BidTypeNative, nil + } else if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } + + } + } + + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Failed to find native/banner/video impression \"%s\" ", impID), + } +} diff --git a/adapters/adxcg/adxcg_test.go b/adapters/adxcg/adxcg_test.go new file mode 100644 index 00000000000..d01e62f670c --- /dev/null +++ b/adapters/adxcg/adxcg_test.go @@ -0,0 +1,23 @@ +package adxcg + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +const testsDir = "adxcgtest" +const testsBidderEndpoint = "http://localhost/prebid_server" + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderAdxcg, config.Adapter{ + Endpoint: testsBidderEndpoint}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, testsDir, bidder) +} diff --git a/adapters/adxcg/adxcgtest/exemplary/simple-banner.json b/adapters/adxcg/adxcgtest/exemplary/simple-banner.json new file mode 100644 index 00000000000..85ed18ff1a3 --- /dev/null +++ b/adapters/adxcg/adxcgtest/exemplary/simple-banner.json @@ -0,0 +1,83 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "https://good.site/url" + }, + "imp": [{ + "id": "test-imp-id", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }] + }, + "ext": { + "bidder": {} + } + }] + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "site": { + "page": "https://good.site/url" + }, + "imp": [{ + "id": "test-imp-id", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }] + }, + "ext": { + "bidder": {} + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [{ + "seat": "adxcg", + "bid": [{ + "id": "randomid", + "impid": "test-imp-id", + "price": 0.500000, + "adid": "12345678", + "adm": "some-test-ad", + "cid": "987", + "crid": "12345678", + "h": 250, + "w": 300 + }] + }], + "cur": "USD" + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "id": "randomid", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-ad", + "adid": "12345678", + "cid": "987", + "crid": "12345678", + "w": 300, + "h": 250 + }, + "type": "banner" + }] + }] +} diff --git a/adapters/adxcg/adxcgtest/exemplary/simple-native.json b/adapters/adxcg/adxcgtest/exemplary/simple-native.json new file mode 100644 index 00000000000..1a449e601a2 --- /dev/null +++ b/adapters/adxcg/adxcgtest/exemplary/simple-native.json @@ -0,0 +1,73 @@ +{ + "mockBidRequest": { + "id": "test-request-native-id", + "imp": [ + { + "id": "test-imp-native-id", + "native": { + "request": "test-native", + "ver": "1.2" + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-native-id", + "imp": [ + { + "id": "test-imp-native-id", + "native": { + "request": "test-native", + "ver": "1.2" + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "adxcg", + "bid": [ + { + "id": "test-request-native-id", + "impid": "test-imp-native-id", + "price": 1.16, + "adm": "native-ad", + "w": 1, + "h": 1 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-native-id", + "impid": "test-imp-native-id", + "price": 1.16, + "adm": "native-ad", + "w": 1, + "h": 1 + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/adxcg/adxcgtest/exemplary/simple-video.json b/adapters/adxcg/adxcgtest/exemplary/simple-video.json new file mode 100644 index 00000000000..b5f54b9bc44 --- /dev/null +++ b/adapters/adxcg/adxcgtest/exemplary/simple-video.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "test-request-video-id", + "imp": [ + { + "id": "test-imp-video-id", + "video": { + "w": 300, + "h": 250, + "maxduration": 60, + "minduration": 1, + "api": [ + 1, + 2, + 5, + 6, + 7 + ], + "mimes": [ + "video\/mp4" + ], + "placement": 4, + "protocols": [ + 2 + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-video-id", + "imp": [ + { + "id": "test-imp-video-id", + "video": { + "w": 300, + "h": 250, + "maxduration": 60, + "minduration": 1, + "api": [ + 1, + 2, + 5, + 6, + 7 + ], + "mimes": [ + "video\/mp4" + ], + "placement": 4, + "protocols": [ + 2 + ] + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "adxcg", + "bid": [ + { + "id": "test-request-video-id", + "impid": "test-imp-video-id", + "price": 1.16, + "adm": "some-test-ad", + "w": 300, + "h": 250 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-video-id", + "impid": "test-imp-video-id", + "price": 1.16, + "adm": "some-test-ad", + "w": 300, + "h": 250 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/adxcg/adxcgtest/params/race/banner.json b/adapters/adxcg/adxcgtest/params/race/banner.json new file mode 100644 index 00000000000..0967ef424bc --- /dev/null +++ b/adapters/adxcg/adxcgtest/params/race/banner.json @@ -0,0 +1 @@ +{} diff --git a/adapters/adxcg/adxcgtest/supplemental/bad_response.json b/adapters/adxcg/adxcgtest/supplemental/bad_response.json new file mode 100644 index 00000000000..f84f5555259 --- /dev/null +++ b/adapters/adxcg/adxcgtest/supplemental/bad_response.json @@ -0,0 +1,61 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": "{\"id\"data.lost" + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "comparison": "literal" + } + ] +} diff --git a/adapters/adxcg/adxcgtest/supplemental/status_204.json b/adapters/adxcg/adxcgtest/supplemental/status_204.json new file mode 100644 index 00000000000..0702c103332 --- /dev/null +++ b/adapters/adxcg/adxcgtest/supplemental/status_204.json @@ -0,0 +1,56 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + + "expectedBidResponses": [] +} diff --git a/adapters/adxcg/adxcgtest/supplemental/status_400.json b/adapters/adxcg/adxcgtest/supplemental/status_400.json new file mode 100644 index 00000000000..65d21406bf0 --- /dev/null +++ b/adapters/adxcg/adxcgtest/supplemental/status_400.json @@ -0,0 +1,61 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/adxcg/adxcgtest/supplemental/status_418.json b/adapters/adxcg/adxcgtest/supplemental/status_418.json new file mode 100644 index 00000000000..4c5dd576aa6 --- /dev/null +++ b/adapters/adxcg/adxcgtest/supplemental/status_418.json @@ -0,0 +1,61 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://localhost/prebid_server", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + } + } + } + ] + } + }, + "mockResponse": { + "status": 418, + "body": {} + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 418. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/adxcg/usersync.go b/adapters/adxcg/usersync.go new file mode 100644 index 00000000000..c6627059703 --- /dev/null +++ b/adapters/adxcg/usersync.go @@ -0,0 +1,12 @@ +package adxcg + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewAdxcgSyncer(urlTemplate *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("adxcg", urlTemplate, adapters.SyncTypeRedirect) +} diff --git a/adapters/adxcg/usersync_test.go b/adapters/adxcg/usersync_test.go new file mode 100644 index 00000000000..53a757f2732 --- /dev/null +++ b/adapters/adxcg/usersync_test.go @@ -0,0 +1,29 @@ +package adxcg + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) + +func TestAdxcgSyncer(t *testing.T) { + syncURL := "https://app.adxcg.net/cma/cm-notify?pi=prebidsrvtst&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdxcgSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "https://app.adxcg.net/cma/cm-notify?pi=prebidsrvtst&gdpr=0&gdpr_consent=", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.Equal(t, false, syncInfo.SupportCORS) +} diff --git a/adapters/adyoulike/adyoulike.go b/adapters/adyoulike/adyoulike.go new file mode 100644 index 00000000000..4cccd5dc5bc --- /dev/null +++ b/adapters/adyoulike/adyoulike.go @@ -0,0 +1,137 @@ +package adyoulike + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "net/http" + + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" +) + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + return &adapter{ + endpoint: config.Endpoint, + }, nil +} + +type adapter struct { + endpoint string +} + +func (a *adapter) MakeRequests( + openRTBRequest *openrtb2.BidRequest, + reqInfo *adapters.ExtraRequestInfo, +) ( + requestsToBidder []*adapters.RequestData, + errs []error, +) { + var err error + var tagID string + + reqCopy := *openRTBRequest + reqCopy.Imp = []openrtb2.Imp{} + for ind, imp := range openRTBRequest.Imp { + reqCopy.Imp = append(reqCopy.Imp, imp) + + tagID, err = jsonparser.GetString(reqCopy.Imp[ind].Ext, "bidder", "placement") + if err != nil { + errs = append(errs, err) + continue + } + + reqCopy.Imp[ind].TagID = tagID + } + + openRTBRequestJSON, err := json.Marshal(reqCopy) + if err != nil { + errs = append(errs, err) + } + + if len(errs) > 0 { + return nil, errs + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + headers.Add("x-openrtb-version", "2.5") + + requestToBidder := &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: openRTBRequestJSON, + Headers: headers, + } + requestsToBidder = append(requestsToBidder, requestToBidder) + + return requestsToBidder, errs +} + +const unexpectedStatusCodeFormat = "" + + "Unexpected status code: %d. Run with request.debug = 1 for more info" + +func (a *adapter) MakeBids( + openRTBRequest *openrtb2.BidRequest, + requestToBidder *adapters.RequestData, + bidderRawResponse *adapters.ResponseData, +) ( + bidderResponse *adapters.BidderResponse, + errs []error, +) { + switch bidderRawResponse.StatusCode { + case http.StatusOK: + break + case http.StatusNoContent: + return nil, []error{errors.New("MakeBids error: No Content")} + case http.StatusBadRequest: + err := &errortypes.BadInput{ + Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode), + } + return nil, []error{err} + default: + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf(unexpectedStatusCodeFormat, bidderRawResponse.StatusCode), + } + return nil, []error{err} + } + + var openRTBBidderResponse openrtb2.BidResponse + if err := json.Unmarshal(bidderRawResponse.Body, &openRTBBidderResponse); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(openRTBRequest.Imp)) + bidResponse.Currency = openRTBBidderResponse.Cur + for _, seatBid := range openRTBBidderResponse.SeatBid { + for idx := range seatBid.Bid { + b := &adapters.TypedBid{ + Bid: &seatBid.Bid[idx], + BidType: getMediaTypeForImp(seatBid.Bid[idx].ImpID, openRTBRequest.Imp), + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, nil +} + +// getMediaTypeForBid determines which type of bid. +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { + mediaType := openrtb_ext.BidTypeBanner + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner == nil && imp.Video != nil { + mediaType = openrtb_ext.BidTypeVideo + } else if imp.Banner == nil && imp.Native != nil { + mediaType = openrtb_ext.BidTypeNative + } + } + } + + return mediaType +} diff --git a/adapters/adyoulike/adyoulike_test.go b/adapters/adyoulike/adyoulike_test.go new file mode 100644 index 00000000000..9ab689f3c77 --- /dev/null +++ b/adapters/adyoulike/adyoulike_test.go @@ -0,0 +1,22 @@ +package adyoulike + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +const testsBidderEndpoint = "https://localhost/bid/4" + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderAdyoulike, config.Adapter{ + Endpoint: testsBidderEndpoint}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "adyouliketest", bidder) +} diff --git a/adapters/adyoulike/adyouliketest/exemplary/multiformat-impression.json b/adapters/adyoulike/adyouliketest/exemplary/multiformat-impression.json new file mode 100644 index 00000000000..2ae99c04969 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/exemplary/multiformat-impression.json @@ -0,0 +1,169 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + }, + { + "id": "video-imp-id", + "video": { + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "placement": "54321" + } + } + }, + { + "id": "native-imp-id", + "native": { + "title": "required" + }, + "ext": { + "bidder": { + "placement": "123123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + }, + { + "ext": { + "bidder": { + "placement": "54321" + } + }, + "id": "video-imp-id", + "tagid": "54321", + "video": { + "h": 480, + "mimes": null, + "w": 640 + } + }, + { + "ext": { + "bidder": { + "placement": "123123" + } + }, + "id": "native-imp-id", + "native": { + "request": "" + }, + "tagid": "123123" + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [{ + "seat": "1", + "bid": [{ + "id": "12340", + "impid": "banner-imp-id", + "price": 300, + "adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2Fhtml%3E", + "nurl": "http://example.com/winnoticeurl0" + }, + { + "id": "12341", + "impid": "video-imp-id", + "price": 301, + "adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2FVAST%3E", + "nurl": "http://example.com/winnoticeurl1" + }, + { + "id": "12342", + "impid": "native-imp-id", + "price": 302, + "adm": "{'json':'response','for':'native'}", + "nurl": "http://example.com/winnoticeurl2" + } + ] + }] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "12340", + "impid": "banner-imp-id", + "price": 300, + "nurl": "http://example.com/winnoticeurl0", + "adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2Fhtml%3E" + }, + "type": "banner" + }, + { + "bid": { + "id": "12341", + "impid": "video-imp-id", + "price": 301, + "nurl": "http://example.com/winnoticeurl1", + "adm": "%3C%3Fxml%20version%3D%221.0%22%20encod%2FVAST%3E" + }, + "type": "video" + }, + { + "bid": { + "id": "12342", + "impid": "native-imp-id", + "price": 302, + "nurl": "http://example.com/winnoticeurl2", + "adm": "{'json':'response','for':'native'}" + }, + "type": "native" + } + ] + } + ] + } diff --git a/adapters/adyoulike/adyouliketest/params/race/banner.json b/adapters/adyoulike/adyouliketest/params/race/banner.json new file mode 100644 index 00000000000..726ca878c05 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/params/race/banner.json @@ -0,0 +1,3 @@ +{ + "placement": "19f1b372c7548ec1fe734d2c9f8dc688" +} diff --git a/adapters/adyoulike/adyouliketest/params/race/video.json b/adapters/adyoulike/adyouliketest/params/race/video.json new file mode 100644 index 00000000000..d0883f5e04a --- /dev/null +++ b/adapters/adyoulike/adyouliketest/params/race/video.json @@ -0,0 +1,3 @@ +{ + "placement": "19f1b372c7548ec1fe734d2c9f8dc688" +} diff --git a/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json new file mode 100644 index 00000000000..bda8d3e6640 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/supplemental/invalid-bid-response.json @@ -0,0 +1,65 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": "" + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adyoulike/adyouliketest/supplemental/status-bad-request.json b/adapters/adyoulike/adyouliketest/supplemental/status-bad-request.json new file mode 100644 index 00000000000..83b5f3611d8 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/supplemental/status-bad-request.json @@ -0,0 +1,66 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": { + } + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adyoulike/adyouliketest/supplemental/status-no-content.json b/adapters/adyoulike/adyouliketest/supplemental/status-no-content.json new file mode 100644 index 00000000000..9ef51e88a41 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/supplemental/status-no-content.json @@ -0,0 +1,66 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": { + } + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [ + { + "value": "MakeBids error: No Content", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adyoulike/adyouliketest/supplemental/status-service-unavailable.json b/adapters/adyoulike/adyouliketest/supplemental/status-service-unavailable.json new file mode 100644 index 00000000000..2b5872a16f5 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/supplemental/status-service-unavailable.json @@ -0,0 +1,66 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + } + ] + } + }, + "mockResponse": { + "status": 503, + "body": { + } + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 503. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adyoulike/adyouliketest/supplemental/status-unknown.json b/adapters/adyoulike/adyouliketest/supplemental/status-unknown.json new file mode 100644 index 00000000000..0b9ce745dd9 --- /dev/null +++ b/adapters/adyoulike/adyouliketest/supplemental/status-unknown.json @@ -0,0 +1,66 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "banner-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://localhost/bid/4", + "body": { + "id": "test-request-id", + "imp": [ + { + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "placement": "12345" + } + }, + "id": "banner-imp-id", + "tagid": "12345" + } + ] + } + }, + "mockResponse": { + "status": 999, + "body": { + } + } + } + ], + + "expectedBidResponses": [], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 999. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/adyoulike/params_test.go b/adapters/adyoulike/params_test.go new file mode 100644 index 00000000000..b57264b3dbd --- /dev/null +++ b/adapters/adyoulike/params_test.go @@ -0,0 +1,62 @@ +package adyoulike + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +// This file actually intends to test static/bidder-params/adyoulike.json +// +// These also validate the format of the external API: request.imp[i].ext.adyoulike + +// TestValidParams makes sure that the adyoulike schema accepts all imp.ext fields which we intend to support. +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderAdyoulike, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adyoulike params: %s", validParam) + } + } +} + +// TestInvalidParams makes sure that the adyoulike schema rejects all the imp.ext fields we don't support. +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, invalidParam := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderAdyoulike, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"placement":"123"}`, + `{"placement":"123","campaign":"456"}`, + `{"placement":"123","campaign":"456","track":"789"}`, + `{"placement":"123","campaign":"456","track":"789","creative":"ABC"}`, + `{"placement":"123","campaign":"456","track":"789","creative":"ABC","source":"SSP"}`, + `{"placement":"123","campaign":"456","track":"789","creative":"ABC","source":"SSP","debug":"info"}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, + `{"invalid":"123"}`, + `{"placement":123}`, + `{"placement":"123","campaign":123}`, +} diff --git a/adapters/adyoulike/usersync.go b/adapters/adyoulike/usersync.go new file mode 100644 index 00000000000..ffea6f69a27 --- /dev/null +++ b/adapters/adyoulike/usersync.go @@ -0,0 +1,12 @@ +package adyoulike + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewAdyoulikeSyncer(urlTemplate *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("adyoulike", urlTemplate, adapters.SyncTypeRedirect) +} diff --git a/adapters/adyoulike/usersync_test.go b/adapters/adyoulike/usersync_test.go new file mode 100644 index 00000000000..72def4cf9b0 --- /dev/null +++ b/adapters/adyoulike/usersync_test.go @@ -0,0 +1,35 @@ +package adyoulike + +import ( + "testing" + "text/template" + + "github.com/stretchr/testify/assert" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" +) + +func TestAdyoulikeSyncer(t *testing.T) { + syncURL := "//visitor.omnitagjs.com/visitor/bsync?uid=19340f4f097d16f41f34fc0274981ca4&name=PrebidServer&gdpr_consent_string={{.GDPRConsent}}&gdpr={{.GDPR}}&us_privacy={{.USPrivacy}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewAdyoulikeSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw", + }, + CCPA: ccpa.Policy{ + Consent: "1-YY", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "//visitor.omnitagjs.com/visitor/bsync?uid=19340f4f097d16f41f34fc0274981ca4&name=PrebidServer&gdpr_consent_string=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&gdpr=1&us_privacy=1-YY", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.Equal(t, false, syncInfo.SupportCORS) +} diff --git a/adapters/aja/aja.go b/adapters/aja/aja.go index afd9c6d7131..6e77fdd5685 100644 --- a/adapters/aja/aja.go +++ b/adapters/aja/aja.go @@ -5,21 +5,21 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/aja/aja_test.go b/adapters/aja/aja_test.go index d2d9d7fa7c1..bab5419d889 100644 --- a/adapters/aja/aja_test.go +++ b/adapters/aja/aja_test.go @@ -3,9 +3,9 @@ package aja import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) const testsBidderEndpoint = "https://localhost/bid/4" diff --git a/adapters/aja/usersync.go b/adapters/aja/usersync.go index deddbabb1d9..6a9fad74e32 100644 --- a/adapters/aja/usersync.go +++ b/adapters/aja/usersync.go @@ -3,10 +3,10 @@ package aja import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAJASyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("aja", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("aja", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/aja/usersync_test.go b/adapters/aja/usersync_test.go index bf03f47af19..dabd5e190b9 100644 --- a/adapters/aja/usersync_test.go +++ b/adapters/aja/usersync_test.go @@ -4,10 +4,10 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -31,6 +31,5 @@ func TestAJASyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://ad.as.amanad.adtdp.com/v1/sync/ssp?ssp=4&gdpr=1&us_privacy=C&redir=localhost/setuid?bidder=aja&gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&uid=%s", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/amx/amx.go b/adapters/amx/amx.go index ddd0c0373da..737fac421f0 100644 --- a/adapters/amx/amx.go +++ b/adapters/amx/amx.go @@ -7,11 +7,11 @@ import ( "net/url" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const vastImpressionFormat = "" @@ -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 6fc850cb2cc..229889db7cf 100644 --- a/adapters/amx/amx_test.go +++ b/adapters/amx/amx_test.go @@ -6,13 +6,13 @@ import ( "regexp" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/adapters/adapterstest" ) const ( @@ -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/amx/amxtest/exemplary/video-simple.json b/adapters/amx/amxtest/exemplary/video-simple.json index f8fe587ff63..678722adf8c 100644 --- a/adapters/amx/amxtest/exemplary/video-simple.json +++ b/adapters/amx/amxtest/exemplary/video-simple.json @@ -242,4 +242,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/amx/amxtest/exemplary/web-simple.json b/adapters/amx/amxtest/exemplary/web-simple.json index 92fc4afc018..f75bd85acb0 100644 --- a/adapters/amx/amxtest/exemplary/web-simple.json +++ b/adapters/amx/amxtest/exemplary/web-simple.json @@ -243,4 +243,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/amx/params_test.go b/adapters/amx/params_test.go index ef177644b21..89e9a3adeb4 100644 --- a/adapters/amx/params_test.go +++ b/adapters/amx/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/adapters/amx/usersync.go b/adapters/amx/usersync.go index d9ff10df562..17ad04d5cfb 100644 --- a/adapters/amx/usersync.go +++ b/adapters/amx/usersync.go @@ -3,11 +3,11 @@ package amx import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) // NewAMXSyncer produces an AMX RTB usersyncer func NewAMXSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("amx", 737, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("amx", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/amx/usersync_test.go b/adapters/amx/usersync_test.go index e6020b27570..b6b6e6babe8 100644 --- a/adapters/amx/usersync_test.go +++ b/adapters/amx/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -18,6 +18,5 @@ func TestAMXSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://pbs.amxrtb.com/cchain/0?gdpr=&gdpr_consent=&cb=localhost%2Fsetuid%3Fbidder%3Damx%26uid%3D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 737, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/applogy/applogy.go b/adapters/applogy/applogy.go index cdeafa0f426..b144c6b836f 100644 --- a/adapters/applogy/applogy.go +++ b/adapters/applogy/applogy.go @@ -6,18 +6,18 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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") @@ -25,7 +25,7 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E result := make([]*adapters.RequestData, 0, len(impressions)) errs := make([]error, 0, len(impressions)) - for i, impression := range impressions { + for _, impression := range impressions { if impression.Banner == nil && impression.Video == nil && impression.Native == nil { errs = append(errs, &errortypes.BadInput{ Message: "Applogy only supports banner, video or native ads", @@ -33,17 +33,17 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E continue } if impression.Banner != nil { - banner := impression.Banner - if banner.W == nil || banner.H == nil || *banner.W == 0 || *banner.H == 0 { - if len(banner.Format) == 0 { + if impression.Banner.W == nil || impression.Banner.H == nil || *impression.Banner.W == 0 || *impression.Banner.H == 0 { + if len(impression.Banner.Format) == 0 { errs = append(errs, &errortypes.BadInput{ Message: "banner size information missing", }) continue } - format := banner.Format[0] - banner.W = &format.W - banner.H = &format.H + banner := *impression.Banner + banner.W = openrtb2.Int64Ptr(banner.Format[0].W) + banner.H = openrtb2.Int64Ptr(banner.Format[0].H) + impression.Banner = &banner } } if len(impression.Ext) == 0 { @@ -70,7 +70,7 @@ func (a *ApplogyAdapter) MakeRequests(request *openrtb.BidRequest, _ *adapters.E errs = append(errs, errors.New("Applogy token required")) continue } - request.Imp = impressions[i : i+1] + 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/applogy/applogy_test.go b/adapters/applogy/applogy_test.go index 63e99ed5895..d86c5cacd68 100644 --- a/adapters/applogy/applogy_test.go +++ b/adapters/applogy/applogy_test.go @@ -3,9 +3,9 @@ package applogy import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/appnexus/appnexus.go b/adapters/appnexus/appnexus.go index 847c11a25ce..8993c7249dc 100644 --- a/adapters/appnexus/appnexus.go +++ b/adapters/appnexus/appnexus.go @@ -11,17 +11,17 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/pbs" "golang.org/x/net/context/ctxhttp" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" ) const defaultPlatformID int = 5 @@ -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)) @@ -391,9 +391,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) @@ -401,7 +401,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 { @@ -409,7 +409,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. @@ -465,7 +465,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 @@ -503,9 +503,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 @@ -552,7 +552,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 } @@ -567,7 +567,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} } @@ -690,5 +690,6 @@ func loadCategoryMapFromFileSystem() map[string]string { return adapterOptions.IabCategories } } + return nil } diff --git a/adapters/appnexus/appnexus_test.go b/adapters/appnexus/appnexus_test.go index 635563a14d3..3386c430fe1 100644 --- a/adapters/appnexus/appnexus_test.go +++ b/adapters/appnexus/appnexus_test.go @@ -10,17 +10,17 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" ) func TestJsonSamples(t *testing.T) { @@ -63,16 +63,16 @@ func TestMemberQueryParam(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) @@ -80,7 +80,7 @@ func TestMemberQueryParam(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") @@ -101,28 +101,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) @@ -130,7 +130,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") @@ -140,7 +140,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") @@ -161,20 +161,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) @@ -182,7 +182,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") @@ -192,7 +192,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") @@ -213,32 +213,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) @@ -246,7 +246,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") @@ -254,7 +254,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") @@ -262,7 +262,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") @@ -284,7 +284,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 @@ -323,7 +323,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) @@ -336,14 +336,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), }, }, } @@ -413,11 +413,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 } @@ -440,7 +440,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, @@ -449,7 +449,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) } @@ -566,7 +566,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/appnexus/params_test.go b/adapters/appnexus/params_test.go index c30f5cf3e2a..f84cccc9a4c 100644 --- a/adapters/appnexus/params_test.go +++ b/adapters/appnexus/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/appnexus.json diff --git a/adapters/appnexus/usersync.go b/adapters/appnexus/usersync.go index 16ffdfa3338..d29f0e3cb6b 100644 --- a/adapters/appnexus/usersync.go +++ b/adapters/appnexus/usersync.go @@ -3,10 +3,10 @@ package appnexus import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAppnexusSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("adnxs", 32, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("adnxs", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/appnexus/usersync_test.go b/adapters/appnexus/usersync_test.go index 6796ce13b96..d01e5704e28 100644 --- a/adapters/appnexus/usersync_test.go +++ b/adapters/appnexus/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestAppNexusSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ib.adnxs.com/getuid?https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 32, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/audienceNetwork/audienceNetworktest/supplemental/no-bid-204.json b/adapters/audienceNetwork/audienceNetworktest/supplemental/no-bid-204.json index 8c97f3e9098..c857ba2c83f 100644 --- a/adapters/audienceNetwork/audienceNetworktest/supplemental/no-bid-204.json +++ b/adapters/audienceNetwork/audienceNetworktest/supplemental/no-bid-204.json @@ -83,4 +83,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/audienceNetwork/facebook.go b/adapters/audienceNetwork/facebook.go index a74c51d9ecb..5cbdbc90561 100644 --- a/adapters/audienceNetwork/facebook.go +++ b/adapters/audienceNetwork/facebook.go @@ -10,19 +10,18 @@ import ( "net/http" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/util/maputil" - - "github.com/PubMatic-OpenWrap/openrtb" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" ) -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/audienceNetwork/facebook_test.go b/adapters/audienceNetwork/facebook_test.go index 596529dbb9a..a2e17b71ca8 100644 --- a/adapters/audienceNetwork/facebook_test.go +++ b/adapters/audienceNetwork/facebook_test.go @@ -4,10 +4,10 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/audienceNetwork/usersync.go b/adapters/audienceNetwork/usersync.go index 6b8ba3ba7a3..4dd0b68ccff 100644 --- a/adapters/audienceNetwork/usersync.go +++ b/adapters/audienceNetwork/usersync.go @@ -3,10 +3,10 @@ package audienceNetwork import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewFacebookSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("audienceNetwork", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("audienceNetwork", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/audienceNetwork/usersync_test.go b/adapters/audienceNetwork/usersync_test.go index e11fb194dec..591ea74f7ba 100644 --- a/adapters/audienceNetwork/usersync_test.go +++ b/adapters/audienceNetwork/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestFacebookSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://www.facebook.com/audiencenetwork/idsync/?partner=partnerId&callback=localhost%2Fsetuid%3Fbidder%3DaudienceNetwork%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/avocet/avocet.go b/adapters/avocet/avocet.go index ef2314e7ebb..7ec4788e858 100644 --- a/adapters/avocet/avocet.go +++ b/adapters/avocet/avocet.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // AvocetAdapter implements a adapters.Bidder compatible with the Avocet advertising platform. @@ -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/exemplary/banner.json b/adapters/avocet/avocet/exemplary/banner.json deleted file mode 100644 index b5e308ea725..00000000000 --- a/adapters/avocet/avocet/exemplary/banner.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "bidder": { - "placement": "5ea9601ac865f911007f1b6a" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://bid.staging.avct.cloud/ortb/bid/5e722ee9bd6df11d063a8013", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "bidder": { - "placement": "5ea9601ac865f911007f1b6a" - } - } - } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "bidid": "dd87f80c-16a0-43c8-a673-b94b3ea4d417", - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "adm": "", - "adomain": ["avocet.io"], - "cid": "5b51e2d689654741306813a4", - "crid": "5b51e49634f2021f127ff7c9", - "h": 250, - "id": "bc708396-9202-437b-b726-08b9864cb8b8", - "impid": "test-imp-id", - "iurl": "https://cdn.staging.avocet.io/snapshots/5b51dd1634f2021f127ff7c0/5b51e49634f2021f127ff7c9.jpeg", - "language": "en", - "price": 15.64434783, - "w": 300 - } - ], - "seat": "TEST_SEAT_ID" - } - ] - } - } - } - ], - - "expectedBids": [ - { - "bid": { - "adm": "", - "adomain": ["avocet.io"], - "cid": "5b51e2d689654741306813a4", - "crid": "5b51e49634f2021f127ff7c9", - "h": 250, - "id": "bc708396-9202-437b-b726-08b9864cb8b8", - "impid": "test-imp-id", - "iurl": "https://cdn.staging.avocet.io/snapshots/5b51dd1634f2021f127ff7c0/5b51e49634f2021f127ff7c9.jpeg", - "language": "en", - "price": 15.64434783, - "w": 300 - }, - "type": "banner" - } - ] -} diff --git a/adapters/avocet/avocet/exemplary/video.json b/adapters/avocet/avocet/exemplary/video.json deleted file mode 100644 index 2398256b0dd..00000000000 --- a/adapters/avocet/avocet/exemplary/video.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1920, - "h": 1080 - }, - "ext": { - "bidder": { - "placement": "5ea9601ac865f911007f1b6a" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://bid.staging.avct.cloud/ortb/bid/5e722ee9bd6df11d063a8013", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1920, - "h": 1080 - }, - "ext": { - "bidder": { - "placement": "5ea9601ac865f911007f1b6a" - } - } - } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "bidid": "a0eec3aa-f9f6-42fb-9aa4-f1b5656d4f42", - "id": "749d36d7-c993-455f-aefd-ffd8a7e3ccf", - "seatbid": [ - { - "bid": [ - { - "adm": "Avocet", - "adomain": ["avocet.io"], - "cid": "5b51e2d689654741306813a4", - "crid": "5ec530e32d57fe1100f17d87", - "h": 396, - "id": "3d4c2d45-5a8c-43b8-9e15-4f48ac45204f", - "impid": "dfp-ad--top-above-nav", - "iurl": "https://cdn.staging.avocet.io/snapshots/5b51dd1634f2021f127ff7c0/5ec530e32d57fe1100f17d87.jpeg", - "language": "en", - "price": 15.64434783, - "w": 600, - "ext": { - "avocet": { - "duration": 30 - } - } - } - ], - "seat": "TEST_SEAT_ID" - } - ] - } - } - } - ], - - "expectedBids": [ - { - "bid": { - "adm": "Avocet", - "adomain": ["avocet.io"], - "cid": "5b51e2d689654741306813a4", - "crid": "5ec530e32d57fe1100f17d87", - "h": 396, - "id": "3d4c2d45-5a8c-43b8-9e15-4f48ac45204f", - "impid": "dfp-ad--top-above-nav", - "iurl": "https://cdn.staging.avocet.io/snapshots/5b51dd1634f2021f127ff7c0/5ec530e32d57fe1100f17d87.jpeg", - "language": "en", - "price": 15.64434783, - "w": 600, - "ext": { - "avocet": { - "duration": 30 - } - } - }, - "type": "video" - } - ] -} diff --git a/adapters/avocet/avocet_test.go b/adapters/avocet/avocet_test.go index f669e34492f..8dc3c333147 100644 --- a/adapters/avocet/avocet_test.go +++ b/adapters/avocet/avocet_test.go @@ -6,12 +6,12 @@ import ( "reflect" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { @@ -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/avocet/usersync.go b/adapters/avocet/usersync.go index ec4f25dd952..0cfa055ae86 100644 --- a/adapters/avocet/usersync.go +++ b/adapters/avocet/usersync.go @@ -3,10 +3,10 @@ package avocet import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewAvocetSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("avocet", 63, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("avocet", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/avocet/usersync_test.go b/adapters/avocet/usersync_test.go index 12b7901cc90..bd4cd4145a2 100644 --- a/adapters/avocet/usersync_test.go +++ b/adapters/avocet/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestAvocetSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://ads.avct.cloud/getuid?&gdpr=1&gdpr_consent=ConsentString&us_privacy=PrivacyString&url=%2Fsetuid%3Fbidder%3Davocet%26gdpr%3D1%26gdpr_consent%3DConsentString%26uid%3D%7B%7BUUID%7D%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 63, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/beachfront/beachfront.go b/adapters/beachfront/beachfront.go index 8aca4ca0427..6bcabf4a39c 100644 --- a/adapters/beachfront/beachfront.go +++ b/adapters/beachfront/beachfront.go @@ -5,15 +5,14 @@ import ( "errors" "fmt" "net/http" - "reflect" "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const Seat = "beachfront" @@ -24,12 +23,13 @@ const defaultVideoEndpoint = "https://reachms.bfmio.com/bid.json?exchange_id" const nurlVideoEndpointSuffix = "&prebidserver" const beachfrontAdapterName = "BF_PREBID_S2S" -const beachfrontAdapterVersion = "0.9.1" +const beachfrontAdapterVersion = "0.9.2" const minBidFloor = 0.01 -const DefaultVideoWidth = 300 -const DefaultVideoHeight = 250 +const defaultVideoWidth = 300 +const defaultVideoHeight = 250 +const fakeIP = "255.255.255.255" type BeachfrontAdapter struct { bannerEndpoint string @@ -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,11 +71,12 @@ 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"` RequestID string `json:"requestId"` + Real204 bool `json:"real204"` } type beachfrontSlot struct { @@ -107,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{} @@ -197,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 && @@ -249,16 +250,12 @@ func getAppId(ext openrtb_ext.ExtImpBeachfront, media openrtb_ext.BidType) (stri var appid string var error error - if fmt.Sprintf("%s", reflect.TypeOf(ext.AppId)) == "string" && - ext.AppId != "" { - + if ext.AppId != "" { appid = ext.AppId - } else if fmt.Sprintf("%s", reflect.TypeOf(ext.AppIds)) == "openrtb_ext.ExtImpBeachfrontAppIds" { - if media == openrtb_ext.BidTypeVideo && ext.AppIds.Video != "" { - appid = ext.AppIds.Video - } else if media == openrtb_ext.BidTypeBanner && ext.AppIds.Banner != "" { - appid = ext.AppIds.Banner - } + } else if media == openrtb_ext.BidTypeVideo && ext.AppIds.Video != "" { + appid = ext.AppIds.Video + } else if media == openrtb_ext.BidTypeBanner && ext.AppIds.Banner != "" { + appid = ext.AppIds.Banner } else { error = errors.New("unable to determine the appId(s) from the supplied extension") } @@ -270,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)) @@ -304,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), }) } @@ -317,7 +314,7 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e } if request.Device != nil { - bfr.IP = getIP(request.Device.IP) + bfr.IP = request.Device.IP bfr.DeviceModel = request.Device.Model bfr.DeviceOs = request.Device.OS if request.Device.DNT != nil { @@ -330,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) @@ -339,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) @@ -371,19 +368,20 @@ func getBannerRequest(request *openrtb.BidRequest) (beachfrontBannerRequest, []e if request.Imp[0].Secure != nil { bfr.Secure = *request.Imp[0].Secure } + bfr.Real204 = true 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) @@ -399,6 +397,7 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] } appid, err := getAppId(beachfrontExt, openrtb_ext.BidTypeVideo) + bfReqs[i].AppId = appid if err != nil { // Failed to get an appid, so this request is junk. @@ -407,20 +406,30 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] continue } - bfReqs[i].AppId = appid + bfReqs[i].Request = *request + var secure int8 - if beachfrontExt.VideoResponseType != "" { - bfReqs[i].VideoResponseType = beachfrontExt.VideoResponseType + var deviceCopy openrtb2.Device + if bfReqs[i].Request.Device == nil { + deviceCopy = openrtb2.Device{} } else { - bfReqs[i].VideoResponseType = "adm" + deviceCopy = *bfReqs[i].Request.Device } - bfReqs[i].Request = *request - var secure int8 + if beachfrontExt.VideoResponseType == "nurl" { + bfReqs[i].VideoResponseType = "nurl" + } else { + bfReqs[i].VideoResponseType = "adm" - if bfReqs[i].Request.Site != nil && bfReqs[i].Request.Site.Domain == "" && bfReqs[i].Request.Site.Page != "" { - bfReqs[i].Request.Site.Domain = getDomain(bfReqs[i].Request.Site.Page) + if deviceCopy.IP == "" { + deviceCopy.IP = fakeIP + } + } + if bfReqs[i].Request.Site != nil && bfReqs[i].Request.Site.Domain == "" && bfReqs[i].Request.Site.Page != "" { + siteCopy := *bfReqs[i].Request.Site + siteCopy.Domain = getDomain(bfReqs[i].Request.Site.Page) + bfReqs[i].Request.Site = &siteCopy secure = isSecure(bfReqs[i].Request.Site.Page) } @@ -433,13 +442,13 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] fmt.Sprintf("%s.%s", chunks[len(chunks)-(len(chunks)-1)], chunks[0]) } } - } - if bfReqs[i].Request.Device != nil && bfReqs[i].Request.Device.DeviceType == 0 { + if deviceCopy.DeviceType == 0 { // More fine graned deviceType methods will be added in the future - bfReqs[i].Request.Device.DeviceType = fallBackDeviceType(request) + deviceCopy.DeviceType = fallBackDeviceType(request) } + bfReqs[i].Request.Device = &deviceCopy imp := request.Imp[i] @@ -454,8 +463,8 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] } if imp.Video.H == 0 && imp.Video.W == 0 { - imp.Video.W = DefaultVideoWidth - imp.Video.H = DefaultVideoHeight + imp.Video.W = defaultVideoWidth + imp.Video.H = defaultVideoHeight } if len(bfReqs[i].Request.Cur) == 0 { @@ -464,12 +473,9 @@ func getVideoRequests(request *openrtb.BidRequest) ([]beachfrontVideoRequest, [] } bfReqs[i].Request.Imp = nil - bfReqs[i].Request.Imp = make([]openrtb.Imp, 1, 1) + bfReqs[i].Request.Imp = make([]openrtb2.Imp, 1) bfReqs[i].Request.Imp[0] = imp - if bfReqs[i].Request.Device != nil && bfReqs[i].Request.Device.IP != "" { - bfReqs[i].Request.Device.IP = getIP(bfReqs[i].Request.Device.IP) - } } // Strip out any failed requests @@ -482,17 +488,20 @@ 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) { - var bids []openrtb.Bid - var errs []error - - if response.StatusCode == http.StatusNoContent || (response.StatusCode == http.StatusOK && len(response.Body) <= 2) { +func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if response.StatusCode == http.StatusNoContent { return nil, nil } - if response.StatusCode == http.StatusBadRequest { + if response.StatusCode >= http.StatusInternalServerError { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("server error status code %d from %s. Run with request.debug = 1 for more info", response.StatusCode, externalRequest.Uri), + }} + } + + if response.StatusCode >= http.StatusBadRequest { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("bad request status code %d from %s. Run with request.debug = 1 for more info", response.StatusCode, externalRequest.Uri), + Message: fmt.Sprintf("request error status code %d from %s. Run with request.debug = 1 for more info", response.StatusCode, externalRequest.Uri), }} } @@ -500,7 +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 xtrnal openrtb.BidRequest + var bids []openrtb2.Bid + var errs = make([]error, 0) + 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 @@ -516,6 +527,7 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern var dur beachfrontVideoBidExtension bidResponse := adapters.NewBidderResponseWithBidsCapacity(BidCapacity) + for i := 0; i < len(bids); i++ { // If we unmarshal without an error, this is an AdM video @@ -548,20 +560,17 @@ 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 errs = make([]error, 0) - var openrtbResp openrtb.BidResponse + var openrtbResp openrtb2.BidResponse - // try it as a video - if err := json.Unmarshal(response.Body, &openrtbResp); err != nil { - errs = append(errs, err) + if err := json.Unmarshal(response.Body, &openrtbResp); err != nil || len(openrtbResp.SeatBid) == 0 { - // try it as a banner if err := json.Unmarshal(response.Body, &beachfrontResp); err != nil { - errs = append(errs, err) - return nil, errs + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprint("server response failed to unmarshal as valid rtb. Run with request.debug = 1 for more info"), + }} } else { return postprocessBanner(beachfrontResp, id) } @@ -570,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) @@ -624,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 @@ -669,18 +678,12 @@ func isSecure(page string) int8 { } -func getIP(ip string) string { - // This will only effect testing. The backend will return "" for localhost IPs, - // and seems not to know what IPv6 is, so just setting it to one that is not likely to - // be used. - if ip == "" || ip == "::1" || ip == "127.0.0.1" { - return "192.168.255.255" +func removeVideoElement(slice []beachfrontVideoRequest, s int) []beachfrontVideoRequest { + if len(slice) >= s+1 { + return append(slice[:s], slice[s+1:]...) } - return ip -} -func removeVideoElement(slice []beachfrontVideoRequest, s int) []beachfrontVideoRequest { - return append(slice[:s], slice[s+1:]...) + return []beachfrontVideoRequest{} } // Builder builds a new instance of the Beachfront adapter for the given bidder with the given config. diff --git a/adapters/beachfront/beachfront_test.go b/adapters/beachfront/beachfront_test.go index aace3224534..1c1c4ff4469 100644 --- a/adapters/beachfront/beachfront_test.go +++ b/adapters/beachfront/beachfront_test.go @@ -3,9 +3,9 @@ package beachfront import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/beachfront/beachfronttest/exemplary/adm-video.json b/adapters/beachfront/beachfronttest/exemplary/adm-video.json new file mode 100644 index 00000000000..edde1301dcc --- /dev/null +++ b/adapters/beachfront/beachfronttest/exemplary/adm-video.json @@ -0,0 +1,124 @@ +{ + "mockBidRequest": { + "id": "adm-video", + "imp": [ + { + "id": "video1", + "ext": { + "bidder": { + "bidfloor": 3.01, + "appId": "videoAppId1" + } + }, + "video": { + "mimes": [ + "video/mp4" + ], + "context": "instream", + "w": 300, + "h": 250 + } + } + ], + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "device":{ + "ip":"192.168.168.168" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/bid.json?exchange_id=videoAppId1", + "body": { + "id": "adm-video", + "imp": [ + { + "video": { + "w": 300, + "h": 250, + "mimes": [ + "video/mp4" + ] + }, + "bidfloor": 3.01, + "id": "video1", + "secure": 1 + } + ], + "site": { + "page": "https://some.domain.us/some/page.html", + "domain": "some.domain.us" + }, + "cur": [ + "USD" + ], + "device":{ + "devicetype": 2, + "ip":"192.168.168.168" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "adm-video", + "seatBid": [ + { + "bid": [ + { + "id": "5fd7c8a6ff2f1f0d42ee6427", + "impid": "video1", + "price": 20, + "adm": "http://example.com/vast.xml", + "adid": "1088", + "adomain": [ + "beachfront.io" + ], + "cid": "277", + "crid": "532", + "w": 300, + "h": 250, + "ext": { + "duration": 30 + } + } + ], + "seat": "bfio-s-1" + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "video1AdmVideo", + "impid": "video1", + "price": 20, + "adm": "http://example.com/vast.xml", + "adid": "1088", + "adomain": [ + "beachfront.io" + ], + "cid": "277", + "crid": "532", + "w": 300, + "h": 250, + "ext": { + "duration": 30 + } + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/beachfront/beachfronttest/exemplary/banner.json b/adapters/beachfront/beachfronttest/exemplary/banner.json index 1eb17286e9c..1a8e830521d 100644 --- a/adapters/beachfront/beachfronttest/exemplary/banner.json +++ b/adapters/beachfront/beachfronttest/exemplary/banner.json @@ -45,6 +45,7 @@ ], "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html", + "real204": true, "referrer": "", "search": "", "secure": 1, @@ -56,7 +57,7 @@ "dnt": 0, "ua": "", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.1", + "adapterVersion": "0.9.2", "user": {} } }, diff --git a/adapters/beachfront/beachfronttest/exemplary/adm-video-by-explicit-type.json b/adapters/beachfront/beachfronttest/supplemental/adm-video-by-explicit.json similarity index 100% rename from adapters/beachfront/beachfronttest/exemplary/adm-video-by-explicit-type.json rename to adapters/beachfront/beachfronttest/supplemental/adm-video-by-explicit.json diff --git a/adapters/beachfront/beachfronttest/exemplary/adm-video-by-default.json b/adapters/beachfront/beachfronttest/supplemental/adm-video-no-ip.json similarity index 98% rename from adapters/beachfront/beachfronttest/exemplary/adm-video-by-default.json rename to adapters/beachfront/beachfronttest/supplemental/adm-video-no-ip.json index d3fa41a23c5..842e0f3777e 100644 --- a/adapters/beachfront/beachfronttest/exemplary/adm-video-by-default.json +++ b/adapters/beachfront/beachfronttest/supplemental/adm-video-no-ip.json @@ -22,9 +22,6 @@ ], "site": { "page": "https://some.domain.us/some/page.html" - }, - "device":{ - "ip":"255.255.255.255" } }, diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-204-with-body.json b/adapters/beachfront/beachfronttest/supplemental/banner-204-with-body.json new file mode 100644 index 00000000000..edba490e814 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/banner-204-with-body.json @@ -0,0 +1,79 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "id": "dudImp", + "bidfloor": 0.02, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 0.02, + "appId": "dudAppId1" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/prebid_display", + "body": { + "slots": [ + { + "slot": "dudImp", + "id": "dudAppId1", + "bidfloor": 0.02, + "sizes": [ + { + "w": 300, + "h": 250 + } + ] + } + ], + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html", + "real204": true, + "referrer": "", + "search": "", + "secure": 1, + "requestId": "some_test_ad", + "isMobile": 0, + "ip": "", + "deviceModel": "", + "deviceOs": "", + "dnt": 0, + "ua": "", + "adapterName": "BF_PREBID_S2S", + "adapterVersion": "0.9.2", + "user": { + } + } + }, + "mockResponse": { + "status": 204, + "body": [ + { + "something": "where nothing should be" + } + ] + } + } + ], + + "expectedBidResponses": [] +} + diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-empty_array-200.json b/adapters/beachfront/beachfronttest/supplemental/banner-204.json similarity index 90% rename from adapters/beachfront/beachfronttest/supplemental/banner-empty_array-200.json rename to adapters/beachfront/beachfronttest/supplemental/banner-204.json index c90c1215f9e..69aa0b882a9 100644 --- a/adapters/beachfront/beachfronttest/supplemental/banner-empty_array-200.json +++ b/adapters/beachfront/beachfronttest/supplemental/banner-204.json @@ -46,6 +46,7 @@ ], "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html", + "real204": true, "referrer": "", "search": "", "secure": 1, @@ -57,17 +58,19 @@ "dnt": 0, "ua": "", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.1", + "adapterVersion": "0.9.2", "user": { } } }, "mockResponse": { - "status": 200, - "body": [] + "status": 204, + "body": "" } } ], - "expectedBidResponses": [] + "expectedBidResponses": [ + + ] } diff --git a/adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-explicit-type.json b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-by-explicit.json similarity index 94% rename from adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-explicit-type.json rename to adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-by-explicit.json index 3482f4ef81e..b060efe6f03 100644 --- a/adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-explicit-type.json +++ b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-by-explicit.json @@ -34,6 +34,9 @@ ], "site": { "page": "https://some.domain.us/some/page.html" + }, + "device":{ + "ip":"255.255.255.255" } }, @@ -57,6 +60,7 @@ ], "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html", + "real204": true, "referrer": "", "search": "", "secure": 1, @@ -64,11 +68,11 @@ "deviceModel": "", "isMobile": 0, "ua": "", - "ip": "", + "ip": "255.255.255.255", "dnt": 0, "user": {}, "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.1", + "adapterVersion": "0.9.2", "requestId": "banner-and-video" } }, @@ -109,6 +113,10 @@ "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html" }, + "device": { + "devicetype": 2, + "ip": "255.255.255.255" + }, "cur": [ "USD" ] diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-expected-204-response-on-banner.json b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-expected-204-response-on-banner.json new file mode 100644 index 00000000000..240994bb370 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video-expected-204-response-on-banner.json @@ -0,0 +1,171 @@ +{ + "mockBidRequest": { + "id": "banner-and-video", + "imp": [ + { + "id": "mix1", + "ext": { + "bidder": { + "bidfloor": 0.41, + "appIds": { + "banner": "bannerAppId1", + "video": "videoAppId1" + } + } + }, + "video": { + "mimes": [ + "video/mp4" + ], + "context": "instream", + "w": 300, + "h": 250 + }, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + } + } + ], + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "device":{ + "ip":"255.255.255.255" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/prebid_display", + "body": { + "slots": [ + { + "slot": "mix1", + "id": "bannerAppId1", + "bidfloor": 0.41, + "sizes": [ + { + "w": 300, + "h": 250 + } + ] + } + ], + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html", + "real204": true, + "referrer": "", + "search": "", + "secure": 1, + "deviceOs": "", + "deviceModel": "", + "isMobile": 0, + "ua": "", + "ip": "255.255.255.255", + "dnt": 0, + "user": {}, + "adapterName": "BF_PREBID_S2S", + "adapterVersion": "0.9.2", + "requestId": "banner-and-video" + } + }, + "mockResponse": { + "status": 204, + "body": "" + } + }, + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/bid.json?exchange_id=videoAppId1", + "body": { + "id": "banner-and-video", + "imp": [ + { + "video": { + "w": 300, + "h": 250, + "mimes": [ + "video/mp4" + ] + }, + "bidfloor": 0.41, + "secure": 1, + "id": "mix1" + } + ], + "site": { + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html" + }, + "device": { + "devicetype": 2, + "ip": "255.255.255.255" + }, + "cur": [ + "USD" + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "61b87329-8790-47b7-90dd-c53ae7ce1723", + "seatbid": [ + { + "bid": [ + { + "id": "5d839458f73decdc1572b7f6", + "impid": "mix1", + "price": 20, + "adm": "http://example.com/vast.xml", + "adid": "1088", + "adomain": [ + "beachfront.io" + ], + "cid": "277", + "crid": "532", + "w": 300, + "h": 250 + } + ], + "seat": "bfb-io-s1" + } + ], + "bidid": "5d839458f73decdc1572b7f6", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + {"bids":[]}, + { + "bids": [ + { + "bid": { + "id": "mix1AdmVideo", + "impid": "mix1", + "price": 20, + "adm": "http://example.com/vast.xml", + "adid": "1088", + "adomain": [ + "beachfront.io" + ], + "cid": "277", + "crid": "532", + "w": 300, + "h": 250 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-default.json b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video.json similarity index 94% rename from adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-default.json rename to adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video.json index bff1b76a688..18e8ca7a1bf 100644 --- a/adapters/beachfront/beachfronttest/exemplary/banner-and-adm-video-by-default.json +++ b/adapters/beachfront/beachfronttest/supplemental/banner-and-adm-video.json @@ -33,6 +33,9 @@ ], "site": { "page": "https://some.domain.us/some/page.html" + }, + "device": { + "ip": "255.255.255.255" } }, @@ -56,6 +59,7 @@ ], "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html", + "real204": true, "referrer": "", "search": "", "secure": 1, @@ -63,11 +67,11 @@ "deviceModel": "", "isMobile": 0, "ua": "", - "ip": "", + "ip": "255.255.255.255", "dnt": 0, "user": {}, "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.1", + "adapterVersion": "0.9.2", "requestId": "banner-and-video" } }, @@ -108,6 +112,10 @@ "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html" }, + "device": { + "devicetype": 2, + "ip": "255.255.255.255" + }, "cur": [ "USD" ] diff --git a/adapters/beachfront/beachfronttest/exemplary/banner-and-nurl-video.json b/adapters/beachfront/beachfronttest/supplemental/banner-and-nurl-video.json similarity index 97% rename from adapters/beachfront/beachfronttest/exemplary/banner-and-nurl-video.json rename to adapters/beachfront/beachfronttest/supplemental/banner-and-nurl-video.json index 9db714f41a1..2ef8ca585e1 100644 --- a/adapters/beachfront/beachfronttest/exemplary/banner-and-nurl-video.json +++ b/adapters/beachfront/beachfronttest/supplemental/banner-and-nurl-video.json @@ -57,6 +57,7 @@ ], "domain": "some.domain.us", "page": "https://some.domain.us/some/page.html", + "real204": true, "referrer": "", "search": "", "secure": 1, @@ -68,7 +69,7 @@ "dnt": 0, "user": {}, "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.9.1", + "adapterVersion": "0.9.2", "requestId": "banner-and-video" } }, @@ -110,6 +111,9 @@ "page": "https://some.domain.us/some/page.html" }, "isPrebid": true, + "device": { + "devicetype": 2 + }, "cur": [ "USD" ] diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json b/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json new file mode 100644 index 00000000000..35926b3c943 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/banner-bad-request-400.json @@ -0,0 +1,77 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "bidfloor": 0.02, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 5.02, + "appId": "dudAppId" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/prebid_display", + "body": { + "slots": [ + { + "slot": "", + "id": "dudAppId", + "bidfloor": 5.02, + "sizes": [ + { + "w": 300, + "h": 250 + } + ] + } + ], + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html", + "real204": true, + "referrer": "", + "search": "", + "secure": 1, + "requestId": "some_test_ad", + "isMobile": 0, + "ip": "", + "deviceModel": "", + "deviceOs": "", + "dnt": 0, + "ua": "", + "adapterName": "BF_PREBID_S2S", + "adapterVersion": "0.9.2", + "user": {} + } + }, + "mockResponse": { + "status": 400, + "body": "" + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "request error status code 400 from https://qa.beachrtb.com/prebid_display. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-no-appid.json b/adapters/beachfront/beachfronttest/supplemental/banner-no-appid.json new file mode 100644 index 00000000000..a53dd8ce1fc --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/banner-no-appid.json @@ -0,0 +1,34 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "bidfloor": 0.02, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 0.02, + "appId": "" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "unable to determine the appId(s) from the supplied extension", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/banner-wrong-appids.json b/adapters/beachfront/beachfronttest/supplemental/banner-wrong-appids.json new file mode 100644 index 00000000000..3b582648bd5 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/banner-wrong-appids.json @@ -0,0 +1,36 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "bidfloor": 0.02, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 0.02, + "appIds": { + "video": "theWrongAppId" + } + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "unable to determine the appId(s) from the supplied extension", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_adm_video.json b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_adm_video.json new file mode 100644 index 00000000000..51c676f5076 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_adm_video.json @@ -0,0 +1,80 @@ +{ + "mockBidRequest": { + "id": "adm-video", + "imp": [ + { + "id": "video1", + "ext": { + "bidder": { + "bidfloor": 3.01, + "appId": "videoAppId1" + } + }, + "video": { + "mimes": [ + "video/mp4" + ], + "context": "instream", + "w": 300, + "h": 250 + } + } + ], + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "device":{ + "ip":"255.255.255.255" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/bid.json?exchange_id=videoAppId1", + "body": { + "id": "adm-video", + "imp": [ + { + "video": { + "w": 300, + "h": 250, + "mimes": [ + "video/mp4" + ] + }, + "bidfloor": 3.01, + "id": "video1", + "secure": 1 + } + ], + "site": { + "page": "https://some.domain.us/some/page.html", + "domain": "some.domain.us" + }, + "cur": [ + "USD" + ], + "device":{ + "devicetype": 2, + "ip":"255.255.255.255" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "wrong": "very very wrong.", + "alsoWrong": "not even close to right." + } + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "server response failed to unmarshal as valid rtb. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_banner.json b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_banner.json new file mode 100644 index 00000000000..e7869d36d6d --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_banner.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "bidfloor": 0.02, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 0.02, + "appId": "bannerAppId1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/prebid_display", + "body": { + "slots": [ + { + "slot": "", + "id": "bannerAppId1", + "bidfloor": 0.02, + "sizes": [ + { + "w": 300, + "h": 250 + } + ] + } + ], + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html", + "real204": true, + "referrer": "", + "search": "", + "secure": 1, + "requestId": "some_test_ad", + "isMobile": 0, + "ip": "", + "deviceModel": "", + "deviceOs": "", + "dnt": 0, + "ua": "", + "adapterName": "BF_PREBID_S2S", + "adapterVersion": "0.9.2", + "user": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "wrong": "very very wrong.", + "alsoWrong": "not even close to right." + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "server response failed to unmarshal as valid rtb. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_nurl_video.json b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_nurl_video.json new file mode 100644 index 00000000000..7990b0a1bb1 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/bidder_response_unmarshal_error_nurl_video.json @@ -0,0 +1,82 @@ +{ + "mockBidRequest": { + "id": "adm-video", + "imp": [ + { + "id": "video1", + "ext": { + "bidder": { + "bidfloor": 3.01, + "appId": "videoAppId1", + "videoResponseType": "nurl" + } + }, + "video": { + "mimes": [ + "video/mp4" + ], + "context": "instream", + "w": 300, + "h": 250 + } + } + ], + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "device":{ + "ip":"255.255.255.255" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/bid.json?exchange_id=videoAppId1&prebidserver", + "body": { + "id": "adm-video", + "imp": [ + { + "video": { + "w": 300, + "h": 250, + "mimes": [ + "video/mp4" + ] + }, + "bidfloor": 3.01, + "id": "video1", + "secure": 1 + } + ], + "isPrebid": true, + "site": { + "page": "https://some.domain.us/some/page.html", + "domain": "some.domain.us" + }, + "cur": [ + "USD" + ], + "device":{ + "devicetype": 2, + "ip":"255.255.255.255" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "wrong": "very very wrong.", + "alsoWrong": "not even close to right." + } + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "server response failed to unmarshal as valid rtb. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} diff --git a/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json b/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json new file mode 100644 index 00000000000..7ebe6cf4aa0 --- /dev/null +++ b/adapters/beachfront/beachfronttest/supplemental/bidfloor-below-min.json @@ -0,0 +1,97 @@ +{ + "mockBidRequest": { + "id": "some_test_ad", + "site": { + "page": "https://some.domain.us/some/page.html" + }, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "bidfloor": 0.002, + "appId": "bannerAppId1" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://qa.beachrtb.com/prebid_display", + "body": { + "slots": [ + { + "slot": "", + "id": "bannerAppId1", + "bidfloor": 0, + "sizes": [ + { + "w": 300, + "h": 250 + } + ] + } + ], + "domain": "some.domain.us", + "page": "https://some.domain.us/some/page.html", + "real204": true, + "referrer": "", + "search": "", + "secure": 1, + "requestId": "some_test_ad", + "isMobile": 0, + "ip": "", + "deviceModel": "", + "deviceOs": "", + "dnt": 0, + "ua": "", + "adapterName": "BF_PREBID_S2S", + "adapterVersion": "0.9.2", + "user": {} + } + }, + "mockResponse": { + "status": 200, + "body": [ + { + "crid": "crid_1", + "price": 2.942808, + "w": 300, + "h": 250, + "slot": "div-gpt-ad-1460505748561-0", + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "ttl": 300, + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }] + }, + { + "seat": "45678", + "bid": [{ + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "ttl": 300, + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + } + ] + }], + "cur": "USD" + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }, + "type": "banner" + }, + { + "bid": { + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + }, + "type": "video" + }] + } + ] +} + diff --git a/adapters/jixie/jixietest/params/race/banner.json b/adapters/jixie/jixietest/params/race/banner.json new file mode 100644 index 00000000000..a0523d34c3f --- /dev/null +++ b/adapters/jixie/jixietest/params/race/banner.json @@ -0,0 +1,4 @@ +{ + "unit": "1000008-AbCdEf123400", + "bidfloor": "0.02" +} diff --git a/adapters/jixie/jixietest/params/race/video.json b/adapters/jixie/jixietest/params/race/video.json new file mode 100644 index 00000000000..b6d11e8fc4e --- /dev/null +++ b/adapters/jixie/jixietest/params/race/video.json @@ -0,0 +1,4 @@ +{ + "unit": "1000008-AbCdEf2345", + "bidfloor": "0.03" +} diff --git a/adapters/jixie/jixietest/supplemental/add-accountid.json b/adapters/jixie/jixietest/supplemental/add-accountid.json new file mode 100644 index 00000000000..d7fe7d864a6 --- /dev/null +++ b/adapters/jixie/jixietest/supplemental/add-accountid.json @@ -0,0 +1,236 @@ +{ + "mockBidRequest": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }, { + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234", + "accountid": "accountJX1234" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345", + "accountid": "accountJX1234" + } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456", + "accountid": "accountJX1234" + } + } + } + ], + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://hb.jixie.io/v2/hbsvrpost", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ], + "X-Forwarded-For": [ + "111.222.333.444" + ], + "Referer": [ + "http://www.publisher.com/today/site?param1=a¶m2=b" + ], + "User-Agent": [ + "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + ] + }, + "body": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + },{ + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234", + "accountid": "accountJX1234" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345", + "accountid": "accountJX1234" + } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456", + "accountid": "accountJX1234" + } + } + }], + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some_test_auction", + "seatbid": [{ + "seat": "12356", + "bid": [{ + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "ttl": 300, + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }] + }, + { + "seat": "45678", + "bid": [{ + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "ttl": 300, + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + } + ] + }], + "cur": "USD" + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }, + "type": "banner" + }, + { + "bid": { + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + }, + "type": "video" + }] + } + ] +} + \ No newline at end of file diff --git a/adapters/jixie/jixietest/supplemental/add-extraprop.json b/adapters/jixie/jixietest/supplemental/add-extraprop.json new file mode 100644 index 00000000000..85c55a3620e --- /dev/null +++ b/adapters/jixie/jixietest/supplemental/add-extraprop.json @@ -0,0 +1,233 @@ +{ + "mockBidRequest": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }, { + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234", + "jxprop1": "abc" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345", + "jxprop1": "def" } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456" + } + } + } + ], + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://hb.jixie.io/v2/hbsvrpost", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ], + "X-Forwarded-For": [ + "111.222.333.444" + ], + "Referer": [ + "http://www.publisher.com/today/site?param1=a¶m2=b" + ], + "User-Agent": [ + "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + ] + }, + "body": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + },{ + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234", + "jxprop1": "abc" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345", + "jxprop1": "def" + } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456" + } + } + }], + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some_test_auction", + "seatbid": [{ + "seat": "12356", + "bid": [{ + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "ttl": 300, + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }] + }, + { + "seat": "45678", + "bid": [{ + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "ttl": 300, + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + } + ] + }], + "cur": "USD" + } + } + }], + + "expectedBidResponses": [{ + "currency": "USD", + "bids": [{ + "bid": { + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }, + "type": "banner" + }, + { + "bid": { + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + }, + "type": "video" + }] + } + ] +} + \ No newline at end of file diff --git a/adapters/jixie/jixietest/supplemental/add-userid.json b/adapters/jixie/jixietest/supplemental/add-userid.json new file mode 100644 index 00000000000..3ed30da4676 --- /dev/null +++ b/adapters/jixie/jixietest/supplemental/add-userid.json @@ -0,0 +1,237 @@ +{ + "mockBidRequest": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + }, { + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345" + } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456" + } + } + } + ], + "user": { + "buyeruid": "awesome-buyeruid", + "id": "awesome-id" + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://hb.jixie.io/v2/hbsvrpost", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ], + "X-Forwarded-For": [ + "111.222.333.444" + ], + "Referer": [ + "http://www.publisher.com/today/site?param1=a¶m2=b" + ], + "User-Agent": [ + "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + ] + }, + "body": { + "id": "some_test_auction", + "imp": [{ + "id": "some_test_ad_id_1", + "banner": { + "format": [{ + "w": 300, + "h": 250 + },{ + "w": 300, + "h": 600 + }], + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf1234" + } + } + }, + { + "id": "some_test_ad_id_2", + "banner": { + "format": [{ + "w": 300, + "h": 50 + }], + "w": 300, + "h": 50 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf2345" + } + } + }, + { + "id": "some_test_ad_id_3", + "video":{ + "mimes": [ + "video/mp4", + "application/javascript" + ], + "protocols":[ + 2, + 3, + 5, + 6 + ], + "w":640, + "h":480 + }, + "ext": { + "bidder": { + "unit": "1000008-AbCdEf3456" + } + } + }], + "user": { + "buyeruid": "awesome-buyeruid", + "id": "awesome-id" + }, + "site": { + "domain": "www.publisher.com", + "page": "http://www.publisher.com/today/site?param1=a¶m2=b" + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36", + "ip": "111.222.333.444" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some_test_auction", + "seatbid": [{ + "seat": "12356", + "bid": [{ + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "ttl": 300, + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }] + }, + { + "seat": "45678", + "bid": [{ + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "ttl": 300, + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + } + ] + }], + "cur": "USD" + } + } + }], + + "expectedBidResponses": [{ + "bids": [{ + "bid": { + "adm": "
", + "id": "some_test_ad_id_1", + "impid": "some_test_ad_id_1", + "crid": "94395500", + "w": 300, + "price": 2.942808, + "adid": "94395500", + "h": 250 + }, + "type": "banner" + }, + { + "bid": { + "adm": " JXADSERVERDEMOin-stream 00:00:10", + "id": "some_test_ad_id_3", + "impid": "some_test_ad_id_3", + "crid": "9999999", + "w": 640, + "price": 1, + "adid": "9999999", + "h": 360 + }, + "type": "video" + }] + } + ] +} + \ No newline at end of file diff --git a/adapters/jixie/params_test.go b/adapters/jixie/params_test.go new file mode 100644 index 00000000000..4bc2e3080c1 --- /dev/null +++ b/adapters/jixie/params_test.go @@ -0,0 +1,57 @@ +package jixie + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderJixie, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected jixie params: %s", validParam) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json-schemas. %v", err) + } + + for _, invalidParam := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderJixie, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"unit": "1000008-AA77BB88CC" }`, + `{"unit": "1000008-AA77BB88CC", "accountid": "9988776655", "jxprop1": "somethingimportant" }`, +} + +var invalidParams = []string{ + `null`, + `nil`, + ``, + `[]`, + `true`, + `{}`, + `{"unit":12345678}`, + `{"Unit":"12345678"}`, + `{"Unit": 12345678}`, + `{"AdUnit": "1"}`, + `{"adUnit": 1}`, + `{"unit": ""}`, + `{"unit": "12345678901234567"}`, + `{"unit":"1000008-AA77BB88CC", "accountid", "jxprop1": "somethingimportant" }`, + `{"unit":"1000008-AA77BB88CC", malformed, }`, +} diff --git a/adapters/jixie/usersync.go b/adapters/jixie/usersync.go new file mode 100644 index 00000000000..137d78f2859 --- /dev/null +++ b/adapters/jixie/usersync.go @@ -0,0 +1,12 @@ +package jixie + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewJixieSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("jixie", temp, adapters.SyncTypeRedirect) +} diff --git a/adapters/jixie/usersync_test.go b/adapters/jixie/usersync_test.go new file mode 100644 index 00000000000..575482435ff --- /dev/null +++ b/adapters/jixie/usersync_test.go @@ -0,0 +1,24 @@ +package jixie + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/stretchr/testify/assert" +) + +func TestJixieSyncer(t *testing.T) { + syncURL := "https://id.jixie.io/api/sync?pid=&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Djixie%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25JXUID%25%25" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewJixieSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + + assert.NoError(t, err) + assert.Equal(t, "https://id.jixie.io/api/sync?pid=&gdpr=&gdpr_consent=&us_privacy=&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Djixie%26gdpr%3D%26gdpr_consent%3D%26uid%3D%25%25JXUID%25%25", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.Equal(t, false, syncInfo.SupportCORS) +} diff --git a/adapters/kidoz/kidoz.go b/adapters/kidoz/kidoz.go index 755ffd24d63..43372dc2f39 100644 --- a/adapters/kidoz/kidoz.go +++ b/adapters/kidoz/kidoz.go @@ -6,18 +6,18 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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 b3365ac70a9..3fd807ea454 100644 --- a/adapters/kidoz/kidoz_test.go +++ b/adapters/kidoz/kidoz_test.go @@ -5,11 +5,11 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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/kidoz/kidoztest/exemplary/simple-banner.json b/adapters/kidoz/kidoztest/exemplary/simple-banner.json index 6b2d6dbc56f..81b5f1e5227 100644 --- a/adapters/kidoz/kidoztest/exemplary/simple-banner.json +++ b/adapters/kidoz/kidoztest/exemplary/simple-banner.json @@ -69,4 +69,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/kidoz/kidoztest/exemplary/simple-video.json b/adapters/kidoz/kidoztest/exemplary/simple-video.json index f50ed907bc0..7c012f95527 100644 --- a/adapters/kidoz/kidoztest/exemplary/simple-video.json +++ b/adapters/kidoz/kidoztest/exemplary/simple-video.json @@ -67,4 +67,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/kidoz/kidoztest/supplemental/status-204.json b/adapters/kidoz/kidoztest/supplemental/status-204.json index 03e337c9fda..add65e7d666 100644 --- a/adapters/kidoz/kidoztest/supplemental/status-204.json +++ b/adapters/kidoz/kidoztest/supplemental/status-204.json @@ -55,4 +55,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/kidoz/params_test.go b/adapters/kidoz/params_test.go index 43c5a68d69d..073d7382d68 100644 --- a/adapters/kidoz/params_test.go +++ b/adapters/kidoz/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/krushmedia/krushmedia.go b/adapters/krushmedia/krushmedia.go index 1f2e6b636c6..f1b80da701f 100644 --- a/adapters/krushmedia/krushmedia.go +++ b/adapters/krushmedia/krushmedia.go @@ -7,12 +7,12 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type KrushmediaAdapter struct { @@ -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/krushmedia/krushmedia_test.go b/adapters/krushmedia/krushmedia_test.go index 0fc5c93fed2..7bdea503569 100644 --- a/adapters/krushmedia/krushmedia_test.go +++ b/adapters/krushmedia/krushmedia_test.go @@ -3,9 +3,9 @@ package krushmedia import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/krushmedia/krushmediatest/exemplary/banner-app.json b/adapters/krushmedia/krushmediatest/exemplary/banner-app.json index ac5be1b6ff0..75defaa0712 100644 --- a/adapters/krushmedia/krushmediatest/exemplary/banner-app.json +++ b/adapters/krushmedia/krushmediatest/exemplary/banner-app.json @@ -156,4 +156,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/krushmedia/krushmediatest/exemplary/native-app.json b/adapters/krushmedia/krushmediatest/exemplary/native-app.json index a2bb393727b..bd27d2dc69e 100644 --- a/adapters/krushmedia/krushmediatest/exemplary/native-app.json +++ b/adapters/krushmedia/krushmediatest/exemplary/native-app.json @@ -154,4 +154,4 @@ } ] } - + \ No newline at end of file diff --git a/adapters/krushmedia/krushmediatest/exemplary/video-web.json b/adapters/krushmedia/krushmediatest/exemplary/video-web.json index 48eedb29f48..1e2d8069407 100644 --- a/adapters/krushmedia/krushmediatest/exemplary/video-web.json +++ b/adapters/krushmedia/krushmediatest/exemplary/video-web.json @@ -163,4 +163,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/krushmedia/params_test.go b/adapters/krushmedia/params_test.go index 0f912513b2c..26daa56e10b 100644 --- a/adapters/krushmedia/params_test.go +++ b/adapters/krushmedia/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) var validParams = []string{ diff --git a/adapters/krushmedia/usersync.go b/adapters/krushmedia/usersync.go index 0a4f664e56f..860cb2204e9 100644 --- a/adapters/krushmedia/usersync.go +++ b/adapters/krushmedia/usersync.go @@ -3,10 +3,10 @@ package krushmedia import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewKrushmediaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("krushmedia", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("krushmedia", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/krushmedia/usersync_test.go b/adapters/krushmedia/usersync_test.go index a5908b8061d..765b0faa18b 100644 --- a/adapters/krushmedia/usersync_test.go +++ b/adapters/krushmedia/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -29,6 +29,5 @@ func TestKrushmediaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://cs.krushmedia.com/4e4abdd5ecc661643458a730b1aa927d.gif?gdpr=0&gdpr_consent=allGdpr&us_privacy=1-YY&redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dkrushmedia%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/kubient/kubient.go b/adapters/kubient/kubient.go index fd6c4ef13e8..a99e9005105 100644 --- a/adapters/kubient/kubient.go +++ b/adapters/kubient/kubient.go @@ -5,12 +5,12 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" ) // Builder builds a new instance of the Kubient adapter for the given bidder with the given config. @@ -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/kubient_test.go b/adapters/kubient/kubient_test.go index e7f8a9ee2fc..19eb3e8ff13 100644 --- a/adapters/kubient/kubient_test.go +++ b/adapters/kubient/kubient_test.go @@ -3,9 +3,9 @@ package kubient import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/legacy.go b/adapters/legacy.go index c3fde16d764..8b2221fe0ca 100644 --- a/adapters/legacy.go +++ b/adapters/legacy.go @@ -6,8 +6,8 @@ import ( "net/http" "time" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/server/ssl" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/server/ssl" ) // This file contains some deprecated, legacy types. diff --git a/adapters/lifestreet/lifestreet.go b/adapters/lifestreet/lifestreet.go index ca9b9688943..14f6931751a 100644 --- a/adapters/lifestreet/lifestreet.go +++ b/adapters/lifestreet/lifestreet.go @@ -9,12 +9,12 @@ import ( "net/http" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/pbs" "golang.org/x/net/context/ctxhttp" ) @@ -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 39712192da6..5c4f47fdff9 100644 --- a/adapters/lifestreet/lifestreet_test.go +++ b/adapters/lifestreet/lifestreet_test.go @@ -10,15 +10,15 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" ) type lsTagInfo struct { @@ -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/lifestreet/usersync.go b/adapters/lifestreet/usersync.go index 4f18854e54a..f5300ebaa90 100644 --- a/adapters/lifestreet/usersync.go +++ b/adapters/lifestreet/usersync.go @@ -3,10 +3,10 @@ package lifestreet import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewLifestreetSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("lifestreet", 67, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("lifestreet", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/lifestreet/usersync_test.go b/adapters/lifestreet/usersync_test.go index 134af2f5b88..e41217fe10f 100644 --- a/adapters/lifestreet/usersync_test.go +++ b/adapters/lifestreet/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestLifestreetSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl=localhost%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24%24visitor_cookie%24%24", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 67, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/lockerdome/lockerdome.go b/adapters/lockerdome/lockerdome.go index ec9ebe8c281..28c966be6de 100644 --- a/adapters/lockerdome/lockerdome.go +++ b/adapters/lockerdome/lockerdome.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const unexpectedStatusCodeMessage = "Unexpected status code: %d. Run with request.debug = 1 for more info" @@ -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/lockerdome_test.go b/adapters/lockerdome/lockerdome_test.go index ca3da099eaa..6ac495d5d7c 100644 --- a/adapters/lockerdome/lockerdome_test.go +++ b/adapters/lockerdome/lockerdome_test.go @@ -3,9 +3,9 @@ package lockerdome import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/lockerdome/params_test.go b/adapters/lockerdome/params_test.go index 61ee259a437..815246571e3 100644 --- a/adapters/lockerdome/params_test.go +++ b/adapters/lockerdome/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file tests static/bidder-params/lockerdome.json diff --git a/adapters/lockerdome/usersync.go b/adapters/lockerdome/usersync.go index 67c4e15dd2d..d5cce16804a 100644 --- a/adapters/lockerdome/usersync.go +++ b/adapters/lockerdome/usersync.go @@ -3,10 +3,10 @@ package lockerdome import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewLockerDomeSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("lockerdome", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("lockerdome", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/lockerdome/usersync_test.go b/adapters/lockerdome/usersync_test.go index acfa788e5f7..3a2bd7f325b 100644 --- a/adapters/lockerdome/usersync_test.go +++ b/adapters/lockerdome/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestLockerDomeSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://lockerdome.com/usync/prebidserver?pid=&gdpr=&gdpr_consent=&us_privacy=&redirect=https%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D%26gdpr_consent%3D%26uid%3D%7B%7Buid%7D%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/logicad/logicad.go b/adapters/logicad/logicad.go index dd316321381..982723d0d0a 100644 --- a/adapters/logicad/logicad.go +++ b/adapters/logicad/logicad.go @@ -5,18 +5,18 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/logicad/logicad_test.go b/adapters/logicad/logicad_test.go index 5da8e56e6c2..820aad9751d 100644 --- a/adapters/logicad/logicad_test.go +++ b/adapters/logicad/logicad_test.go @@ -3,9 +3,9 @@ package logicad import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/logicad/params_test.go b/adapters/logicad/params_test.go index 8b5d296bd1f..eb34452811b 100644 --- a/adapters/logicad/params_test.go +++ b/adapters/logicad/params_test.go @@ -2,7 +2,7 @@ package logicad import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/logicad/usersync.go b/adapters/logicad/usersync.go index 34d29a25543..e685cc985fc 100644 --- a/adapters/logicad/usersync.go +++ b/adapters/logicad/usersync.go @@ -3,10 +3,10 @@ package logicad import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewLogicadSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("logicad", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("logicad", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/logicad/usersync_test.go b/adapters/logicad/usersync_test.go index aeb029d3380..e8b10c665fe 100644 --- a/adapters/logicad/usersync_test.go +++ b/adapters/logicad/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -26,6 +26,5 @@ func TestLogicadSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://localhost/cookiesender?r=true&gdpr=1&gdpr_consent=A&ru=localhost%2Fsetuid%3Fbidder%3Dlogicad%26gdpr%3D1%26gdpr_consent%3DA%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/lunamedia/lunamedia.go b/adapters/lunamedia/lunamedia.go index c5e0ef8a3ee..899269e661f 100644 --- a/adapters/lunamedia/lunamedia.go +++ b/adapters/lunamedia/lunamedia.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type LunaMediaAdapter struct { @@ -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/lunamedia/lunamedia_test.go b/adapters/lunamedia/lunamedia_test.go index 6d0952cdd9c..4149060c809 100644 --- a/adapters/lunamedia/lunamedia_test.go +++ b/adapters/lunamedia/lunamedia_test.go @@ -3,9 +3,9 @@ package lunamedia import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/lunamedia/params_test.go b/adapters/lunamedia/params_test.go index 2f21ea45510..b4faeea1f77 100644 --- a/adapters/lunamedia/params_test.go +++ b/adapters/lunamedia/params_test.go @@ -2,7 +2,7 @@ package lunamedia import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/lunamedia/usersync.go b/adapters/lunamedia/usersync.go index 194c4b77dbe..39c9a808040 100644 --- a/adapters/lunamedia/usersync.go +++ b/adapters/lunamedia/usersync.go @@ -3,10 +3,10 @@ package lunamedia import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewLunaMediaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("lunamedia", 0, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("lunamedia", temp, adapters.SyncTypeIframe) } diff --git a/adapters/lunamedia/usersync_test.go b/adapters/lunamedia/usersync_test.go index 3a549aec5f7..24cd740d600 100644 --- a/adapters/lunamedia/usersync_test.go +++ b/adapters/lunamedia/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -26,6 +26,5 @@ func TestLunaMediaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://api.lunamedia.io/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=lunamedia&gdpr=1&gdpr_consent=A&uid=$UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/marsmedia/marsmedia.go b/adapters/marsmedia/marsmedia.go index f1cffac2274..a63db09e208 100644 --- a/adapters/marsmedia/marsmedia.go +++ b/adapters/marsmedia/marsmedia.go @@ -6,18 +6,18 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/marsmedia/marsmedia_test.go b/adapters/marsmedia/marsmedia_test.go index 03e46312ca2..ab87bf773a4 100644 --- a/adapters/marsmedia/marsmedia_test.go +++ b/adapters/marsmedia/marsmedia_test.go @@ -3,9 +3,9 @@ package marsmedia import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/marsmedia/params_test.go b/adapters/marsmedia/params_test.go index 2e3b483824d..43cd49c2ed3 100644 --- a/adapters/marsmedia/params_test.go +++ b/adapters/marsmedia/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/marsmedia.json diff --git a/adapters/marsmedia/usersync.go b/adapters/marsmedia/usersync.go index 63d06d9dcc5..4ac76d1f5f2 100644 --- a/adapters/marsmedia/usersync.go +++ b/adapters/marsmedia/usersync.go @@ -3,10 +3,10 @@ package marsmedia import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewMarsmediaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("marsmedia", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("marsmedia", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/marsmedia/usersync_test.go b/adapters/marsmedia/usersync_test.go index cc4f0b819f9..975af65fcf5 100644 --- a/adapters/marsmedia/usersync_test.go +++ b/adapters/marsmedia/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,7 +30,6 @@ func TestMarsmediaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://dmp.rtbsrv.com/dmp/profiles/cm?p_id=179&gdpr=A&gdpr_consent=B&us_privacy=C&redirect=localhost:8000%2Fsetuid%3Fbidder%3Dmarsmedia%26gdpr%3DA%26gdpr_consent%3DB%26uid%3D%24%7BUUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/mediafuse/usersync.go b/adapters/mediafuse/usersync.go index ca299c724f6..d482ad774bd 100644 --- a/adapters/mediafuse/usersync.go +++ b/adapters/mediafuse/usersync.go @@ -3,10 +3,10 @@ package mediafuse import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewMediafuseSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("mediafuse", 411, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("mediafuse", temp, adapters.SyncTypeIframe) } diff --git a/adapters/mediafuse/usersync_test.go b/adapters/mediafuse/usersync_test.go index 95e6a7cf93f..95045689a87 100644 --- a/adapters/mediafuse/usersync_test.go +++ b/adapters/mediafuse/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -24,7 +24,6 @@ func TestMediafuseSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.hbmp.mediafuse.com/csync?t=p&ep=0&redir=localhost%2Fsetuid%3Fbidder%3Dmediafuse%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7Buid%7D", syncInfo.URL) - assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 411, syncer.GDPRVendorID()) + assert.Equal(t, "iframe", syncInfo.Type) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/mgid/mgid.go b/adapters/mgid/mgid.go index 9754ba8088e..95ede0ab5c4 100644 --- a/adapters/mgid/mgid.go +++ b/adapters/mgid/mgid.go @@ -6,11 +6,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type MgidAdapter struct { @@ -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/mgid/mgid_test.go b/adapters/mgid/mgid_test.go index 11f5596ed9a..7d30045168d 100644 --- a/adapters/mgid/mgid_test.go +++ b/adapters/mgid/mgid_test.go @@ -3,9 +3,9 @@ package mgid import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/mgid/usersync.go b/adapters/mgid/usersync.go index 3eb77025d4d..94cf12e119d 100644 --- a/adapters/mgid/usersync.go +++ b/adapters/mgid/usersync.go @@ -3,10 +3,10 @@ package mgid import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewMgidSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("mgid", 358, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("mgid", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/mgid/usersync_test.go b/adapters/mgid/usersync_test.go index b918dabfe0b..3fa5a151bd8 100644 --- a/adapters/mgid/usersync_test.go +++ b/adapters/mgid/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestMgidSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://cm.mgid.com/m?cdsp=363893&adu=https%3A//external.com%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%7Bmuidn%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 358, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/mobfoxpb/mobfoxpb.go b/adapters/mobfoxpb/mobfoxpb.go index 42ac3dc02d4..7fcf416a480 100644 --- a/adapters/mobfoxpb/mobfoxpb.go +++ b/adapters/mobfoxpb/mobfoxpb.go @@ -4,13 +4,24 @@ import ( "encoding/json" "fmt" "net/http" + "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" +) + +const ( + ROUTE_NATIVE = "o" + ROUTE_RTB = "rtb" + METHOD_NATIVE = "ortb" + METHOD_RTB = "req" + MACROS_ROUTE = "__route__" + MACROS_METHOD = "__method__" + MACROS_KEY = "__key__" ) type adapter struct { @@ -26,23 +37,38 @@ 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 err error - var tagID string - + var route string + var method string var adapterRequests []*adapters.RequestData + requestURI := a.URI reqCopy := *request imp := request.Imp[0] - tagID, err = jsonparser.GetString(imp.Ext, "bidder", "TagID") - if err != nil { - errs = append(errs, err) + tagID, errTag := jsonparser.GetString(imp.Ext, "bidder", "TagID") + key, errKey := jsonparser.GetString(imp.Ext, "bidder", "key") + if errTag != nil && errKey != nil { + errs = append(errs, &errortypes.BadInput{ + Message: fmt.Sprintf("Invalid or non existing key and tagId, atleast one should be present"), + }) return nil, errs } - imp.TagID = tagID - reqCopy.Imp = []openrtb.Imp{imp} - adapterReq, err := a.makeRequest(&reqCopy) + + if key != "" { + route = ROUTE_RTB + method = METHOD_RTB + requestURI = strings.Replace(requestURI, MACROS_KEY, key, 1) + } else if tagID != "" { + method = METHOD_NATIVE + route = ROUTE_NATIVE + } + + requestURI = strings.Replace(requestURI, MACROS_ROUTE, route, 1) + requestURI = strings.Replace(requestURI, MACROS_METHOD, method, 1) + + reqCopy.Imp = []openrtb2.Imp{imp} + adapterReq, err := a.makeRequest(&reqCopy, requestURI) if err != nil { errs = append(errs, err) } @@ -52,7 +78,7 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex return adapterRequests, errs } -func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, error) { +func (a *adapter) makeRequest(request *openrtb2.BidRequest, requestURI string) (*adapters.RequestData, error) { reqJSON, err := json.Marshal(request) if err != nil { @@ -64,14 +90,14 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat headers.Add("Accept", "application/json") return &adapters.RequestData{ Method: "POST", - Uri: a.URI, + Uri: requestURI, Body: reqJSON, Headers: headers, }, nil } // 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 { @@ -84,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} @@ -98,18 +124,17 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest if err != nil { errs = append(errs, err) } else { - b := &adapters.TypedBid{ + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, BidType: bidType, - } - bidResponse.Bids = append(bidResponse.Bids, b) + }) } } } 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 { @@ -126,6 +151,6 @@ func getMediaTypeForImp(impID string, imps []openrtb.Imp) (openrtb_ext.BidType, // This shouldnt happen. Lets handle it just incase by returning an error. return "", &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Failed to find impression \"%s\" ", impID), + Message: fmt.Sprintf("Failed to find impression \"%s\"", impID), } } diff --git a/adapters/mobfoxpb/mobfoxpb_test.go b/adapters/mobfoxpb/mobfoxpb_test.go index 23bdb28118c..56ad948bcde 100644 --- a/adapters/mobfoxpb/mobfoxpb_test.go +++ b/adapters/mobfoxpb/mobfoxpb_test.go @@ -3,14 +3,14 @@ package mobfoxpb import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderMobfoxpb, config.Adapter{ - Endpoint: "http://example.com/?c=o&m=ortb"}) + Endpoint: "http://example.com/?c=__route__&m=__method__&key=__key__"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) } diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-direct-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-direct-route.json new file mode 100644 index 00000000000..fb6bd260f74 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-direct-route.json @@ -0,0 +1,128 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "key": "6" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=rtb&m=req&key=6", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "key": "6" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-rtb-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-rtb-route.json new file mode 100644 index 00000000000..7b38008536d --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner-rtb-route.json @@ -0,0 +1,128 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "6" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "6" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner.json deleted file mode 100644 index b1936661a71..00000000000 --- a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-banner.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "6", - "ext": { - "bidder": { - "TagID": "6" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } -}, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "6", - "ext": { - "bidder": { - "TagID": "6" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } - } - ] - } - ] - } - } - } - ], - - "expectedBidResponses": [ - { - "bids":[ - { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } - }, - "type": "banner" - } - ] - } - ] -} diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-direct-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-direct-route.json new file mode 100644 index 00000000000..a949fdb1527 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-direct-route.json @@ -0,0 +1,125 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "key": "7" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=rtb&m=req&key=7", + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "key": "7" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + } + ], + "seat": "mobfoxpb" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-rtb-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-rtb-route.json new file mode 100644 index 00000000000..a33f0e62fc7 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video-rtb-route.json @@ -0,0 +1,125 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "TagID": "7" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "TagID": "7" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + } + ], + "seat": "mobfoxpb" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "00:01:00", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "ext": { + "prebid": { + "type": "video" + } + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video.json deleted file mode 100644 index 6cdcdc5a6cc..00000000000 --- a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-video.json +++ /dev/null @@ -1,119 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - }, - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "imp": [ - { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1024, - "h": 576 - }, - "ext": { - "bidder": { - "TagID": "7" - } - } - } - ] - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - }, - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "imp": [ - { - "id": "test-imp-id", - "video": { - "mimes": ["video/mp4"], - "protocols": [2, 5], - "w": 1024, - "h": 576 - }, - "tagid": "7", - "ext": { - "bidder": { - "TagID": "7" - } - } - } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "00:01:00", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } - } - ], - "seat": "mobfoxpb" - } - ], - "cur": "USD" - } - } - } - ], - - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "00:01:00", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } - }, - "type": "video" - } - ] - } - ] -} diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-direct-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-direct-route.json new file mode 100644 index 00000000000..d8727226723 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-direct-route.json @@ -0,0 +1,128 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "key": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=rtb&m=req&key=8", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "key": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "mobfoxpb" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-rtb-route.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-rtb-route.json new file mode 100644 index 00000000000..adbb7173848 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner-rtb-route.json @@ -0,0 +1,128 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "mobfoxpb" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner.json b/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner.json deleted file mode 100644 index bba728ac1e9..00000000000 --- a/adapters/mobfoxpb/mobfoxpbtest/exemplary/simple-web-banner.json +++ /dev/null @@ -1,130 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "8", - "ext": { - "bidder": { - "TagID": "8" - } - } - } - ], - "site": { - "id": "1", - "domain": "test.com" - }, - "device": { - "ip": "123.123.123.123" - } - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "8", - "ext": { - "bidder": { - "TagID": "8" - } - } - } - ], - "site": { - "id": "1", - "domain": "test.com" - }, - "device": { - "ip": "123.123.123.123" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 468, - "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } - } - ], - "seat": "mobfoxpb" - } - ], - "cur": "USD" - } - } - } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid": { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 468, - "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } - }, - "type": "banner" - } - ] - } - ] -} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-direct-route.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-direct-route.json new file mode 100644 index 00000000000..3ffcd9bf63c --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-direct-route.json @@ -0,0 +1,3 @@ +{ + "TagID": "6" +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-rtb-route.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-rtb-route.json new file mode 100644 index 00000000000..3ce815613d1 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/params/race/banner-rtb-route.json @@ -0,0 +1,3 @@ +{ + "key": "6" +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/banner.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/banner.json deleted file mode 100644 index dbdac1ad995..00000000000 --- a/adapters/mobfoxpb/mobfoxpbtest/params/race/banner.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "TagID": "6" -} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/video-direct-route.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/video-direct-route.json new file mode 100644 index 00000000000..1e42cfc4a05 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/params/race/video-direct-route.json @@ -0,0 +1,3 @@ +{ + "TagID": "7" +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/video-rtb-route.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/video-rtb-route.json new file mode 100644 index 00000000000..8c4421b65ef --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/params/race/video-rtb-route.json @@ -0,0 +1,3 @@ +{ + "key": "7" +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/params/race/video.json b/adapters/mobfoxpb/mobfoxpbtest/params/race/video.json deleted file mode 100644 index 6e2e0b3803b..00000000000 --- a/adapters/mobfoxpb/mobfoxpbtest/params/race/video.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "TagID": "7" -} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json index ac3dce598eb..6f2b95a8c54 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad-imp-ext.json @@ -1,42 +1,41 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "mobfoxpb": { + "TagID": "6" + } + } } - ] + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" }, - "tagid": "6", - "ext": { - "mobfoxpb": { - "TagID": "6" - } + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] + "expectedMakeRequestsErrors": [ + { + "value": "Invalid or non existing key and tagId, atleast one should be present", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json index 2f834c92be7..d61cb8837c4 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_response.json @@ -1,87 +1,85 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "17", - "ext": { - "bidder": { - "TagID": "17" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "17", - "ext": { - "bidder": { - "TagID": "17" + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "17" + } } - } } - ], - "app": { + ], + "app": { "id": "1", "bundle": "com.wls.testwlsapplication" - }, - "device": { + }, + "device": { "ip": "123.123.123.123", "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } } - }, - "mockResponse": { - "status": 200, - "body": "" - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "json: cannot unmarshal string into Go value of type openrtb.BidResponse", - "comparison": "literal" - } - ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 200, + "body": "" + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_status_code.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_status_code.json index 96d3a649109..60ee36e48e3 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_status_code.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/bad_status_code.json @@ -1,81 +1,79 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "100000000" + } + } } - ] + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" }, - "tagid": "100000000", - "ext": { - "bidder": { - "TagID": "100000000" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "device": {} }, - "device": {} - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "100000000", - "ext": { - "bidder": { - "TagID": "100000000" + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": {} } - } + }, + "mockResponse": { + "status": 400, + "body": {} } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": {} } - }, - "mockResponse": { - "status": 400, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", - "comparison": "literal" - } - ] + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json index cc56fa25c2c..9179916e922 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_empty_object.json @@ -1,38 +1,37 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": {} } - ] + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" }, - "tagid": "6", - "ext": {} - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] + "expectedMakeRequestsErrors": [ + { + "value": "Invalid or non existing key and tagId, atleast one should be present", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json index 464c9e31e39..45c32a1aa63 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/imp_ext_string.json @@ -1,38 +1,37 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": "" } - ] + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" }, - "tagid": "6", - "ext": "" - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + } }, - "device": { - "ip": "123.123.123.123", - "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" - } - }, - "expectedMakeRequestsErrors": [ - { - "value": "Key path not found", - "comparison": "literal" - } - ] + "expectedMakeRequestsErrors": [ + { + "value": "Invalid or non existing key and tagId, atleast one should be present", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/missmatch_bid_id.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/missmatch_bid_id.json new file mode 100644 index 00000000000..28a1b6c72d4 --- /dev/null +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/missmatch_bid_id.json @@ -0,0 +1,109 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "8" + } + } + } + ], + "site": { + "id": "1", + "domain": "test.com" + }, + "device": { + "ip": "123.123.123.123" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id-not", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 468, + "h": 60, + "ext": { + "prebid": { + "type": "banner" + } + } + } + ], + "seat": "mobfoxpb" + } + ], + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Failed to find impression \"test-imp-id-not\"", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-204.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-204.json index c1091969991..e69b248d2a1 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-204.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-204.json @@ -1,82 +1,80 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "17", - "ext": { - "bidder": { - "TagID": "17" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "17", - "ext": { - "bidder": { - "TagID": "17" + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "17" + } } - } } - ], - "app": { + ], + "app": { "id": "1", "bundle": "com.wls.testwlsapplication" - }, - "device": { + }, + "device": { "ip": "123.123.123.123", "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } } - }, - "expectedBidResponses": [], - "mockResponse": { - "status": 204, - "body": {} - } - } - ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "17" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "expectedBidResponses": [], + "mockResponse": { + "status": 204, + "body": {} + } + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-404.json b/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-404.json index d9ef7108017..987b9daf980 100644 --- a/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-404.json +++ b/adapters/mobfoxpb/mobfoxpbtest/supplemental/status-404.json @@ -1,87 +1,85 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "100000000", - "ext": { - "bidder": { - "TagID": "100000000" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/?c=o&m=ortb", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "tagid": "100000000", - "ext": { - "bidder": { - "TagID": "100000000" + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "100000000" + } } - } } - ], - "app": { + ], + "app": { "id": "1", "bundle": "com.wls.testwlsapplication" - }, - "device": { + }, + "device": { "ip": "123.123.123.123", "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } } - }, - "mockResponse": { - "status": 404, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", - "comparison": "literal" - } - ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/?c=o&m=ortb&key=__key__", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "TagID": "100000000" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + } + }, + "mockResponse": { + "status": 404, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] } \ No newline at end of file diff --git a/adapters/mobfoxpb/params_test.go b/adapters/mobfoxpb/params_test.go index ddd738ece2b..799fdcfa61b 100644 --- a/adapters/mobfoxpb/params_test.go +++ b/adapters/mobfoxpb/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // TestValidParams makes sure that the mobfoxpb schema accepts all imp.ext fields which we intend to support. @@ -37,6 +37,7 @@ func TestInvalidParams(t *testing.T) { var validParams = []string{ `{"TagID": "6"}`, + `{"key": "1"}`, } var invalidParams = []string{ @@ -44,4 +45,7 @@ var invalidParams = []string{ `{"tagid": "123"}`, `{"TagID": 16}`, `{"TagID": ""}`, + `{"Key": "1"}`, + `{"key": 1}`, + `{"key":""}`, } diff --git a/adapters/mobilefuse/mobilefuse.go b/adapters/mobilefuse/mobilefuse.go index 4e545ec1adc..47ee1cab743 100644 --- a/adapters/mobilefuse/mobilefuse.go +++ b/adapters/mobilefuse/mobilefuse.go @@ -7,12 +7,12 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type MobileFuseAdapter struct { @@ -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/mobilefuse/mobilefuse_test.go b/adapters/mobilefuse/mobilefuse_test.go index 52d2ab20768..3abe627fab0 100644 --- a/adapters/mobilefuse/mobilefuse_test.go +++ b/adapters/mobilefuse/mobilefuse_test.go @@ -3,9 +3,9 @@ package mobilefuse import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/mobilefuse/params_test.go b/adapters/mobilefuse/params_test.go index 6d98f656983..dbfd8894e70 100644 --- a/adapters/mobilefuse/params_test.go +++ b/adapters/mobilefuse/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(test *testing.T) { diff --git a/adapters/nanointeractive/nanointeractive.go b/adapters/nanointeractive/nanointeractive.go index 9dfee06eb42..a2ec89b0d5b 100644 --- a/adapters/nanointeractive/nanointeractive.go +++ b/adapters/nanointeractive/nanointeractive.go @@ -5,21 +5,21 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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,21 +88,23 @@ 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) { if response.StatusCode == http.StatusNoContent { return nil, nil } else if response.StatusCode == http.StatusBadRequest { - return nil, []error{adapters.BadInput("Invalid request.")} + return nil, []error{&errortypes.BadInput{ + Message: "Invalid request.", + }} } else if response.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("unexpected HTTP status %d.", response.StatusCode), }} } - var openRtbBidResponse openrtb.BidResponse + var openRtbBidResponse openrtb2.BidResponse if err := json.Unmarshal(response.Body, &openRtbBidResponse); err != nil { return nil, []error{&errortypes.BadServerResponse{ @@ -127,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/nanointeractive/nanointeractive_test.go b/adapters/nanointeractive/nanointeractive_test.go index 79caf9cf417..d0955511f8b 100644 --- a/adapters/nanointeractive/nanointeractive_test.go +++ b/adapters/nanointeractive/nanointeractive_test.go @@ -3,9 +3,9 @@ package nanointeractive import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/nanointeractive/params_test.go b/adapters/nanointeractive/params_test.go index 309d19b5128..b290f3d94b1 100644 --- a/adapters/nanointeractive/params_test.go +++ b/adapters/nanointeractive/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/nanointeractive.json diff --git a/adapters/nanointeractive/usersync.go b/adapters/nanointeractive/usersync.go index 180e2c53520..6bd9cd1f036 100644 --- a/adapters/nanointeractive/usersync.go +++ b/adapters/nanointeractive/usersync.go @@ -3,10 +3,10 @@ package nanointeractive import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewNanoInteractiveSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("nanointeractive", 72, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("nanointeractive", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/nanointeractive/usersync_test.go b/adapters/nanointeractive/usersync_test.go index 44040756316..4d816ab7384 100644 --- a/adapters/nanointeractive/usersync_test.go +++ b/adapters/nanointeractive/usersync_test.go @@ -4,10 +4,10 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -31,6 +31,5 @@ func TestNewNanoInteractiveSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://ad.audiencemanager.de/hbs/cookie_sync?gdpr=1&consent=BONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw&us_privacy=1NYN&redirectUri=http%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dnanointeractive%26gdpr%3D1%26gdpr_consent%3DBONciguONcjGKADACHENAOLS1rAHDAFAAEAASABQAMwAeACEAFw%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 72, userSync.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/ninthdecimal/ninthdecimal.go b/adapters/ninthdecimal/ninthdecimal.go index 5cb631db6f1..fc29b38cdab 100755 --- a/adapters/ninthdecimal/ninthdecimal.go +++ b/adapters/ninthdecimal/ninthdecimal.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type NinthDecimalAdapter struct { @@ -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/ninthdecimal/ninthdecimal_test.go b/adapters/ninthdecimal/ninthdecimal_test.go index 9d82f38783b..ccb8114f8a9 100755 --- a/adapters/ninthdecimal/ninthdecimal_test.go +++ b/adapters/ninthdecimal/ninthdecimal_test.go @@ -3,9 +3,9 @@ package ninthdecimal import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/ninthdecimal/params_test.go b/adapters/ninthdecimal/params_test.go index cc06088caff..8d3ef3d706f 100755 --- a/adapters/ninthdecimal/params_test.go +++ b/adapters/ninthdecimal/params_test.go @@ -2,7 +2,7 @@ package ninthdecimal import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/ninthdecimal/usersync.go b/adapters/ninthdecimal/usersync.go index 4ea91d031cb..a01fdb636e3 100755 --- a/adapters/ninthdecimal/usersync.go +++ b/adapters/ninthdecimal/usersync.go @@ -3,10 +3,10 @@ package ninthdecimal import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewNinthDecimalSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("ninthdecimal", 0, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("ninthdecimal", temp, adapters.SyncTypeIframe) } diff --git a/adapters/ninthdecimal/usersync_test.go b/adapters/ninthdecimal/usersync_test.go index ded5bf0dbf4..e722a2b6e69 100755 --- a/adapters/ninthdecimal/usersync_test.go +++ b/adapters/ninthdecimal/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -26,6 +26,5 @@ func TestNinthDecimalSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect=localhost/setuid?bidder=ninthdecimal&gdpr=1&gdpr_consent=A&uid=$UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/nobid/nobid.go b/adapters/nobid/nobid.go index 77d1a7f806f..f8db812d9ca 100644 --- a/adapters/nobid/nobid.go +++ b/adapters/nobid/nobid.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // NoBidAdapter - NoBid Adapter definition @@ -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/nobid/nobid_test.go b/adapters/nobid/nobid_test.go index 420c57f36bc..674d189d661 100644 --- a/adapters/nobid/nobid_test.go +++ b/adapters/nobid/nobid_test.go @@ -3,9 +3,9 @@ package nobid import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/nobid/params_test.go b/adapters/nobid/params_test.go index f8c0533c300..75d69943d35 100644 --- a/adapters/nobid/params_test.go +++ b/adapters/nobid/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/nobid/usersync.go b/adapters/nobid/usersync.go index 3b36e59fa3d..442075648ce 100644 --- a/adapters/nobid/usersync.go +++ b/adapters/nobid/usersync.go @@ -3,10 +3,10 @@ package nobid import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewNoBidSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("nobid", 816, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("nobid", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/nobid/usersync_test.go b/adapters/nobid/usersync_test.go index a59d70a4f91..bc55d130509 100644 --- a/adapters/nobid/usersync_test.go +++ b/adapters/nobid/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) diff --git a/adapters/onetag/onetag.go b/adapters/onetag/onetag.go new file mode 100644 index 00000000000..1721d76df6a --- /dev/null +++ b/adapters/onetag/onetag.go @@ -0,0 +1,152 @@ +package onetag + +import ( + "encoding/json" + "fmt" + "net/http" + "text/template" + + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" +) + +type adapter struct { + endpointTemplate template.Template +} + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + template, err := template.New("endpointTemplate").Parse(config.Endpoint) + if err != nil { + return nil, fmt.Errorf("unable to parse endpoint url template: %v", err) + } + + bidder := &adapter{ + endpointTemplate: *template, + } + + return bidder, nil +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + pubID := "" + for idx, imp := range request.Imp { + onetagExt, err := getImpressionExt(imp) + if err != nil { + return nil, []error{err} + } + if onetagExt.PubId != "" { + if pubID == "" { + pubID = onetagExt.PubId + } else if pubID != onetagExt.PubId { + return nil, []error{&errortypes.BadInput{ + Message: "There must be only one publisher ID", + }} + } + } else { + return nil, []error{&errortypes.BadInput{ + Message: "The publisher ID must not be empty", + }} + } + request.Imp[idx].Ext = onetagExt.Ext + } + + url, err := a.buildEndpointURL(pubID) + if err != nil { + return nil, []error{err} + } + + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} + } + + requestData := &adapters.RequestData{ + Method: "POST", + Uri: url, + Body: requestJSON, + } + + return []*adapters.RequestData{requestData}, nil +} + +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{ + Message: "Bidder extension not provided or can't be unmarshalled", + } + } + + var onetagExt openrtb_ext.ExtImpOnetag + if err := json.Unmarshal(bidderExt.Bidder, &onetagExt); err != nil { + return nil, &errortypes.BadInput{ + Message: "Error while unmarshaling bidder extension", + } + } + + return &onetagExt, nil +} + +func (a *adapter) buildEndpointURL(pubID string) (string, error) { + endpointParams := macros.EndpointTemplateParams{PublisherID: pubID} + return macros.ResolveMacros(a.endpointTemplate, endpointParams) +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + for _, seatBid := range response.SeatBid { + for _, bid := range seatBid.Bid { + bidMediaType, err := getMediaTypeForBid(request.Imp, bid) + if err != nil { + return nil, []error{err} + } + b := &adapters.TypedBid{ + Bid: &bid, + BidType: bidMediaType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, nil +} + +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 { + return openrtb_ext.BidTypeBanner, nil + } + if impression.Video != nil { + return openrtb_ext.BidTypeVideo, nil + } + if impression.Native != nil { + return openrtb_ext.BidTypeNative, nil + } + } + } + + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("The impression with ID %s is not present into the request", bid.ImpID), + } +} diff --git a/adapters/onetag/onetag_test.go b/adapters/onetag/onetag_test.go new file mode 100644 index 00000000000..9f7c8e50115 --- /dev/null +++ b/adapters/onetag/onetag_test.go @@ -0,0 +1,26 @@ +package onetag + +import ( + "testing" + + "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" +) + +func TestEndpointTemplateMalformed(t *testing.T) { + _, buildErr := Builder(openrtb_ext.BidderOneTag, config.Adapter{ + Endpoint: "{{Malformed}}"}) + + assert.Error(t, buildErr) +} + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderOneTag, config.Adapter{ + Endpoint: "https://example.com/prebid-server/{{.PublisherID}}"}) + + assert.NoError(t, buildErr, "Builder returned unexpected error %v", buildErr) + + adapterstest.RunJSONBidderTest(t, "onetagtest", bidder) +} diff --git a/adapters/onetag/onetagtest/exemplary/no-bid.json b/adapters/onetag/onetagtest/exemplary/no-bid.json new file mode 100644 index 00000000000..012834ca8a4 --- /dev/null +++ b/adapters/onetag/onetagtest/exemplary/no-bid.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [] + } \ No newline at end of file diff --git a/adapters/onetag/onetagtest/exemplary/simple-banner.json b/adapters/onetag/onetagtest/exemplary/simple-banner.json new file mode 100644 index 00000000000..7489a27dbff --- /dev/null +++ b/adapters/onetag/onetagtest/exemplary/simple-banner.json @@ -0,0 +1,201 @@ +{ + "mockBidRequest": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + }, + { + "id": "121-dt2", + "banner": { + "h": 728, + "w": 90, + "pos": 0 + }, + "bidfloor": 0.12, + "ext": { + "bidder": { + "pubId": "386276e072", + "ext": { + "key1": "value1", + "key2": "value2" + } + } + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05 + }, + { + "id": "121-dt2", + "banner": { + "h": 728, + "w": 90, + "pos": 0 + }, + "bidfloor": 0.12, + "ext": { + "key1": "value1", + "key2": "value2" + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + } + }, + "mockResponse": { + "status": 200, + "headers": {}, + "body": { + "id": "BID-4-ZIMP-4b309eae-504a-4252-a8a8-4c8ceee9791a", + "seatbid": [ + { + "bid": [ + { + "adid": "52a12b5955314b7194a4c9ff", + "adm": "", + "adomain": ["ads.com"], + "cid": "52a12b5955314b7194a4c9ff", + "crid": "52a12b5955314b7194a4c9ff_1386294105", + "dealid": "DX-1985-010A", + "id": "24195efda36066ee21f967bc1de14c82db841f07", + "impid": "121-dt1", + "nurl": "http://ads.com/win/52a12b5955314b7194a4c9ff?won=${AUCTION_PRICE}", + "price": 1.028428, + "attr": [] + } + ], + "seat": "42" + }, + { + "bid": [ + { + "adid": "527c9fdd55314ba06815f25e", + "adm": "", + "adomain": ["ads.com"], + "cid": "527c9fdd55314ba06815f25e", + "crid": "527c9fdd55314ba06815f25e_1383899102", + "id": "24195efda36066ee21f967bc1de14c82db841f08", + "impid": "121-dt2", + "nurl": "http://ads.com/win/527c9fdd55314ba06815f25e?won=${AUCTION_PRICE}", + "price": 0.04958, + "attr": [] + } + ], + "seat": "772" + } + ] + }, + "cur": "USD" + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "type": "banner", + "bid": { + "adid": "52a12b5955314b7194a4c9ff", + "adm": "", + "adomain": ["ads.com"], + "cid": "52a12b5955314b7194a4c9ff", + "crid": "52a12b5955314b7194a4c9ff_1386294105", + "dealid": "DX-1985-010A", + "id": "24195efda36066ee21f967bc1de14c82db841f07", + "impid": "121-dt1", + "nurl": "http://ads.com/win/52a12b5955314b7194a4c9ff?won=${AUCTION_PRICE}", + "price": 1.028428 + } + }, + { + "type": "banner", + "bid": { + "adid": "527c9fdd55314ba06815f25e", + "adm": "", + "adomain": ["ads.com"], + "cid": "527c9fdd55314ba06815f25e", + "crid": "527c9fdd55314ba06815f25e_1383899102", + "id": "24195efda36066ee21f967bc1de14c82db841f08", + "impid": "121-dt2", + "nurl": "http://ads.com/win/527c9fdd55314ba06815f25e?won=${AUCTION_PRICE}", + "price": 0.04958 + } + } + ] + } + ] + } \ No newline at end of file diff --git a/adapters/onetag/onetagtest/exemplary/simple-native.json b/adapters/onetag/onetagtest/exemplary/simple-native.json new file mode 100644 index 00000000000..08fef34f7a7 --- /dev/null +++ b/adapters/onetag/onetagtest/exemplary/simple-native.json @@ -0,0 +1,121 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "tmax": 1000, + "user": { + "buyeruid": "0000-000-000-0000" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "123456789" + } + }, + "imp": [ + { + "id": "some-impression-id", + "native": { + "ver":"1.1", + "request":"{\"adunit\":2,\"assets\":[{\"id\":3,\"img\":{\"h\":120,\"hmin\":0,\"type\":3,\"w\":180,\"wmin\":0},\"required\":1},{\"id\":0,\"required\":1,\"title\":{\"len\":25}},{\"data\":{\"len\":25,\"type\":1},\"id\":4,\"required\":1},{\"data\":{\"len\":140,\"type\":2},\"id\":6,\"required\":1}],\"context\":1,\"layout\":1,\"contextsubtype\":11,\"plcmtcnt\":1,\"plcmttype\":2,\"ver\":\"1.1\",\"ext\":{\"banner\":{\"w\":320,\"h\":50}}}" + }, + "ext": { + "bidder": { + "pubId": "386276e072", + "ext": { + "key1": "value1" + } + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "imp": [ + { + "id": "some-impression-id", + "native": { + "ver":"1.1", + "request":"{\"adunit\":2,\"assets\":[{\"id\":3,\"img\":{\"h\":120,\"hmin\":0,\"type\":3,\"w\":180,\"wmin\":0},\"required\":1},{\"id\":0,\"required\":1,\"title\":{\"len\":25}},{\"data\":{\"len\":25,\"type\":1},\"id\":4,\"required\":1},{\"data\":{\"len\":140,\"type\":2},\"id\":6,\"required\":1}],\"context\":1,\"layout\":1,\"contextsubtype\":11,\"plcmtcnt\":1,\"plcmttype\":2,\"ver\":\"1.1\",\"ext\":{\"banner\":{\"w\":320,\"h\":50}}}" + }, + "ext": { + "key1": "value1" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "123456789" + } + }, + "user": { + "buyeruid": "0000-000-000-0000" + }, + "tmax": 1000 + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "awesome-resp-id", + "seatbid": [ + { + "bid": [ + { + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "some-impression-id", + "price": 3.5, + "adm": "awesome-markup", + "adomain": [ + "awesome.com" + ], + "crid": "20" + } + ], + "seat": "onetag" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids":[ + { + "type": "native", + "bid": { + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "some-impression-id", + "price": 3.5, + "adm": "awesome-markup", + "crid": "20", + "adomain": [ + "awesome.com" + ] + } + } + ] + } + ] + } \ No newline at end of file diff --git a/adapters/onetag/onetagtest/exemplary/simple-video.json b/adapters/onetag/onetagtest/exemplary/simple-video.json new file mode 100644 index 00000000000..ea656a98fc8 --- /dev/null +++ b/adapters/onetag/onetagtest/exemplary/simple-video.json @@ -0,0 +1,115 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "some-test-ad", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid" + } + ], + "seat": "adman" + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "some-test-ad", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid" + }, + "type": "video" + } + ] + } + ] + } \ No newline at end of file diff --git a/adapters/onetag/onetagtest/params/race/banner.json b/adapters/onetag/onetagtest/params/race/banner.json new file mode 100644 index 00000000000..687438d6be6 --- /dev/null +++ b/adapters/onetag/onetagtest/params/race/banner.json @@ -0,0 +1,4 @@ +{ + "pubId": "386276e072", + "ext": {} +} \ No newline at end of file diff --git a/adapters/onetag/onetagtest/params/race/native.json b/adapters/onetag/onetagtest/params/race/native.json new file mode 100644 index 00000000000..687438d6be6 --- /dev/null +++ b/adapters/onetag/onetagtest/params/race/native.json @@ -0,0 +1,4 @@ +{ + "pubId": "386276e072", + "ext": {} +} \ No newline at end of file diff --git a/adapters/onetag/onetagtest/params/race/video.json b/adapters/onetag/onetagtest/params/race/video.json new file mode 100644 index 00000000000..687438d6be6 --- /dev/null +++ b/adapters/onetag/onetagtest/params/race/video.json @@ -0,0 +1,4 @@ +{ + "pubId": "386276e072", + "ext": {} +} \ No newline at end of file diff --git a/adapters/onetag/onetagtest/supplemental/empty-publisher-id.json b/adapters/onetag/onetagtest/supplemental/empty-publisher-id.json new file mode 100644 index 00000000000..d5ca3b144bc --- /dev/null +++ b/adapters/onetag/onetagtest/supplemental/empty-publisher-id.json @@ -0,0 +1,65 @@ +{ + "mockBidRequest": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05, + "ext": { + "bidder": { + "pubId" : "1" + } + } + }, + { + "id": "121-dt2", + "banner": { + "h": 728, + "w": 90, + "pos": 0 + }, + "bidfloor": 0.12, + "ext": { + "bidder": { + "pubId" : "" + } + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "The publisher ID must not be empty", + "comparison": "literal" + } + ] +} + \ No newline at end of file diff --git a/adapters/onetag/onetagtest/supplemental/internal-server-error.json b/adapters/onetag/onetagtest/supplemental/internal-server-error.json new file mode 100644 index 00000000000..4fc069598c7 --- /dev/null +++ b/adapters/onetag/onetagtest/supplemental/internal-server-error.json @@ -0,0 +1,81 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + }, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "test-request-id", + "device": { + "ip": "123.123.123.123", + "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" + }, + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "imp": [ + { + "id": "test-imp-id", + "instl": 1, + "video": { + "placement": 3, + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576 + } + } + ] + } + }, + "mockResponse": { + "status": 500, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [{ + "value": "Unexpected status code: 500. Run with request.debug = 1 for more info.", + "comparison": "literal" + }] + } \ No newline at end of file diff --git a/adapters/onetag/onetagtest/supplemental/required-publisher-id.json b/adapters/onetag/onetagtest/supplemental/required-publisher-id.json new file mode 100644 index 00000000000..6e8ccf0d3cc --- /dev/null +++ b/adapters/onetag/onetagtest/supplemental/required-publisher-id.json @@ -0,0 +1,66 @@ +{ + "mockBidRequest": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05, + "ext": { + "bidder": {} + } + }, + { + "id": "121-dt2", + "banner": { + "h": 728, + "w": 90, + "pos": 0 + }, + "bidfloor": 0.12, + "ext": { + "bidder": { + "ext": { + "key1": "value1", + "key2": "value2" + } + } + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "The publisher ID must not be empty", + "comparison": "literal" + } + ] +} + \ No newline at end of file diff --git a/adapters/onetag/onetagtest/supplemental/unique-publisher-id.json b/adapters/onetag/onetagtest/supplemental/unique-publisher-id.json new file mode 100644 index 00000000000..fe2e3914fae --- /dev/null +++ b/adapters/onetag/onetagtest/supplemental/unique-publisher-id.json @@ -0,0 +1,69 @@ +{ + "mockBidRequest": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + }, + { + "id": "121-dt2", + "banner": { + "h": 728, + "w": 90, + "pos": 0 + }, + "bidfloor": 0.12, + "ext": { + "bidder": { + "pubId": "386276e072a", + "ext": { + "key1": "value1", + "key2": "value2" + } + } + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "There must be only one publisher ID", + "comparison": "literal" + } + ] +} + \ No newline at end of file diff --git a/adapters/onetag/onetagtest/supplemental/wrong-impression-id.json b/adapters/onetag/onetagtest/supplemental/wrong-impression-id.json new file mode 100644 index 00000000000..bfdfcc5f3e3 --- /dev/null +++ b/adapters/onetag/onetagtest/supplemental/wrong-impression-id.json @@ -0,0 +1,121 @@ +{ + "mockBidRequest": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05, + "ext": { + "bidder": { + "pubId": "386276e072" + } + } + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://example.com/prebid-server/386276e072", + "headers": {}, + "body": { + "id": "8652a8680db33faabbf3fa76150f35df50a67060", + "imp": [ + { + "id": "121-dt1", + "banner": { + "h": 250, + "w": 300, + "pos": 1 + }, + "bidfloor": 0.05 + } + ], + "site": { + "id": "15047", + "domain": "dailymotion.com", + "cat": ["IAB1"], + "page": "http://www.dailymotion.com/video/xxeauj_www-dramacafe-tv-hd-yyyy-yy-yyyyyyy-2012-yyyy_shortfilms", + "publisher": { + "id": "8796", + "name": "dailymotion", + "cat": ["IAB3-1"], + "domain": "dailymotion.com" + } + }, + "user": { + "id": "518c3da3717203f34019b038" + }, + "device": { + "ua": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; (R1 1.6); SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)", + "ip": "123.145.167.189" + }, + "at": 1, + "cur": [ + "USD" + ] + } + }, + "mockResponse": { + "status": 200, + "headers": {}, + "body": { + "id": "BID-4-ZIMP-4b309eae-504a-4252-a8a8-4c8ceee9791a", + "seatbid": [ + { + "bid": [ + { + "adid": "52a12b5955314b7194a4c9ff", + "adm": "", + "adomain": ["ads.com"], + "cid": "52a12b5955314b7194a4c9ff", + "crid": "52a12b5955314b7194a4c9ff_1386294105", + "dealid": "DX-1985-010A", + "id": "24195efda36066ee21f967bc1de14c82db841f07", + "impid": "1", + "nurl": "http://ads.com/win/52a12b5955314b7194a4c9ff?won=${AUCTION_PRICE}", + "price": 1.028428, + "attr": [] + } + ], + "seat": "42" + } + ] + }, + "cur": "USD" + } + } + ], + "expectedMakeBidsErrors": [{ + "value": "The impression with ID 1 is not present into the request", + "comparison": "literal" + }] +} \ No newline at end of file diff --git a/adapters/onetag/params_test.go b/adapters/onetag/params_test.go new file mode 100644 index 00000000000..4c7326ac9f0 --- /dev/null +++ b/adapters/onetag/params_test.go @@ -0,0 +1,54 @@ +package onetag + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderOneTag, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderOneTag, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{ "pubId": "386276e072", + "ext": { + "key1": "value1", + "key2": "value2" + } + }`, + `{"pubId": "386276e072"}`, +} + +var invalidParams = []string{ + `{"ext": { + "key1": "value1", + "key2": "value2" + }`, + `{}`, + `{"pubId": ""}`, + `{"pubId": 123}`, +} diff --git a/adapters/onetag/usersync.go b/adapters/onetag/usersync.go new file mode 100644 index 00000000000..9a2b700dd3d --- /dev/null +++ b/adapters/onetag/usersync.go @@ -0,0 +1,12 @@ +package onetag + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewSyncer(template *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("onetag", template, adapters.SyncTypeIframe) +} diff --git a/adapters/onetag/usersync_test.go b/adapters/onetag/usersync_test.go new file mode 100644 index 00000000000..21f4837d5e1 --- /dev/null +++ b/adapters/onetag/usersync_test.go @@ -0,0 +1,23 @@ +package onetag + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/stretchr/testify/assert" +) + +func TestOneTagSyncer(t *testing.T) { + syncURL := "https://onetag-sys.com/usync/?redir=" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{}) + + assert.NoError(t, err) + assert.Equal(t, "https://onetag-sys.com/usync/?redir=", syncInfo.URL) + assert.Equal(t, "iframe", syncInfo.Type) +} diff --git a/adapters/openrtb_util.go b/adapters/openrtb_util.go index 88023920b8d..6aa07c6b764 100644 --- a/adapters/openrtb_util.go +++ b/adapters/openrtb_util.go @@ -3,10 +3,9 @@ package adapters import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/pbs" ) 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 fbb9ab57991..b7d03fbfc6c 100644 --- a/adapters/openrtb_util_test.go +++ b/adapters/openrtb_util_test.go @@ -5,9 +5,9 @@ import ( "encoding/json" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/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 21fbd37e99f..208b06f7c86 100644 --- a/adapters/openx/openx.go +++ b/adapters/openx/openx.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const hbconfig = "hb_pbs_1.0.0" @@ -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{ @@ -130,7 +130,9 @@ func preprocess(imp *openrtb.Imp, reqExt *openxReqExt) error { reqExt.Platform = openxExt.Platform imp.TagID = openxExt.Unit - imp.BidFloor = openxExt.CustomFloor + if imp.BidFloor == 0 && openxExt.CustomFloor > 0 { + imp.BidFloor = openxExt.CustomFloor + } imp.Ext = nil if openxExt.CustomParams != nil { @@ -158,7 +160,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 +177,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 +204,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 5eec4feb41a..ea90dc875da 100644 --- a/adapters/openx/openx_test.go +++ b/adapters/openx/openx_test.go @@ -4,11 +4,11 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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/openx/openxtest/exemplary/optional-params.json b/adapters/openx/openxtest/exemplary/optional-params.json index b2fd9c2f4fb..93dbafc5bfb 100644 --- a/adapters/openx/openxtest/exemplary/optional-params.json +++ b/adapters/openx/openxtest/exemplary/optional-params.json @@ -16,6 +16,21 @@ "customParams": {"foo": "bar"} } } + }, + { + "bidfloor": 0.5, + "id": "test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "ext": { + "bidder": { + "unit": "539439964", + "delDomain": "se-demo-d.openx.net", + "platform": "PLATFORM", + "customFloor": 0.1 + } + } } ] }, @@ -37,6 +52,14 @@ "ext": { "customParams": {"foo": "bar"} } + }, + { + "id":"test-imp-id", + "banner": { + "format": [{"w": 728, "h": 90}] + }, + "tagid": "539439964", + "bidfloor": 0.5 } ], "ext": { diff --git a/adapters/openx/params_test.go b/adapters/openx/params_test.go index 87ce08fc733..b7ea970ab1f 100644 --- a/adapters/openx/params_test.go +++ b/adapters/openx/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/openx.json diff --git a/adapters/openx/usersync.go b/adapters/openx/usersync.go index f557e5e4095..875b60fbd10 100644 --- a/adapters/openx/usersync.go +++ b/adapters/openx/usersync.go @@ -3,10 +3,10 @@ package openx import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewOpenxSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("openx", 69, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("openx", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/openx/usersync_test.go b/adapters/openx/usersync_test.go index 7bb30399069..14ec38be118 100644 --- a/adapters/openx/usersync_test.go +++ b/adapters/openx/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestOpenxSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://rtb.openx.net/sync/prebid?gdpr=&gdpr_consent=&r=localhost%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 69, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/orbidder/orbidder.go b/adapters/orbidder/orbidder.go index 4e13fc6f50e..77985c8dae0 100644 --- a/adapters/orbidder/orbidder.go +++ b/adapters/orbidder/orbidder.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type OrbidderAdapter struct { @@ -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,13 +104,12 @@ 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} } bidResponse := adapters.NewBidderResponseWithBidsCapacity(5) - for _, seatBid := range bidResp.SeatBid { for _, bid := range seatBid.Bid { bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ @@ -119,6 +118,9 @@ func (rcv OrbidderAdapter) MakeBids(internalRequest *openrtb.BidRequest, externa }) } } + if bidResp.Cur != "" { + bidResponse.Currency = bidResp.Cur + } return bidResponse, nil } diff --git a/adapters/orbidder/orbidder_test.go b/adapters/orbidder/orbidder_test.go index 4e9fc2f8bb7..0eaed23a971 100644 --- a/adapters/orbidder/orbidder_test.go +++ b/adapters/orbidder/orbidder_test.go @@ -4,9 +4,9 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/orbidder/params_test.go b/adapters/orbidder/params_test.go index 98fcf0217db..19c4ed8d9d4 100644 --- a/adapters/orbidder/params_test.go +++ b/adapters/orbidder/params_test.go @@ -2,7 +2,7 @@ package orbidder import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/outbrain/outbrain.go b/adapters/outbrain/outbrain.go new file mode 100644 index 00000000000..282a6d53aa0 --- /dev/null +++ b/adapters/outbrain/outbrain.go @@ -0,0 +1,180 @@ +package outbrain + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb/v15/native1" + nativeResponse "github.com/mxmCherry/openrtb/v15/native1/response" + "github.com/mxmCherry/openrtb/v15/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" +) + +type adapter struct { + endpoint string +} + +// Builder builds a new instance of the Outbrain adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + reqCopy := *request + + var errs []error + var outbrainExt openrtb_ext.ExtImpOutbrain + for i := 0; i < len(reqCopy.Imp); i++ { + imp := reqCopy.Imp[i] + + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + errs = append(errs, err) + continue + } + if err := json.Unmarshal(bidderExt.Bidder, &outbrainExt); err != nil { + errs = append(errs, err) + continue + } + imp.TagID = outbrainExt.TagId + reqCopy.Imp[i] = imp + } + + publisher := &openrtb2.Publisher{ + ID: outbrainExt.Publisher.Id, + Name: outbrainExt.Publisher.Name, + Domain: outbrainExt.Publisher.Domain, + } + if reqCopy.Site != nil { + siteCopy := *reqCopy.Site + siteCopy.Publisher = publisher + reqCopy.Site = &siteCopy + } else if reqCopy.App != nil { + appCopy := *reqCopy.App + appCopy.Publisher = publisher + reqCopy.App = &appCopy + } + + if outbrainExt.BCat != nil { + reqCopy.BCat = outbrainExt.BCat + } + if outbrainExt.BAdv != nil { + reqCopy.BAdv = outbrainExt.BAdv + } + + requestJSON, err := json.Marshal(reqCopy) + if err != nil { + errs = append(errs, err) + return nil, errs + } + + requestData := &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, + } + + return []*adapters.RequestData{requestData}, nil +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode == http.StatusBadRequest { + err := &errortypes.BadInput{ + Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + } + return nil, []error{err} + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + + var errs []error + for _, seatBid := range response.SeatBid { + for i := range seatBid.Bid { + bid := seatBid.Bid[i] + bidType, err := getMediaTypeForImp(bid.ImpID, request.Imp) + if err != nil { + errs = append(errs, err) + continue + } + if bidType == openrtb_ext.BidTypeNative { + var nativePayload nativeResponse.Response + if err := json.Unmarshal(json.RawMessage(bid.AdM), &nativePayload); err != nil { + errs = append(errs, err) + continue + } + transformEventTrackers(&nativePayload) + nativePayloadJson, err := json.Marshal(nativePayload) + if err != nil { + errs = append(errs, err) + continue + } + bid.AdM = string(nativePayloadJson) + } + + b := &adapters.TypedBid{ + Bid: &bid, + BidType: bidType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + + return bidResponse, errs +} + +func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { + for _, imp := range imps { + if imp.ID == impID { + if imp.Native != nil { + return openrtb_ext.BidTypeNative, nil + } else if imp.Banner != nil { + return openrtb_ext.BidTypeBanner, nil + } + } + } + + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Failed to find native/banner impression \"%s\" ", impID), + } +} + +func transformEventTrackers(nativePayload *nativeResponse.Response) { + // the native-trk.js library used to trigger the trackers currently doesn't support the native 1.2 eventtrackers, + // so transform them to the deprecated imptrackers and jstracker + for _, eventTracker := range nativePayload.EventTrackers { + if eventTracker.Event != native1.EventTypeImpression { + continue + } + switch eventTracker.Method { + case native1.EventTrackingMethodImage: + nativePayload.ImpTrackers = append(nativePayload.ImpTrackers, eventTracker.URL) + case native1.EventTrackingMethodJS: + nativePayload.JSTracker = fmt.Sprintf("", eventTracker.URL) + } + } + nativePayload.EventTrackers = nil +} diff --git a/adapters/outbrain/outbrain_test.go b/adapters/outbrain/outbrain_test.go new file mode 100644 index 00000000000..533bad388ce --- /dev/null +++ b/adapters/outbrain/outbrain_test.go @@ -0,0 +1,20 @@ +package outbrain + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderOutbrain, config.Adapter{ + Endpoint: "http://example.com/bid"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "outbraintest", bidder) +} diff --git a/adapters/outbrain/outbraintest/exemplary/banner.json b/adapters/outbrain/outbraintest/exemplary/banner.json new file mode 100644 index 00000000000..16d52cf1c0f --- /dev/null +++ b/adapters/outbrain/outbraintest/exemplary/banner.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "site": { + "page": "http://example.com" + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "site": { + "page": "http://example.com", + "publisher": { + "id": "publisher-id" + } + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5095a742-1c27-402b-ab6f-66b1bd53383b", + "seatbid": [ + { + "bid": [ + { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + } + ], + "seat": "acc-1876" + } + ], + "bidid": "43ccadf2-8b2e-11eb-b294-de4c49e99ff6", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/outbrain/outbraintest/exemplary/native.json b/adapters/outbrain/outbraintest/exemplary/native.json new file mode 100644 index 00000000000..bf1eb7f53ff --- /dev/null +++ b/adapters/outbrain/outbraintest/exemplary/native.json @@ -0,0 +1,121 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{\"context\":1,\"plcmttype\":1,\"assets\":[{\"id\":0,\"required\":1,\"img\":{\"type\":3,\"w\":120,\"h\":100}},{\"id\":1,\"required\":1,\"title\":{\"len\":140}},{\"id\":2,\"data\":{\"type\":1}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1]}]}", + "ver": "1.2" + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "site": { + "page": "http://example.com" + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{\"context\":1,\"plcmttype\":1,\"assets\":[{\"id\":0,\"required\":1,\"img\":{\"type\":3,\"w\":120,\"h\":100}},{\"id\":1,\"required\":1,\"title\":{\"len\":140}},{\"id\":2,\"data\":{\"type\":1}}],\"eventtrackers\":[{\"event\":1,\"methods\":[1]}]}", + "ver": "1.2" + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "site": { + "page": "http://example.com", + "publisher": { + "id": "publisher-id" + } + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5095a742-1c27-402b-ab6f-66b1bd53383b", + "seatbid": [ + { + "bid": [ + { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":3,\"required\":1,\"img\":{\"url\":\"http://example.com/img/url\",\"w\":120,\"h\":100}},{\"id\":0,\"required\":1,\"title\":{\"text\":\"Test title\"}},{\"id\":5,\"data\":{\"value\":\"Test sponsor\"}}],\"link\":{\"url\":\"http://example.com/click/url\"},\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"http://example.com/impression\"},{\"event\":1,\"method\":2,\"url\":\"http://example.com/impression\"}]}", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ] + } + ], + "seat": "acc-1876" + } + ], + "bidid": "43ccadf2-8b2e-11eb-b294-de4c49e99ff6", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "{\"ver\":\"1.2\",\"assets\":[{\"id\":3,\"required\":1,\"img\":{\"url\":\"http://example.com/img/url\",\"w\":120,\"h\":100}},{\"id\":0,\"required\":1,\"title\":{\"text\":\"Test title\"}},{\"id\":5,\"data\":{\"value\":\"Test sponsor\"}}],\"link\":{\"url\":\"http://example.com/click/url\"},\"imptrackers\":[\"http://example.com/impression\"],\"jstracker\":\"\\u003cscript src=\\\"http://example.com/impression\\\"\\u003e\\u003c/script\\u003e\"}", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ] + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/outbrain/outbraintest/params/race/banner.json b/adapters/outbrain/outbraintest/params/race/banner.json new file mode 100644 index 00000000000..05577a78e8b --- /dev/null +++ b/adapters/outbrain/outbraintest/params/race/banner.json @@ -0,0 +1,10 @@ +{ + "publisher": { + "id": "publisher-id", + "name": "publisher-name", + "domain": "publisher-domain.com" + }, + "tagid": "tag-id", + "bcat": ["bad-category"], + "badv": ["bad-advertiser"] +} \ No newline at end of file diff --git a/adapters/outbrain/outbraintest/params/race/native.json b/adapters/outbrain/outbraintest/params/race/native.json new file mode 100644 index 00000000000..05577a78e8b --- /dev/null +++ b/adapters/outbrain/outbraintest/params/race/native.json @@ -0,0 +1,10 @@ +{ + "publisher": { + "id": "publisher-id", + "name": "publisher-name", + "domain": "publisher-domain.com" + }, + "tagid": "tag-id", + "bcat": ["bad-category"], + "badv": ["bad-advertiser"] +} \ No newline at end of file diff --git a/adapters/outbrain/outbraintest/supplemental/app_request.json b/adapters/outbrain/outbraintest/supplemental/app_request.json new file mode 100644 index 00000000000..c8e7c4cf69f --- /dev/null +++ b/adapters/outbrain/outbraintest/supplemental/app_request.json @@ -0,0 +1,144 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "app": { + "name": "test-app", + "bundle": "org.test", + "ver": "1.10", + "publisher": { + "id": "pub-id" + } + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86_arm Build/RSR1.201013.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36", + "model": "sdk_gphone_x86_arm", + "os": "android", + "h": 735, + "w": 392 + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ], + "app": { + "name": "test-app", + "bundle": "org.test", + "ver": "1.10", + "publisher": { + "id": "publisher-id" + } + }, + "device": { + "ua": "Mozilla/5.0 (Linux; Android 11; sdk_gphone_x86_arm Build/RSR1.201013.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36", + "model": "sdk_gphone_x86_arm", + "os": "android", + "h": 735, + "w": 392 + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5095a742-1c27-402b-ab6f-66b1bd53383b", + "seatbid": [ + { + "bid": [ + { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + } + ], + "seat": "acc-1876" + } + ], + "bidid": "43ccadf2-8b2e-11eb-b294-de4c49e99ff6", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/outbrain/outbraintest/supplemental/optional_params.json b/adapters/outbrain/outbraintest/supplemental/optional_params.json new file mode 100644 index 00000000000..a69ceaa0c85 --- /dev/null +++ b/adapters/outbrain/outbraintest/supplemental/optional_params.json @@ -0,0 +1,148 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id", + "name": "publisher-name", + "domain": "publisher-domain.com" + }, + "tagid": "tag-id", + "bcat": ["bad-category"], + "badv": ["bad-advertiser"] + } + } + } + ], + "site": { + "page": "http://example.com" + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "tagid": "tag-id", + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id", + "name": "publisher-name", + "domain": "publisher-domain.com" + }, + "tagid": "tag-id", + "bcat": ["bad-category"], + "badv": ["bad-advertiser"] + } + } + } + ], + "bcat": ["bad-category"], + "badv": ["bad-advertiser"], + "site": { + "page": "http://example.com", + "publisher": { + "id": "publisher-id", + "name": "publisher-name", + "domain": "publisher-domain.com" + } + }, + "device": { + "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36", + "h": 500, + "w": 1000 + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5095a742-1c27-402b-ab6f-66b1bd53383b", + "seatbid": [ + { + "bid": [ + { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + } + ], + "seat": "acc-1876" + } + ], + "bidid": "43ccadf2-8b2e-11eb-b294-de4c49e99ff6", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "test-request-id", + "impid": "test-imp-id", + "price": 1000, + "nurl": "http://example.com/win/1000", + "adm": "
ad
", + "adomain": [ + "example.com" + ], + "cid": "test-cid", + "crid": "test-crid", + "cat": [ + "IAB13-4" + ], + "w": 300, + "h": 250 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/outbrain/outbraintest/supplemental/status_204.json b/adapters/outbrain/outbraintest/supplemental/status_204.json new file mode 100644 index 00000000000..9f668736953 --- /dev/null +++ b/adapters/outbrain/outbraintest/supplemental/status_204.json @@ -0,0 +1,62 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + + "expectedBidResponses": [] +} diff --git a/adapters/outbrain/outbraintest/supplemental/status_400.json b/adapters/outbrain/outbraintest/supplemental/status_400.json new file mode 100644 index 00000000000..441162070d8 --- /dev/null +++ b/adapters/outbrain/outbraintest/supplemental/status_400.json @@ -0,0 +1,67 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/adapters/outbrain/outbraintest/supplemental/status_418.json b/adapters/outbrain/outbraintest/supplemental/status_418.json new file mode 100644 index 00000000000..08e26804806 --- /dev/null +++ b/adapters/outbrain/outbraintest/supplemental/status_418.json @@ -0,0 +1,67 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/bid", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisher": { + "id": "publisher-id" + } + } + } + } + ] + } + }, + "mockResponse": { + "status": 418, + "body": {} + } + } + ], + + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 418. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/adapters/outbrain/params_test.go b/adapters/outbrain/params_test.go new file mode 100644 index 00000000000..a8d81d6234d --- /dev/null +++ b/adapters/outbrain/params_test.go @@ -0,0 +1,50 @@ +package outbrain + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderOutbrain, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderOutbrain, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{"publisher": {"id": "publisher-id"}}`, + `{"publisher": {"id": "publisher-id", "name": "publisher-name", "domain": "publisher-domain.com"}, "tagid": "tag-id", "bcat": ["bad-category"], "badv": ["bad-advertiser"]}`, +} + +var invalidParams = []string{ + `{"publisher": {"id": 1234}}`, + `{"publisher": {"id": "pub-id", "name": 1234}}`, + `{"publisher": {"id": "pub-id", "domain": 1234}}`, + `{"publisher": {"id": "pub-id"}, "tagid": 1234}`, + `{"publisher": {"id": "pub-id"}, "bcat": "not-array"}`, + `{"publisher": {"id": "pub-id"}, "bcat": [1234]}`, + `{"publisher": {"id": "pub-id"}, "badv": "not-array"}`, + `{"publisher": {"id": "pub-id"}, "badv": [1234]}`, +} diff --git a/adapters/outbrain/usersync.go b/adapters/outbrain/usersync.go new file mode 100644 index 00000000000..7dd60306c60 --- /dev/null +++ b/adapters/outbrain/usersync.go @@ -0,0 +1,12 @@ +package outbrain + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewOutbrainSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("outbrain", temp, adapters.SyncTypeRedirect) +} diff --git a/adapters/outbrain/usersync_test.go b/adapters/outbrain/usersync_test.go new file mode 100644 index 00000000000..f531834fc48 --- /dev/null +++ b/adapters/outbrain/usersync_test.go @@ -0,0 +1,33 @@ +package outbrain + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) + +func TestSyncer(t *testing.T) { + syncURL := "http://prebidtest.zemanta.com/usersync/prebidtest?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb=host%2Fsetuid%3Fbidder%3Dzemanta%26uid%3D__ZUID__" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewOutbrainSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "A", + Consent: "B", + }, + CCPA: ccpa.Policy{ + Consent: "C", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "http://prebidtest.zemanta.com/usersync/prebidtest?gdpr=A&gdpr_consent=B&us_privacy=C&cb=host%2Fsetuid%3Fbidder%3Dzemanta%26uid%3D__ZUID__", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) +} diff --git a/adapters/pangle/pangle.go b/adapters/pangle/pangle.go new file mode 100644 index 00000000000..a4694c71559 --- /dev/null +++ b/adapters/pangle/pangle.go @@ -0,0 +1,197 @@ +package pangle + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb/v15/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" +) + +type adapter struct { + Endpoint string +} + +type wrappedExtImpBidder struct { + *adapters.ExtImpBidder + AdType int `json:"adtype,omitempty"` +} + +type pangleBidExt struct { + Pangle *bidExt `json:"pangle,omitempty"` +} + +type bidExt struct { + AdType *int `json:"adtype,omitempty"` +} + +/* Builder */ + +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &adapter{ + Endpoint: config.Endpoint, + } + + return bidder, nil +} + +/* MakeRequests */ + +func getAdType(imp openrtb2.Imp, parsedImpExt *wrappedExtImpBidder) int { + // video + if imp.Video != nil { + if parsedImpExt != nil && parsedImpExt.Prebid != nil && parsedImpExt.Prebid.IsRewardedInventory == 1 { + return 7 + } + if imp.Instl == 1 { + return 8 + } + } + // banner + if imp.Banner != nil { + if imp.Instl == 1 { + return 2 + } else { + return 1 + } + } + // native + if imp.Native != nil && len(imp.Native.Request) > 0 { + return 5 + } + + return -1 +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var requests []*adapters.RequestData + var errs []error + + requestCopy := *request + for _, imp := range request.Imp { + var impExt wrappedExtImpBidder + if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + errs = append(errs, fmt.Errorf("failed unmarshalling imp ext (err)%s", err.Error())) + continue + } + // detect and fill adtype + if adType := getAdType(imp, &impExt); adType == -1 { + errs = append(errs, &errortypes.BadInput{Message: "not a supported adtype"}) + continue + } else { + impExt.AdType = adType + if newImpExt, err := json.Marshal(impExt); err == nil { + imp.Ext = newImpExt + } else { + errs = append(errs, fmt.Errorf("failed re-marshalling imp ext with adtype")) + continue + } + } + // for setting token + var bidderImpExt openrtb_ext.ImpExtPangle + if err := json.Unmarshal(impExt.Bidder, &bidderImpExt); err != nil { + errs = append(errs, fmt.Errorf("failed unmarshalling bidder imp ext (err)%s", err.Error())) + continue + } + + requestCopy.Imp = []openrtb2.Imp{imp} + requestJSON, err := json.Marshal(requestCopy) + if err != nil { + errs = append(errs, err) + continue + } + + requestData := &adapters.RequestData{ + Method: "POST", + Uri: a.Endpoint, + Body: requestJSON, + Headers: http.Header{ + "TOKEN": []string{bidderImpExt.Token}, + "Content-Type": []string{"application/json"}, + }, + } + requests = append(requests, requestData) + } + + return requests, errs +} + +/* MakeBids */ + +func getMediaTypeForBid(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { + if bid == nil { + return "", fmt.Errorf("the bid request object is nil") + } + + var bidExt pangleBidExt + if err := json.Unmarshal(bid.Ext, &bidExt); err != nil { + return "", fmt.Errorf("invalid bid ext") + } else if bidExt.Pangle == nil || bidExt.Pangle.AdType == nil { + return "", fmt.Errorf("missing pangleExt/adtype in bid ext") + } + + switch *bidExt.Pangle.AdType { + case 1: + return openrtb_ext.BidTypeBanner, nil + case 2: + return openrtb_ext.BidTypeBanner, nil + case 5: + return openrtb_ext.BidTypeNative, nil + case 7: + return openrtb_ext.BidTypeVideo, nil + case 8: + return openrtb_ext.BidTypeVideo, nil + } + + return "", fmt.Errorf("unrecognized adtype in response") +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode == http.StatusBadRequest { + err := &errortypes.BadInput{ + Message: "Unexpected status code: 400. Bad request from publisher. Run with request.debug = 1 for more info.", + } + return nil, []error{err} + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + var errs []error + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + bidResponse.Currency = response.Cur + for _, seatBid := range response.SeatBid { + for _, temp := range seatBid.Bid { + bid := temp // avoid taking address of a for loop variable + mediaType, err := getMediaTypeForBid(&bid) + if err != nil { + errs = append(errs, err) + continue + } + b := &adapters.TypedBid{ + Bid: &bid, + BidType: mediaType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + + return bidResponse, errs +} diff --git a/adapters/pangle/pangle_test.go b/adapters/pangle/pangle_test.go new file mode 100644 index 00000000000..89d5eee56c3 --- /dev/null +++ b/adapters/pangle/pangle_test.go @@ -0,0 +1,21 @@ +package pangle + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + conf := config.Adapter{ + Endpoint: "https://pangle.io/api/get_ads", + } + bidder, buildErr := Builder(openrtb_ext.BidderPangle, conf) + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "pangletest", bidder) +} diff --git a/adapters/pangle/pangletest/exemplary/app_banner.json b/adapters/pangle/pangletest/exemplary/app_banner.json new file mode 100644 index 00000000000..3fa410e5b7f --- /dev/null +++ b/adapters/pangle/pangletest/exemplary/app_banner.json @@ -0,0 +1,127 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 1 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.5, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 300, + "h": 250, + "ext": { + "pangle": { + "adtype": 1 + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/exemplary/app_banner_instl.json b/adapters/pangle/pangletest/exemplary/app_banner_instl.json new file mode 100644 index 00000000000..585d155a057 --- /dev/null +++ b/adapters/pangle/pangletest/exemplary/app_banner_instl.json @@ -0,0 +1,129 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "instl": 1, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "instl": 1, + "ext": { + "adtype": 2, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 2 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.5, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 300, + "h": 250, + "ext": { + "pangle": { + "adtype": 2 + } + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/exemplary/app_native.json b/adapters/pangle/pangletest/exemplary/app_native.json new file mode 100644 index 00000000000..2502baa4f9f --- /dev/null +++ b/adapters/pangle/pangletest/exemplary/app_native.json @@ -0,0 +1,117 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}" + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "request": "{}" + }, + "ext": { + "adtype": 5, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 5 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.5, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 300, + "h": 250, + "ext": { + "pangle": { + "adtype": 5 + } + } + }, + "type": "native" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/exemplary/app_video_instl.json b/adapters/pangle/pangletest/exemplary/app_video_instl.json new file mode 100644 index 00000000000..d5af392fd91 --- /dev/null +++ b/adapters/pangle/pangletest/exemplary/app_video_instl.json @@ -0,0 +1,141 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576, + "ext": { + "foo": "bar" + } + }, + "instl": 1, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576, + "ext": { + "foo": "bar" + } + }, + "instl": 1, + "ext": { + "adtype": 8, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 8 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.5, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 300, + "h": 250, + "ext": { + "pangle": { + "adtype": 8 + } + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/exemplary/app_video_rewarded.json b/adapters/pangle/pangletest/exemplary/app_video_rewarded.json new file mode 100644 index 00000000000..2dbf08b944e --- /dev/null +++ b/adapters/pangle/pangletest/exemplary/app_video_rewarded.json @@ -0,0 +1,146 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576, + "ext": { + "foo": "bar" + } + }, + "ext": { + "prebid": { + "is_rewarded_inventory": 1 + }, + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576, + "ext": { + "foo": "bar" + } + }, + "ext": { + "adtype": 7, + "prebid": { + "bidder": null, + "is_rewarded_inventory": 1, + "storedrequest": null + }, + "bidder": { + "token": "123" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 7 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.5, + "adm": "some-test-ad", + "crid": "test-crid", + "w": 300, + "h": 250, + "ext": { + "pangle": { + "adtype": 7 + } + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/params/race/banner.json b/adapters/pangle/pangletest/params/race/banner.json new file mode 100644 index 00000000000..afd1684b04e --- /dev/null +++ b/adapters/pangle/pangletest/params/race/banner.json @@ -0,0 +1,3 @@ +{ + "token": "123" +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/params/race/native.json b/adapters/pangle/pangletest/params/race/native.json new file mode 100644 index 00000000000..afd1684b04e --- /dev/null +++ b/adapters/pangle/pangletest/params/race/native.json @@ -0,0 +1,3 @@ +{ + "token": "123" +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/params/race/video.json b/adapters/pangle/pangletest/params/race/video.json new file mode 100644 index 00000000000..afd1684b04e --- /dev/null +++ b/adapters/pangle/pangletest/params/race/video.json @@ -0,0 +1,3 @@ +{ + "token": "123" +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/pangle_ext_check.json b/adapters/pangle/pangletest/supplemental/pangle_ext_check.json new file mode 100644 index 00000000000..c9dc5c28c6a --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/pangle_ext_check.json @@ -0,0 +1,107 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": {} + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "missing pangleExt/adtype in bid ext", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/response_code_204.json b/adapters/pangle/pangletest/supplemental/response_code_204.json new file mode 100644 index 00000000000..16c13bdf18f --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/response_code_204.json @@ -0,0 +1,79 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/response_code_400.json b/adapters/pangle/pangletest/supplemental/response_code_400.json new file mode 100644 index 00000000000..0a5810325e2 --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/response_code_400.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400.*", + "comparison": "regex" + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/response_code_non_200.json b/adapters/pangle/pangletest/supplemental/response_code_non_200.json new file mode 100644 index 00000000000..0d1447db1fe --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/response_code_non_200.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 403, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 403.*", + "comparison": "regex" + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/unrecognized_adtype.json b/adapters/pangle/pangletest/supplemental/unrecognized_adtype.json new file mode 100644 index 00000000000..451c0ed1909 --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/unrecognized_adtype.json @@ -0,0 +1,110 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://pangle.io/api/get_ads", + "headers": { + "Content-Type": [ + "application/json" + ], + "TOKEN": [ + "123" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ] + }, + "ext": { + "adtype": 1, + "bidder": { + "token": "123" + }, + "prebid": null + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "seat-id", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "adid": "11110126", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "test-crid", + "h": 250, + "w": 300, + "ext": { + "pangle": { + "adtype": 100 + } + } + } + ] + } + ], + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + ], + "expectedMakeBidsErrors": [ + { + "value": "unrecognized adtype in response", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/pangle/pangletest/supplemental/unsupported_adtype.json b/adapters/pangle/pangletest/supplemental/unsupported_adtype.json new file mode 100644 index 00000000000..bcd916ca322 --- /dev/null +++ b/adapters/pangle/pangletest/supplemental/unsupported_adtype.json @@ -0,0 +1,48 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ifa": "87857b31-8942-4646-ae80-ab9c95bf3fab" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 5 + ], + "w": 1024, + "h": 576, + "ext": { + "foo": "bar" + } + }, + "instl": 0, + "ext": { + "bidder": { + "token": "123" + } + } + } + ] + }, + "httpCalls": [ + ], + "expectedBidResponses": [ + ], + "expectedMakeRequestsErrors": [ + { + "value": "not a supported adtype", + "comparison": "literal" + } + ], + "expectedMakeBidsErrors": [ + ] + } \ No newline at end of file diff --git a/adapters/pangle/param_test.go b/adapters/pangle/param_test.go new file mode 100644 index 00000000000..7b037bd52d6 --- /dev/null +++ b/adapters/pangle/param_test.go @@ -0,0 +1,45 @@ +package pangle + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +var validParams = []string{ + `{"token": "SomeAccessToken"}`, +} + +var invalidParams = []string{ + `{"token": ""}`, + `{"token": 42}`, + `{"token": null}`, + `{}`, +} + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderPangle, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderPangle, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} diff --git a/adapters/pubmatic/params_test.go b/adapters/pubmatic/params_test.go index 9615fb978e6..c8a300b9910 100644 --- a/adapters/pubmatic/params_test.go +++ b/adapters/pubmatic/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/pubmatic.json diff --git a/adapters/pubmatic/pubmatic.go b/adapters/pubmatic/pubmatic.go index b21e31ed930..c9e3660b4c8 100644 --- a/adapters/pubmatic/pubmatic.go +++ b/adapters/pubmatic/pubmatic.go @@ -11,13 +11,13 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" "github.com/golang/glog" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -171,8 +171,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) @@ -203,12 +203,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 } } @@ -277,7 +277,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{ @@ -326,7 +326,7 @@ func (a *PubmaticAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder return bids, nil } -func getBidderParam(request *openrtb.BidRequest, key string) ([]byte, error) { +func getBidderParam(request *openrtb2.BidRequest, key string) ([]byte, error) { var reqExt openrtb_ext.ExtRequest if len(request.Ext) <= 0 { return nil, nil @@ -361,7 +361,7 @@ func getBidderParam(request *openrtb.BidRequest, key string) ([]byte, error) { return bytes, nil } -func getCookiesFromRequest(request *openrtb.BidRequest) ([]string, error) { +func getCookiesFromRequest(request *openrtb2.BidRequest) ([]string, error) { cbytes, err := getBidderParam(request, "Cookie") if err != nil { return nil, err @@ -381,7 +381,7 @@ func getCookiesFromRequest(request *openrtb.BidRequest) ([]string, error) { return cookies, 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 @@ -422,7 +422,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 { @@ -432,7 +432,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 } @@ -442,17 +442,17 @@ func (a *PubmaticAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *ada var userExt *openrtb_ext.ExtUser if err = json.Unmarshal(request.User.Ext, &userExt); err == nil { if userExt != nil && userExt.Eids != nil { - var eidArr []openrtb.Eid + var eidArr []openrtb2.Eid for _, eid := range userExt.Eids { - //var newEid openrtb.Eid - newEid := &openrtb.Eid{ + //var newEid openrtb2.Eid + newEid := &openrtb2.Eid{ ID: eid.ID, Source: eid.Source, Ext: eid.Ext, } - var uidArr []openrtb.Uid + var uidArr []openrtb2.Uid for _, uid := range eid.Uids { - newUID := &openrtb.Uid{ + newUID := &openrtb2.Uid{ ID: uid.ID, AType: uid.Atype, Ext: uid.Ext, @@ -506,7 +506,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 { @@ -540,8 +540,8 @@ func validateAdSlot(adslot string, imp *openrtb.Imp) error { //In case of video, size could be derived from the player size if imp.Banner != nil && height != 0 && width != 0 { - imp.Banner.H = openrtb.Uint64Ptr(uint64(height)) - imp.Banner.W = openrtb.Uint64Ptr(uint64(width)) + imp.Banner.H = openrtb2.Int64Ptr(int64(height)) + imp.Banner.W = openrtb2.Int64Ptr(int64(width)) } } else { return errors.New(fmt.Sprintf("Invalid adSlot %v", adSlotStr)) @@ -550,7 +550,7 @@ func validateAdSlot(adslot string, imp *openrtb.Imp) error { return nil } -func assignBannerSize(banner *openrtb.Banner) error { +func assignBannerSize(banner *openrtb2.Banner) error { if banner == nil { return nil } @@ -563,16 +563,16 @@ func assignBannerSize(banner *openrtb.Banner) error { return errors.New(fmt.Sprintf("No sizes provided for Banner %v", banner.Format)) } - banner.W = new(uint64) + banner.W = new(int64) *banner.W = banner.Format[0].W - banner.H = new(uint64) + banner.H = new(int64) *banner.H = banner.Format[0].H return nil } // parseImpressionObject parse the imp to get it ready to send to pubmatic -func parseImpressionObject(imp *openrtb.Imp, wrapExt *pubmaticWrapperExt, pubID *string, wrapperExtSet *bool) error { +func parseImpressionObject(imp *openrtb2.Imp, wrapExt *pubmaticWrapperExt, pubID *string, wrapperExtSet *bool) 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) @@ -668,7 +668,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 } @@ -683,7 +683,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 6709414ac8a..b0df1903a42 100644 --- a/adapters/pubmatic/pubmatic_test.go +++ b/adapters/pubmatic/pubmatic_test.go @@ -12,14 +12,14 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" ) func TestJsonSamples(t *testing.T) { @@ -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 { - bid := openrtb.Bid{ + bid := openrtb2.Bid{ ID: fmt.Sprintf("SeatID_%d", i), ImpID: imp.ID, Price: float64(int(rand.Float64()*1000)) / 100, @@ -132,7 +132,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, @@ -167,7 +167,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, @@ -203,7 +203,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, @@ -236,7 +236,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, @@ -308,7 +308,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, @@ -344,7 +344,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, @@ -389,7 +389,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, @@ -401,7 +401,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, @@ -437,7 +437,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, @@ -449,7 +449,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, @@ -486,7 +486,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, @@ -497,7 +497,7 @@ func TestPubmaticMobileResponse(t *testing.T) { }, } - pbReq.App = &openrtb.App{ + pbReq.App = &openrtb2.App{ ID: "com.test", Name: "testApp", } @@ -526,7 +526,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, @@ -558,7 +558,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, @@ -638,7 +638,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/pubmatic/pubmatictest/supplemental/trimPublisherID.json b/adapters/pubmatic/pubmatictest/supplemental/trimPublisherID.json index 1aa98fcb892..6a344ee091a 100644 --- a/adapters/pubmatic/pubmatictest/supplemental/trimPublisherID.json +++ b/adapters/pubmatic/pubmatictest/supplemental/trimPublisherID.json @@ -1,152 +1,159 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-imp-id", - "banner": { - "format": [{ - "w": 300, - "h": 250 - }] - }, - "ext": { - "bidder": { - "adSlot": "AdTag_Div1@300x250", - "publisherId": " 999 ", - "keywords": [{ - "key": "pmZoneID", - "value": ["Zone1", "Zone2"] - }, - { - "key": "preference", - "value": ["sports", "movies"] - } - ], - "wrapper": { - "version": 1, - "profile": 5123 - } - } + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 } - }], - "device":{ - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" + ] }, - "site": { - "id": "siteID", - "publisher": { - "id": "1234" - } - }, - "ext":{ - "prebid" :{ - "bidderparams": { - "wiid": "dwzafakjflan-tygannnvlla-mlljvj" + "ext": { + "bidder": { + "adSlot": "AdTag_Div1@300x250", + "publisherId": " 999 ", + "keywords": [ + { + "key": "pmZoneID", + "value": [ + "Zone1", + "Zone2" + ] + }, + { + "key": "preference", + "value": [ + "sports", + "movies" + ] + } + ], + "wrapper": { + "version": 1, + "profile": 5123 } } } - }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://hbopenbid.pubmatic.com/translator?source=prebid-server", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "tagid":"AdTag_Div1", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - } + } + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" + }, + "site": { + "id": "siteID", + "publisher": { + "id": "1234" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://hbopenbid.pubmatic.com/translator?source=prebid-server", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "tagid": "AdTag_Div1", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } ], "h": 250, "w": 300 - }, - "ext": { - "pmZoneID": "Zone1,Zone2", - "preference": "sports,movies" - } + }, + "ext": { + "pmZoneID": "Zone1,Zone2", + "preference": "sports,movies" } - ], - "device":{ - "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" - }, - "site": { - "id": "siteID", - "publisher": { - "id": "999" - } - }, - "ext": { - "wrapper": { - "profile": 5123, - "version":1, - "wiid" : "dwzafakjflan-tygannnvlla-mlljvj" - } + } + ], + "device": { + "ua": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" + }, + "site": { + "id": "siteID", + "publisher": { + "id": "999" + } + }, + "ext": { + "wrapper": { + "profile": 5123, + "version": 1 } } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "958", - "bid": [{ + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "958", + "bid": [ + { "id": "7706636740145184841", "impid": "test-imp-id", "price": 0.500000, "adid": "29681110", "adm": "some-test-ad", - "adomain": ["pubmatic.com"], + "adomain": [ + "pubmatic.com" + ], "crid": "29681110", "h": 250, "w": 300, - "dealid":"test deal", + "dealid": "test deal", "ext": { "dspid": 6, "deal_channel": 1 } - }] - } - ], - "bidid": "5778926625248726496", - "cur": "USD" - } + } + ] + } + ], + "bidid": "5778926625248726496", + "cur": "USD" } } - ], - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "7706636740145184841", - "impid": "test-imp-id", - "price": 0.5, - "adid": "29681110", - "adm": "some-test-ad", - "adomain": ["pubmatic.com"], - "crid": "29681110", - "w": 300, - "h": 250, - "dealid":"test deal", - "ext": { - "dspid": 6, - "deal_channel": 1 - } - }, - "type": "banner" - } - ] - } - ] - } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "7706636740145184841", + "impid": "test-imp-id", + "price": 0.5, + "adid": "29681110", + "adm": "some-test-ad", + "adomain": [ + "pubmatic.com" + ], + "crid": "29681110", + "w": 300, + "h": 250, + "dealid": "test deal", + "ext": { + "dspid": 6, + "deal_channel": 1 + } + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/pubmatic/usersync.go b/adapters/pubmatic/usersync.go index f35470c0ad9..822f13cea3d 100644 --- a/adapters/pubmatic/usersync.go +++ b/adapters/pubmatic/usersync.go @@ -3,10 +3,10 @@ package pubmatic import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewPubmaticSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("pubmatic", 76, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("pubmatic", temp, adapters.SyncTypeIframe) } diff --git a/adapters/pubmatic/usersync_test.go b/adapters/pubmatic/usersync_test.go index e32650ac543..0f4d2e857d3 100644 --- a/adapters/pubmatic/usersync_test.go +++ b/adapters/pubmatic/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestPubmaticSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ads.pubmatic.com/AdServer/js/user_sync.html?gdpr=A&gdpr_consent=B&us_privacy=C&predirect=localhost%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3DA%26gdpr_consent%3DB%26uid%3D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 76, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/pubnative/pubnative.go b/adapters/pubnative/pubnative.go index 36edceee53f..8093c841fb2 100644 --- a/adapters/pubnative/pubnative.go +++ b/adapters/pubnative/pubnative.go @@ -7,18 +7,18 @@ import ( "net/url" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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,39 +87,45 @@ 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.", } } if imp.Banner != nil { - err := convertBanner(imp.Banner) + bannerCopy, err := convertBanner(imp.Banner) if err != nil { return err } + imp.Banner = bannerCopy } return nil } // make sure that banner has openrtb 2.3-compatible size information -func convertBanner(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] - banner.W = &f.W - banner.H = &f.H + + bannerCopy := *banner + + bannerCopy.W = openrtb2.Int64Ptr(f.W) + bannerCopy.H = openrtb2.Int64Ptr(f.H) + + return &bannerCopy, nil } else { - return &errortypes.BadInput{ + return nil, &errortypes.BadInput{ Message: "Size information missing for banner", } } } - return nil + 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 } @@ -136,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(), @@ -167,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/pubnative/pubnative_test.go b/adapters/pubnative/pubnative_test.go index 484315cac5e..6955b85f5de 100644 --- a/adapters/pubnative/pubnative_test.go +++ b/adapters/pubnative/pubnative_test.go @@ -3,9 +3,9 @@ package pubnative import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/pulsepoint/params_test.go b/adapters/pulsepoint/params_test.go index f6d6baf9f06..ac2b314b96f 100644 --- a/adapters/pulsepoint/params_test.go +++ b/adapters/pulsepoint/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/pulsepoint/pulsepoint.go b/adapters/pulsepoint/pulsepoint.go index 8025e9b29c8..6b6b4305607 100644 --- a/adapters/pulsepoint/pulsepoint.go +++ b/adapters/pulsepoint/pulsepoint.go @@ -1,22 +1,21 @@ package pulsepoint import ( + "bytes" + "context" "encoding/json" "fmt" + "io/ioutil" "net/http" "strconv" - - "bytes" - "context" - "io/ioutil" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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 7e9b51016ea..fac0bfd4de8 100644 --- a/adapters/pulsepoint/pulsepoint_test.go +++ b/adapters/pulsepoint/pulsepoint_test.go @@ -5,9 +5,9 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/openrtb_ext" "bytes" "context" @@ -16,11 +16,11 @@ import ( "net/http/httptest" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" ) func TestJsonSamples(t *testing.T) { @@ -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/pulsepoint/usersync.go b/adapters/pulsepoint/usersync.go index 4c7d5ca63c8..1b6903f9f02 100644 --- a/adapters/pulsepoint/usersync.go +++ b/adapters/pulsepoint/usersync.go @@ -3,10 +3,10 @@ package pulsepoint import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewPulsepointSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("pulsepoint", 81, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("pulsepoint", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/pulsepoint/usersync_test.go b/adapters/pulsepoint/usersync_test.go index 8dd32564930..7cfea57cb91 100644 --- a/adapters/pulsepoint/usersync_test.go +++ b/adapters/pulsepoint/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestPulsepointSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//bh.contextweb.com/rtset?pid=561205&ev=1&rurl=http%3A%2F%2Flocalhost%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D%26gdpr_consent%3D%26uid%3D%25%25VGUID%25%25", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 81, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/revcontent/revcontent.go b/adapters/revcontent/revcontent.go index c6a7ff9d827..173917c2314 100644 --- a/adapters/revcontent/revcontent.go +++ b/adapters/revcontent/revcontent.go @@ -3,12 +3,13 @@ package revcontent import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "net/http" + + "github.com/mxmCherry/openrtb/v15/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" ) 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/revcontent_test.go b/adapters/revcontent/revcontent_test.go index d7f83cdb2aa..836ef138eb7 100644 --- a/adapters/revcontent/revcontent_test.go +++ b/adapters/revcontent/revcontent_test.go @@ -3,9 +3,9 @@ package revcontent import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/params_test.go b/adapters/rhythmone/params_test.go index 00eacf15082..7d8cad47d53 100644 --- a/adapters/rhythmone/params_test.go +++ b/adapters/rhythmone/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/rhythmone/rhythmone.go b/adapters/rhythmone/rhythmone.go index e2fc9aa8f0d..de43537e55b 100644 --- a/adapters/rhythmone/rhythmone.go +++ b/adapters/rhythmone/rhythmone.go @@ -6,18 +6,18 @@ import ( "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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++ { @@ -132,9 +132,9 @@ func (a *RhythmoneAdapter) preProcess(req *openrtb.BidRequest, errors []error) ( errors = append(errors, err) return nil, "", errors } - bidderExtCopy := openrtb_ext.ExtBid{ - Bidder: rhythmoneExtCopy, - } + bidderExtCopy := struct { + Bidder json.RawMessage `json:"bidder,omitempty"` + }{rhythmoneExtCopy} impExtCopy, err := json.Marshal(&bidderExtCopy) if err != nil { errors = append(errors, err) diff --git a/adapters/rhythmone/rhythmone_test.go b/adapters/rhythmone/rhythmone_test.go index e2419f33568..c0c0a891ef4 100644 --- a/adapters/rhythmone/rhythmone_test.go +++ b/adapters/rhythmone/rhythmone_test.go @@ -3,9 +3,9 @@ package rhythmone import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/rhythmone/usersync.go b/adapters/rhythmone/usersync.go index 534c60dd4bc..990fcb065f6 100644 --- a/adapters/rhythmone/usersync.go +++ b/adapters/rhythmone/usersync.go @@ -3,10 +3,10 @@ package rhythmone import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewRhythmoneSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("rhythmone", 36, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("rhythmone", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/rhythmone/usersync_test.go b/adapters/rhythmone/usersync_test.go index 1c725626a46..97920fb4980 100644 --- a/adapters/rhythmone/usersync_test.go +++ b/adapters/rhythmone/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestRhythmoneSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://sync.1rx.io/usersync2/rmphb?gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&us_privacy=1NYN&redir=localhost%2Fsetuid%3Fbidder%3Drhythmone%26gdpr%3D1%26gdpr_consent%3DBOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA%26uid%3D%5BRX_UUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 36, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/rtbhouse/rtbhouse.go b/adapters/rtbhouse/rtbhouse.go index 26f85d4adad..44adddee8fd 100644 --- a/adapters/rtbhouse/rtbhouse.go +++ b/adapters/rtbhouse/rtbhouse.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // Builder builds a new instance of the RTBHouse adapter for the given bidder with the given config. @@ -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/rtbhouse_test.go b/adapters/rtbhouse/rtbhouse_test.go index 15dfd1fc9b2..bae9a636038 100644 --- a/adapters/rtbhouse/rtbhouse_test.go +++ b/adapters/rtbhouse/rtbhouse_test.go @@ -3,9 +3,9 @@ package rtbhouse import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) const testsDir = "rtbhousetest" 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/rtbhouse/usersync.go b/adapters/rtbhouse/usersync.go index 97e673124aa..baa0b994373 100644 --- a/adapters/rtbhouse/usersync.go +++ b/adapters/rtbhouse/usersync.go @@ -3,17 +3,15 @@ package rtbhouse import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) -const rtbHouseGDPRVendorID = uint16(16) const rtbHouseFamilyName = "rtbhouse" func NewRTBHouseSyncer(urlTemplate *template.Template) usersync.Usersyncer { return adapters.NewSyncer( rtbHouseFamilyName, - rtbHouseGDPRVendorID, urlTemplate, adapters.SyncTypeRedirect, ) diff --git a/adapters/rtbhouse/usersync_test.go b/adapters/rtbhouse/usersync_test.go index 7b1d198b74d..a7cb2590f90 100644 --- a/adapters/rtbhouse/usersync_test.go +++ b/adapters/rtbhouse/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestRTBHouseSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://creativecdn.com/cm-notify?pi=prebidsrvtst&gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, rtbHouseGDPRVendorID, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/rubicon/rubicon.go b/adapters/rubicon/rubicon.go index 7fe88640cb0..89d69522fe8 100644 --- a/adapters/rubicon/rubicon.go +++ b/adapters/rubicon/rubicon.go @@ -10,16 +10,14 @@ import ( "net/url" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" "github.com/golang/glog" - + "github.com/mxmCherry/openrtb/v15/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" - - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" ) const badvLimitSize = 50 @@ -93,6 +91,10 @@ type rubiconExtUserTpID struct { UID string `json:"uid"` } +type rubiconUserDataExt struct { + TaxonomyName string `json:"taxonomyname"` +} + type rubiconUserExt struct { Consent string `json:"consent,omitempty"` DigiTrust *openrtb_ext.ExtUserDigiTrust `json:"digitrust"` @@ -322,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{ @@ -381,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{ @@ -519,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 } @@ -534,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) @@ -612,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 @@ -670,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 @@ -752,6 +754,11 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap userCopy := *request.User userExtRP := rubiconUserExt{RP: rubiconUserExtRP{Target: rubiconExt.Visitor}} + if err := updateUserExtWithIabAttribute(&userExtRP, userCopy.Data); err != nil { + errs = append(errs, err) + continue + } + if request.User.Ext != nil { var userExt *openrtb_ext.ExtUser if err = json.Unmarshal(userCopy.Ext, &userExt); err != nil { @@ -844,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 } @@ -863,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 @@ -886,6 +893,43 @@ func (a *RubiconAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return requestData, errs } +func updateUserExtWithIabAttribute(userExtRP *rubiconUserExt, data []openrtb2.Data) error { + var segmentIdsToCopy = make([]string, 0) + + for _, dataRecord := range data { + if dataRecord.Ext != nil { + var dataExtObject rubiconUserDataExt + err := json.Unmarshal(dataRecord.Ext, &dataExtObject) + if err != nil { + continue + } + if strings.EqualFold(dataExtObject.TaxonomyName, "iab") { + for _, segment := range dataRecord.Segment { + segmentIdsToCopy = append(segmentIdsToCopy, segment.ID) + } + } + } + } + + userExtRPTarget := make(map[string]interface{}) + + if userExtRP.RP.Target != nil { + if err := json.Unmarshal(userExtRP.RP.Target, &userExtRPTarget); err != nil { + return &errortypes.BadInput{Message: err.Error()} + } + } + + userExtRPTarget["iab"] = segmentIdsToCopy + + if target, err := json.Marshal(&userExtRPTarget); err != nil { + return &errortypes.BadInput{Message: err.Error()} + } else { + userExtRP.RP.Target = target + } + + return nil +} + func getTpIdsAndSegments(eids []openrtb_ext.ExtUserEid) (mappedRubiconUidsParam, []error) { rubiconUidsParam := mappedRubiconUidsParam{ tpIds: make([]rubiconExtUserTpID, 0), @@ -972,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. @@ -981,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 } @@ -1003,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} } @@ -1057,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 @@ -1066,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 54953b213b1..dc5b3a90423 100644 --- a/adapters/rubicon/rubicon_test.go +++ b/adapters/rubicon/rubicon_test.go @@ -4,7 +4,6 @@ import ( "bytes" "context" "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" "io/ioutil" "net/http" "net/http/httptest" @@ -12,19 +11,21 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/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" + "github.com/prebid/prebid-server/usersync" "fmt" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -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/rubicon/rubicontest/exemplary/simple-video.json b/adapters/rubicon/rubicontest/exemplary/simple-video.json index 76c64ff95ec..b85c28def44 100644 --- a/adapters/rubicon/rubicontest/exemplary/simple-video.json +++ b/adapters/rubicon/rubicontest/exemplary/simple-video.json @@ -9,6 +9,52 @@ "id": "1", "bundle": "com.wls.testwlsapplication" }, + "user": { + "data": [ + { + "ext": { + "taxonomyname": "iab" + }, + "segment": [ + { + "id": "idToCopy" + } + ] + }, + { + "ext": { + "taxonomyname": "someValue" + }, + "segment": [ + { + "id": "shouldNotBeCopied" + } + ] + }, + { + "ext": { + "taxonomyname": "IaB" + }, + "segment": [ + { + "id": "idToCopy2" + } + ] + }, + { + "ext": { + "taxonomyname": [ + "wrong iab type" + ] + }, + "segment": [ + { + "id": "shouldNotBeCopied2" + } + ] + } + ] + }, "imp": [ { "id": "test-imp-id", @@ -30,8 +76,8 @@ "video": { }, "accountId": 1001, - "siteId":113932, - "zoneId":535510 + "siteId": 113932, + "zoneId": 535510 } } } @@ -52,6 +98,63 @@ "ip": "123.123.123.123", "ifa": "zxcjbzxmc-zxcbmz-zxbcz-zxczx" }, + "user": { + "data": [ + { + "ext": { + "taxonomyname": "iab" + }, + "segment": [ + { + "id": "idToCopy" + } + ] + }, + { + "ext": { + "taxonomyname": "someValue" + }, + "segment": [ + { + "id": "shouldNotBeCopied" + } + ] + }, + { + "ext": { + "taxonomyname": "IaB" + }, + "segment": [ + { + "id": "idToCopy2" + } + ] + }, + { + "ext": { + "taxonomyname": [ + "wrong iab type" + ] + }, + "segment": [ + { + "id": "shouldNotBeCopied2" + } + ] + } + ], + "ext": { + "digitrust": null, + "rp": { + "target": { + "iab": [ + "idToCopy", + "idToCopy2" + ] + } + } + } + }, "app": { "id": "1", "ext": { @@ -91,7 +194,7 @@ }, "ext": { "rp": { - "track":{ + "track": { "mint": "", "mint_version": "" }, diff --git a/adapters/rubicon/usersync.go b/adapters/rubicon/usersync.go index 9c86024771e..a4ab464a73f 100644 --- a/adapters/rubicon/usersync.go +++ b/adapters/rubicon/usersync.go @@ -3,10 +3,10 @@ package rubicon import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewRubiconSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("rubicon", 52, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("rubicon", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/rubicon/usersync_test.go b/adapters/rubicon/usersync_test.go index 2fd53d6b62b..eca4056206e 100644 --- a/adapters/rubicon/usersync_test.go +++ b/adapters/rubicon/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,7 +25,6 @@ func TestRubiconSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://pixel.rubiconproject.com/exchange/sync.php?p=prebid&gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 52, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) assert.Equal(t, "rubicon", syncer.FamilyName()) } diff --git a/adapters/sharethrough/butler.go b/adapters/sharethrough/butler.go index 738d382a938..b34ae0844ab 100644 --- a/adapters/sharethrough/butler.go +++ b/adapters/sharethrough/butler.go @@ -9,11 +9,11 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/privacy/ccpa" ) const defaultTmax = 10000 // 10 sec @@ -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 f6d43971f4e..fbef417e530 100644 --- a/adapters/sharethrough/butler_test.go +++ b/adapters/sharethrough/butler_test.go @@ -9,17 +9,17 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) 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/params_test.go b/adapters/sharethrough/params_test.go index e4e659f4420..416f459341d 100644 --- a/adapters/sharethrough/params_test.go +++ b/adapters/sharethrough/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/sharethrough/sharethrough.go b/adapters/sharethrough/sharethrough.go index 63958d029f1..410ca391bd4 100644 --- a/adapters/sharethrough/sharethrough.go +++ b/adapters/sharethrough/sharethrough.go @@ -5,11 +5,11 @@ import ( "net/http" "regexp" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const supplyId = "FGMrCMMc" @@ -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 0e31a90bac4..1cf45d1fde2 100644 --- a/adapters/sharethrough/sharethrough_test.go +++ b/adapters/sharethrough/sharethrough_test.go @@ -6,11 +6,11 @@ import ( "regexp" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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/stretchr/testify/assert" ) @@ -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/usersync.go b/adapters/sharethrough/usersync.go index 7d5d6f135a8..f76f41ca83e 100644 --- a/adapters/sharethrough/usersync.go +++ b/adapters/sharethrough/usersync.go @@ -1,11 +1,12 @@ package sharethrough import ( - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSharethroughSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("sharethrough", 80, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("sharethrough", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/sharethrough/usersync_test.go b/adapters/sharethrough/usersync_test.go index c48a6d51f8e..00b3c427fb8 100644 --- a/adapters/sharethrough/usersync_test.go +++ b/adapters/sharethrough/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,7 +25,6 @@ func TestSharethroughSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://match.sharethrough.com?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 80, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) assert.Equal(t, "sharethrough", syncer.FamilyName()) } diff --git a/adapters/sharethrough/utils.go b/adapters/sharethrough/utils.go index 2dc22615aa7..e10a8f90b7b 100644 --- a/adapters/sharethrough/utils.go +++ b/adapters/sharethrough/utils.go @@ -5,27 +5,28 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/buger/jsonparser" "html/template" "net" "net/url" "regexp" "strconv" "time" + + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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 aa5ae58cc5c..b842cf0b0c0 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/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/stretchr/testify/assert" "regexp" "testing" + + "github.com/mxmCherry/openrtb/v15/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/params_test.go b/adapters/silvermob/params_test.go index fbfb5f3d097..13009f6a08b 100644 --- a/adapters/silvermob/params_test.go +++ b/adapters/silvermob/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // TestValidParams makes sure that the silvermob schema accepts all imp.ext fields which we intend to support. diff --git a/adapters/silvermob/silvermob.go b/adapters/silvermob/silvermob.go index 0e79f44369f..8a5c6b259b6 100644 --- a/adapters/silvermob/silvermob.go +++ b/adapters/silvermob/silvermob.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type SilverMobAdapter struct { @@ -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/silvermob_test.go b/adapters/silvermob/silvermob_test.go index 8045542c7c5..795d58fd834 100644 --- a/adapters/silvermob/silvermob_test.go +++ b/adapters/silvermob/silvermob_test.go @@ -3,9 +3,9 @@ package silvermob import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/silvermob/silvermobtest/exemplary/native-app.json b/adapters/silvermob/silvermobtest/exemplary/native-app.json index b5af81f07e4..c1cb8cf3d49 100644 --- a/adapters/silvermob/silvermobtest/exemplary/native-app.json +++ b/adapters/silvermob/silvermobtest/exemplary/native-app.json @@ -156,4 +156,4 @@ } ] } - + \ No newline at end of file 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/params_test.go b/adapters/smaato/params_test.go index 80993dc5739..6c71cbe75c6 100644 --- a/adapters/smaato/params_test.go +++ b/adapters/smaato/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file intends to test static/bidder-params/smaato.json diff --git a/adapters/smaato/smaato.go b/adapters/smaato/smaato.go index 2873f1311a4..9aea2e1e614 100644 --- a/adapters/smaato/smaato.go +++ b/adapters/smaato/smaato.go @@ -6,15 +6,15 @@ import ( "net/http" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" ) -const clientVersion = "prebid_server_0.1" +const clientVersion = "prebid_server_0.2" type adMarkupType string @@ -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"}) @@ -81,9 +81,10 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt i-- } } + 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 @@ -98,6 +99,13 @@ func (a *SmaatoAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapt request.Site = &siteCopy } + if request.App != nil { + appCopy := *request.App + appCopy.Publisher = &openrtb2.Publisher{ID: publisherID} + + request.App = &appCopy + } + if request.User != nil && request.User.Ext != nil { var userExt userExt var userExtRaw map[string]json.RawMessage @@ -155,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 } @@ -170,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} } @@ -251,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 } @@ -259,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 @@ -295,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/smaato/smaato_test.go b/adapters/smaato/smaato_test.go index 5fdea31693f..c7c4a65017f 100644 --- a/adapters/smaato/smaato_test.go +++ b/adapters/smaato/smaato_test.go @@ -3,9 +3,9 @@ package smaato import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json new file mode 100644 index 00000000000..8194f568c28 --- /dev/null +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-app.json @@ -0,0 +1,225 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "app": { + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "app": { + "publisher": { + "id": "1100042525" + }, + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"image\":{\"img\":{\"url\":\"//prebid-test.smaatolabs.net/img/320x50.jpg\",\"w\":350,\"h\":50,\"ctaurl\":\"//prebid-test.smaatolabs.net/track/ctaurl/1\"},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json new file mode 100644 index 00000000000..46722c4ff71 --- /dev/null +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia-app.json @@ -0,0 +1,229 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "app": { + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "gender": "M", + "keywords": "a,b", + "yob": 1984, + "ext": { + "consent": "gdprConsentString" + } + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "app": { + "publisher": { + "id": "1100042525" + }, + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "{\"richmedia\":{\"mediadata\":{\"content\":\"
hello
\", \"w\":350,\"h\":50},\"impressiontrackers\":[\"//prebid-test.smaatolabs.net/track/imp/1\",\"//prebid-test.smaatolabs.net/track/imp/2\"],\"clicktrackers\":[\"//prebid-test.smaatolabs.net/track/click/1\",\"//prebid-test.smaatolabs.net/track/click/2\"]}}", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "
hello
\"\"\"\"
", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://bidstalkcreatives.s3.amazonaws.com/1x1.png", + "nurl": "https://ets-eu-west-1.track.smaato.net/v1/view?sessionId=e4e17adb-9599-42b1-bb5f-a1f1b3bee572&adSourceId=6906aae8-7f74-4edd-9a4f-f49379a3cadd&originalRequestTime=1552310449698&expires=1552311350698&winurl=ama8JbpJVpFWxvEja5viE3cLXFu58qRI8dGUh23xtsOn3N2-5UU0IwkgNEmR82pI37fcMXejL5IWTNAoW6Cnsjf-Dxl_vx2dUqMrVEevX-Vdx2VVnf-D5f73gZhvi4t36iPL8Dsw4aACekoLvVOV7-eXDjz7GHy60QFqcwKf5g2AlKPOInyZ6vJg_fn4qA9argvCRgwVybXE9Ndm2W0v8La4uFYWpJBOUveDDUrSQfzal7RsYvLb_OyaMlPHdrd_bwA9qqZWuyJXd-L9lxr7RQ%3D%3D%7CMw3kt91KJR0Uy5L-oNztAg%3D%3D&dpid=4XVofb_lH-__hr2JNGhKfg%3D%3D%7Cr9ciCU1cx3zmHXihItKO0g%3D%3D", + "price": 0.01, + "w": 350, + "h": 50 + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json index 7b662e8813a..1018dbc39ac 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner-richMedia.json @@ -129,7 +129,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/simple-banner.json b/adapters/smaato/smaatotest/exemplary/simple-banner.json index a50fd9289e3..0ba4050a143 100644 --- a/adapters/smaato/smaatotest/exemplary/simple-banner.json +++ b/adapters/smaato/smaatotest/exemplary/simple-banner.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } }, diff --git a/adapters/smaato/smaatotest/exemplary/video-app.json b/adapters/smaato/smaatotest/exemplary/video-app.json new file mode 100644 index 00000000000..bf939eb078a --- /dev/null +++ b/adapters/smaato/smaatotest/exemplary/video-app.json @@ -0,0 +1,230 @@ +{ + "mockBidRequest": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "postbid_iframe", + "video": { + "mimes": [ + "video/mp4", + "video/quicktime", + "video/3gpp", + "video/x-m4v" + ], + "minduration": 5, + "maxduration": 30, + "protocols": [ + 7 + ], + "w": 1024, + "h": 768, + "startdelay": 0, + "linearity": 1, + "skip": 1, + "skipmin": 5, + "api": [ + 7 + ], + "ext": { + "rewarded": 0 + } + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "app": { + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "device": { + "ua": "test-user-agent" + }, + "user": { + "ext": { + "data": {} + } + }, + "ext": { + "prebid": { + "auctiontimestamp": 1598262728811, + "targeting": { + "includewinners": true, + "includebidderkeys": false + } + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "447a0a1d-389d-4730-a418-3777e95de7bd", + "imp": [ + { + "id": "postbid_iframe", + "tagid": "130563103", + "video": { + "w": 1024, + "h": 768, + "ext": { + "rewarded": 0 + }, + "mimes": [ + "video/mp4", + "video/quicktime", + "video/3gpp", + "video/x-m4v" + ], + "minduration": 5, + "startdelay": 0, + "linearity": 1, + "maxduration": 30, + "skip": 1, + "protocols": [ + 7 + ], + "skipmin": 5, + "api": [ + 7 + ] + } + } + ], + "user": { + "ext": { + } + }, + "device": { + "ua": "test-user-agent" + }, + "app": { + "publisher": { + "id": "1100042525" + }, + "id": "app-id", + "name": "app-name", + "bundle": "app-bundle", + "storeurl": "app-storeurl", + "cat": [ + "IAB3-1" + ], + "ver": "app-version", + "paid": 1, + "content": { + "id": "content-id", + "title": "content-title", + "series": "content-series", + "genre": "content-genre", + "producer": { + "id": "producer-id", + "name": "producer-name" + }, + "cat": [ + "IAB8-6" + ], + "livestream": 1, + "language": "en" + }, + "keywords": "keywords" + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "5ebea288-f13a-4754-be6d-4ade66c68877", + "seatbid": [ + { + "seat": "CM6523", + "bid": [ + { + "adm": "", + "adomain": [ + "smaato.com" + ], + "bidderName": "smaato", + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768 + } + ] + } + ], + "bidid": "04db8629-179d-4bcd-acce-e54722969006", + "cur": "USD" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "adm": "", + "adomain": [ + "smaato.com" + ], + "cid": "CM6523", + "crid": "CR69381", + "id": "6906aae8-7f74-4edd-9a4f-f49379a3cadd", + "impid": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "iurl": "https://iurl", + "nurl": "https://nurl", + "price": 0.01, + "w": 1024, + "h": 768 + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/exemplary/video.json b/adapters/smaato/smaatotest/exemplary/video.json index f2896d3d9d8..bad3825bb62 100644 --- a/adapters/smaato/smaatotest/exemplary/video.json +++ b/adapters/smaato/smaatotest/exemplary/video.json @@ -122,7 +122,7 @@ } }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json index 1fce58f0dfe..db724565d52 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-adm-response.json +++ b/adapters/smaato/smaatotest/supplemental/bad-adm-response.json @@ -125,7 +125,7 @@ "keywords": "power tools" }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json b/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json index b9560f0f9ca..768b4ef9d2c 100644 --- a/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json +++ b/adapters/smaato/smaatotest/supplemental/bad-imp-banner-format-req.json @@ -40,7 +40,7 @@ } }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } } diff --git a/adapters/smaato/smaatotest/supplemental/no-consent-info.json b/adapters/smaato/smaatotest/supplemental/no-consent-info.json index 9e0ccfdcdde..b9a4294b00b 100644 --- a/adapters/smaato/smaatotest/supplemental/no-consent-info.json +++ b/adapters/smaato/smaatotest/supplemental/no-consent-info.json @@ -72,7 +72,7 @@ } }, "ext": { - "client": "prebid_server_0.1" + "client": "prebid_server_0.2" } } }, diff --git a/adapters/smaato/smaatotest/supplemental/status-code-204.json b/adapters/smaato/smaatotest/supplemental/status-code-204.json new file mode 100644 index 00000000000..b409597f986 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/status-code-204.json @@ -0,0 +1,139 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 204 + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/smaato/smaatotest/supplemental/status-code-400.json b/adapters/smaato/smaatotest/supplemental/status-code-400.json new file mode 100644 index 00000000000..fc84c93e269 --- /dev/null +++ b/adapters/smaato/smaatotest/supplemental/status-code-400.json @@ -0,0 +1,144 @@ +{ + "mockBidRequest": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "ext": { + "data": { + "keywords": "power tools", + "search": "drill", + "content": { + "userrating": 4 + } + } + } + }, + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "banner": { + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + }, + "ext": { + "bidder": { + "publisherId": "1100042525", + "adspaceId": "130563103" + } + } + } + ], + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "user": { + "ext": { + "consent": "gdprConsentString", + "data": { + "keywords": "a,b", + "gender": "M", + "yob": 1984, + "geo": { + "country": "ca" + } + } + } + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"] + }, + "uri": "https://prebid/bidder", + "body": { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "imp": [ + { + "id": "1C86242D-9535-47D6-9576-7B1FE87F282C", + "tagid": "130563103", + "banner": { + "h": 50, + "w": 320, + "format": [ + { + "w": 320, + "h": 50 + }, + { + "w": 320, + "h": 250 + } + ] + } + } + ], + "user": { + "ext": { + "consent": "gdprConsentString" + }, + "gender": "M", + "keywords": "a,b", + "yob": 1984 + }, + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "regs": { + "coppa": 1, + "ext": { + "gdpr": 1, + "us_privacy": "uspConsentString" + } + }, + "site": { + "publisher": { + "id": "1100042525" + }, + "page": "http://localhost:3000/server.html?pbjs_debug=true&endpoint=http://localhost:3000/bidder", + "keywords": "power tools" + }, + "ext": { + "client": "prebid_server_0.2" + } + } + }, + "mockResponse": { + "status": 400 + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/smartadserver/params_test.go b/adapters/smartadserver/params_test.go index 363886d96b1..b424cbe0a1d 100644 --- a/adapters/smartadserver/params_test.go +++ b/adapters/smartadserver/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/smartadserver.json diff --git a/adapters/smartadserver/smartadserver.go b/adapters/smartadserver/smartadserver.go index 1231ab677ec..3954a00b4d5 100644 --- a/adapters/smartadserver/smartadserver.go +++ b/adapters/smartadserver/smartadserver.go @@ -8,11 +8,11 @@ import ( "path" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type SmartAdserverAdapter struct { @@ -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/smartadserver/smartadserver_test.go b/adapters/smartadserver/smartadserver_test.go index e6cf5e12b55..978be336471 100644 --- a/adapters/smartadserver/smartadserver_test.go +++ b/adapters/smartadserver/smartadserver_test.go @@ -3,9 +3,9 @@ package smartadserver import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/smartadserver/usersync.go b/adapters/smartadserver/usersync.go index cc155966c12..f7199965441 100644 --- a/adapters/smartadserver/usersync.go +++ b/adapters/smartadserver/usersync.go @@ -3,10 +3,10 @@ package smartadserver import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSmartadserverSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("smartadserver", 45, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("smartadserver", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/smartadserver/usersync_test.go b/adapters/smartadserver/usersync_test.go index aeb34dd69f9..319ce5b58a6 100644 --- a/adapters/smartadserver/usersync_test.go +++ b/adapters/smartadserver/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestSmartadserverSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ssbsync.smartadserver.com/getuid?gdpr=1&gdpr_consent=COyASAoOyASAoAfAAAENAfCAAAAAAAAAAAAAAAAAAAAA&us_privacy=1YNN&url=localhost%2Fsetuid%3Fbidder%3Dsmartadserver%26gdpr%3D1%26gdpr_consent%3DCOyASAoOyASAoAfAAAENAfCAAAAAAAAAAAAAAAAAAAAA%26uid%3D%5Bsas_uid%5D%22", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 45, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/smartrtb/smartrtb.go b/adapters/smartrtb/smartrtb.go index 0613bb6815f..e123d4eb6d2 100644 --- a/adapters/smartrtb/smartrtb.go +++ b/adapters/smartrtb/smartrtb.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) // Base adapter structure. @@ -59,15 +59,19 @@ 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 adapters.BadInput(err.Error()) + return &errortypes.BadInput{ + Message: err.Error(), + } } var src openrtb_ext.ExtImpSmartRTB if err := json.Unmarshal(ext.Bidder, &src); err != nil { - return adapters.BadInput(err.Error()) + return &errortypes.BadInput{ + Message: err.Error(), + } } if dst.PubID == "" { @@ -80,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) @@ -107,7 +111,7 @@ func (s *SmartRTBAdapter) MakeRequests(brq *openrtb.BidRequest, reqInfo *adapter } if ext.PubID == "" { - return nil, append(errs, adapters.BadInput("Cannot infer publisher ID from bid ext")) + return nil, append(errs, &errortypes.BadInput{Message: "Cannot infer publisher ID from bid ext"}) } brq.Ext, err = json.Marshal(ext) @@ -140,20 +144,20 @@ 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 { return nil, nil } else if rs.StatusCode == http.StatusBadRequest { - return nil, []error{adapters.BadInput("Invalid request.")} + return nil, []error{&errortypes.BadInput{Message: "Invalid request."}} } else if rs.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Unexpected HTTP status %d.", rs.StatusCode), }} } - 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/smartrtb_test.go b/adapters/smartrtb/smartrtb_test.go index 1d592dfc6d8..ef5fce668f4 100644 --- a/adapters/smartrtb/smartrtb_test.go +++ b/adapters/smartrtb/smartrtb_test.go @@ -3,9 +3,9 @@ package smartrtb import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/smartrtb/smartrtbtest/supplemental/empty-imps.json b/adapters/smartrtb/smartrtbtest/supplemental/empty-imps.json index 1c951dd9f8e..2ba12019f41 100644 --- a/adapters/smartrtb/smartrtbtest/supplemental/empty-imps.json +++ b/adapters/smartrtb/smartrtbtest/supplemental/empty-imps.json @@ -13,4 +13,4 @@ }, "httpCalls": [], "expectedBidResponses": [] -} +} \ No newline at end of file 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/smartrtb/usersync.go b/adapters/smartrtb/usersync.go index 1148dcc1584..74ef0e9960b 100644 --- a/adapters/smartrtb/usersync.go +++ b/adapters/smartrtb/usersync.go @@ -3,10 +3,10 @@ package smartrtb import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSmartRTBSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("smartrtb", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("smartrtb", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/smartrtb/usersync_test.go b/adapters/smartrtb/usersync_test.go index 6fa5c837296..68a8452a316 100644 --- a/adapters/smartrtb/usersync_test.go +++ b/adapters/smartrtb/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -15,6 +15,5 @@ func TestSmartRTBSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://market-east.smrtb.com/sync/all?nid=smartrtb&gdpr=&gdpr_consent=&url=localhost%2Fsetuid%3Fbidder%smartrtb%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/smartyads/params_test.go b/adapters/smartyads/params_test.go index 048989a2c40..3aa5c0e837d 100644 --- a/adapters/smartyads/params_test.go +++ b/adapters/smartyads/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) var validParams = []string{ diff --git a/adapters/smartyads/smartyads.go b/adapters/smartyads/smartyads.go index 93a94a74568..b5a09223eb0 100644 --- a/adapters/smartyads/smartyads.go +++ b/adapters/smartyads/smartyads.go @@ -7,12 +7,12 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type SmartyAdsAdapter struct { @@ -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/smartyads/smartyads_test.go b/adapters/smartyads/smartyads_test.go index dae8e2a0726..4ea20e98c74 100644 --- a/adapters/smartyads/smartyads_test.go +++ b/adapters/smartyads/smartyads_test.go @@ -3,9 +3,9 @@ package smartyads import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/smartyads/smartyadstest/exemplary/banner-app.json b/adapters/smartyads/smartyadstest/exemplary/banner-app.json index 4d913fd91f0..56052236310 100644 --- a/adapters/smartyads/smartyadstest/exemplary/banner-app.json +++ b/adapters/smartyads/smartyadstest/exemplary/banner-app.json @@ -159,4 +159,4 @@ } ] } - + \ No newline at end of file diff --git a/adapters/smartyads/smartyadstest/exemplary/native-app.json b/adapters/smartyads/smartyadstest/exemplary/native-app.json index 73bdb8d7f3a..c14beb550ee 100644 --- a/adapters/smartyads/smartyadstest/exemplary/native-app.json +++ b/adapters/smartyads/smartyadstest/exemplary/native-app.json @@ -157,4 +157,4 @@ } ] } - + \ No newline at end of file diff --git a/adapters/smartyads/usersync.go b/adapters/smartyads/usersync.go index d394fb730b0..9075aa9bcd7 100644 --- a/adapters/smartyads/usersync.go +++ b/adapters/smartyads/usersync.go @@ -3,10 +3,10 @@ package smartyads import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSmartyAdsSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("smartyads", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("smartyads", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/smartyads/usersync_test.go b/adapters/smartyads/usersync_test.go index 6ea8aa81846..4f94591c634 100644 --- a/adapters/smartyads/usersync_test.go +++ b/adapters/smartyads/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -29,6 +29,5 @@ func TestSmartyAdsSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://as.ck-ie.com/prebid.gif?gdpr=0&gdpr_consent=ANDFJDS&us_privacy=1-YY&redir=http%3A%2F%2Flocalhost%3A8000%2Fsetuid%3Fbidder%3Dsmartyads%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/somoaudience/params_test.go b/adapters/somoaudience/params_test.go index b74725aac21..2cbb2b1f51a 100644 --- a/adapters/somoaudience/params_test.go +++ b/adapters/somoaudience/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/somoaudience.json diff --git a/adapters/somoaudience/somoaudience.go b/adapters/somoaudience/somoaudience.go index 2e096dfe1b3..1e807bb2370 100644 --- a/adapters/somoaudience/somoaudience.go +++ b/adapters/somoaudience/somoaudience.go @@ -6,12 +6,11 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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" ) 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/somoaudience/somoaudience_test.go b/adapters/somoaudience/somoaudience_test.go index 3f3ce8c6ca9..07a1d2b3b65 100644 --- a/adapters/somoaudience/somoaudience_test.go +++ b/adapters/somoaudience/somoaudience_test.go @@ -3,9 +3,9 @@ package somoaudience import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/somoaudience/usersync.go b/adapters/somoaudience/usersync.go index 2d0b715d669..5d1ddd71bc6 100644 --- a/adapters/somoaudience/usersync.go +++ b/adapters/somoaudience/usersync.go @@ -3,10 +3,10 @@ package somoaudience import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSomoaudienceSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("somoaudience", 341, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("somoaudience", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/somoaudience/usersync_test.go b/adapters/somoaudience/usersync_test.go index 9abcc65e748..2367a5674dd 100644 --- a/adapters/somoaudience/usersync_test.go +++ b/adapters/somoaudience/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestSomoaudienceSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//publisher-east.mobileadtrading.com/usersync?ru=localhost%2Fsetuid%3Fbidder%3Dsomoaudience%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24%7BUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 341, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/sonobi/params_test.go b/adapters/sonobi/params_test.go index 00fe63c6b6e..3e9d63e8101 100644 --- a/adapters/sonobi/params_test.go +++ b/adapters/sonobi/params_test.go @@ -2,7 +2,7 @@ package sonobi import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/sonobi/sonobi.go b/adapters/sonobi/sonobi.go index 3deebbbd9d4..690d5f59f67 100644 --- a/adapters/sonobi/sonobi.go +++ b/adapters/sonobi/sonobi.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // SonobiAdapter - Sonobi SonobiAdapter definition @@ -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/sonobi/sonobi_test.go b/adapters/sonobi/sonobi_test.go index 7a5d94bd5ac..7e8f2dc2916 100644 --- a/adapters/sonobi/sonobi_test.go +++ b/adapters/sonobi/sonobi_test.go @@ -3,9 +3,9 @@ package sonobi import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/sonobi/usersync.go b/adapters/sonobi/usersync.go index 6ac950563bc..6fedd8bfa05 100644 --- a/adapters/sonobi/usersync.go +++ b/adapters/sonobi/usersync.go @@ -1,11 +1,12 @@ package sonobi import ( - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSonobiSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("sonobi", 104, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("sonobi", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/sonobi/usersync_test.go b/adapters/sonobi/usersync_test.go index 8eadaef8f9c..995c3757ba4 100644 --- a/adapters/sonobi/usersync_test.go +++ b/adapters/sonobi/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestSonobiSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.go.sonobi.com/us.gif?loc=external.com%2Fsetuid%3Fbidder%3Dsonobi%26consent_string%3D0%26gdpr%3D%26uid%3D%5BUID%5D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 104, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/sovrn/sovrn.go b/adapters/sovrn/sovrn.go index 24920fa7998..be1c2221ae5 100644 --- a/adapters/sovrn/sovrn.go +++ b/adapters/sovrn/sovrn.go @@ -12,12 +12,12 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" + "github.com/mxmCherry/openrtb/v15/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" ) @@ -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 5f43c1a569f..c3290c30a2b 100644 --- a/adapters/sovrn/sovrn_test.go +++ b/adapters/sovrn/sovrn_test.go @@ -8,10 +8,10 @@ import ( "net/http/httptest" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" "context" "net/http" @@ -19,10 +19,10 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/config" ) func TestJsonSamples(t *testing.T) { @@ -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/sovrn/usersync.go b/adapters/sovrn/usersync.go index 3f4e81439c6..225f2888196 100644 --- a/adapters/sovrn/usersync.go +++ b/adapters/sovrn/usersync.go @@ -3,10 +3,10 @@ package sovrn import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSovrnSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("sovrn", 13, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("sovrn", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/sovrn/usersync_test.go b/adapters/sovrn/usersync_test.go index e91c73245bb..6c35ecdb05d 100644 --- a/adapters/sovrn/usersync_test.go +++ b/adapters/sovrn/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestSovrnSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ap.lijit.com/pixel?redir=external.com%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 13, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/spotx/params_test.go b/adapters/spotx/params_test.go index 6212fef3bec..de96ebe7953 100644 --- a/adapters/spotx/params_test.go +++ b/adapters/spotx/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestSpotxParams(t *testing.T) { diff --git a/adapters/spotx/spotx.go b/adapters/spotx/spotx.go index 6b9c4ff2ea1..92d12c82d90 100644 --- a/adapters/spotx/spotx.go +++ b/adapters/spotx/spotx.go @@ -6,18 +6,18 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type Adapter struct { url string } -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 adapterRequests []*adapters.RequestData @@ -42,7 +42,7 @@ func (a *Adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex return adapterRequests, errs } -func makeRequest(a *Adapter, originalReq *openrtb.BidRequest, imp openrtb.Imp) (*adapters.RequestData, []error) { +func makeRequest(a *Adapter, originalReq *openrtb2.BidRequest, imp openrtb2.Imp) (*adapters.RequestData, []error) { var errs []error var bidderExt adapters.ExtImpBidder @@ -113,12 +113,12 @@ func makeRequest(a *Adapter, originalReq *openrtb.BidRequest, imp openrtb.Imp) ( return &adapters.RequestData{ Method: "POST", Uri: fmt.Sprintf("%s/%s", a.url, spotxExt.ChannelID), - Body: reqJSON, //TODO: This is a custom request struct, other adapters are sending this openrtb.BidRequest + Body: reqJSON, //TODO: This is a custom request struct, other adapters are sending this openrtb2.BidRequest Headers: headers, }, errs } -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 } @@ -135,7 +135,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} } @@ -155,7 +155,7 @@ func (a *Adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest return bidResponse, 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 && imp.Video != nil { return openrtb_ext.BidTypeVideo, nil diff --git a/adapters/spotx/spotx_test.go b/adapters/spotx/spotx_test.go index a6641b27c0f..d516f39b8a2 100644 --- a/adapters/spotx/spotx_test.go +++ b/adapters/spotx/spotx_test.go @@ -2,9 +2,9 @@ package spotx import ( "encoding/json" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" "github.com/magiconair/properties/assert" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" "testing" ) @@ -23,12 +23,12 @@ func TestSpotxMakeBid(t *testing.T) { } }`) - request := &openrtb.BidRequest{ + request := &openrtb2.BidRequest{ ID: "1559039248176", - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: "28635736ddc2bb", - Video: &openrtb.Video{ + Video: &openrtb2.Video{ MIMEs: []string{"video/3gpp"}, }, Secure: &secure, diff --git a/adapters/synacormedia/params_test.go b/adapters/synacormedia/params_test.go index d7585c9d58c..a216818e382 100644 --- a/adapters/synacormedia/params_test.go +++ b/adapters/synacormedia/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/synacormedia.json diff --git a/adapters/synacormedia/synacormedia.go b/adapters/synacormedia/synacormedia.go index e87c665da59..aec3169fe54 100644 --- a/adapters/synacormedia/synacormedia.go +++ b/adapters/synacormedia/synacormedia.go @@ -6,12 +6,12 @@ import ( "net/http" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type SynacorMediaAdapter struct { @@ -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/synacormedia_test.go b/adapters/synacormedia/synacormedia_test.go index ce696a67ee1..6a018dc3287 100644 --- a/adapters/synacormedia/synacormedia_test.go +++ b/adapters/synacormedia/synacormedia_test.go @@ -3,9 +3,9 @@ package synacormedia import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) 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/synacormedia/usersync.go b/adapters/synacormedia/usersync.go index d7de9150744..c7fa5c42aea 100644 --- a/adapters/synacormedia/usersync.go +++ b/adapters/synacormedia/usersync.go @@ -3,10 +3,10 @@ package synacormedia import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewSynacorMediaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("synacormedia", 0, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("synacormedia", temp, adapters.SyncTypeIframe) } diff --git a/adapters/synacormedia/usersync_test.go b/adapters/synacormedia/usersync_test.go index 7ee7b1aa19b..ce45353c7e5 100644 --- a/adapters/synacormedia/usersync_test.go +++ b/adapters/synacormedia/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestSynacormediaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.technoratimedia.com/services?srv=cs&pid=70&cb=localhost%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.False(t, syncInfo.SupportCORS) } diff --git a/adapters/syncer.go b/adapters/syncer.go index 13985db6275..b9752b50ce1 100644 --- a/adapters/syncer.go +++ b/adapters/syncer.go @@ -3,35 +3,22 @@ package adapters import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/usersync" ) -func GDPRAwareSyncerIDs(syncers map[openrtb_ext.BidderName]usersync.Usersyncer) map[openrtb_ext.BidderName]uint16 { - gdprAwareSyncers := make(map[openrtb_ext.BidderName]uint16, len(syncers)) - for bidderName, syncer := range syncers { - if syncer.GDPRVendorID() != 0 { - gdprAwareSyncers[bidderName] = syncer.GDPRVendorID() - } - } - return gdprAwareSyncers -} - type Syncer struct { - familyName string - gdprVendorID uint16 - urlTemplate *template.Template - syncType SyncType + familyName string + syncType SyncType + urlTemplate *template.Template } -func NewSyncer(familyName string, vendorID uint16, urlTemplate *template.Template, syncType SyncType) *Syncer { +func NewSyncer(familyName string, urlTemplate *template.Template, syncType SyncType) *Syncer { return &Syncer{ - familyName: familyName, - gdprVendorID: vendorID, - urlTemplate: urlTemplate, - syncType: syncType, + familyName: familyName, + urlTemplate: urlTemplate, + syncType: syncType, } } @@ -62,7 +49,3 @@ func (s *Syncer) GetUsersyncInfo(privacyPolicies privacy.Policies) (*usersync.Us func (s *Syncer) FamilyName() string { return s.familyName } - -func (s *Syncer) GDPRVendorID() uint16 { - return s.gdprVendorID -} diff --git a/adapters/syncer_test.go b/adapters/syncer_test.go index 7961608c29d..ca33a9a130d 100644 --- a/adapters/syncer_test.go +++ b/adapters/syncer_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) diff --git a/adapters/tagbidder/bidder_macro.go b/adapters/tagbidder/bidder_macro.go index 68f883eb243..33f5e541eea 100644 --- a/adapters/tagbidder/bidder_macro.go +++ b/adapters/tagbidder/bidder_macro.go @@ -3,16 +3,16 @@ package tagbidder import ( "encoding/json" "fmt" + "github.com/mxmCherry/openrtb/v15/openrtb2" "net/http" "strconv" "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/openrtb" ) //BidderMacro default implementation @@ -24,12 +24,12 @@ type BidderMacro struct { //BidderConf *BidderConfig //OpenRTB Specific Parameters - Request *openrtb.BidRequest + Request *openrtb2.BidRequest IsApp bool HasGeo bool - Imp *openrtb.Imp - Publisher *openrtb.Publisher - Content *openrtb.Content + Imp *openrtb2.Imp + Publisher *openrtb2.Publisher + Content *openrtb2.Content UserExt *openrtb_ext.ExtUser RegsExt *openrtb_ext.ExtRegs } @@ -70,13 +70,13 @@ func (tag *BidderMacro) init() { } //InitBidRequest will initialise BidRequest -func (tag *BidderMacro) InitBidRequest(request *openrtb.BidRequest) { +func (tag *BidderMacro) InitBidRequest(request *openrtb2.BidRequest) { tag.Request = request tag.init() } //LoadImpression will set current imp -func (tag *BidderMacro) LoadImpression(imp *openrtb.Imp) error { +func (tag *BidderMacro) LoadImpression(imp *openrtb2.Imp) error { tag.Imp = imp return nil } diff --git a/adapters/tagbidder/ibidder_macro.go b/adapters/tagbidder/ibidder_macro.go index baf83cdb77a..9456b651b2c 100644 --- a/adapters/tagbidder/ibidder_macro.go +++ b/adapters/tagbidder/ibidder_macro.go @@ -2,10 +2,10 @@ package tagbidder import ( "errors" + "github.com/mxmCherry/openrtb/v15/openrtb2" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/config" ) //Flags of each tag bidder @@ -16,8 +16,8 @@ type Flags struct { //IBidderMacro interface will capture all macro definition type IBidderMacro interface { //Helper Function - InitBidRequest(request *openrtb.BidRequest) - LoadImpression(imp *openrtb.Imp) error + InitBidRequest(request *openrtb2.BidRequest) + LoadImpression(imp *openrtb2.Imp) error GetBidderKeys() map[string]string SetAdapterConfig(*config.Adapter) //SetBidderConfig(*BidderConfig) diff --git a/adapters/tagbidder/itag_response_handler.go b/adapters/tagbidder/itag_response_handler.go index d58cfa2a1b1..227984d3632 100644 --- a/adapters/tagbidder/itag_response_handler.go +++ b/adapters/tagbidder/itag_response_handler.go @@ -2,15 +2,15 @@ package tagbidder import ( "errors" + "github.com/mxmCherry/openrtb/v15/openrtb2" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters" ) //ITagResponseHandler parse bidder response type ITagResponseHandler interface { - Validate(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) []error - MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) + Validate(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) []error + MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) } //GetResponseHandler returns response handler diff --git a/adapters/tagbidder/tagbidder.go b/adapters/tagbidder/tagbidder.go index c12037ab4cd..30d1c69cd29 100644 --- a/adapters/tagbidder/tagbidder.go +++ b/adapters/tagbidder/tagbidder.go @@ -3,11 +3,11 @@ package tagbidder import ( "errors" "fmt" + "github.com/mxmCherry/openrtb/v15/openrtb2" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) //TagBidder is default implementation of ITagBidder @@ -40,7 +40,7 @@ func NewTestTagBidder(bidderName openrtb_ext.BidderName, config config.Adapter) } //MakeRequests will contains default definition for processing queries -func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TagBidder) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { bidderMacro, err := GetNewBidderMacro(a.bidderName) if nil != err { return nil, []error{err} @@ -85,7 +85,7 @@ func (a *TagBidder) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters. } //MakeBids makes bids -func (a *TagBidder) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TagBidder) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { //response validation can be done here independently //handler, err := GetResponseHandler(a.bidderConfig.ResponseType) handler, err := GetResponseHandler(VASTTagResponseHandlerType) diff --git a/adapters/tagbidder/vast_tag_response_handler.go b/adapters/tagbidder/vast_tag_response_handler.go index 34244501293..9d3aaeb3730 100644 --- a/adapters/tagbidder/vast_tag_response_handler.go +++ b/adapters/tagbidder/vast_tag_response_handler.go @@ -3,15 +3,15 @@ package tagbidder import ( "errors" "fmt" + "github.com/mxmCherry/openrtb/v15/openrtb2" "net/http" "regexp" "strconv" "time" "github.com/PubMatic-OpenWrap/etree" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/openrtb_ext" ) var durationRegExp = regexp.MustCompile(`^([01]?\d|2[0-3]):([0-5]?\d):([0-5]?\d)(\.(\d{1,3}))?$`) @@ -33,7 +33,7 @@ func NewVASTTagResponseHandler() *VASTTagResponseHandler { } //Validate will return bids -func (handler *VASTTagResponseHandler) Validate(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) []error { +func (handler *VASTTagResponseHandler) Validate(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) []error { if response.StatusCode != http.StatusOK { return []error{errors.New(`validation failed`)} } @@ -41,7 +41,7 @@ func (handler *VASTTagResponseHandler) Validate(internalRequest *openrtb.BidRequ } //MakeBids will return bids -func (handler *VASTTagResponseHandler) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (handler *VASTTagResponseHandler) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if err := handler.Validate(internalRequest, externalRequest, response); len(err) > 0 { return nil, err[:] } @@ -56,7 +56,7 @@ func (handler *VASTTagResponseHandler) ParseExtension(version string, ad *etree. return nil } -func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error doc := etree.NewDocument() @@ -82,7 +82,7 @@ func (handler *VASTTagResponseHandler) vastTagToBidderResponse(internalRequest * } typedBid := &adapters.TypedBid{ - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeVideo, BidVideo: &openrtb_ext.ExtBidPrebidVideo{}, } diff --git a/adapters/tagbidder/vast_tag_response_handler_test.go b/adapters/tagbidder/vast_tag_response_handler_test.go index 80d7836cd80..64674719688 100644 --- a/adapters/tagbidder/vast_tag_response_handler_test.go +++ b/adapters/tagbidder/vast_tag_response_handler_test.go @@ -2,21 +2,21 @@ package tagbidder import ( "errors" + "github.com/mxmCherry/openrtb/v15/openrtb2" "testing" "github.com/PubMatic-OpenWrap/etree" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters" ) func TestVASTTagResponseHandler_vastTagToBidderResponse(t *testing.T) { type args struct { - internalRequest *openrtb.BidRequest + internalRequest *openrtb2.BidRequest externalRequest *adapters.RequestData response *adapters.ResponseData } @@ -32,9 +32,9 @@ func TestVASTTagResponseHandler_vastTagToBidderResponse(t *testing.T) { { name: `InlinePricingNode`, args: args{ - internalRequest: &openrtb.BidRequest{ + internalRequest: &openrtb2.BidRequest{ ID: `request_id_1`, - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ { ID: `imp_id_1`, }, @@ -51,7 +51,7 @@ func TestVASTTagResponseHandler_vastTagToBidderResponse(t *testing.T) { bidderResponse: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ ID: `1234`, ImpID: `imp_id_1`, Price: 0.05, diff --git a/adapters/tappx/params_test.go b/adapters/tappx/params_test.go index d6fcbb9cff6..3a73d4dab53 100644 --- a/adapters/tappx/params_test.go +++ b/adapters/tappx/params_test.go @@ -2,7 +2,7 @@ package tappx import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/tappx/tappx.go b/adapters/tappx/tappx.go index 2e044e82bb9..5970ccb6cfe 100644 --- a/adapters/tappx/tappx.go +++ b/adapters/tappx/tappx.go @@ -6,18 +6,19 @@ import ( "net/http" "net/url" "strconv" + "strings" "text/template" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) -const TAPPX_BIDDER_VERSION = "1.1" +const TAPPX_BIDDER_VERSION = "1.2" const TYPE_CNN = "prebid" type TappxAdapter struct { @@ -37,7 +38,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", @@ -126,7 +127,9 @@ func (a *TappxAdapter) buildEndpointURL(params *openrtb_ext.ExtImpTappx, test in } } - thisURI.Path += params.Endpoint + if !(strings.Contains(strings.ToLower(thisURI.Host), strings.ToLower(params.Endpoint))) { + thisURI.Path += params.Endpoint //Now version is backward compatible. In future, this condition and content will be delete + } queryParams := url.Values{} @@ -146,7 +149,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 +164,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 +184,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/tappx/tappx_test.go b/adapters/tappx/tappx_test.go index 465828b0bdf..10e57d12132 100644 --- a/adapters/tappx/tappx_test.go +++ b/adapters/tappx/tappx_test.go @@ -4,15 +4,15 @@ import ( "regexp" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderTappx, config.Adapter{ - Endpoint: "https://{{.Host}}"}) + Endpoint: "http://{{.Host}}"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) @@ -30,7 +30,7 @@ func TestEndpointTemplateMalformed(t *testing.T) { func TestTsValue(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderTappx, config.Adapter{ - Endpoint: "https://{{.Host}}"}) + Endpoint: "http://{{.Host}}"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) @@ -47,7 +47,7 @@ func TestTsValue(t *testing.T) { url, err := bidderTappx.buildEndpointURL(&tappxExt, test) - match, err := regexp.MatchString(`https://example\.host\.tappx\.com/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.1`, url) + match, err := regexp.MatchString(`http://example\.host\.tappx\.com/DUMMYENDPOINT\?tappxkey=dummy-tappx-key&ts=[0-9]{13}&type_cnn=prebid&v=1\.2`, url) if err != nil { t.Errorf("Error while running regex validation: %s", err.Error()) return diff --git a/adapters/tappx/tappxtest/exemplary/single-banner-impression-future-feature.json b/adapters/tappx/tappxtest/exemplary/single-banner-impression-future-feature.json new file mode 100644 index 00000000000..3c3037afefb --- /dev/null +++ b/adapters/tappx/tappxtest/exemplary/single-banner-impression-future-feature.json @@ -0,0 +1,116 @@ +{ + "mockBidRequest": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "adunit-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "tappxkey": "pub-12345-android-9876", + "endpoint": "ZZ123456PS", + "host": "ZZ123456PS.ssp.tappx.com/rtb/" + } + } + } + ], + "app": { + "id": "app_001", + "bundle": "com.rovio.angrybirds", + "publisher": { + "id": "2" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://ZZ123456PS.ssp.tappx.com/rtb/?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", + "body": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "adunit-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "tappxkey": "pub-12345-android-9876", + "endpoint": "ZZ123456PS", + "host": "ZZ123456PS.ssp.tappx.com/rtb/" + } + } + } + ], + "app": { + "bundle": "com.rovio.angrybirds", + "id": "app_001", + "publisher": { + "id": "2" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "75472df2-1cb3-4f8e-9a28-10cb95fe05a4", + "seatbid": [{ + "bid": [{ + "id": "wehM-93KGr0_0_0", + "impid": "adunit-1", + "price": 0.5, + "cid": "3706", + "crid": "19005", + "adid": "19005", + "adm": "", + "cat": ["IAB2"], + "adomain": ["test.com"], + "h": 250, + "w": 300 + }] + }], + "bidid": "wehM-93KGr0" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "wehM-93KGr0_0_0", + "impid": "adunit-1", + "price": 0.5, + "adm": "", + "adid": "19005", + "adomain": ["test.com"], + "cid": "3706", + "crid": "19005", + "w": 300, + "h": 250, + "cat": ["IAB2"] + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/tappx/tappxtest/exemplary/single-banner-impression.json b/adapters/tappx/tappxtest/exemplary/single-banner-impression.json index 3a365db645e..54f472d9fff 100644 --- a/adapters/tappx/tappxtest/exemplary/single-banner-impression.json +++ b/adapters/tappx/tappxtest/exemplary/single-banner-impression.json @@ -12,8 +12,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } @@ -33,7 +33,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -47,8 +47,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/exemplary/single-banner-site.json b/adapters/tappx/tappxtest/exemplary/single-banner-site.json new file mode 100644 index 00000000000..58490233ede --- /dev/null +++ b/adapters/tappx/tappxtest/exemplary/single-banner-site.json @@ -0,0 +1,124 @@ +{ + "mockBidRequest": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "adunit-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "tappxkey": "pub-12345-site-9876", + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" + } + } + } + ], + "site": { + "id": "102855", + "cat": [ "IAB3-1" ], + "domain": "www.tappx.com", + "page": "https://www.tappx.com/example.html ", + "publisher": { + "id": "8953", "name": "publisher.com", + "cat": [ "IAB3-1" ], + "domain": "publisher.com" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.2", + "body": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "adunit-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "tappxkey": "pub-12345-site-9876", + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" + } + } + } + ], + "site": { + "id": "102855", + "cat": [ "IAB3-1" ], + "domain": "www.tappx.com", + "page": "https://www.tappx.com/example.html ", + "publisher": { + "id": "8953", "name": "publisher.com", + "cat": [ "IAB3-1" ], + "domain": "publisher.com" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "75472df2-1cb3-4f8e-9a28-10cb95fe05a4", + "seatbid": [{ + "bid": [{ + "id": "wehM-93KGr0_0_0", + "impid": "adunit-1", + "price": 0.5, + "cid": "3706", + "crid": "19005", + "adid": "19005", + "adm": "", + "cat": ["IAB2"], + "adomain": ["test.com"], + "h": 250, + "w": 300 + }] + }], + "bidid": "wehM-93KGr0" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "wehM-93KGr0_0_0", + "impid": "adunit-1", + "price": 0.5, + "adm": "", + "adid": "19005", + "adomain": ["test.com"], + "cid": "3706", + "crid": "19005", + "w": 300, + "h": 250, + "cat": ["IAB2"] + }, + "type": "banner" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/tappx/tappxtest/exemplary/single-video-impression.json b/adapters/tappx/tappxtest/exemplary/single-video-impression.json index 49cb3c7e568..d6ce0554c5f 100644 --- a/adapters/tappx/tappxtest/exemplary/single-video-impression.json +++ b/adapters/tappx/tappxtest/exemplary/single-video-impression.json @@ -15,8 +15,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "VZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } @@ -35,7 +35,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -51,8 +51,8 @@ }, "ext": { "bidder": { - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com", + "endpoint": "VZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/", "tappxkey": "pub-12345-android-9876" } } diff --git a/adapters/tappx/tappxtest/exemplary/single-video-site.json b/adapters/tappx/tappxtest/exemplary/single-video-site.json new file mode 100644 index 00000000000..f151151e776 --- /dev/null +++ b/adapters/tappx/tappxtest/exemplary/single-video-site.json @@ -0,0 +1,136 @@ +{ + "mockBidRequest": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "video-adunit-2", + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "tappxkey": "pub-12345-site-9876", + "endpoint": "VZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" + } + } + } + ], + "site": { + "id": "102855", + "cat": [ "IAB3-1" ], + "domain": "www.tappx.com", + "page": "https://www.tappx.com/example.html ", + "publisher": { + "id": "8953", "name": "publisher.com", + "cat": [ "IAB3-1" ], + "domain": "publisher.com" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://testing.ssp.tappx.com/rtb/v2/VZ123456PS?tappxkey=pub-12345-site-9876&type_cnn=prebid&v=1.2", + "body": { + "id": "0000000000001", + "test": 1, + "imp": [ + { + "id": "video-adunit-2", + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { + "endpoint": "VZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/", + "tappxkey": "pub-12345-site-9876" + } + } + } + ], + "site": { + "id": "102855", + "cat": [ "IAB3-1" ], + "domain": "www.tappx.com", + "page": "https://www.tappx.com/example.html ", + "publisher": { + "id": "8953", "name": "publisher.com", + "cat": [ "IAB3-1" ], + "domain": "publisher.com" + } + }, + "user": { + "buyeruid": "A-38327932832" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "75472df2-1cb3-4f8e-9a28-10cb95fe05a4", + "seatbid": [ + { + "bid": [ + { + "id": "bid02", + "impid": "video-adunit-2", + "price": 2.25, + "cid": "1001", + "crid": "2002", + "adid": "2002", + "adm": "", + "cat": [ + "IAB2" + ], + "adomain": [ + "video-example.com" + ] + } + ] + } + ], + "bidid": "wehM-93KGr0" + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid02", + "impid": "video-adunit-2", + "price": 2.25, + "adm": "", + "adomain": [ + "video-example.com" + ], + "cid": "1001", + "adid": "2002", + "crid": "2002", + "cat": [ + "IAB2" + ] + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/tappx/tappxtest/params/race/banner.json b/adapters/tappx/tappxtest/params/race/banner.json index 4c2ec640ff5..9264443a5ca 100644 --- a/adapters/tappx/tappxtest/params/race/banner.json +++ b/adapters/tappx/tappxtest/params/race/banner.json @@ -1,5 +1,5 @@ { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } \ No newline at end of file diff --git a/adapters/tappx/tappxtest/params/race/video.json b/adapters/tappx/tappxtest/params/race/video.json index 4c2ec640ff5..438543f2362 100644 --- a/adapters/tappx/tappxtest/params/race/video.json +++ b/adapters/tappx/tappxtest/params/race/video.json @@ -1,5 +1,5 @@ { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "VZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } \ No newline at end of file diff --git a/adapters/tappx/tappxtest/supplemental/204status.json b/adapters/tappx/tappxtest/supplemental/204status.json index 288837b7b91..1c72cc90f24 100644 --- a/adapters/tappx/tappxtest/supplemental/204status.json +++ b/adapters/tappx/tappxtest/supplemental/204status.json @@ -12,8 +12,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } @@ -30,7 +30,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -44,8 +44,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/supplemental/banner-impression-badhost.json b/adapters/tappx/tappxtest/supplemental/banner-impression-badhost.json index c82d0e852f3..12f9c54ae02 100644 --- a/adapters/tappx/tappxtest/supplemental/banner-impression-badhost.json +++ b/adapters/tappx/tappxtest/supplemental/banner-impression-badhost.json @@ -11,7 +11,7 @@ "ext": { "bidder": { "host": "example.ho%st.tappx.com", - "endpoint": "PREBIDTEMPLATE", + "endpoint": "ZZ123456PS", "tappxkey": "pub-12345-android-9876" } } @@ -31,7 +31,7 @@ "expectedMakeRequestsErrors": [ { - "value": "Malformed URL: parse (\\\")?https://example\\.ho%st\\.tappx.com(\\\")?: invalid URL escape \\\"%st\\\"", + "value": "Malformed URL: parse (\\\")?http://example\\.ho%st\\.tappx.com(\\\")?: invalid URL escape \\\"%st\\\"", "comparison": "regex" } ] diff --git a/adapters/tappx/tappxtest/supplemental/banner-impression-noendpoint.json b/adapters/tappx/tappxtest/supplemental/banner-impression-noendpoint.json index 9a49c8b05a0..85370b4b07c 100644 --- a/adapters/tappx/tappxtest/supplemental/banner-impression-noendpoint.json +++ b/adapters/tappx/tappxtest/supplemental/banner-impression-noendpoint.json @@ -11,7 +11,7 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "host": "test.tappx.com" + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/supplemental/banner-impression-nohost.json b/adapters/tappx/tappxtest/supplemental/banner-impression-nohost.json index ffe0f14f949..df650dde39a 100644 --- a/adapters/tappx/tappxtest/supplemental/banner-impression-nohost.json +++ b/adapters/tappx/tappxtest/supplemental/banner-impression-nohost.json @@ -10,7 +10,7 @@ }, "ext": { "bidder": { - "endpoint": "PREBIDTEMPLATE", + "endpoint": "ZZ123456PS", "tappxkey": "pub-12345-android-9876" } } diff --git a/adapters/tappx/tappxtest/supplemental/banner-impression-nokey.json b/adapters/tappx/tappxtest/supplemental/banner-impression-nokey.json index 2bc147ec07f..4dba6d3b366 100644 --- a/adapters/tappx/tappxtest/supplemental/banner-impression-nokey.json +++ b/adapters/tappx/tappxtest/supplemental/banner-impression-nokey.json @@ -10,8 +10,8 @@ }, "ext": { "bidder": { - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/supplemental/bidfloor.json b/adapters/tappx/tappxtest/supplemental/bidfloor.json index 61e96a442a0..093f77adfc6 100644 --- a/adapters/tappx/tappxtest/supplemental/bidfloor.json +++ b/adapters/tappx/tappxtest/supplemental/bidfloor.json @@ -12,8 +12,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com", + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/", "bidfloor": 1.5 } } @@ -34,7 +34,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -49,8 +49,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com", + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/", "bidfloor": 1.5 } } diff --git a/adapters/tappx/tappxtest/supplemental/http-err-status.json b/adapters/tappx/tappxtest/supplemental/http-err-status.json index c2db2e1eea8..a80a5eaa675 100644 --- a/adapters/tappx/tappxtest/supplemental/http-err-status.json +++ b/adapters/tappx/tappxtest/supplemental/http-err-status.json @@ -12,8 +12,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } @@ -30,7 +30,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -44,8 +44,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/supplemental/http-err-status2.json b/adapters/tappx/tappxtest/supplemental/http-err-status2.json index b09ee26b68e..41dcc26d653 100644 --- a/adapters/tappx/tappxtest/supplemental/http-err-status2.json +++ b/adapters/tappx/tappxtest/supplemental/http-err-status2.json @@ -12,8 +12,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } @@ -30,7 +30,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "https://test.tappx.com/PREBIDTEMPLATE?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.1", + "uri": "http://testing.ssp.tappx.com/rtb/v2/ZZ123456PS?tappxkey=pub-12345-android-9876&type_cnn=prebid&v=1.2", "body": { "id": "0000000000001", "test": 1, @@ -44,8 +44,8 @@ "ext": { "bidder": { "tappxkey": "pub-12345-android-9876", - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/tappxtest/supplemental/wrong-imp-ext-1.json b/adapters/tappx/tappxtest/supplemental/wrong-imp-ext-1.json index 1cbd3eefda1..1404204eaf1 100644 --- a/adapters/tappx/tappxtest/supplemental/wrong-imp-ext-1.json +++ b/adapters/tappx/tappxtest/supplemental/wrong-imp-ext-1.json @@ -11,8 +11,8 @@ "ext": { "bidder": { "tappxkey": 1, - "endpoint": "PREBIDTEMPLATE", - "host": "test.tappx.com" + "endpoint": "ZZ123456PS", + "host": "testing.ssp.tappx.com/rtb/v2/" } } } diff --git a/adapters/tappx/usersync.go b/adapters/tappx/usersync.go new file mode 100644 index 00000000000..01477c35363 --- /dev/null +++ b/adapters/tappx/usersync.go @@ -0,0 +1,12 @@ +package tappx + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewTappxSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("tappx", temp, adapters.SyncTypeIframe) +} diff --git a/adapters/tappx/usersync_test.go b/adapters/tappx/usersync_test.go new file mode 100644 index 00000000000..992a35de9a8 --- /dev/null +++ b/adapters/tappx/usersync_test.go @@ -0,0 +1,34 @@ +package tappx + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) + +func TestTappxSyncer(t *testing.T) { + syncURL := "//testing.ssp.tappx.com/cs/usersync.php?gdpr_optin={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&type=iframe&ruid=localhost%2Fsetuid%3Fbidder%3Dtappx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7BTPPXUID%7D%7D" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewTappxSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "1", + Consent: "A", + }, + CCPA: ccpa.Policy{ + Consent: "1YNN", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "//testing.ssp.tappx.com/cs/usersync.php?gdpr_optin=1&gdpr_consent=A&us_privacy=1YNN&type=iframe&ruid=localhost%2Fsetuid%3Fbidder%3Dtappx%26gdpr%3D1%26gdpr_consent%3DA%26uid%3D%7B%7BTPPXUID%7D%7D", syncInfo.URL) + assert.Equal(t, "iframe", syncInfo.Type) + assert.Equal(t, false, syncInfo.SupportCORS) +} diff --git a/adapters/telaria/params_test.go b/adapters/telaria/params_test.go index 76f936cecfc..efa3fba1be9 100644 --- a/adapters/telaria/params_test.go +++ b/adapters/telaria/params_test.go @@ -2,7 +2,7 @@ package telaria import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 57cb53929b8..e0a451a9e6c 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -6,11 +6,11 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) const Endpoint = "https://ads.tremorhub.com/ad/rtb/prebid" @@ -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/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index b7eddbad523..be29ed40f03 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -3,9 +3,9 @@ package telaria import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/telaria/usersync.go b/adapters/telaria/usersync.go index 71cf85b6110..76be62026f8 100644 --- a/adapters/telaria/usersync.go +++ b/adapters/telaria/usersync.go @@ -3,10 +3,10 @@ package telaria import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewTelariaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("telaria", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/telaria/usersync_test.go b/adapters/telaria/usersync_test.go index dc3accbbafa..f019ed5ceaf 100644 --- a/adapters/telaria/usersync_test.go +++ b/adapters/telaria/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -26,7 +26,6 @@ func TestTelariaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://pbs.publishers.tremorhub.com/pubsync?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 202, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) assert.Equal(t, "telaria", syncer.FamilyName()) diff --git a/adapters/triplelift/triplelift.go b/adapters/triplelift/triplelift.go index 6b9f5ecfd41..3cd651cee5c 100644 --- a/adapters/triplelift/triplelift.go +++ b/adapters/triplelift/triplelift.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type TripleliftAdapter struct { @@ -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/triplelift_test.go b/adapters/triplelift/triplelift_test.go index 3f23e0dcdc6..5107d7cc997 100644 --- a/adapters/triplelift/triplelift_test.go +++ b/adapters/triplelift/triplelift_test.go @@ -3,9 +3,9 @@ package triplelift import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/triplelift/usersync.go b/adapters/triplelift/usersync.go index 0bd678b0e14..4a47615bd29 100644 --- a/adapters/triplelift/usersync.go +++ b/adapters/triplelift/usersync.go @@ -3,10 +3,10 @@ package triplelift import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewTripleliftSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("triplelift", 28, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("triplelift", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/triplelift/usersync_test.go b/adapters/triplelift/usersync_test.go index 30b1a33b3e9..012e33a4d0a 100644 --- a/adapters/triplelift/usersync_test.go +++ b/adapters/triplelift/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestTripleliftSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//eb2.3lift.com/getuid?gdpr=&cmp_cs=&us_privacy=&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 28, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/triplelift_native/triplelift_native.go b/adapters/triplelift_native/triplelift_native.go index 65c6994c0b3..d412def437f 100644 --- a/adapters/triplelift_native/triplelift_native.go +++ b/adapters/triplelift_native/triplelift_native.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type TripleliftNativeAdapter struct { @@ -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/triplelift_native/triplelift_native_test.go b/adapters/triplelift_native/triplelift_native_test.go index 19b40232155..fef24949e79 100644 --- a/adapters/triplelift_native/triplelift_native_test.go +++ b/adapters/triplelift_native/triplelift_native_test.go @@ -3,9 +3,9 @@ package triplelift_native import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) diff --git a/adapters/triplelift_native/usersync.go b/adapters/triplelift_native/usersync.go index a8d246f07cd..2a07740a761 100644 --- a/adapters/triplelift_native/usersync.go +++ b/adapters/triplelift_native/usersync.go @@ -3,10 +3,10 @@ package triplelift_native import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewTripleliftSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("triplelift", 28, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("triplelift", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/triplelift_native/usersync_test.go b/adapters/triplelift_native/usersync_test.go index ec229e2e68c..7fd878b7f92 100644 --- a/adapters/triplelift_native/usersync_test.go +++ b/adapters/triplelift_native/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -20,6 +20,5 @@ func TestTripleliftSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//eb2.3lift.com/getuid?gdpr=&cmp_cs=&us_privacy=&redir=https%3A%2F%2Feb2.3lift.com%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 28, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/trustx/usersync.go b/adapters/trustx/usersync.go new file mode 100644 index 00000000000..a738e8e9b79 --- /dev/null +++ b/adapters/trustx/usersync.go @@ -0,0 +1,12 @@ +package trustx + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewTrustXSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("trustx", temp, adapters.SyncTypeRedirect) +} diff --git a/adapters/trustx/usersync_test.go b/adapters/trustx/usersync_test.go new file mode 100644 index 00000000000..ba371bc2061 --- /dev/null +++ b/adapters/trustx/usersync_test.go @@ -0,0 +1,29 @@ +package trustx + +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) + +func TestTrustXSyncer(t *testing.T) { + syncURL := "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewTrustXSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dgrid%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.Equal(t, false, syncInfo.SupportCORS) +} diff --git a/adapters/ucfunnel/params_test.go b/adapters/ucfunnel/params_test.go index c33bc89a6b6..4faec8739da 100644 --- a/adapters/ucfunnel/params_test.go +++ b/adapters/ucfunnel/params_test.go @@ -2,7 +2,7 @@ package ucfunnel import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/ucfunnel/ucfunnel.go b/adapters/ucfunnel/ucfunnel.go index 7a6060f2930..1d3efc04451 100644 --- a/adapters/ucfunnel/ucfunnel.go +++ b/adapters/ucfunnel/ucfunnel.go @@ -6,11 +6,11 @@ import ( "net/http" "net/url" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type UcfunnelAdapter struct { @@ -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 3860c988b32..95ac5985f56 100644 --- a/adapters/ucfunnel/ucfunnel_test.go +++ b/adapters/ucfunnel/ucfunnel_test.go @@ -5,40 +5,40 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) 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/ucfunnel/ucfunneltest/exemplary/ucfunnel.json b/adapters/ucfunnel/ucfunneltest/exemplary/ucfunnel.json index e1e361875e2..9a4dad9b0f9 100644 --- a/adapters/ucfunnel/ucfunneltest/exemplary/ucfunnel.json +++ b/adapters/ucfunnel/ucfunneltest/exemplary/ucfunnel.json @@ -101,4 +101,4 @@ } } } -} +} \ No newline at end of file diff --git a/adapters/ucfunnel/usersync.go b/adapters/ucfunnel/usersync.go index 8220fe6e1fa..0ae9948dd77 100644 --- a/adapters/ucfunnel/usersync.go +++ b/adapters/ucfunnel/usersync.go @@ -3,10 +3,10 @@ package ucfunnel import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewUcfunnelSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("ucfunnel", 607, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("ucfunnel", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/ucfunnel/usersync_test.go b/adapters/ucfunnel/usersync_test.go index 25d879d808a..204de978150 100644 --- a/adapters/ucfunnel/usersync_test.go +++ b/adapters/ucfunnel/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestUcfunnelSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//sync.aralego.com/idsync?gdpr=0&redirect=externalURL.com%2Fsetuid%3Fbidder%3Ducfunnel%26uid%3DSspCookieUserId", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 607, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/unicorn/params_test.go b/adapters/unicorn/params_test.go new file mode 100644 index 00000000000..4a534208e84 --- /dev/null +++ b/adapters/unicorn/params_test.go @@ -0,0 +1,61 @@ +package unicorn + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestValidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range validParams { + if err := validator.Validate(openrtb_ext.BidderUnicorn, json.RawMessage(p)); err != nil { + t.Errorf("Schema rejected valid params: %s", p) + } + } +} + +func TestInvalidParams(t *testing.T) { + validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") + if err != nil { + t.Fatalf("Failed to fetch the json schema. %v", err) + } + + for _, p := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderUnicorn, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{ + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + }`, + `{ + "accountId": 199578, + "mediaId": "test_media" + }`, +} + +var invalidParams = []string{ + `{}`, + `{ + "accountId": "199578", + "publisherId": "123456", + "mediaId": 12345, + "placementId": 12345 + }`, + `{ + "publisherId": 123456, + "placementId": "test_placement" + }`, +} diff --git a/adapters/unicorn/unicorn.go b/adapters/unicorn/unicorn.go new file mode 100644 index 00000000000..8d1413f43dd --- /dev/null +++ b/adapters/unicorn/unicorn.go @@ -0,0 +1,244 @@ +package unicorn + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/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" +) + +type adapter struct { + endpoint string +} + +// unicornImpExt is imp ext for UNICORN +type unicornImpExt struct { + Context *unicornImpExtContext `json:"context,omitempty"` + Bidder openrtb_ext.ExtImpUnicorn `json:"bidder"` +} + +type unicornImpExtContext struct { + Data interface{} `json:"data,omitempty"` +} + +// unicornExt is ext for UNICORN +type unicornExt struct { + Prebid *openrtb_ext.ExtImpPrebid `json:"prebid,omitempty"` + AccountID int64 `json:"accountId,omitempty"` +} + +// Builder builds a new instance of the UNICORN adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +// MakeRequests makes the HTTP requests which should be made to fetch bids. +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 { + return nil, []error{&errortypes.BadInput{ + Message: "COPPA is not supported", + }} + } + if err := json.Unmarshal(request.Regs.Ext, &extRegs); err == nil { + if extRegs.GDPR != nil && (*extRegs.GDPR == 1) { + return nil, []error{&errortypes.BadInput{ + Message: "GDPR is not supported", + }} + } + if extRegs.USPrivacy != "" { + return nil, []error{&errortypes.BadInput{ + Message: "CCPA is not supported", + }} + } + } + } + + err := modifyImps(request) + if err != nil { + return nil, []error{err} + } + + var modifiableSource openrtb2.Source + if request.Source != nil { + modifiableSource = *request.Source + } else { + modifiableSource = openrtb2.Source{} + } + modifiableSource.Ext = setSourceExt() + request.Source = &modifiableSource + + request.Ext, err = setExt(request) + if err != nil { + return nil, []error{err} + } + + requestJSON, err := json.Marshal(request) + if err != nil { + return nil, []error{err} + } + + requestData := &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: requestJSON, + Headers: getHeaders(request), + } + + return []*adapters.RequestData{requestData}, nil +} + +func getHeaders(request *openrtb2.BidRequest) http.Header { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + headers.Add("X-Openrtb-Version", "2.5") + + if request.Device != nil { + if len(request.Device.UA) > 0 { + headers.Add("User-Agent", request.Device.UA) + } + + if len(request.Device.IPv6) > 0 { + headers.Add("X-Forwarded-For", request.Device.IPv6) + } + + if len(request.Device.IP) > 0 { + headers.Add("X-Forwarded-For", request.Device.IP) + } + } + + return headers +} + +func modifyImps(request *openrtb2.BidRequest) error { + for i := 0; i < len(request.Imp); i++ { + imp := &request.Imp[i] + + var ext unicornImpExt + err := json.Unmarshal(imp.Ext, &ext) + + if err != nil { + return &errortypes.BadInput{ + Message: fmt.Sprintf("Error while decoding imp[%d].ext: %s", i, err), + } + } + + if ext.Bidder.PlacementID == "" { + ext.Bidder.PlacementID, err = getStoredRequestImpID(imp) + if err != nil { + return &errortypes.BadInput{ + Message: fmt.Sprintf("Error get StoredRequestImpID from imp[%d]: %s", i, err), + } + } + } + + imp.Ext, err = json.Marshal(ext) + if err != nil { + return &errortypes.BadInput{ + Message: fmt.Sprintf("Error while encoding imp[%d].ext: %s", i, err), + } + } + + secure := int8(1) + imp.Secure = &secure + imp.TagID = ext.Bidder.PlacementID + } + return nil +} + +func getStoredRequestImpID(imp *openrtb2.Imp) (string, error) { + v, err := jsonparser.GetString(imp.Ext, "prebid", "storedrequest", "id") + + if err != nil { + return "", fmt.Errorf("stored request id not found: %s", err) + } + + return v, nil +} + +func setSourceExt() json.RawMessage { + return json.RawMessage(`{"stype": "prebid_server_uncn", "bidder": "unicorn"}`) +} + +func setExt(request *openrtb2.BidRequest) (json.RawMessage, error) { + accountID, err := jsonparser.GetInt(request.Imp[0].Ext, "bidder", "accountId") + if err != nil { + accountID = 0 + } + var decodedExt *unicornExt + err = json.Unmarshal(request.Ext, &decodedExt) + if err != nil { + decodedExt = &unicornExt{ + Prebid: nil, + } + } + decodedExt.AccountID = accountID + + ext, err := json.Marshal(decodedExt) + if err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error while encoding ext, err: %s", err), + } + } + return ext, nil +} + +// MakeBids unpacks the server's response into Bids. +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + + if responseData.StatusCode == http.StatusNoContent { + return nil, nil + } + + if responseData.StatusCode == http.StatusBadRequest { + err := &errortypes.BadInput{ + Message: "Unexpected http status code: 400", + } + return nil, []error{err} + } + + if responseData.StatusCode != http.StatusOK { + err := &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected http status code: %d", responseData.StatusCode), + } + return nil, []error{err} + } + + var response openrtb2.BidResponse + if err := json.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{err} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + bidResponse.Currency = response.Cur + for _, seatBid := range response.SeatBid { + for _, bid := range seatBid.Bid { + bid := bid + var bidType openrtb_ext.BidType + for _, imp := range request.Imp { + if imp.ID == bid.ImpID { + if imp.Banner != nil { + bidType = openrtb_ext.BidTypeBanner + } + } + } + b := &adapters.TypedBid{ + Bid: &bid, + BidType: bidType, + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, nil +} diff --git a/adapters/unicorn/unicorn_test.go b/adapters/unicorn/unicorn_test.go new file mode 100644 index 00000000000..1a0d67d29f7 --- /dev/null +++ b/adapters/unicorn/unicorn_test.go @@ -0,0 +1,20 @@ +package unicorn + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderUnicorn, config.Adapter{ + Endpoint: "https://ds.uncn.jp"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "unicorntest", bidder) +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app-no-source.json b/adapters/unicorn/unicorntest/exemplary/banner-app-no-source.json new file mode 100644 index 00000000000..c37c2095d48 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app-no-source.json @@ -0,0 +1,228 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + } + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app-with-ip.json b/adapters/unicorn/unicorntest/exemplary/banner-app-with-ip.json new file mode 100644 index 00000000000..2d38a990db3 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app-with-ip.json @@ -0,0 +1,236 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "ip": "12.1.2.3", + "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "ip": "12.1.2.3", + "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app-with-ipv6.json b/adapters/unicorn/unicorntest/exemplary/banner-app-with-ipv6.json new file mode 100644 index 00000000000..595741a0aa1 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app-with-ipv6.json @@ -0,0 +1,236 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "ipv6": "2400:2410:9120:3400:15f3:8c50:3a0:6820", + "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "ipv6": "2400:2410:9120:3400:15f3:8c50:3a0:6820", + "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148", + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app-without-ext.json b/adapters/unicorn/unicorntest/exemplary/banner-app-without-ext.json new file mode 100644 index 00000000000..8b5423a5556 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app-without-ext.json @@ -0,0 +1,212 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 78.3, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 78.3, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app-without-placementid.json b/adapters/unicorn/unicorntest/exemplary/banner-app-without-placementid.json new file mode 100644 index 00000000000..c05d3b6f536 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app-without-placementid.json @@ -0,0 +1,231 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media" + } + } + } + ], + "cur": ["USD"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["USD"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_unicorn" + } + }, + "tagid": "test_unicorn", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "USD", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 0.783, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "USD", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 0.783, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app.json b/adapters/unicorn/unicorntest/exemplary/banner-app.json new file mode 100644 index 00000000000..b29c1e1d625 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app.json @@ -0,0 +1,232 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app_with_fpd.json b/adapters/unicorn/unicorntest/exemplary/banner-app_with_fpd.json new file mode 100644 index 00000000000..0a6fb420adc --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app_with_fpd.json @@ -0,0 +1,244 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + }, + "context": { + "data": { + "firstPartyData1": ["firstPartyData1"], + "uuid": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] + } + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + }, + "context": { + "data": { + "firstPartyData1": ["firstPartyData1"], + "uuid": ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] + } + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/exemplary/banner-app_with_no_fpd.json b/adapters/unicorn/unicorntest/exemplary/banner-app_with_no_fpd.json new file mode 100644 index 00000000000..022246382f8 --- /dev/null +++ b/adapters/unicorn/unicorntest/exemplary/banner-app_with_no_fpd.json @@ -0,0 +1,238 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + }, + "context": { + "data": {} + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + }, + "context": { + "data": {} + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "url": "https://ds.uncn.jp", + "status": 200, + "headers": { + "Content-Type": ["application/json"], + "Date": ["Thu, 04 Feb 2021 06:36:31 GMT"], + "Vary": ["Accept-Encoding"] + }, + "body": { + "bidid": "f1248280-24ec-4fbc-bdf5-6a866e7dcea4", + "cur": "JPY", + "ext": {}, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "seatbid": [ + { + "bid": [ + { + "adid": "uoNYbq1L_-123456", + "adm": "awesome domain", + "adomain": ["example.com"], + "attr": [], + "bundle": "example.com", + "cid": "7314", + "crid": "-123456", + "ext": {}, + "h": 250, + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "iurl": "https://example.com/banner.png", + "price": 73.283, + "w": 300 + } + ], + "group": 0, + "seat": "274" + } + ], + "units": 0 + } + } + } + ], + "expectedBidResponses": [ + { + "Currency": "JPY", + "bids": [ + { + "Bid": { + "id": "1", + "impid": "29D2F33E-F865-40DA-9320-16EF77935254", + "price": 73.283, + "adm": "awesome domain", + "adid": "uoNYbq1L_-123456", + "adomain": ["example.com"], + "bundle": "example.com", + "iurl": "https://example.com/banner.png", + "cid": "7314", + "crid": "-123456", + "w": 300, + "h": 250, + "ext": {} + }, + "type": "banner", + "BidType": "banner", + "BidVideo": null, + "DealPriority": 0 + } + ] + } + ] +} diff --git a/adapters/unicorn/unicorntest/params/race/banner.json b/adapters/unicorn/unicorntest/params/race/banner.json new file mode 100644 index 00000000000..668983e3d19 --- /dev/null +++ b/adapters/unicorn/unicorntest/params/race/banner.json @@ -0,0 +1,6 @@ +{ + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" +} diff --git a/adapters/unicorn/unicorntest/supplemental/204.json b/adapters/unicorn/unicorntest/supplemental/204.json new file mode 100644 index 00000000000..a05864090ea --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/204.json @@ -0,0 +1,170 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [] +} + diff --git a/adapters/unicorn/unicorntest/supplemental/400.json b/adapters/unicorn/unicorntest/supplemental/400.json new file mode 100644 index 00000000000..6578082ca19 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/400.json @@ -0,0 +1,175 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected http status code: 400", + "comparison": "literal" + } + ] +} + diff --git a/adapters/unicorn/unicorntest/supplemental/500.json b/adapters/unicorn/unicorntest/supplemental/500.json new file mode 100644 index 00000000000..c0811be4b24 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/500.json @@ -0,0 +1,175 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + }, + "ext": { + "prebid": { + "targeting": {}, + "cache": { + "bids": {} + }, + "storedrequest": { + "id": "test" + } + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://ds.uncn.jp", + "body": { + "app": { + "bundle": "net.ada.test", + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "publisher": { + "id": "test" + }, + "ver": "1.9.0" + }, + "at": 1, + "cur": ["JPY"], + "device": { + "connectiontype": 1, + "ext": { + "atts": 0 + }, + "h": 568, + "ifa": "00000000-0000-0000-0000-000000000000", + "make": "Apple", + "model": "Simulator", + "os": "iOS", + "osv": "14.4", + "pxratio": 2, + "w": 320 + }, + "ext": { + "prebid": { + "bidder": null, + "is_rewarded_inventory": 0, + "storedrequest": { + "id": "test" + } + }, + "accountId": 199578 + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "imp": [ + { + "banner": { + "api": [5], + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + }, + "tagid": "test_placement", + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "source": { + "ext": { + "bidder": "unicorn", + "stype": "prebid_server_uncn" + }, + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "user": { + "gender": "O" + } + } + }, + "mockResponse": { + "status": 500, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected http status code: 500", + "comparison": "literal" + } + ] +} + diff --git a/adapters/unicorn/unicorntest/supplemental/ccpa-is-enabled.json b/adapters/unicorn/unicorntest/supplemental/ccpa-is-enabled.json new file mode 100644 index 00000000000..6bc396c67f1 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/ccpa-is-enabled.json @@ -0,0 +1,80 @@ +{ + "mockBidRequest": { + "at": 1, + "regs": { + "ext": { + "us_privacy": "1YNN" + } + }, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "CCPA is not supported", + "comparison": "literal" + } + ] +} diff --git a/adapters/unicorn/unicorntest/supplemental/coppa-is-enabled.json b/adapters/unicorn/unicorntest/supplemental/coppa-is-enabled.json new file mode 100644 index 00000000000..1c33ce2e805 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/coppa-is-enabled.json @@ -0,0 +1,78 @@ +{ + "mockBidRequest": { + "at": 1, + "regs": { + "coppa": 1 + }, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "COPPA is not supported", + "comparison": "literal" + } + ] +} diff --git a/adapters/unicorn/unicorntest/supplemental/gdpr-is-enabled.json b/adapters/unicorn/unicorntest/supplemental/gdpr-is-enabled.json new file mode 100644 index 00000000000..3c9222d8cc2 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/gdpr-is-enabled.json @@ -0,0 +1,80 @@ +{ + "mockBidRequest": { + "at": 1, + "regs": { + "ext": { + "gdpr": 1 + } + }, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + "storedrequest": { + "id": "test_unicorn" + } + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media", + "placementId": "test_placement" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "GDPR is not supported", + "comparison": "literal" + } + ] +} diff --git a/adapters/unicorn/unicorntest/supplemental/no-imp-ext-prebid.json b/adapters/unicorn/unicorntest/supplemental/no-imp-ext-prebid.json new file mode 100644 index 00000000000..2e6ce79a176 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/no-imp-ext-prebid.json @@ -0,0 +1,67 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors" : [{ + "value": "Error get StoredRequestImpID from imp[0]: stored request id not found: Key path not found", + "comparison": "literal" + }] +} diff --git a/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json b/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json new file mode 100644 index 00000000000..bab6e8d9603 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/no-imp-ext.json @@ -0,0 +1,62 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1 + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "Error while decoding imp[0].ext: unexpected end of JSON input", + "comparison": "literal" + } + ] +} diff --git a/adapters/unicorn/unicorntest/supplemental/no-storedrequest-imp.json b/adapters/unicorn/unicorntest/supplemental/no-storedrequest-imp.json new file mode 100644 index 00000000000..d903effd466 --- /dev/null +++ b/adapters/unicorn/unicorntest/supplemental/no-storedrequest-imp.json @@ -0,0 +1,69 @@ +{ + "mockBidRequest": { + "at": 1, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 250 + } + ], + "api": [5] + }, + "id": "29D2F33E-F865-40DA-9320-16EF77935254", + "secure": 1, + "ext": { + "prebid": { + }, + "bidder": { + "accountId": 199578, + "publisherId": 123456, + "mediaId": "test_media" + } + } + } + ], + "cur": ["JPY"], + "app": { + "publisher": { + "id": "test" + }, + "ext": { + "prebid": { + "source": "prebid-mobile", + "version": "1.9.0" + } + }, + "bundle": "net.ada.test", + "ver": "1.9.0" + }, + "id": "CFD24FB1-916F-467D-8825-34892B315DB7", + "source": { + "tid": "A4B3EA9F-FF57-4716-AC85-6CBF6A46CFBD" + }, + "device": { + "make": "Apple", + "osv": "14.4", + "connectiontype": 1, + "os": "iOS", + "w": 320, + "model": "Simulator", + "ifa": "00000000-0000-0000-0000-000000000000", + "devtime": 1612413327, + "h": 568, + "pxratio": 2, + "ext": { + "atts": 0 + } + }, + "user": { + "gender": "O" + } + }, + "expectedMakeRequestsErrors" : [{ + "value": "Error get StoredRequestImpID from imp[0]: stored request id not found: Key path not found", + "comparison": "literal" + }] +} diff --git a/adapters/unruly/params_test.go b/adapters/unruly/params_test.go index af1f2f2bce8..9b8f3110912 100644 --- a/adapters/unruly/params_test.go +++ b/adapters/unruly/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestValidParams(t *testing.T) { diff --git a/adapters/unruly/unruly.go b/adapters/unruly/unruly.go index 131e53af393..0077fae4df5 100644 --- a/adapters/unruly/unruly.go +++ b/adapters/unruly/unruly.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type UnrulyAdapter struct { @@ -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 e0f3ccc75e0..445745c102d 100644 --- a/adapters/unruly/unruly_test.go +++ b/adapters/unruly/unruly_test.go @@ -7,12 +7,12 @@ import ( "reflect" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -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/unruly/usersync.go b/adapters/unruly/usersync.go index 248b4923875..5dc60c859bb 100644 --- a/adapters/unruly/usersync.go +++ b/adapters/unruly/usersync.go @@ -3,10 +3,10 @@ package unruly import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewUnrulySyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("unruly", 162, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("unruly", temp, adapters.SyncTypeIframe) } diff --git a/adapters/unruly/usersync_test.go b/adapters/unruly/usersync_test.go index e85a066dddc..f0702cebd34 100644 --- a/adapters/unruly/usersync_test.go +++ b/adapters/unruly/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestUnrulySyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr=A&consent=B&us_privacy=C&rurl=%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3DA%26gdpr_consent%3DB%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "iframe", syncInfo.Type) - assert.EqualValues(t, 162, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/valueimpression/params_test.go b/adapters/valueimpression/params_test.go index b80962ff4dd..46471de24bb 100644 --- a/adapters/valueimpression/params_test.go +++ b/adapters/valueimpression/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/valueimpression.json diff --git a/adapters/valueimpression/usersync.go b/adapters/valueimpression/usersync.go index 4cc1539103b..08490a5ed3e 100644 --- a/adapters/valueimpression/usersync.go +++ b/adapters/valueimpression/usersync.go @@ -3,10 +3,10 @@ package valueimpression import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewValueImpressionSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("valueimpression", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("valueimpression", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/valueimpression/usersync_test.go b/adapters/valueimpression/usersync_test.go index ed75969ac0d..7b3a13c5dd6 100644 --- a/adapters/valueimpression/usersync_test.go +++ b/adapters/valueimpression/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestValueImpressionSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://rtb.valueimpression.com/usersync?gdpr=1&gdpr_consent=BOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA&redirectUri=http%3A%2F%2Flocalhost:8000%2Fsetuid%3Fbidder%3Dvalueimpression%26gdpr%3D1%26gdpr_consent%3DBOPVK28OVJoTBABABAENBs-AAAAhuAKAANAAoACwAGgAPAAxAB0AHgAQAAiABOADkA%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.False(t, syncInfo.SupportCORS) } diff --git a/adapters/valueimpression/valueimpression.go b/adapters/valueimpression/valueimpression.go index 87b66674f85..aac8faab52c 100644 --- a/adapters/valueimpression/valueimpression.go +++ b/adapters/valueimpression/valueimpression.go @@ -5,18 +5,18 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/valueimpression_test.go b/adapters/valueimpression/valueimpression_test.go index b2c6500389f..f4d33864978 100644 --- a/adapters/valueimpression/valueimpression_test.go +++ b/adapters/valueimpression/valueimpression_test.go @@ -3,9 +3,9 @@ package valueimpression import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/valueimpression/valueimpressiontest/exemplary/banner-and-video.json b/adapters/valueimpression/valueimpressiontest/exemplary/banner-and-video.json index a92080aa96f..fd9d401cd44 100644 --- a/adapters/valueimpression/valueimpressiontest/exemplary/banner-and-video.json +++ b/adapters/valueimpression/valueimpressiontest/exemplary/banner-and-video.json @@ -127,4 +127,4 @@ } ]} ] -} +} \ No newline at end of file diff --git a/adapters/valueimpression/valueimpressiontest/supplemental/explicit-dimensions.json b/adapters/valueimpression/valueimpressiontest/supplemental/explicit-dimensions.json index d9d8e9db251..cf2fd7dd01e 100644 --- a/adapters/valueimpression/valueimpressiontest/supplemental/explicit-dimensions.json +++ b/adapters/valueimpression/valueimpressiontest/supplemental/explicit-dimensions.json @@ -54,4 +54,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file diff --git a/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-no-bids.json b/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-no-bids.json index 6ef3b3e5838..48122f5926a 100644 --- a/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-no-bids.json +++ b/adapters/valueimpression/valueimpressiontest/supplemental/invalid-response-no-bids.json @@ -48,4 +48,4 @@ } ], "expectedBidResponses": [] -} +} \ No newline at end of file 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/params_test.go b/adapters/verizonmedia/params_test.go index 9250c265526..febda6058e6 100644 --- a/adapters/verizonmedia/params_test.go +++ b/adapters/verizonmedia/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/verizonmedia.json diff --git a/adapters/verizonmedia/usersync.go b/adapters/verizonmedia/usersync.go index 612aab3b1f0..2c7354d1146 100644 --- a/adapters/verizonmedia/usersync.go +++ b/adapters/verizonmedia/usersync.go @@ -1,11 +1,12 @@ package verizonmedia import ( - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewVerizonMediaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("verizonmedia", 25, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("verizonmedia", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/verizonmedia/usersync_test.go b/adapters/verizonmedia/usersync_test.go index 6455078a6f5..9dd1ae70c25 100644 --- a/adapters/verizonmedia/usersync_test.go +++ b/adapters/verizonmedia/usersync_test.go @@ -4,7 +4,7 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy" "github.com/stretchr/testify/assert" ) @@ -19,5 +19,4 @@ func TestVerizonMediaSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 25, syncer.GDPRVendorID()) } diff --git a/adapters/verizonmedia/verizonmedia.go b/adapters/verizonmedia/verizonmedia.go index d90deea324b..aa215c01691 100644 --- a/adapters/verizonmedia/verizonmedia.go +++ b/adapters/verizonmedia/verizonmedia.go @@ -6,18 +6,18 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/verizonmedia/verizonmedia_test.go b/adapters/verizonmedia/verizonmedia_test.go index e0e46c462c1..869ae9e9faa 100644 --- a/adapters/verizonmedia/verizonmedia_test.go +++ b/adapters/verizonmedia/verizonmedia_test.go @@ -3,10 +3,10 @@ package verizonmedia import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/influxdata/influxdb/pkg/testing/assert" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestVerizonMediaBidderEndpointConfig(t *testing.T) { diff --git a/adapters/visx/params_test.go b/adapters/visx/params_test.go index f59ce49a46d..e857e8d2639 100644 --- a/adapters/visx/params_test.go +++ b/adapters/visx/params_test.go @@ -2,7 +2,7 @@ package visx import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/visx/usersync.go b/adapters/visx/usersync.go index e8223083033..dc143570ab9 100644 --- a/adapters/visx/usersync.go +++ b/adapters/visx/usersync.go @@ -3,10 +3,10 @@ package visx import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewVisxSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("visx", 154, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("visx", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/visx/usersync_test.go b/adapters/visx/usersync_test.go index e71ee35f5d8..ec4cf82b04b 100644 --- a/adapters/visx/usersync_test.go +++ b/adapters/visx/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -30,6 +30,5 @@ func TestVisxSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://t.visx.net/s2s_sync?gdpr=A&gdpr_consent=B&us_privacy=C&redir=%2Fsetuid%3Fbidder%3Dvisx%26gdpr%3DA%26gdpr_consent%3DB%26uid%3D%24%7BUUID%7D", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 154, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/visx/visx.go b/adapters/visx/visx.go index 2a00b2def69..8e2b10f7c32 100644 --- a/adapters/visx/visx.go +++ b/adapters/visx/visx.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type VisxAdapter struct { @@ -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/visx/visx_test.go b/adapters/visx/visx_test.go index d637e908913..2f51af76597 100644 --- a/adapters/visx/visx_test.go +++ b/adapters/visx/visx_test.go @@ -3,9 +3,9 @@ package visx import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/vrtcal/params_test.go b/adapters/vrtcal/params_test.go index 5f80812f26f..ba57b6d82f8 100644 --- a/adapters/vrtcal/params_test.go +++ b/adapters/vrtcal/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) //Vrtcal doesn't currently require any custom fields. This file is included for conformity only diff --git a/adapters/vrtcal/usersync.go b/adapters/vrtcal/usersync.go index 0fd97875a0e..8a6ddc0ca26 100644 --- a/adapters/vrtcal/usersync.go +++ b/adapters/vrtcal/usersync.go @@ -3,10 +3,10 @@ package vrtcal import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewVrtcalSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("vrtcal", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("vrtcal", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/vrtcal/usersync_test.go b/adapters/vrtcal/usersync_test.go index faea653f795..7f8ca220a96 100644 --- a/adapters/vrtcal/usersync_test.go +++ b/adapters/vrtcal/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,7 +25,6 @@ func TestVrtcalSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "http://usync-prebid.vrtcal.com/s?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) assert.Equal(t, "vrtcal", syncer.FamilyName()) } diff --git a/adapters/vrtcal/vrtcal.go b/adapters/vrtcal/vrtcal.go index 5d4bd705d2f..e4986b2f6fb 100644 --- a/adapters/vrtcal/vrtcal.go +++ b/adapters/vrtcal/vrtcal.go @@ -5,18 +5,18 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) 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/vrtcal/vrtcal_test.go b/adapters/vrtcal/vrtcal_test.go index c1f3cfb0796..332217650f6 100644 --- a/adapters/vrtcal/vrtcal_test.go +++ b/adapters/vrtcal/vrtcal_test.go @@ -3,9 +3,9 @@ package vrtcal import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/yeahmobi/params_test.go b/adapters/yeahmobi/params_test.go index 79b8273a362..997bf93a53f 100644 --- a/adapters/yeahmobi/params_test.go +++ b/adapters/yeahmobi/params_test.go @@ -2,7 +2,7 @@ package yeahmobi import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/yeahmobi/yeahmobi.go b/adapters/yeahmobi/yeahmobi.go index 0e342052008..8a692d4ff2e 100644 --- a/adapters/yeahmobi/yeahmobi.go +++ b/adapters/yeahmobi/yeahmobi.go @@ -7,13 +7,13 @@ import ( "net/url" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) type YeahmobiAdapter struct { @@ -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{} @@ -95,13 +95,15 @@ func transform(request *openrtb.BidRequest) { continue } - request.Imp[i].Native.Request = string(nativeReqByte) + nativeCopy := *request.Imp[i].Native + nativeCopy.Request = string(nativeReqByte) + request.Imp[i].Native = &nativeCopy } } } } -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 @@ -129,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 } @@ -146,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} @@ -167,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/yeahmobi_test.go b/adapters/yeahmobi/yeahmobi_test.go index 9f983633452..a38480b0486 100644 --- a/adapters/yeahmobi/yeahmobi_test.go +++ b/adapters/yeahmobi/yeahmobi_test.go @@ -3,9 +3,9 @@ package yeahmobi import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) 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/params_test.go b/adapters/yieldlab/params_test.go index f66121e35e8..8c230c15b15 100644 --- a/adapters/yieldlab/params_test.go +++ b/adapters/yieldlab/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/yieldlab.json diff --git a/adapters/yieldlab/usersync.go b/adapters/yieldlab/usersync.go index a0462e19e6e..90507e31161 100644 --- a/adapters/yieldlab/usersync.go +++ b/adapters/yieldlab/usersync.go @@ -3,10 +3,10 @@ package yieldlab import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewYieldlabSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("yieldlab", 70, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("yieldlab", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/yieldlab/usersync_test.go b/adapters/yieldlab/usersync_test.go index cdca7f9f417..eabd46f6dce 100644 --- a/adapters/yieldlab/usersync_test.go +++ b/adapters/yieldlab/usersync_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" ) func TestYieldlabSyncer(t *testing.T) { @@ -21,6 +21,5 @@ func TestYieldlabSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "https://ad.yieldlab.net/mr?t=2&pid=9140838&gdpr=0&gdpr_consent=&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dyieldlab%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%25%25YL_UID%25%25", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 70, syncer.GDPRVendorID()) assert.False(t, syncInfo.SupportCORS) } diff --git a/adapters/yieldlab/yieldlab.go b/adapters/yieldlab/yieldlab.go index adce598d60d..ee9170c25cf 100644 --- a/adapters/yieldlab/yieldlab.go +++ b/adapters/yieldlab/yieldlab.go @@ -9,13 +9,13 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" "golang.org/x/text/currency" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) // YieldlabAdapter connects the Yieldlab API to prebid server @@ -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/yieldlab/yieldlab_test.go b/adapters/yieldlab/yieldlab_test.go index 83f7d1e813f..273117e3bdf 100644 --- a/adapters/yieldlab/yieldlab_test.go +++ b/adapters/yieldlab/yieldlab_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) const testURL = "https://ad.yieldlab.net/testing/" diff --git a/adapters/yieldmo/params_test.go b/adapters/yieldmo/params_test.go index 87044a2dd57..0a8fe2d10f1 100644 --- a/adapters/yieldmo/params_test.go +++ b/adapters/yieldmo/params_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file actually intends to test static/bidder-params/yieldmo.json diff --git a/adapters/yieldmo/usersync.go b/adapters/yieldmo/usersync.go index 25d65f229a2..d06caa90c0b 100644 --- a/adapters/yieldmo/usersync.go +++ b/adapters/yieldmo/usersync.go @@ -3,10 +3,10 @@ package yieldmo import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewYieldmoSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("yieldmo", 173, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("yieldmo", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/yieldmo/usersync_test.go b/adapters/yieldmo/usersync_test.go index 1212efdb878..5d12c63e4aa 100644 --- a/adapters/yieldmo/usersync_test.go +++ b/adapters/yieldmo/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestYieldmoSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//ads.yieldmo.com/pbsync?gdpr=0&gdpr_consent=&us_privacy=&redirectUri=http%3A%2F%2Flocalhost%2F%2Fsetuid%3Fbidder%3Dyieldmo%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 173, syncer.GDPRVendorID()) assert.False(t, syncInfo.SupportCORS) } diff --git a/adapters/yieldmo/yieldmo.go b/adapters/yieldmo/yieldmo.go index 95fbfa33f48..7d7a8f22b01 100644 --- a/adapters/yieldmo/yieldmo.go +++ b/adapters/yieldmo/yieldmo.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type YieldmoAdapter struct { @@ -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/yieldmo/yieldmo_test.go b/adapters/yieldmo/yieldmo_test.go index faee55c3890..cb0a8d60aa5 100644 --- a/adapters/yieldmo/yieldmo_test.go +++ b/adapters/yieldmo/yieldmo_test.go @@ -3,9 +3,9 @@ package yieldmo import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { diff --git a/adapters/yieldone/params_test.go b/adapters/yieldone/params_test.go index e0142334d6e..6048ea5d7dc 100644 --- a/adapters/yieldone/params_test.go +++ b/adapters/yieldone/params_test.go @@ -2,7 +2,7 @@ package yieldone import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "testing" ) diff --git a/adapters/yieldone/usersync.go b/adapters/yieldone/usersync.go index 333550aa775..4d5d8283a68 100644 --- a/adapters/yieldone/usersync.go +++ b/adapters/yieldone/usersync.go @@ -3,10 +3,10 @@ package yieldone import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewYieldoneSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("yieldone", 0, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("yieldone", temp, adapters.SyncTypeRedirect) } diff --git a/adapters/yieldone/usersync_test.go b/adapters/yieldone/usersync_test.go index 730f9103017..c4d0fee92dd 100644 --- a/adapters/yieldone/usersync_test.go +++ b/adapters/yieldone/usersync_test.go @@ -4,8 +4,8 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) @@ -25,6 +25,5 @@ func TestYieldoneSyncer(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "//not_localhost/synclocalhost%2Fsetuid%3Fbidder%3Dyieldone%26gdpr%3D0%26gdpr_consent%3D%26uid%3D%24UID", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) - assert.EqualValues(t, 0, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) } diff --git a/adapters/yieldone/yieldone.go b/adapters/yieldone/yieldone.go index 33debb26bd9..4e22b1446a7 100644 --- a/adapters/yieldone/yieldone.go +++ b/adapters/yieldone/yieldone.go @@ -5,11 +5,11 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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" ) type YieldoneAdapter struct { @@ -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/yieldone_test.go b/adapters/yieldone/yieldone_test.go index ca2c3851ad4..8544c21f4e7 100644 --- a/adapters/yieldone/yieldone_test.go +++ b/adapters/yieldone/yieldone_test.go @@ -3,9 +3,9 @@ package yieldone import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestJsonSamples(t *testing.T) { 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/usersync.go b/adapters/zeroclickfraud/usersync.go index a5435335ab8..41c589818ca 100644 --- a/adapters/zeroclickfraud/usersync.go +++ b/adapters/zeroclickfraud/usersync.go @@ -3,10 +3,10 @@ package zeroclickfraud import ( "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" ) func NewZeroClickFraudSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("zeroclickfraud", 0, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("zeroclickfraud", temp, adapters.SyncTypeIframe) } diff --git a/adapters/zeroclickfraud/usersync_test.go b/adapters/zeroclickfraud/usersync_test.go index 445b07ab8eb..5e8f8fdf111 100644 --- a/adapters/zeroclickfraud/usersync_test.go +++ b/adapters/zeroclickfraud/usersync_test.go @@ -4,9 +4,9 @@ import ( "testing" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" "github.com/stretchr/testify/assert" ) diff --git a/adapters/zeroclickfraud/zeroclickfraud.go b/adapters/zeroclickfraud/zeroclickfraud.go index eb98aed1ece..cf27c83d4a7 100644 --- a/adapters/zeroclickfraud/zeroclickfraud.go +++ b/adapters/zeroclickfraud/zeroclickfraud.go @@ -7,19 +7,19 @@ import ( "strconv" "text/template" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/macros" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/macros" + "github.com/prebid/prebid-server/openrtb_ext" ) 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/zeroclickfraud_test.go b/adapters/zeroclickfraud/zeroclickfraud_test.go index 2942c25a4f3..654d9450da0 100644 --- a/adapters/zeroclickfraud/zeroclickfraud_test.go +++ b/adapters/zeroclickfraud/zeroclickfraud_test.go @@ -3,9 +3,9 @@ package zeroclickfraud import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adapterstest" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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" ) 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 c3606e83563..05e43aca1e2 100644 --- a/amp/parse.go +++ b/amp/parse.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 1b9d30804da..91027f8e67c 100644 --- a/amp/parse_test.go +++ b/amp/parse_test.go @@ -4,7 +4,7 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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/clients/http.go b/analytics/clients/http.go index 68af3073a78..bc7f863ebdd 100644 --- a/analytics/clients/http.go +++ b/analytics/clients/http.go @@ -7,6 +7,6 @@ import ( var defaultHttpInstance = http.DefaultClient func GetDefaultHttpInstance() *http.Client { - // TODO 2020-06-22 @see https://github.com/PubMatic-OpenWrap/prebid-server/pull/1331#discussion_r436110097 + // TODO 2020-06-22 @see https://github.com/prebid/prebid-server/pull/1331#discussion_r436110097 return defaultHttpInstance } diff --git a/analytics/config/config.go b/analytics/config/config.go index ac145ee363e..fa63cb5a1e4 100644 --- a/analytics/config/config.go +++ b/analytics/config/config.go @@ -1,12 +1,12 @@ package config import ( - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/analytics/clients" - "github.com/PubMatic-OpenWrap/prebid-server/analytics/filesystem" - "github.com/PubMatic-OpenWrap/prebid-server/analytics/pubstack" - "github.com/PubMatic-OpenWrap/prebid-server/config" "github.com/golang/glog" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/analytics/clients" + "github.com/prebid/prebid-server/analytics/filesystem" + "github.com/prebid/prebid-server/analytics/pubstack" + "github.com/prebid/prebid-server/config" ) //Modules that need to be logged to need to be initialized here diff --git a/analytics/config/config_test.go b/analytics/config/config_test.go index 02ea6a54261..310dbe1a481 100644 --- a/analytics/config/config_test.go +++ b/analytics/config/config_test.go @@ -1,14 +1,15 @@ package config import ( - "github.com/stretchr/testify/assert" "net/http" "os" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/stretchr/testify/assert" + + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" ) const TEST_DIR string = "testFiles" @@ -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 78ca1df2c9a..38c4f779327 100644 --- a/analytics/core.go +++ b/analytics/core.go @@ -3,10 +3,10 @@ package analytics import ( "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/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.go b/analytics/filesystem/file_module.go index bb94fa783a5..a0721d98a2a 100644 --- a/analytics/filesystem/file_module.go +++ b/analytics/filesystem/file_module.go @@ -5,8 +5,8 @@ import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" "github.com/chasex/glog" + "github.com/prebid/prebid-server/analytics" ) type RequestType string diff --git a/analytics/filesystem/file_module_test.go b/analytics/filesystem/file_module_test.go index e46e9259319..0c3d3c9e6ac 100644 --- a/analytics/filesystem/file_module_test.go +++ b/analytics/filesystem/file_module_test.go @@ -1,15 +1,16 @@ package filesystem import ( - "github.com/PubMatic-OpenWrap/prebid-server/config" "net/http" "os" "strings" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/usersync" ) const TEST_DIR string = "testFiles" @@ -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.go b/analytics/pubstack/helpers/json.go index 11c5bf8ec05..f02f1120626 100644 --- a/analytics/pubstack/helpers/json.go +++ b/analytics/pubstack/helpers/json.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" + "github.com/prebid/prebid-server/analytics" ) func JsonifyAuctionObject(ao *analytics.AuctionObject, scope string) ([]byte, error) { diff --git a/analytics/pubstack/helpers/json_test.go b/analytics/pubstack/helpers/json_test.go index 4f453ccdf58..7673b067f8a 100644 --- a/analytics/pubstack/helpers/json_test.go +++ b/analytics/pubstack/helpers/json_test.go @@ -1,11 +1,12 @@ package helpers import ( - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "net/http" "testing" + + "github.com/mxmCherry/openrtb/v15/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.go b/analytics/pubstack/pubstack_module.go index ae32dc52638..60ccde02a8c 100644 --- a/analytics/pubstack/pubstack_module.go +++ b/analytics/pubstack/pubstack_module.go @@ -2,7 +2,7 @@ package pubstack import ( "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/analytics/pubstack/eventchannel" + "github.com/prebid/prebid-server/analytics/pubstack/eventchannel" "net/http" "net/url" "os" @@ -11,10 +11,10 @@ import ( "syscall" "time" - "github.com/PubMatic-OpenWrap/prebid-server/analytics/pubstack/helpers" "github.com/golang/glog" + "github.com/prebid/prebid-server/analytics/pubstack/helpers" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" + "github.com/prebid/prebid-server/analytics" ) type Configuration struct { diff --git a/analytics/pubstack/pubstack_module_test.go b/analytics/pubstack/pubstack_module_test.go index 143fb217913..cb8f088d0bf 100644 --- a/analytics/pubstack/pubstack_module_test.go +++ b/analytics/pubstack/pubstack_module_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" + "github.com/mxmCherry/openrtb/v15/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/cache/dummycache/dummycache.go b/cache/dummycache/dummycache.go index 245b36325aa..8cf9f2c4dff 100644 --- a/cache/dummycache/dummycache.go +++ b/cache/dummycache/dummycache.go @@ -3,7 +3,7 @@ package dummycache import ( "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/cache" + "github.com/prebid/prebid-server/cache" ) // Cache dummy config that will echo back results diff --git a/cache/filecache/filecache.go b/cache/filecache/filecache.go index d49f755edb4..0c1ba435388 100644 --- a/cache/filecache/filecache.go +++ b/cache/filecache/filecache.go @@ -4,8 +4,8 @@ import ( "fmt" "io/ioutil" - "github.com/PubMatic-OpenWrap/prebid-server/cache" "github.com/golang/glog" + "github.com/prebid/prebid-server/cache" "gopkg.in/yaml.v2" ) diff --git a/cache/postgrescache/postgrescache.go b/cache/postgrescache/postgrescache.go index aa0d3c3ea8b..df8b8fe49b2 100644 --- a/cache/postgrescache/postgrescache.go +++ b/cache/postgrescache/postgrescache.go @@ -7,11 +7,11 @@ import ( "encoding/gob" "time" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/cache" "github.com/coocood/freecache" "github.com/lib/pq" + "github.com/prebid/prebid-server/cache" ) type CacheConfig struct { diff --git a/config/accounts.go b/config/accounts.go index 548092451c3..f7b380fca48 100644 --- a/config/accounts.go +++ b/config/accounts.go @@ -39,8 +39,9 @@ func (a *AccountCCPA) EnabledForIntegrationType(integrationType IntegrationType) // AccountGDPR represents account-specific GDPR configuration type AccountGDPR struct { - Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"` - IntegrationEnabled AccountIntegration `mapstructure:"integration_enabled" json:"integration_enabled"` + Enabled *bool `mapstructure:"enabled" json:"enabled,omitempty"` + IntegrationEnabled AccountIntegration `mapstructure:"integration_enabled" json:"integration_enabled"` + BasicEnforcementVendors []string `mapstructure:"basic_enforcement_vendors" json:"basic_enforcement_vendors"` } // EnabledForIntegrationType indicates whether GDPR is turned on at the account level for the specified integration type diff --git a/config/adapter.go b/config/adapter.go index 5f188ac4a62..ff262b186fd 100644 --- a/config/adapter.go +++ b/config/adapter.go @@ -4,8 +4,8 @@ import ( "fmt" "text/template" - "github.com/PubMatic-OpenWrap/prebid-server/macros" validator "github.com/asaskevich/govalidator" + "github.com/prebid/prebid-server/macros" ) type Adapter struct { diff --git a/config/bidderinfo.go b/config/bidderinfo.go new file mode 100644 index 00000000000..9eff288f64f --- /dev/null +++ b/config/bidderinfo.go @@ -0,0 +1,101 @@ +package config + +import ( + "fmt" + "io/ioutil" + "strings" + + "github.com/prebid/prebid-server/openrtb_ext" + "gopkg.in/yaml.v2" +) + +// BidderInfos contains a mapping of bidder name to bidder info. +type BidderInfos map[string]BidderInfo + +// BidderInfo is the maintainer information, supported auction types, and feature opts-in for a bidder. +type BidderInfo struct { + Enabled bool // copied from adapter config for convenience. to be refactored. + Maintainer *MaintainerInfo `yaml:"maintainer"` + Capabilities *CapabilitiesInfo `yaml:"capabilities"` + ModifyingVastXmlAllowed bool `yaml:"modifyingVastXmlAllowed"` + Debug *DebugInfo `yaml:"debug,omitempty"` + GVLVendorID uint16 `yaml:"gvlVendorID,omitempty"` +} + +// MaintainerInfo is the support email address for a bidder. +type MaintainerInfo struct { + Email string `yaml:"email"` +} + +// CapabilitiesInfo is the supported platforms for a bidder. +type CapabilitiesInfo struct { + App *PlatformInfo `yaml:"app"` + Site *PlatformInfo `yaml:"site"` +} + +// PlatformInfo is the supported media types for a bidder. +type PlatformInfo struct { + MediaTypes []openrtb_ext.BidType `yaml:"mediaTypes"` +} + +// DebugInfo is the supported debug options for a bidder. +type DebugInfo struct { + Allow bool `yaml:"allow"` +} + +// LoadBidderInfoFromDisk parses all static/bidder-info/{bidder}.yaml files from the file system. +func LoadBidderInfoFromDisk(path string, adapterConfigs map[string]Adapter, bidders []string) (BidderInfos, error) { + reader := infoReaderFromDisk{path} + return loadBidderInfo(reader, adapterConfigs, bidders) +} + +func loadBidderInfo(r infoReader, adapterConfigs map[string]Adapter, bidders []string) (BidderInfos, error) { + infos := BidderInfos{} + + for _, bidder := range bidders { + data, err := r.Read(bidder) + if err != nil { + return nil, err + } + + info := BidderInfo{} + if err := yaml.Unmarshal(data, &info); err != nil { + return nil, fmt.Errorf("error parsing yaml for bidder %s: %v", bidder, err) + } + + info.Enabled = isEnabledByConfig(adapterConfigs, bidder) + infos[bidder] = info + } + + return infos, nil +} + +func isEnabledByConfig(adapterConfigs map[string]Adapter, bidderName string) bool { + a, ok := adapterConfigs[strings.ToLower(bidderName)] + return ok && !a.Disabled +} + +type infoReader interface { + Read(bidder string) ([]byte, error) +} + +type infoReaderFromDisk struct { + path string +} + +func (r infoReaderFromDisk) Read(bidder string) ([]byte, error) { + path := fmt.Sprintf("%v/%v.yaml", r.path, bidder) + return ioutil.ReadFile(path) +} + +// ToGVLVendorIDMap transforms a BidderInfos object to a map of bidder names to GVL id. Disabled +// bidders are omitted from the result. +func (infos BidderInfos) ToGVLVendorIDMap() map[openrtb_ext.BidderName]uint16 { + m := make(map[openrtb_ext.BidderName]uint16, len(infos)) + for name, info := range infos { + if info.Enabled && info.GVLVendorID != 0 { + m[openrtb_ext.BidderName(name)] = info.GVLVendorID + } + } + return m +} diff --git a/config/bidderinfo_test.go b/config/bidderinfo_test.go new file mode 100644 index 00000000000..62a0b853abd --- /dev/null +++ b/config/bidderinfo_test.go @@ -0,0 +1,210 @@ +package config + +import ( + "errors" + "strings" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/stretchr/testify/assert" +) + +const testInfoFilesPath = "./test/bidder-info" +const testYAML = ` +maintainer: + email: "some-email@domain.com" +gvlVendorID: 42 +capabilities: + app: + mediaTypes: + - banner + - native + site: + mediaTypes: + - banner + - video + - native +` + +func TestLoadBidderInfoFromDisk(t *testing.T) { + bidder := "someBidder" + + adapterConfigs := make(map[string]Adapter) + adapterConfigs[strings.ToLower(bidder)] = Adapter{} + + infos, err := LoadBidderInfoFromDisk(testInfoFilesPath, adapterConfigs, []string{bidder}) + if err != nil { + t.Fatal(err) + } + + expected := BidderInfos{ + bidder: { + Enabled: true, + Maintainer: &MaintainerInfo{ + Email: "some-email@domain.com", + }, + GVLVendorID: 42, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeNative}, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative}, + }, + }, + }, + } + assert.Equal(t, expected, infos) +} + +func TestLoadBidderInfo(t *testing.T) { + bidder := "someBidder" // important to be mixed case for tests + + testCases := []struct { + description string + givenConfigs map[string]Adapter + givenContent string + givenError error + expectedInfo BidderInfos + expectedError string + }{ + { + description: "Enabled", + givenConfigs: map[string]Adapter{strings.ToLower(bidder): {}}, + givenContent: testYAML, + expectedInfo: map[string]BidderInfo{ + bidder: { + Enabled: true, + Maintainer: &MaintainerInfo{ + Email: "some-email@domain.com", + }, + GVLVendorID: 42, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeNative}, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative}, + }, + }, + }, + }, + }, + { + description: "Disabled - Bidder Not Configured", + givenConfigs: map[string]Adapter{}, + givenContent: testYAML, + expectedInfo: map[string]BidderInfo{ + bidder: { + Enabled: false, + Maintainer: &MaintainerInfo{ + Email: "some-email@domain.com", + }, + GVLVendorID: 42, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeNative}, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative}, + }, + }, + }, + }, + }, + { + description: "Disabled - Bidder Wrong Case", + givenConfigs: map[string]Adapter{bidder: {}}, + givenContent: testYAML, + expectedInfo: map[string]BidderInfo{ + bidder: { + Enabled: false, + Maintainer: &MaintainerInfo{ + Email: "some-email@domain.com", + }, + GVLVendorID: 42, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeNative}, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative}, + }, + }, + }, + }, + }, + { + description: "Disabled - Explicitly Configured", + givenConfigs: map[string]Adapter{strings.ToLower(bidder): {Disabled: false}}, + givenContent: testYAML, + expectedInfo: map[string]BidderInfo{ + bidder: { + Enabled: true, + Maintainer: &MaintainerInfo{ + Email: "some-email@domain.com", + }, + GVLVendorID: 42, + Capabilities: &CapabilitiesInfo{ + App: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeNative}, + }, + Site: &PlatformInfo{ + MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo, openrtb_ext.BidTypeNative}, + }, + }, + }, + }, + }, + { + description: "Read Error", + givenConfigs: map[string]Adapter{strings.ToLower(bidder): {}}, + givenError: errors.New("any read error"), + expectedError: "any read error", + }, + { + description: "Unmarshal Error", + givenConfigs: map[string]Adapter{strings.ToLower(bidder): {}}, + givenContent: "invalid yaml", + expectedError: "error parsing yaml for bidder someBidder: yaml: unmarshal errors:\n line 1: cannot unmarshal !!str `invalid...` into config.BidderInfo", + }, + } + + for _, test := range testCases { + r := fakeInfoReader{test.givenContent, test.givenError} + info, err := loadBidderInfo(r, test.givenConfigs, []string{bidder}) + + if test.expectedError == "" { + assert.NoError(t, err, test.description) + } else { + assert.EqualError(t, err, test.expectedError, test.description) + } + + assert.Equal(t, test.expectedInfo, info, test.description) + } +} + +type fakeInfoReader struct { + content string + err error +} + +func (r fakeInfoReader) Read(bidder string) ([]byte, error) { + return []byte(r.content), r.err +} + +func TestToGVLVendorIDMap(t *testing.T) { + givenBidderInfos := BidderInfos{ + "bidderA": BidderInfo{Enabled: true, GVLVendorID: 0}, + "bidderB": BidderInfo{Enabled: true, GVLVendorID: 100}, + "bidderC": BidderInfo{Enabled: false, GVLVendorID: 0}, + "bidderD": BidderInfo{Enabled: false, GVLVendorID: 200}, + } + + expectedGVLVendorIDMap := map[openrtb_ext.BidderName]uint16{ + "bidderB": 100, + } + + result := givenBidderInfos.ToGVLVendorIDMap() + assert.Equal(t, expectedGVLVendorIDMap, result) +} diff --git a/config/bidderinfo_validate_test.go b/config/bidderinfo_validate_test.go new file mode 100644 index 00000000000..23d6e3df034 --- /dev/null +++ b/config/bidderinfo_validate_test.go @@ -0,0 +1,115 @@ +package config + +import ( + "errors" + "fmt" + "io/ioutil" + "os" + "strings" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/stretchr/testify/assert" + "gopkg.in/yaml.v2" +) + +const bidderInfoRelativePath = "../static/bidder-info" + +// TestBidderInfoFiles ensures each bidder has a valid static/bidder-info/bidder.yaml file. Validation is performed directly +// against the file system with separate yaml unmarshalling from the LoadBidderInfoFromDisk func. +func TestBidderInfoFiles(t *testing.T) { + fileInfos, err := ioutil.ReadDir(bidderInfoRelativePath) + if err != nil { + assert.FailNow(t, "Error reading the static/bidder-info directory: %v", err) + } + + // Ensure YAML Files Are For A Known Core Bidder + for _, fileInfo := range fileInfos { + bidder := strings.TrimSuffix(fileInfo.Name(), ".yaml") + + _, isKnown := openrtb_ext.NormalizeBidderName(bidder) + assert.True(t, isKnown, "unexpected bidder info yaml file %s", fileInfo.Name()) + } + + // Ensure YAML Files Are Defined For Each Core Bidder + expectedFileInfosLength := len(openrtb_ext.CoreBidderNames()) + assert.Len(t, fileInfos, expectedFileInfosLength, "static/bidder-info contains %d files, but there are %d known bidders. Did you forget to add a YAML file for your bidder?", len(fileInfos), expectedFileInfosLength) + + // Validate Contents + for _, fileInfo := range fileInfos { + path := fmt.Sprintf(bidderInfoRelativePath + "/" + fileInfo.Name()) + + infoFileData, err := os.Open(path) + assert.NoError(t, err, "Unexpected error: %v", err) + + content, err := ioutil.ReadAll(infoFileData) + assert.NoError(t, err, "Failed to read static/bidder-info/%s: %v", fileInfo.Name(), err) + + var fileInfoContent BidderInfo + err = yaml.Unmarshal(content, &fileInfoContent) + assert.NoError(t, err, "Error interpreting content from static/bidder-info/%s: %v", fileInfo.Name(), err) + + err = validateInfo(&fileInfoContent) + assert.NoError(t, err, "Invalid content in static/bidder-info/%s: %v", fileInfo.Name(), err) + } +} + +func validateInfo(info *BidderInfo) error { + if err := validateMaintainer(info.Maintainer); err != nil { + return err + } + + if err := validateCapabilities(info.Capabilities); err != nil { + return err + } + + return nil +} + +func validateMaintainer(info *MaintainerInfo) error { + if info == nil || info.Email == "" { + return errors.New("missing required field: maintainer.email") + } + return nil +} + +func validateCapabilities(info *CapabilitiesInfo) error { + if info == nil { + return errors.New("missing required field: capabilities") + } + + if info.App == nil && info.Site == nil { + return errors.New("at least one of capabilities.site or capabilities.app must exist") + } + + if info.App != nil { + if err := validatePlatformInfo(info.App); err != nil { + return fmt.Errorf("capabilities.app failed validation: %v", err) + } + } + + if info.Site != nil { + if err := validatePlatformInfo(info.Site); err != nil { + return fmt.Errorf("capabilities.site failed validation: %v", err) + } + } + return nil +} + +func validatePlatformInfo(info *PlatformInfo) error { + if info == nil { + return errors.New("object cannot be empty") + } + + if len(info.MediaTypes) == 0 { + return errors.New("mediaTypes should be an array with at least one string element") + } + + for index, mediaType := range info.MediaTypes { + if mediaType != "banner" && mediaType != "video" && mediaType != "native" && mediaType != "audio" { + return fmt.Errorf("unrecognized media type at index %d: %s", index, mediaType) + } + } + + return nil +} diff --git a/config/config.go b/config/config.go index d9d2b331bb9..66a11ca71bf 100755 --- a/config/config.go +++ b/config/config.go @@ -9,9 +9,9 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/spf13/viper" ) @@ -79,7 +79,9 @@ type Configuration struct { // RequestValidation specifies the request validation options. RequestValidation RequestValidation `mapstructure:"request_validation"` // When true, PBS will assign a randomly generated UUID to req.Source.TID if it is empty - AutoGenSourceTID bool `mapstructure:"auto_gen_source_tid"` + AutoGenSourceTID bool `mapstructure:"auto_gen_source_tid"` + //When true, new bid id will be generated in seatbid[].bid[].ext.prebid.bidid and used in event urls instead + GenerateBidID bool `mapstructure:"generate_bid_id"` TrackerURL string `mapstructure:"tracker_url"` } @@ -523,7 +525,7 @@ func New(v *viper.Viper) (*Configuration, error) { glog.Info("Logging the resolved configuration:") logGeneral(reflect.ValueOf(c), " \t") if errs := c.validate(); len(errs) > 0 { - return &c, errortypes.NewAggregateErrors("validation errors", errs) + return &c, errortypes.NewAggregateError("validation errors", errs) } return &c, nil @@ -572,12 +574,14 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdkernel, "https://sync.adkernel.com/user-sync?t=image&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadkernel%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdkernelAdn, "https://tag.adkernel.com/syncr?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3DadkernelAdn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BUID%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdpone, "https://usersync.adpone.com/csync?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadpone%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdtarget, "https://sync.console.adtarget.com.tr/csync?t=p&ep=0&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadtarget%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdtelligent, "https://sync.adtelligent.com/csync?t=p&ep=0&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadtelligent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D") + // openrtb_ext.BidderAdtarget doesn't have a good default. + // openrtb_ext.BidderAdtelligent doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdmixer, "https://inv-nets.admixer.net/adxcm.aspx?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir=1&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadmixer%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%24visitor_cookie%24%24") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdman, "https://sync.admanmedia.com/pbs.gif?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadman%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BUID%5D") // openrtb_ext.BidderAdOcean doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdvangelists, "https://nep.advangelists.com/xp/user-sync?acctid={aid}&&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadvangelists%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") + // openrtb_ext.BidderAdxcg doesn't have a good default. + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAdyoulike, "http://visitor.omnitagjs.com/visitor/bsync?uid=19340f4f097d16f41f34fc0274981ca4&name=PrebidServer&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&url="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadyoulike%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BBUYER_USERID%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAJA, "https://ad.as.amanad.adtdp.com/v1/sync/ssp?ssp=4&gdpr={{.GDPR}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Daja%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25s") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAMX, "https://prebid.a-mo.net/cchain/0?gdpr={{.GDPR}}&us_privacy={{.USPrivacy}}&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Damx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderAppnexus, "https://ib.adnxs.com/getuid?"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dadnxs%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") @@ -592,10 +596,12 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderCpmstar, "https://server.cpmstar.com/usersync.aspx?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dcpmstar%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDatablocks, "https://sync.v5prebid.datablocks.net/s2ssync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7Buid%7D") // openrtb_ext.BidderDecenterAds doesn't have a good default. - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDmx, "https://dmx.districtm.io/s/v1/img/s/10007?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddatablocks%26gdpr%3D%24%7Bgdpr%7D%26gdpr_consent%3D%24%7Bgdpr_consent%7D%26uid%3D%24%7Buid%7D") + // openrtb_ext.BidderDmx doesn't have a good default. + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderDeepintent, "https://match.deepintent.com/usersync/136?id=unk&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ddeepintent%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BUID%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEngageBDR, "https://match.bnmla.com/usersync/s2s_sync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dengagebdr%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") + // openrtb_ext.BidderEpom doesn't have a good default. // openrtb_ext.BidderFacebook doesn't have a good default. // openrtb_ext.BidderGamma doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderGamoshi, "https://rtb.gamoshi.io/user_sync_prebid?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dgamoshi%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Bgusr%5D") @@ -604,18 +610,21 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderImprovedigital, "https://ad.360yield.com/server_match?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dimprovedigital%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7BPUB_USER_ID%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderIx, "https://ssum.casalemedia.com/usermatchredir?s=186523&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") // openrtb_ext.BidderInvibes doesn't have a good default. + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderJixie, "https://id.jixie.io/api/sync?pid=&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Djixie%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25JXUID%25%25") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderKrushmedia, "https://cs.krushmedia.com/4e4abdd5ecc661643458a730b1aa927d.gif?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dkrushmedia%26uid%3D%5BUID%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLifestreet, "https://ads.lfstmedia.com/idsync/137062?synced=1&ttl=1s&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlifestreet%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%24visitor_cookie%24%24") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLockerDome, "https://lockerdome.com/usync/prebidserver?pid="+cfg.Adapters["lockerdome"].PlatformID+"&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlockerdome%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7Buid%7D%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLogicad, "https://cr-p31.ladsp.jp/cookiesender/31?r=true&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&ru="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlogicad%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderLunaMedia, "https://api.lunamedia.io/xp/user-sync?redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dlunamedia%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderMarsmedia, "https://dmp.rtbsrv.com/dmp/profiles/cm?p_id=179&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dmarsmedia%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D") - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderMediafuse, "https://sync.hbmp.mediafuse.com/csync?t=p&ep=0&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dmediafuse%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Buid%7D") + // openrtb_ext.BidderMediafuse doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderMgid, "https://cm.mgid.com/m?cdsp=363893&adu="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dmgid%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7Bmuidn%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNanoInteractive, "https://ad.audiencemanager.de/hbs/cookie_sync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirectUri="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dnanointeractive%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNinthDecimal, "https://rtb.ninthdecimal.com/xp/user-sync?acctid={aid}&&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dninthdecimal%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderNoBid, "https://ads.servenobid.com/getsync?tek=pbs&ver=1&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dnobid%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderOpenx, "https://rtb.openx.net/sync/prebid?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dopenx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUID%7D") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderOneTag, "https://onetag-sys.com/usync/?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Donetag%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUSER_TOKEN%7D") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderOutbrain, "https://prebidtest.zemanta.com/usersync/prebidtest?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Doutbrain%26uid%3D__ZUID__") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPubmatic, "https://ads.pubmatic.com/AdServer/js/user_sync.html?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&predirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpubmatic%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderPulsepoint, "https://bh.contextweb.com/rtset?pid=561205&ev=1&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dpulsepoint%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%25%25VGUID%25%25") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderRhythmone, "https://sync.1rx.io/usersync2/rmphb?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Drhythmone%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5BRX_UUID%5D") @@ -629,11 +638,13 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSonobi, "https://sync.go.sonobi.com/us.gif?loc="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsonobi%26consent_string%3D{{.GDPR}}%26gdpr%3D{{.GDPRConsent}}%26uid%3D%5BUID%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") - // openrtb_ext.BidderTappx doesn't have a good default. + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTappx, "https://ssp.api.tappx.com/cs/usersync.php?gdpr_optin={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&type=iframe&ruid="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtappx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%7B%7BTPPXUID%7D%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.tremorhub.com/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTrustX, "https://x.bidswitch.net/check_uuid/"+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtrustx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BBSW_UUID%7D?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUcfunnel, "https://sync.aralego.com/idsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&usprivacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ducfunnel%26uid%3DSspCookieUserId") + // openrtb_ext.BidderUnicorn doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUnruly, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderValueImpression, "https://rtb.valueimpression.com/usersync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dvalueimpression%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderVisx, "https://t.visx.net/s2s_sync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dvisx%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D") @@ -790,9 +801,9 @@ func SetupViper(v *viper.Viper, filename string) { } // Disabling adapters by default that require some specific config params. - // If you're using one of these, make sure you check out the documentation (https://github.com/PubMatic-OpenWrap/prebid-server/tree/master/docs/bidders) + // If you're using one of these, make sure you check out the documentation (https://github.com/prebid/prebid-server/tree/master/docs/bidders) // for them and specify all the parameters they need for them to work correctly. - v.SetDefault("adapters.33across.endpoint", "http://ssc.33across.com/api/v1/hb") + v.SetDefault("adapters.33across.endpoint", "https://ssc.33across.com/api/v1/s2s") v.SetDefault("adapters.33across.partner_id", "") v.SetDefault("adapters.acuityads.endpoint", "http://{{.Host}}.admanmedia.com/bid?token={{.AccountID}}") v.SetDefault("adapters.adform.endpoint", "https://adx.adform.net/adx") @@ -810,6 +821,8 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adtarget.endpoint", "http://ghb.console.adtarget.com.tr/pbs/ortb") v.SetDefault("adapters.adtelligent.endpoint", "http://ghb.adtelligent.com/pbs/ortb") v.SetDefault("adapters.advangelists.endpoint", "http://nep.advangelists.com/xp/get?pubid={{.PublisherID}}") + v.SetDefault("adapters.adxcg.disabled", true) + v.SetDefault("adapters.adyoulike.endpoint", "https://broker.omnitagjs.com/broker/bid?partnerId=19340f4f097d16f41f34fc0274981ca4") v.SetDefault("adapters.aja.endpoint", "https://ad.as.amanad.adtdp.com/v1/bid/4") v.SetDefault("adapters.amx.endpoint", "http://pbs.amxrtb.com/auction/openrtb") v.SetDefault("adapters.applogy.endpoint", "http://rtb.applogy.com/v1/prebid") @@ -822,12 +835,14 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.beachfront.extra_info", "{\"video_endpoint\":\"https://reachms.bfmio.com/bid.json?exchange_id\"}") v.SetDefault("adapters.beintoo.endpoint", "https://ib.beintoo.com/um") v.SetDefault("adapters.between.endpoint", "http://{{.Host}}.betweendigital.com/openrtb_bid?sspId={{.PublisherID}}") + v.SetDefault("adapters.bidmachine.endpoint", "https://{{.Host}}.bidmachine.io") v.SetDefault("adapters.brightroll.endpoint", "http://east-bid.ybp.yahoo.com/bid/appnexuspbs") v.SetDefault("adapters.colossus.endpoint", "http://colossusssp.com/?c=o&m=rtb") v.SetDefault("adapters.connectad.endpoint", "http://bidder.connectad.io/API?src=pbs") v.SetDefault("adapters.consumable.endpoint", "https://e.serverbid.com/api/v2") v.SetDefault("adapters.conversant.endpoint", "http://api.hb.ad.cpe.dotomi.com/cvx/server/hb/ortb/25") v.SetDefault("adapters.cpmstar.endpoint", "https://server.cpmstar.com/openrtbbidrq.aspx") + v.SetDefault("adapters.criteo.endpoint", "https://bidder.criteo.com/cdb?profileId=230") v.SetDefault("adapters.datablocks.endpoint", "http://{{.Host}}/openrtb2?sid={{.SourceId}}") v.SetDefault("adapters.decenterads.endpoint", "http://supply.decenterads.com/?c=o&m=rtb") v.SetDefault("adapters.deepintent.endpoint", "https://prebid.deepintent.com/prebid") @@ -835,13 +850,17 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.emx_digital.endpoint", "https://hb.emxdgt.com") v.SetDefault("adapters.engagebdr.endpoint", "http://dsp.bnmla.com/hb") v.SetDefault("adapters.eplanning.endpoint", "http://rtb.e-planning.net/pbs/1") + v.SetDefault("adapters.epom.endpoint", "https://an.epom.com/ortb") + v.SetDefault("adapters.epom.disabled", true) v.SetDefault("adapters.gamma.endpoint", "https://hb.gammaplatform.com/adx/request/") v.SetDefault("adapters.gamoshi.endpoint", "https://rtb.gamoshi.io") v.SetDefault("adapters.grid.endpoint", "https://grid.bidswitch.net/sp_bid?sp=prebid") v.SetDefault("adapters.gumgum.endpoint", "https://g2.gumgum.com/providers/prbds2s/bid") v.SetDefault("adapters.improvedigital.endpoint", "http://ad.360yield.com/pbs") v.SetDefault("adapters.inmobi.endpoint", "https://api.w.inmobi.com/showad/openrtb/bidder/prebid") + v.SetDefault("adapters.ix.disabled", false) v.SetDefault("adapters.ix.endpoint", "http://exchange.indexww.com/pbs?p=192919") + v.SetDefault("adapters.jixie.endpoint", "https://hb.jixie.io/v2/hbsvrpost") v.SetDefault("adapters.krushmedia.endpoint", "http://ads4.krushmedia.com/?c=rtb&m=req&key={{.AccountID}}") v.SetDefault("adapters.invibes.endpoint", "https://{{.Host}}/bid/ServerBidAdContent") v.SetDefault("adapters.kidoz.endpoint", "http://prebid-adapter.kidoz.net/openrtb2/auction?src=prebid-server") @@ -854,12 +873,15 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.mediafuse.endpoint", "http://ghb.hbmp.mediafuse.com/pbs/ortb") v.SetDefault("adapters.mgid.endpoint", "https://prebid.mgid.com/prebid/") v.SetDefault("adapters.mobilefuse.endpoint", "http://mfx.mobilefuse.com/openrtb?pub_id={{.PublisherID}}") - v.SetDefault("adapters.mobfoxpb.endpoint", "http://bes.mobfox.com/?c=o&m=ortb") + v.SetDefault("adapters.mobfoxpb.endpoint", "http://bes.mobfox.com/?c=__route__&m=__method__&key=__key__") v.SetDefault("adapters.nanointeractive.endpoint", "https://ad.audiencemanager.de/hbs") v.SetDefault("adapters.ninthdecimal.endpoint", "http://rtb.ninthdecimal.com/xp/get?pubid={{.PublisherID}}") v.SetDefault("adapters.nobid.endpoint", "https://ads.servenobid.com/ortb_adreq?tek=pbs&ver=1") + v.SetDefault("adapters.onetag.endpoint", "https://prebid-server.onetag-sys.com/prebid-server/{{.PublisherID}}") v.SetDefault("adapters.openx.endpoint", "http://rtb.openx.net/prebid") v.SetDefault("adapters.orbidder.endpoint", "https://orbidder.otto.de/openrtb2") + v.SetDefault("adapters.outbrain.endpoint", "https://prebidtest.zemanta.com/api/bidder/prebidtest/bid/") + v.SetDefault("adapters.pangle.disabled", true) v.SetDefault("adapters.pubmatic.endpoint", "https://hbopenbid.pubmatic.com/translator?source=prebid-server") v.SetDefault("adapters.pubnative.endpoint", "http://dsp.pubnative.net/bid/v1/request") v.SetDefault("adapters.pulsepoint.endpoint", "http://bid.contextweb.com/header/s/ortb/prebid-s2s") @@ -878,14 +900,16 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.somoaudience.endpoint", "http://publisher-east.mobileadtrading.com/rtb/bid") v.SetDefault("adapters.sonobi.endpoint", "https://apex.go.sonobi.com/prebid?partnerid=71d9d3d8af") v.SetDefault("adapters.sovrn.endpoint", "http://ap.lijit.com/rtb/bid?src=prebid_server") - v.SetDefault("adapters.synacormedia.endpoint", "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}") v.SetDefault("adapters.spotx.endpoint", "https://search.spotxchange.com/openrtb/2.3/dados") - v.SetDefault("adapters.tappx.endpoint", "https://{{.Host}}") + v.SetDefault("adapters.synacormedia.endpoint", "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}") + v.SetDefault("adapters.tappx.endpoint", "http://{{.Host}}") v.SetDefault("adapters.telaria.endpoint", "https://ads.tremorhub.com/ad/rtb/prebid") v.SetDefault("adapters.triplelift_native.disabled", true) v.SetDefault("adapters.triplelift_native.extra_info", "{\"publisher_whitelist\":[]}") v.SetDefault("adapters.triplelift.endpoint", "https://tlx.3lift.com/s2s/auction?sra=1&supplier_id=20") + v.SetDefault("adapters.trustx.endpoint", "https://grid.bidswitch.net/sp_bid?sp=trustx") v.SetDefault("adapters.ucfunnel.endpoint", "https://pbs.aralego.com/prebid") + v.SetDefault("adapters.unicorn.endpoint", "https://ds.uncn.jp/pb/0/bid.json") v.SetDefault("adapters.unruly.endpoint", "http://targeting.unrulymedia.com/openrtb/2.2") v.SetDefault("adapters.valueimpression.endpoint", "https://rtb.valueimpression.com/endpoint") v.SetDefault("adapters.verizonmedia.disabled", true) @@ -943,6 +967,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("account_defaults.debug_allow", true) v.SetDefault("certificates_file", "") v.SetDefault("auto_gen_source_tid", true) + v.SetDefault("generate_bid_id", false) v.SetDefault("request_timeout_headers.request_time_in_queue", "") v.SetDefault("request_timeout_headers.request_timeout_in_queue", "") diff --git a/config/config_test.go b/config/config_test.go index f6792cb7648..43ee8fa21df 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -11,7 +11,7 @@ import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/spf13/viper" "github.com/stretchr/testify/assert" ) @@ -139,6 +139,7 @@ func TestDefaults(t *testing.T) { cmpBools(t, "stored_requests.filesystem.enabled", false, cfg.StoredRequests.Files.Enabled) cmpStrings(t, "stored_requests.filesystem.directorypath", "./stored_requests/data/by_id", cfg.StoredRequests.Files.Path) cmpBools(t, "auto_gen_source_tid", cfg.AutoGenSourceTID, true) + cmpBools(t, "generate_bid_id", cfg.GenerateBidID, false) } var fullConfig = []byte(` @@ -230,6 +231,7 @@ certificates_file: /etc/ssl/cert.pem request_validation: ipv4_private_networks: ["1.1.1.0/24"] ipv6_private_networks: ["1111::/16", "2222::/16"] +generate_bid_id: true `) var adapterExtraInfoConfig = []byte(` @@ -415,6 +417,7 @@ func TestFullConfig(t *testing.T) { cmpStrings(t, "request_validation.ipv4_private_networks", cfg.RequestValidation.IPv4PrivateNetworks[0], "1.1.1.0/24") cmpStrings(t, "request_validation.ipv6_private_networks", cfg.RequestValidation.IPv6PrivateNetworks[0], "1111::/16") cmpStrings(t, "request_validation.ipv6_private_networks", cfg.RequestValidation.IPv6PrivateNetworks[1], "2222::/16") + cmpBools(t, "generate_bid_id", cfg.GenerateBidID, true) } func TestUnmarshalAdapterExtraInfo(t *testing.T) { diff --git a/adapters/adapterstest/bidder-info/someBidder.yaml b/config/test/bidder-info/someBidder.yaml similarity index 91% rename from adapters/adapterstest/bidder-info/someBidder.yaml rename to config/test/bidder-info/someBidder.yaml index b5216f0fe46..232b73d0aac 100644 --- a/adapters/adapterstest/bidder-info/someBidder.yaml +++ b/config/test/bidder-info/someBidder.yaml @@ -1,5 +1,6 @@ maintainer: email: "some-email@domain.com" +gvlVendorID: 42 capabilities: app: mediaTypes: diff --git a/currency/rate_converter.go b/currency/rate_converter.go index 269cf7551ea..39b9cd59ca2 100644 --- a/currency/rate_converter.go +++ b/currency/rate_converter.go @@ -8,9 +8,9 @@ import ( "sync/atomic" "time" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/util/timeutil" "github.com/golang/glog" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/util/timeutil" ) // RateConverter holds the currencies conversion rates dictionary diff --git a/currency/rate_converter_test.go b/currency/rate_converter_test.go index b3e26c86a47..e1d6741dff2 100644 --- a/currency/rate_converter_test.go +++ b/currency/rate_converter_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/util/task" + "github.com/prebid/prebid-server/util/task" "github.com/stretchr/testify/assert" ) diff --git a/docs/developers/automated-tests.md b/docs/developers/automated-tests.md index 93bd28f6187..9e435aaf57e 100644 --- a/docs/developers/automated-tests.md +++ b/docs/developers/automated-tests.md @@ -1,6 +1,6 @@ # Automated Tests -This project uses [TravisCI](https://travis-ci.org/) to make sure that every PR passes automated tests. +This project uses GitHub Actions to make sure that every PR passes automated tests. To reproduce these tests locally, use: ``` diff --git a/docs/developers/contributing.md b/docs/developers/contributing.md index b418efa2877..cc2daaecd11 100644 --- a/docs/developers/contributing.md +++ b/docs/developers/contributing.md @@ -40,7 +40,7 @@ those updates must be submitted in the same Pull Request as the code changes. When you're ready, [submit a Pull Request](https://help.github.com/articles/creating-a-pull-request/) against the `master` branch of [our GitHub repository](https://github.com/PubMatic-OpenWrap/prebid-server/compare). -Pull Requests will be vetted through [Travis CI](https://travis-ci.com/). +Pull Requests will be vetted through GitHub Actions. To reproduce these same tests locally, do: ```bash diff --git a/endpoints/auction.go b/endpoints/auction.go index 4416b602f1a..069abfec4e5 100644 --- a/endpoints/auction.go +++ b/endpoints/auction.go @@ -10,21 +10,21 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/cache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - pbc "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - gdprPrivacy "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/cache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + pbc "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/privacy" + gdprPrivacy "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/usersync" ) type bidResult struct { @@ -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 331ddc2500c..17ed7f74f45 100644 --- a/endpoints/auction_test.go +++ b/endpoints/auction_test.go @@ -10,17 +10,17 @@ import ( "net/http/httptest" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - gdprPolicy "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/usersync/usersyncers" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + metricsConf "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/prebid_cache_client" + gdprPolicy "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/usersync/usersyncers" "github.com/spf13/viper" "github.com/stretchr/testify/assert" @@ -454,7 +454,7 @@ func (m *auctionMockPermissions) BidderSyncAllowed(ctx context.Context, bidder o return m.allowBidderSync, nil } -func (m *auctionMockPermissions) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string) (bool, bool, bool, error) { +func (m *auctionMockPermissions) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return m.allowPI, m.allowGeo, m.allowID, nil } @@ -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/cookie_sync.go b/endpoints/cookie_sync.go index aaa7a2425a3..0396ee9f107 100644 --- a/endpoints/cookie_sync.go +++ b/endpoints/cookie_sync.go @@ -10,18 +10,18 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - gdprPrivacy "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/buger/jsonparser" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + gdprPrivacy "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/usersync" ) func NewCookieSyncEndpoint( @@ -156,7 +156,6 @@ func (deps *cookieSyncDeps) Endpoint(w http.ResponseWriter, r *http.Request, _ h Status: cookieSyncStatus(userSyncCookie.LiveSyncCount()), BidderStatus: make([]*usersync.CookieSyncBidders, 0, len(parsedReq.Bidders)), } - for i := 0; i < len(parsedReq.Bidders); i++ { bidder := parsedReq.Bidders[i] diff --git a/endpoints/cookie_sync_test.go b/endpoints/cookie_sync_test.go index 14a699177bc..d4b89a15118 100644 --- a/endpoints/cookie_sync_test.go +++ b/endpoints/cookie_sync_test.go @@ -9,18 +9,18 @@ import ( "text/template" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/appnexus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/audienceNetwork" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lifestreet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pubmatic" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/buger/jsonparser" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/adapters/appnexus" + "github.com/prebid/prebid-server/adapters/audienceNetwork" + "github.com/prebid/prebid-server/adapters/lifestreet" + "github.com/prebid/prebid-server/adapters/pubmatic" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + metricsConf "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/usersync" "github.com/stretchr/testify/assert" ) @@ -28,9 +28,7 @@ func TestCookieSyncNoCookies(t *testing.T) { rr := doPost(`{"bidders":["appnexus", "audienceNetwork", "random"]}`, nil, true, syncersForTest()) assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8") assert.Equal(t, http.StatusOK, rr.Code) - syncs := parseSyncs(t, rr.Body.Bytes()) - assert.Contains(t, syncs, "appnexus") - assert.Contains(t, syncs, "audienceNetwork") + assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork"}, parseSyncs(t, rr.Body.Bytes())) assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes())) } @@ -48,8 +46,7 @@ func TestGDPRPreventsBidders(t *testing.T) { }) assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8") assert.Equal(t, http.StatusOK, rr.Code) - syncs := parseSyncs(t, rr.Body.Bytes()) - assert.Contains(t, syncs, "lifestreet") + assert.ElementsMatch(t, []string{"lifestreet"}, parseSyncs(t, rr.Body.Bytes())) assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes())) } @@ -57,9 +54,7 @@ func TestGDPRIgnoredIfZero(t *testing.T) { rr := doPost(`{"gdpr":0,"bidders":["appnexus", "pubmatic"]}`, nil, false, nil) assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8") assert.Equal(t, http.StatusOK, rr.Code) - syncs := parseSyncs(t, rr.Body.Bytes()) - assert.Contains(t, syncs, "appnexus") - assert.Contains(t, syncs, "pubmatic") + assert.ElementsMatch(t, []string{"appnexus", "pubmatic"}, parseSyncs(t, rr.Body.Bytes())) assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes())) } @@ -150,11 +145,7 @@ func TestCookieSyncNoBidders(t *testing.T) { rr := doPost("{}", nil, true, syncersForTest()) assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8") assert.Equal(t, http.StatusOK, rr.Code) - syncs := parseSyncs(t, rr.Body.Bytes()) - assert.Contains(t, syncs, "appnexus") - assert.Contains(t, syncs, "audienceNetwork") - assert.Contains(t, syncs, "lifestreet") - assert.Contains(t, syncs, "pubmatic") + assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork", "lifestreet", "pubmatic"}, parseSyncs(t, rr.Body.Bytes())) assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes())) } @@ -162,9 +153,7 @@ func TestCookieSyncNoCookiesBrokenGDPR(t *testing.T) { rr := doConfigurablePost(`{"bidders":["appnexus", "audienceNetwork", "random"],"gdpr_consent":"GLKHGKGKKGK"}`, nil, true, map[openrtb_ext.BidderName]usersync.Usersyncer{}, config.GDPR{UsersyncIfAmbiguous: true}, config.CCPA{}) assert.Equal(t, rr.Header().Get("Content-Type"), "application/json; charset=utf-8") assert.Equal(t, http.StatusOK, rr.Code) - syncs := parseSyncs(t, rr.Body.Bytes()) - assert.Contains(t, syncs, "appnexus") - assert.Contains(t, syncs, "audienceNetwork") + assert.ElementsMatch(t, []string{"appnexus", "audienceNetwork"}, parseSyncs(t, rr.Body.Bytes())) assert.Equal(t, "no_cookie", parseStatus(t, rr.Body.Bytes())) } @@ -265,6 +254,6 @@ func (g *gdprPerms) BidderSyncAllowed(ctx context.Context, bidder openrtb_ext.Bi return ok, nil } -func (g *gdprPerms) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string) (bool, bool, bool, error) { +func (g *gdprPerms) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return true, true, true, nil } diff --git a/endpoints/currency_rates.go b/endpoints/currency_rates.go index de5a47e19b9..d35cb74cea4 100644 --- a/endpoints/currency_rates.go +++ b/endpoints/currency_rates.go @@ -5,8 +5,8 @@ import ( "net/http" "time" - "github.com/PubMatic-OpenWrap/prebid-server/currency" "github.com/golang/glog" + "github.com/prebid/prebid-server/currency" ) // currencyRatesInfo holds currency rates information. diff --git a/endpoints/currency_rates_test.go b/endpoints/currency_rates_test.go index e73893aa837..7fc513e7dbe 100644 --- a/endpoints/currency_rates_test.go +++ b/endpoints/currency_rates_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/currency" + "github.com/prebid/prebid-server/currency" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/events/account_test.go b/endpoints/events/account_test.go index 559b39d096c..b61f29dc5c9 100644 --- a/endpoints/events/account_test.go +++ b/endpoints/events/account_test.go @@ -3,16 +3,16 @@ package events import ( "errors" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/julienschmidt/httprouter" - "github.com/stretchr/testify/assert" "io/ioutil" "net/http" "net/http/httptest" "strings" "testing" + + "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/stored_requests" + "github.com/stretchr/testify/assert" ) func TestHandleAccountServiceErrors(t *testing.T) { @@ -155,7 +155,7 @@ func vast(t *testing.T, cfg *config.Configuration, fetcher stored_requests.Accou r *http.Request }{ name: "vast", - h: NewVTrackEndpoint(cfg, fetcher, &vtrackMockCacheClient{}, adapters.BidderInfos{}), + h: NewVTrackEndpoint(cfg, fetcher, &vtrackMockCacheClient{}, config.BidderInfos{}), r: httptest.NewRequest("POST", "/vtrack?a=testacc", strings.NewReader(vtrackBody)), } } diff --git a/endpoints/events/event.go b/endpoints/events/event.go index da18b16bd53..fe178d8f271 100644 --- a/endpoints/events/event.go +++ b/endpoints/events/event.go @@ -4,12 +4,12 @@ import ( "context" "errors" "fmt" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" "github.com/julienschmidt/httprouter" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/stored_requests" "net/http" "net/url" "strconv" diff --git a/endpoints/events/event_test.go b/endpoints/events/event_test.go index d32d01ad562..ba8071843f4 100644 --- a/endpoints/events/event_test.go +++ b/endpoints/events/event_test.go @@ -4,9 +4,9 @@ import ( "context" "encoding/base64" "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/stored_requests" "github.com/stretchr/testify/assert" "io/ioutil" "net/http" diff --git a/endpoints/events/vtrack.go b/endpoints/events/vtrack.go index 8ef09f50b78..27a1ceea746 100644 --- a/endpoints/events/vtrack.go +++ b/endpoints/events/vtrack.go @@ -5,6 +5,9 @@ import ( "encoding/json" "errors" "fmt" + "github.com/PubMatic-OpenWrap/etree" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" "io" "io/ioutil" "net/http" @@ -12,20 +15,14 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/openrtb" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - - // "github.com/beevik/etree" - "github.com/PubMatic-OpenWrap/etree" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/stored_requests" ) const ( @@ -37,7 +34,7 @@ const ( type vtrackEndpoint struct { Cfg *config.Configuration Accounts stored_requests.AccountFetcher - BidderInfos adapters.BidderInfos + BidderInfos config.BidderInfos Cache prebid_cache_client.Client } @@ -87,7 +84,7 @@ var eventIDMap = map[string]string{ "complete": "6", } -func NewVTrackEndpoint(cfg *config.Configuration, accounts stored_requests.AccountFetcher, cache prebid_cache_client.Client, bidderInfos adapters.BidderInfos) httprouter.Handle { +func NewVTrackEndpoint(cfg *config.Configuration, accounts stored_requests.AccountFetcher, cache prebid_cache_client.Client, bidderInfos config.BidderInfos) httprouter.Handle { vte := &vtrackEndpoint{ Cfg: cfg, Accounts: accounts, @@ -281,7 +278,7 @@ func (v *vtrackEndpoint) cachePutObjects(ctx context.Context, req *BidCacheReque } // getBiddersAllowingVastUpdate returns a list of bidders that allow VAST XML modification -func getBiddersAllowingVastUpdate(req *BidCacheRequest, bidderInfos *adapters.BidderInfos, allowUnknownBidder bool) map[string]struct{} { +func getBiddersAllowingVastUpdate(req *BidCacheRequest, bidderInfos *config.BidderInfos, allowUnknownBidder bool) map[string]struct{} { bl := map[string]struct{}{} for _, bcr := range req.Puts { @@ -294,12 +291,12 @@ func getBiddersAllowingVastUpdate(req *BidCacheRequest, bidderInfos *adapters.Bi } // isAllowVastForBidder checks if a bidder is active and allowed to modify vast xml data -func isAllowVastForBidder(bidder string, bidderInfos *adapters.BidderInfos, allowUnknownBidder bool) bool { +func isAllowVastForBidder(bidder string, bidderInfos *config.BidderInfos, allowUnknownBidder bool) bool { //if bidder is active and isModifyingVastXmlAllowed is true // check if bidder is configured if b, ok := (*bidderInfos)[bidder]; bidderInfos != nil && ok { // check if bidder is enabled - return b.Status == adapters.StatusActive && b.ModifyingVastXmlAllowed + return b.Enabled && b.ModifyingVastXmlAllowed } return allowUnknownBidder @@ -346,7 +343,7 @@ func ModifyVastXmlJSON(externalUrl string, data json.RawMessage, bidid, bidder, //InjectVideoEventTrackers injects the video tracking events //Returns VAST xml contains as first argument. Second argument indicates whether the trackers are injected and last argument indicates if there is any error in injecting the trackers -func InjectVideoEventTrackers(trackerURL, vastXML string, bid *openrtb.Bid, bidder, accountID string, timestamp int64, bidRequest *openrtb.BidRequest) ([]byte, bool, error) { +func InjectVideoEventTrackers(trackerURL, vastXML string, bid *openrtb2.Bid, bidder, accountID string, timestamp int64, bidRequest *openrtb2.BidRequest) ([]byte, bool, error) { // parse VAST doc := etree.NewDocument() err := doc.ReadFromString(vastXML) @@ -358,7 +355,7 @@ func InjectVideoEventTrackers(trackerURL, vastXML string, bid *openrtb.Bid, bidd //Maintaining BidRequest Impression Map (Copied from exchange.go#applyCategoryMapping) //TODO: It should be optimized by forming once and reusing - impMap := make(map[string]*openrtb.Imp) + impMap := make(map[string]*openrtb2.Imp) for i := range bidRequest.Imp { impMap[bidRequest.Imp[i].ID] = &bidRequest.Imp[i] } @@ -387,9 +384,9 @@ func InjectVideoEventTrackers(trackerURL, vastXML string, bid *openrtb.Bid, bidd // } switch imp.Video.Linearity { - case openrtb.VideoLinearityLinearInStream: + case openrtb2.VideoLinearityLinearInStream: creative.AddChild(doc.CreateElement("Linear")) - case openrtb.VideoLinearityNonLinearOverlay: + case openrtb2.VideoLinearityNonLinearOverlay: creative.AddChild(doc.CreateElement("NonLinearAds")) default: // create both type of creatives creative.AddChild(doc.CreateElement("Linear")) @@ -431,7 +428,7 @@ func InjectVideoEventTrackers(trackerURL, vastXML string, bid *openrtb.Bid, bidd // firstQuartile, midpoint, thirdQuartile, complete // If your company can not use [EVENT_ID] and has its own macro. provide config.TrackerMacros implementation // and ensure that your macro is part of trackerURL configuration -func GetVideoEventTracking(trackerURL string, bid *openrtb.Bid, bidder string, accountId string, timestamp int64, req *openrtb.BidRequest, doc *etree.Document, impMap map[string]*openrtb.Imp) map[string]string { +func GetVideoEventTracking(trackerURL string, bid *openrtb2.Bid, bidder string, accountId string, timestamp int64, req *openrtb2.BidRequest, doc *etree.Document, impMap map[string]*openrtb2.Imp) map[string]string { eventURLMap := make(map[string]string) if "" == strings.TrimSpace(trackerURL) { return eventURLMap diff --git a/endpoints/events/vtrack_test.go b/endpoints/events/vtrack_test.go index 3d2bca3bb4d..0f3b5028576 100644 --- a/endpoints/events/vtrack_test.go +++ b/endpoints/events/vtrack_test.go @@ -5,19 +5,17 @@ import ( "context" "encoding/json" "fmt" + "github.com/PubMatic-OpenWrap/etree" + "github.com/mxmCherry/openrtb/v15/openrtb2" "io/ioutil" "net/http/httptest" "net/url" "strings" "testing" - "github.com/PubMatic-OpenWrap/etree" - // "github.com/beevik/etree" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/stored_requests" "github.com/stretchr/testify/assert" ) @@ -379,13 +377,13 @@ func TestShouldSendToCacheExpectedPutsAndUpdatableBiddersWhenBidderVastNotAllowe cfg.MarshalAccountDefaults() // bidder info - bidderInfos := make(adapters.BidderInfos) - bidderInfos["bidder"] = adapters.BidderInfo{ - Status: adapters.StatusActive, + bidderInfos := make(config.BidderInfos) + bidderInfos["bidder"] = config.BidderInfo{ + Enabled: true, ModifyingVastXmlAllowed: false, } - bidderInfos["updatable_bidder"] = adapters.BidderInfo{ - Status: adapters.StatusActive, + bidderInfos["updatable_bidder"] = config.BidderInfo{ + Enabled: true, ModifyingVastXmlAllowed: true, } @@ -442,13 +440,13 @@ func TestShouldSendToCacheExpectedPutsAndUpdatableBiddersWhenBidderVastAllowed(t cfg.MarshalAccountDefaults() // bidder info - bidderInfos := make(adapters.BidderInfos) - bidderInfos["bidder"] = adapters.BidderInfo{ - Status: adapters.StatusActive, + bidderInfos := make(config.BidderInfos) + bidderInfos["bidder"] = config.BidderInfo{ + Enabled: true, ModifyingVastXmlAllowed: true, } - bidderInfos["updatable_bidder"] = adapters.BidderInfo{ - Status: adapters.StatusActive, + bidderInfos["updatable_bidder"] = config.BidderInfo{ + Enabled: true, ModifyingVastXmlAllowed: true, } @@ -505,7 +503,7 @@ func TestShouldSendToCacheExpectedPutsAndUpdatableUnknownBiddersWhenUnknownBidde cfg.MarshalAccountDefaults() // bidder info - bidderInfos := make(adapters.BidderInfos) + bidderInfos := make(config.BidderInfos) // prepare data, err := getValidVTrackRequestBody(true, false) @@ -561,7 +559,7 @@ func TestShouldReturnBadRequestWhenRequestExceedsMaxRequestSize(t *testing.T) { cfg.MarshalAccountDefaults() // bidder info - bidderInfos := make(adapters.BidderInfos) + bidderInfos := make(config.BidderInfos) // prepare data, err := getValidVTrackRequestBody(true, false) @@ -699,8 +697,8 @@ func getVTrackRequestData(wi bool, wic bool) (db []byte, e error) { func TestInjectVideoEventTrackers(t *testing.T) { type args struct { externalURL string - bid *openrtb.Bid - req *openrtb.BidRequest + bid *openrtb2.Bid + req *openrtb2.BidRequest } type want struct { eventURLs map[string][]string @@ -714,7 +712,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { name: "linear_creative", args: args{ externalURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ AdM: ` @@ -727,7 +725,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { `, }, - req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, }, want: want{ eventURLs: map[string][]string{ @@ -747,7 +745,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { name: "non_linear_creative", args: args{ externalURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb.Bid{ // Adm contains to TrackingEvents tag + bid: &openrtb2.Bid{ // Adm contains to TrackingEvents tag AdM: ` @@ -756,7 +754,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { `, }, - req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, }, want: want{ eventURLs: map[string][]string{ @@ -775,13 +773,13 @@ func TestInjectVideoEventTrackers(t *testing.T) { name: "no_traker_url_configured", // expect no injection args: args{ externalURL: "", - bid: &openrtb.Bid{ // Adm contains to TrackingEvents tag + bid: &openrtb2.Bid{ // Adm contains to TrackingEvents tag AdM: ` `, }, - req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, }, want: want{ eventURLs: map[string][]string{}, @@ -791,7 +789,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { name: "wrapper_vast_xml_from_partner", // expect we are injecting trackers inside wrapper args: args{ externalURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb.Bid{ // Adm contains to TrackingEvents tag + bid: &openrtb2.Bid{ // Adm contains to TrackingEvents tag AdM: ` @@ -804,7 +802,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { `, }, - req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, }, want: want{ eventURLs: map[string][]string{ @@ -824,10 +822,10 @@ func TestInjectVideoEventTrackers(t *testing.T) { // name: "vast_tag_uri_response_from_partner", // args: args{ // externalURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - // bid: &openrtb.Bid{ // Adm contains to TrackingEvents tag + // bid: &openrtb2.Bid{ // Adm contains to TrackingEvents tag // AdM: ``, // }, - // req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + // req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, // }, // want: want{ // eventURLs: map[string][]string{ @@ -842,11 +840,11 @@ func TestInjectVideoEventTrackers(t *testing.T) { // name: "adm_empty", // args: args{ // externalURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - // bid: &openrtb.Bid{ // Adm contains to TrackingEvents tag + // bid: &openrtb2.Bid{ // Adm contains to TrackingEvents tag // AdM: "", // NURL: "nurl_contents", // }, - // req: &openrtb.BidRequest{App: &openrtb.App{Bundle: "abc"}}, + // req: &openrtb2.BidRequest{App: &openrtb2.App{Bundle: "abc"}}, // }, // want: want{ // eventURLs: map[string][]string{ @@ -865,7 +863,7 @@ func TestInjectVideoEventTrackers(t *testing.T) { vast = tc.args.bid.AdM // original vast } // bind this bid id with imp object - tc.args.req.Imp = []openrtb.Imp{{ID: "123", Video: &openrtb.Video{}}} + tc.args.req.Imp = []openrtb2.Imp{{ID: "123", Video: &openrtb2.Video{}}} tc.args.bid.ImpID = tc.args.req.Imp[0].ID accountID := "" timestamp := int64(0) @@ -919,11 +917,11 @@ func TestInjectVideoEventTrackers(t *testing.T) { func TestGetVideoEventTracking(t *testing.T) { type args struct { trackerURL string - bid *openrtb.Bid + bid *openrtb2.Bid bidder string accountId string timestamp int64 - req *openrtb.BidRequest + req *openrtb2.BidRequest doc *etree.Document } type want struct { @@ -938,14 +936,14 @@ func TestGetVideoEventTracking(t *testing.T) { name: "valid_scenario", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ // AdM: vastXMLWith2Creatives, }, - req: &openrtb.BidRequest{ - App: &openrtb.App{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ Bundle: "someappbundle", }, - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -965,10 +963,10 @@ func TestGetVideoEventTracking(t *testing.T) { name: "no_macro_value", // expect no replacement args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - bid: &openrtb.Bid{}, - req: &openrtb.BidRequest{ - App: &openrtb.App{}, // no app bundle value - Imp: []openrtb.Imp{}, + bid: &openrtb2.Bid{}, + req: &openrtb2.BidRequest{ + App: &openrtb2.App{}, // no app bundle value + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -988,11 +986,11 @@ func TestGetVideoEventTracking(t *testing.T) { name: "prefer_company_value_for_standard_macro", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]", - req: &openrtb.BidRequest{ - App: &openrtb.App{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ Bundle: "myapp", // do not expect this value }, - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, Ext: []byte(`{"prebid":{ "macros": { "[DOMAIN]": "my_custom_value" @@ -1016,11 +1014,11 @@ func TestGetVideoEventTracking(t *testing.T) { name: "multireplace_macro", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]&appbundle=[DOMAIN]¶meter2=[DOMAIN]", - req: &openrtb.BidRequest{ - App: &openrtb.App{ + req: &openrtb2.BidRequest{ + App: &openrtb2.App{ Bundle: "myapp123", }, - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -1040,13 +1038,13 @@ func TestGetVideoEventTracking(t *testing.T) { name: "custom_macro_without_prefix_and_suffix", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]¶m1=[CUSTOM_MACRO]", - req: &openrtb.BidRequest{ + req: &openrtb2.BidRequest{ Ext: []byte(`{"prebid":{ "macros": { "CUSTOM_MACRO": "my_custom_value" } }}`), - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -1066,13 +1064,13 @@ func TestGetVideoEventTracking(t *testing.T) { name: "empty_macro", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]¶m1=[CUSTOM_MACRO]", - req: &openrtb.BidRequest{ + req: &openrtb2.BidRequest{ Ext: []byte(`{"prebid":{ "macros": { "": "my_custom_value" } }}`), - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -1092,13 +1090,13 @@ func TestGetVideoEventTracking(t *testing.T) { name: "macro_is_case_sensitive", args: args{ trackerURL: "http://company.tracker.com?eventId=[EVENT_ID]¶m1=[CUSTOM_MACRO]", - req: &openrtb.BidRequest{ + req: &openrtb2.BidRequest{ Ext: []byte(`{"prebid":{ "macros": { "": "my_custom_value" } }}`), - Imp: []openrtb.Imp{}, + Imp: []openrtb2.Imp{}, }, }, want: want{ @@ -1116,15 +1114,15 @@ func TestGetVideoEventTracking(t *testing.T) { }, { name: "empty_tracker_url", - args: args{trackerURL: " ", req: &openrtb.BidRequest{Imp: []openrtb.Imp{}}}, + args: args{trackerURL: " ", req: &openrtb2.BidRequest{Imp: []openrtb2.Imp{}}}, want: want{trackerURLMap: make(map[string]string)}, }, { name: "all_macros", // expect encoding for WRAPPER_IMPRESSION_ID macro args: args{ trackerURL: "https://company.tracker.com?operId=8&e=[EVENT_ID]&p=[PBS-ACCOUNT]&pid=[PROFILE_ID]&v=[PROFILE_VERSION]&ts=[UNIX_TIMESTAMP]&pn=[PBS-BIDDER]&advertiser_id=[ADVERTISER_NAME]&sURL=[DOMAIN]&pfi=[PLATFORM]&af=[ADTYPE]&iid=[WRAPPER_IMPRESSION_ID]&pseq=[PODSEQUENCE]&adcnt=[ADCOUNT]&cb=[CACHEBUSTING]&au=[AD_UNIT]&bidid=[PBS-BIDID]", - req: &openrtb.BidRequest{ - App: &openrtb.App{Bundle: "com.someapp.com", Publisher: &openrtb.Publisher{ID: "5890"}}, + req: &openrtb2.BidRequest{ + App: &openrtb2.App{Bundle: "com.someapp.com", Publisher: &openrtb2.Publisher{ID: "5890"}}, Ext: []byte(`{ "prebid": { "macros": { @@ -1136,11 +1134,11 @@ func TestGetVideoEventTracking(t *testing.T) { } } }`), - Imp: []openrtb.Imp{ + Imp: []openrtb2.Imp{ {TagID: "/testadunit/1", ID: "imp_1"}, }, }, - bid: &openrtb.Bid{ADomain: []string{"http://a.com/32?k=v", "b.com"}, ImpID: "imp_1", ID: "test_bid_id"}, + bid: &openrtb2.Bid{ADomain: []string{"http://a.com/32?k=v", "b.com"}, ImpID: "imp_1", ID: "test_bid_id"}, bidder: "test_bidder:234", }, want: want{ @@ -1157,10 +1155,10 @@ func TestGetVideoEventTracking(t *testing.T) { t.Run(tc.name, func(t *testing.T) { if nil == tc.args.bid { - tc.args.bid = &openrtb.Bid{} + tc.args.bid = &openrtb2.Bid{} } - impMap := map[string]*openrtb.Imp{} + impMap := map[string]*openrtb2.Imp{} for _, imp := range tc.args.req.Imp { impMap[imp.ID] = &imp diff --git a/endpoints/getuids.go b/endpoints/getuids.go index e02efe15b3a..859c0e7288c 100644 --- a/endpoints/getuids.go +++ b/endpoints/getuids.go @@ -3,9 +3,9 @@ package endpoints import ( "net/http" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/usersync" "encoding/json" ) diff --git a/endpoints/getuids_test.go b/endpoints/getuids_test.go index fb984e15c35..7988acbaffe 100644 --- a/endpoints/getuids_test.go +++ b/endpoints/getuids_test.go @@ -5,7 +5,7 @@ import ( "net/http/httptest" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/config" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/info/bidders.go b/endpoints/info/bidders.go index 7c44c7ec6fa..2bd925ce62d 100644 --- a/endpoints/info/bidders.go +++ b/endpoints/info/bidders.go @@ -3,128 +3,40 @@ package info import ( "encoding/json" "net/http" + "sort" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/buger/jsonparser" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" ) -// NewBiddersEndpoint implements /info/bidders -func NewBiddersEndpoint(aliases map[string]string) httprouter.Handle { - bidderNames := make([]string, 0) - - for _, bidderName := range openrtb_ext.CoreBidderNames() { - bidderNames = append(bidderNames, string(bidderName)) - } - - for aliasName := range aliases { - bidderNames = append(bidderNames, aliasName) - } - - biddersJson, err := json.Marshal(bidderNames) +// NewBiddersEndpoint builds a handler for the /info/bidders endpoint. +func NewBiddersEndpoint(bidders config.BidderInfos, aliases map[string]string) httprouter.Handle { + response, err := prepareBiddersResponse(bidders, aliases) if err != nil { glog.Fatalf("error creating /info/bidders endpoint response: %v", err) } return func(w http.ResponseWriter, _ *http.Request, _ httprouter.Params) { w.Header().Set("Content-Type", "application/json") - if _, err := w.Write(biddersJson); err != nil { + if _, err := w.Write(response); err != nil { glog.Errorf("error writing response to /info/bidders: %v", err) } } } -// NewBidderDetailsEndpoint implements /info/bidders/* -func NewBidderDetailsEndpoint(infos adapters.BidderInfos, aliases map[string]string) httprouter.Handle { - // Validate if there exist and alias with name "all". If it does error out because - // that will break the /info/bidders/all endpoint. - if _, ok := aliases["all"]; ok { - glog.Fatal("Default aliases shouldn't contain an alias with name \"all\". This will break the /info/bidders/all endpoint") - } - - // Build a new map that's basically a copy of "infos" but will also contain - // alias bidder infos - var allBidderInfo = make(map[string]adapters.BidderInfo, len(infos)+len(aliases)) - - // Build all the responses up front, since there are a finite number and it won't use much memory. - responses := make(map[string]json.RawMessage, len(infos)+len(aliases)) - for bidderName, bidderInfo := range infos { - // Copy bidderInfo into "allBidderInfo" map - allBidderInfo[bidderName] = bidderInfo +func prepareBiddersResponse(bidders config.BidderInfos, aliases map[string]string) ([]byte, error) { + bidderNames := make([]string, 0, len(bidders)+len(aliases)) - // JSON encode bidder info and add it to the "responses" map - jsonData, err := json.Marshal(bidderInfo) - if err != nil { - glog.Fatalf("Failed to JSON-marshal bidder-info/%s.yaml data.", bidderName) - } - responses[bidderName] = jsonData + for name := range bidders { + bidderNames = append(bidderNames, name) } - // Add in any default aliases - for aliasName, bidderName := range aliases { - // Add the alias bidder info into "allBidderInfo" map - aliasInfo := infos[bidderName] - aliasInfo.AliasOf = bidderName - allBidderInfo[aliasName] = aliasInfo - - // JSON encode core bidder info for the alias and add it to the "responses" map - responses[aliasName] = createAliasInfo(responses, aliasName, bidderName) + for name := range aliases { + bidderNames = append(bidderNames, name) } - allBidderResponse, err := json.Marshal(allBidderInfo) - if err != nil { - glog.Fatal("Failed to JSON-marshal all bidder info data.") - } - // Add the json response containing all bidders info for the /info/bidders/all endpoint - responses["all"] = allBidderResponse - - // Return an endpoint which writes the responses from memory. - return func(w http.ResponseWriter, _ *http.Request, ps httprouter.Params) { - forBidder := ps.ByName("bidderName") - - // If the requested path was /info/bidders/{bidderName} then return the info about that bidder - if response, ok := responses[forBidder]; ok { - w.Header().Set("Content-Type", "application/json") - if _, err := w.Write(response); err != nil { - glog.Errorf("error writing response to /info/bidders/%s: %v", forBidder, err) - } - } else { - w.WriteHeader(http.StatusNotFound) - } - } -} - -func createAliasInfo(responses map[string]json.RawMessage, alias string, core string) json.RawMessage { - coreJSON, ok := responses[core] - if !ok { - glog.Fatalf("Unknown core bidder %s for default alias %s", core, alias) - } - jsonData := make(json.RawMessage, len(coreJSON)) - copy(jsonData, coreJSON) - - jsonInfo, err := jsonparser.Set(jsonData, []byte(`"`+core+`"`), "aliasOf") - if err != nil { - glog.Fatalf("Failed to generate bidder info for %s, an alias of %s", alias, core) - } - return jsonInfo -} - -type infoFile struct { - Maintainer *maintainerInfo `yaml:"maintainer" json:"maintainer"` - Capabilities *capabilitiesInfo `yaml:"capabilities" json:"capabilities"` -} - -type maintainerInfo struct { - Email string `yaml:"email" json:"email"` -} - -type capabilitiesInfo struct { - App *platformInfo `yaml:"app" json:"app"` - Site *platformInfo `yaml:"site" json:"site"` -} + sort.Strings(bidderNames) -type platformInfo struct { - MediaTypes []string `yaml:"mediaTypes" json:"mediaTypes"` + return json.Marshal(bidderNames) } diff --git a/endpoints/info/bidders_detail.go b/endpoints/info/bidders_detail.go new file mode 100644 index 00000000000..04bc9b04fca --- /dev/null +++ b/endpoints/info/bidders_detail.go @@ -0,0 +1,185 @@ +package info + +import ( + "encoding/json" + "fmt" + "net/http" + "strings" + + "github.com/golang/glog" + "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +const ( + statusActive string = "ACTIVE" + statusDisabled string = "DISABLED" +) + +// NewBiddersDetailEndpoint builds a handler for the /info/bidders/ endpoint. +func NewBiddersDetailEndpoint(bidders config.BidderInfos, biddersConfig map[string]config.Adapter, aliases map[string]string) httprouter.Handle { + responses, err := prepareBiddersDetailResponse(bidders, biddersConfig, aliases) + if err != nil { + glog.Fatalf("error creating /info/bidders/ endpoint response: %v", err) + } + + return func(w http.ResponseWriter, _ *http.Request, ps httprouter.Params) { + bidder := ps.ByName("bidderName") + + if response, ok := responses[bidder]; ok { + w.Header().Set("Content-Type", "application/json") + if _, err := w.Write(response); err != nil { + glog.Errorf("error writing response to /info/bidders/%s: %v", bidder, err) + } + } else { + w.WriteHeader(http.StatusNotFound) + } + } +} + +func prepareBiddersDetailResponse(bidders config.BidderInfos, biddersConfig map[string]config.Adapter, aliases map[string]string) (map[string][]byte, error) { + details, err := mapDetails(bidders, biddersConfig, aliases) + if err != nil { + return nil, err + } + + responses, err := marshalDetailsResponse(details) + if err != nil { + return nil, err + } + + all, err := marshalAllResponse(responses) + if err != nil { + return nil, err + } + responses["all"] = all + + return responses, nil +} + +func mapDetails(bidders config.BidderInfos, biddersConfig map[string]config.Adapter, aliases map[string]string) (map[string]bidderDetail, error) { + details := map[string]bidderDetail{} + + for bidderName, bidderInfo := range bidders { + endpoint := resolveEndpoint(bidderName, biddersConfig) + details[bidderName] = mapDetailFromConfig(bidderInfo, endpoint) + } + + for aliasName, bidderName := range aliases { + aliasBaseInfo, aliasBaseInfoFound := details[bidderName] + if !aliasBaseInfoFound { + return nil, fmt.Errorf("base adapter %s for alias %s not found", bidderName, aliasName) + } + + aliasInfo := aliasBaseInfo + aliasInfo.AliasOf = bidderName + details[aliasName] = aliasInfo + } + + return details, nil +} + +func resolveEndpoint(bidder string, biddersConfig map[string]config.Adapter) string { + if c, found := biddersConfig[bidder]; found { + return c.Endpoint + } + + return "" +} + +func marshalDetailsResponse(details map[string]bidderDetail) (map[string][]byte, error) { + responses := map[string][]byte{} + + for bidder, detail := range details { + json, err := json.Marshal(detail) + if err != nil { + return nil, fmt.Errorf("unable to marshal info for bidder %s: %v", bidder, err) + } + responses[bidder] = json + } + + return responses, nil +} + +func marshalAllResponse(responses map[string][]byte) ([]byte, error) { + responsesJSON := make(map[string]json.RawMessage, len(responses)) + + for k, v := range responses { + responsesJSON[k] = json.RawMessage(v) + } + + json, err := json.Marshal(responsesJSON) + if err != nil { + return nil, fmt.Errorf("unable to marshal info for bidder all: %v", err) + } + return json, nil +} + +type bidderDetail struct { + Status string `json:"status"` + UsesHTTPS *bool `json:"usesHttps,omitempty"` + Maintainer *maintainer `json:"maintainer,omitempty"` + Capabilities *capabilities `json:"capabilities,omitempty"` + AliasOf string `json:"aliasOf,omitempty"` +} + +type maintainer struct { + Email string `json:"email"` +} + +type capabilities struct { + App *platform `json:"app,omitempty"` + Site *platform `json:"site,omitempty"` +} + +type platform struct { + MediaTypes []string `json:"mediaTypes"` +} + +func mapDetailFromConfig(c config.BidderInfo, endpoint string) bidderDetail { + var bidderDetail bidderDetail + + if c.Maintainer != nil { + bidderDetail.Maintainer = &maintainer{ + Email: c.Maintainer.Email, + } + } + + if c.Enabled { + bidderDetail.Status = statusActive + + usesHTTPS := strings.HasPrefix(strings.ToLower(endpoint), "https://") + bidderDetail.UsesHTTPS = &usesHTTPS + + if c.Capabilities != nil { + bidderDetail.Capabilities = &capabilities{} + + if c.Capabilities.App != nil { + bidderDetail.Capabilities.App = &platform{ + MediaTypes: mapMediaTypes(c.Capabilities.App.MediaTypes), + } + } + + if c.Capabilities.Site != nil { + bidderDetail.Capabilities.Site = &platform{ + MediaTypes: mapMediaTypes(c.Capabilities.Site.MediaTypes), + } + } + } + } else { + bidderDetail.Status = statusDisabled + } + + return bidderDetail +} + +func mapMediaTypes(m []openrtb_ext.BidType) []string { + mediaTypes := make([]string, len(m)) + + for i, v := range m { + mediaTypes[i] = string(v) + } + + return mediaTypes +} diff --git a/endpoints/info/bidders_detail_test.go b/endpoints/info/bidders_detail_test.go new file mode 100644 index 00000000000..d8b6f2bf4ad --- /dev/null +++ b/endpoints/info/bidders_detail_test.go @@ -0,0 +1,497 @@ +package info + +import ( + "bytes" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/stretchr/testify/assert" +) + +func TestPrepareBiddersDetailResponse(t *testing.T) { + bidderAInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderA"}} + bidderAConfig := config.Adapter{Endpoint: "https://secureEndpoint.com"} + bidderAResponse := []byte(`{"status":"ACTIVE","usesHttps":true,"maintainer":{"email":"bidderA"}}`) + + bidderBInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderB"}} + bidderBConfig := config.Adapter{Endpoint: "http://unsecureEndpoint.com"} + bidderBResponse := []byte(`{"status":"ACTIVE","usesHttps":false,"maintainer":{"email":"bidderB"}}`) + + allResponseBidderA := bytes.Buffer{} + allResponseBidderA.WriteString(`{"a":`) + allResponseBidderA.Write(bidderAResponse) + allResponseBidderA.WriteString(`}`) + + allResponseBidderAB := bytes.Buffer{} + allResponseBidderAB.WriteString(`{"a":`) + allResponseBidderAB.Write(bidderAResponse) + allResponseBidderAB.WriteString(`,"b":`) + allResponseBidderAB.Write(bidderBResponse) + allResponseBidderAB.WriteString(`}`) + + var testCases = []struct { + description string + givenBidders config.BidderInfos + givenBiddersConfig map[string]config.Adapter + givenAliases map[string]string + expectedResponses map[string][]byte + expectedError string + }{ + { + description: "None", + givenBidders: config.BidderInfos{}, + givenBiddersConfig: map[string]config.Adapter{}, + givenAliases: map[string]string{}, + expectedResponses: map[string][]byte{"all": []byte(`{}`)}, + }, + { + description: "One", + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{}, + expectedResponses: map[string][]byte{"a": bidderAResponse, "all": allResponseBidderA.Bytes()}, + }, + { + description: "Many", + givenBidders: config.BidderInfos{"a": bidderAInfo, "b": bidderBInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig, "b": bidderBConfig}, + givenAliases: map[string]string{}, + expectedResponses: map[string][]byte{"a": bidderAResponse, "b": bidderBResponse, "all": allResponseBidderAB.Bytes()}, + }, + { + description: "Error - Map Details", // Returns error due to invalid alias. + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{"zAlias": "z"}, + expectedError: "base adapter z for alias zAlias not found", + }, + } + + for _, test := range testCases { + responses, err := prepareBiddersDetailResponse(test.givenBidders, test.givenBiddersConfig, test.givenAliases) + + if test.expectedError == "" { + assert.Equal(t, test.expectedResponses, responses, test.description+":responses") + assert.NoError(t, err, test.expectedError, test.description+":err") + } else { + assert.Empty(t, responses, test.description+":responses") + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + } +} + +func TestMapDetails(t *testing.T) { + trueValue := true + falseValue := false + + bidderAInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderA"}} + bidderAConfig := config.Adapter{Endpoint: "https://secureEndpoint.com"} + bidderADetail := bidderDetail{Status: "ACTIVE", UsesHTTPS: &trueValue, Maintainer: &maintainer{Email: "bidderA"}} + aliasADetail := bidderDetail{Status: "ACTIVE", UsesHTTPS: &trueValue, Maintainer: &maintainer{Email: "bidderA"}, AliasOf: "a"} + + bidderBInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderB"}} + bidderBConfig := config.Adapter{Endpoint: "http://unsecureEndpoint.com"} + bidderBDetail := bidderDetail{Status: "ACTIVE", UsesHTTPS: &falseValue, Maintainer: &maintainer{Email: "bidderB"}} + aliasBDetail := bidderDetail{Status: "ACTIVE", UsesHTTPS: &falseValue, Maintainer: &maintainer{Email: "bidderB"}, AliasOf: "b"} + + var testCases = []struct { + description string + givenBidders config.BidderInfos + givenBiddersConfig map[string]config.Adapter + givenAliases map[string]string + expectedDetails map[string]bidderDetail + expectedError string + }{ + { + description: "None", + givenBidders: config.BidderInfos{}, + givenBiddersConfig: map[string]config.Adapter{}, + givenAliases: map[string]string{}, + expectedDetails: map[string]bidderDetail{}, + }, + { + description: "One Core Bidder", + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{}, + expectedDetails: map[string]bidderDetail{"a": bidderADetail}, + }, + { + description: "Many Core Bidders", + givenBidders: config.BidderInfos{"a": bidderAInfo, "b": bidderBInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig, "b": bidderBConfig}, + givenAliases: map[string]string{}, + expectedDetails: map[string]bidderDetail{"a": bidderADetail, "b": bidderBDetail}, + }, + { + description: "One Alias", + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{"aAlias": "a"}, + expectedDetails: map[string]bidderDetail{"a": bidderADetail, "aAlias": aliasADetail}, + }, + { + description: "Many Aliases - Same Core Bidder", + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{"aAlias1": "a", "aAlias2": "a"}, + expectedDetails: map[string]bidderDetail{"a": bidderADetail, "aAlias1": aliasADetail, "aAlias2": aliasADetail}, + }, + { + description: "Many Aliases - Different Core Bidders", + givenBidders: config.BidderInfos{"a": bidderAInfo, "b": bidderBInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig, "b": bidderBConfig}, + givenAliases: map[string]string{"aAlias": "a", "bAlias": "b"}, + expectedDetails: map[string]bidderDetail{"a": bidderADetail, "b": bidderBDetail, "aAlias": aliasADetail, "bAlias": aliasBDetail}, + }, + { + description: "Error - Alias Without Core Bidder", + givenBidders: config.BidderInfos{"a": bidderAInfo}, + givenBiddersConfig: map[string]config.Adapter{"a": bidderAConfig}, + givenAliases: map[string]string{"zAlias": "z"}, + expectedError: "base adapter z for alias zAlias not found", + }, + } + + for _, test := range testCases { + details, err := mapDetails(test.givenBidders, test.givenBiddersConfig, test.givenAliases) + + if test.expectedError == "" { + assert.Equal(t, test.expectedDetails, details, test.description+":details") + assert.NoError(t, err, test.expectedError, test.description+":err") + } else { + assert.Empty(t, details, test.description+":details") + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + } +} + +func TestResolveEndpoint(t *testing.T) { + var testCases = []struct { + description string + givenBidder string + givenBiddersConfig map[string]config.Adapter + expectedEndpoint string + }{ + { + description: "Bidder Found - Uses Config Value", + givenBidder: "a", + givenBiddersConfig: map[string]config.Adapter{"a": {Endpoint: "anyEndpoint"}}, + expectedEndpoint: "anyEndpoint", + }, + { + description: "Bidder Not Found - Returns Empty", + givenBidder: "hasNoConfig", + givenBiddersConfig: map[string]config.Adapter{"a": {Endpoint: "anyEndpoint"}}, + expectedEndpoint: "", + }, + } + + for _, test := range testCases { + result := resolveEndpoint(test.givenBidder, test.givenBiddersConfig) + assert.Equal(t, test.expectedEndpoint, result, test.description) + } +} + +func TestMarshalDetailsResponse(t *testing.T) { + // Verifies omitempty is working correctly for bidderDetail, maintainer, capabilities, and aliasOf. + bidderDetailA := bidderDetail{Status: "ACTIVE", Maintainer: &maintainer{Email: "bidderA"}} + bidderDetailAResponse := []byte(`{"status":"ACTIVE","maintainer":{"email":"bidderA"}}`) + + // Verifies omitempty is working correctly for capabilities.app / capabilities.site. + bidderDetailB := bidderDetail{Status: "ACTIVE", Maintainer: &maintainer{Email: "bidderB"}, Capabilities: &capabilities{App: &platform{MediaTypes: []string{"banner"}}}} + bidderDetailBResponse := []byte(`{"status":"ACTIVE","maintainer":{"email":"bidderB"},"capabilities":{"app":{"mediaTypes":["banner"]}}}`) + + var testCases = []struct { + description string + givenDetails map[string]bidderDetail + expectedResponse map[string][]byte + }{ + { + description: "None", + givenDetails: map[string]bidderDetail{}, + expectedResponse: map[string][]byte{}, + }, + { + description: "One", + givenDetails: map[string]bidderDetail{"a": bidderDetailA}, + expectedResponse: map[string][]byte{"a": bidderDetailAResponse}, + }, + { + description: "Many", + givenDetails: map[string]bidderDetail{"a": bidderDetailA, "b": bidderDetailB}, + expectedResponse: map[string][]byte{"a": bidderDetailAResponse, "b": bidderDetailBResponse}, + }, + } + + for _, test := range testCases { + response, err := marshalDetailsResponse(test.givenDetails) + + assert.NoError(t, err, test.description+":err") + assert.Equal(t, test.expectedResponse, response, test.description+":response") + } +} + +func TestMarshalAllResponse(t *testing.T) { + responses := map[string][]byte{ + "a": []byte(`{"Status":"ACTIVE"}`), + "b": []byte(`{"Status":"DISABLED"}`), + } + + result, err := marshalAllResponse(responses) + + assert.NoError(t, err) + assert.Equal(t, []byte(`{"a":{"Status":"ACTIVE"},"b":{"Status":"DISABLED"}}`), result) +} + +func TestMapDetailFromConfig(t *testing.T) { + trueValue := true + falseValue := false + + var testCases = []struct { + description string + givenBidderInfo config.BidderInfo + givenEndpoint string + expected bidderDetail + }{ + { + description: "Enabled - All Values Present", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + Maintainer: &config.MaintainerInfo{ + Email: "foo@bar.com", + }, + Capabilities: &config.CapabilitiesInfo{ + App: &config.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}}, + Site: &config.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeVideo}}, + }, + }, + givenEndpoint: "http://amyEndpoint", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &falseValue, + Maintainer: &maintainer{ + Email: "foo@bar.com", + }, + Capabilities: &capabilities{ + App: &platform{MediaTypes: []string{"banner"}}, + Site: &platform{MediaTypes: []string{"video"}}, + }, + AliasOf: "", + }, + }, + { + description: "Disabled - All Values Present", + givenBidderInfo: config.BidderInfo{ + Enabled: false, + Maintainer: &config.MaintainerInfo{ + Email: "foo@bar.com", + }, + Capabilities: &config.CapabilitiesInfo{ + App: &config.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}}, + Site: &config.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeVideo}}, + }, + }, + givenEndpoint: "http://amyEndpoint", + expected: bidderDetail{ + Status: "DISABLED", + UsesHTTPS: nil, + Maintainer: &maintainer{ + Email: "foo@bar.com", + }, + Capabilities: nil, + AliasOf: "", + }, + }, + { + description: "Enabled - No Values Present", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + }, + givenEndpoint: "http://amyEndpoint", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &falseValue, + }, + }, + { + description: "Enabled - Protocol - HTTP", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + }, + givenEndpoint: "http://amyEndpoint", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &falseValue, + }, + }, + { + description: "Enabled - Protocol - HTTPS", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + }, + givenEndpoint: "https://amyEndpoint", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &trueValue, + }, + }, + { + description: "Enabled - Protocol - HTTPS - Case Insensitive", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + }, + givenEndpoint: "https://amyEndpoint", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &trueValue, + }, + }, + { + description: "Enabled - Protocol - Unknown", + givenBidderInfo: config.BidderInfo{ + Enabled: true, + }, + givenEndpoint: "endpointWithoutProtocol", + expected: bidderDetail{ + Status: "ACTIVE", + UsesHTTPS: &falseValue, + }, + }, + } + + for _, test := range testCases { + result := mapDetailFromConfig(test.givenBidderInfo, test.givenEndpoint) + assert.Equal(t, test.expected, result, test.description) + } +} + +func TestMapMediaTypes(t *testing.T) { + var testCases = []struct { + description string + mediaTypes []openrtb_ext.BidType + expected []string + }{ + { + description: "Nil", + mediaTypes: nil, + expected: nil, + }, + { + description: "None", + mediaTypes: []openrtb_ext.BidType{}, + expected: []string{}, + }, + { + description: "One", + mediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}, + expected: []string{"banner"}, + }, + { + description: "Many", + mediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner, openrtb_ext.BidTypeVideo}, + expected: []string{"banner", "video"}, + }, + } + + for _, test := range testCases { + result := mapMediaTypes(test.mediaTypes) + assert.ElementsMatch(t, test.expected, result, test.description) + } +} + +func TestBiddersDetailHandler(t *testing.T) { + bidderAInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderA"}} + bidderAConfig := config.Adapter{Endpoint: "https://secureEndpoint.com"} + bidderAResponse := []byte(`{"status":"ACTIVE","usesHttps":true,"maintainer":{"email":"bidderA"}}`) + aliasAResponse := []byte(`{"status":"ACTIVE","usesHttps":true,"maintainer":{"email":"bidderA"},"aliasOf":"a"}`) + + bidderBInfo := config.BidderInfo{Enabled: true, Maintainer: &config.MaintainerInfo{Email: "bidderB"}} + bidderBConfig := config.Adapter{Endpoint: "http://unsecureEndpoint.com"} + bidderBResponse := []byte(`{"status":"ACTIVE","usesHttps":false,"maintainer":{"email":"bidderB"}}`) + + allResponse := bytes.Buffer{} + allResponse.WriteString(`{"a":`) + allResponse.Write(bidderAResponse) + allResponse.WriteString(`,"aAlias":`) + allResponse.Write(aliasAResponse) + allResponse.WriteString(`,"b":`) + allResponse.Write(bidderBResponse) + allResponse.WriteString(`}`) + + bidders := config.BidderInfos{"a": bidderAInfo, "b": bidderBInfo} + biddersConfig := map[string]config.Adapter{"a": bidderAConfig, "b": bidderBConfig} + aliases := map[string]string{"aAlias": "a"} + + handler := NewBiddersDetailEndpoint(bidders, biddersConfig, aliases) + + var testCases = []struct { + description string + givenBidder string + expectedStatus int + expectedHeaders http.Header + expectedResponse []byte + }{ + { + description: "Bidder A", + givenBidder: "a", + expectedStatus: http.StatusOK, + expectedHeaders: http.Header{"Content-Type": []string{"application/json"}}, + expectedResponse: bidderAResponse, + }, + { + description: "Bidder B", + givenBidder: "b", + expectedStatus: http.StatusOK, + expectedHeaders: http.Header{"Content-Type": []string{"application/json"}}, + expectedResponse: bidderBResponse, + }, + { + description: "Bidder A Alias", + givenBidder: "aAlias", + expectedStatus: http.StatusOK, + expectedHeaders: http.Header{"Content-Type": []string{"application/json"}}, + expectedResponse: aliasAResponse, + }, + { + description: "All Bidders", + givenBidder: "all", + expectedStatus: http.StatusOK, + expectedHeaders: http.Header{"Content-Type": []string{"application/json"}}, + expectedResponse: allResponse.Bytes(), + }, + { + description: "All Bidders - Wrong Case", + givenBidder: "ALL", + expectedStatus: http.StatusNotFound, + expectedHeaders: http.Header{}, + expectedResponse: []byte{}, + }, + { + description: "Invalid Bidder", + givenBidder: "doesntExist", + expectedStatus: http.StatusNotFound, + expectedHeaders: http.Header{}, + expectedResponse: []byte{}, + }, + } + + for _, test := range testCases { + responseRecorder := httptest.NewRecorder() + handler(responseRecorder, nil, httprouter.Params{{"bidderName", test.givenBidder}}) + + result := responseRecorder.Result() + assert.Equal(t, result.StatusCode, test.expectedStatus, test.description+":statuscode") + + resultBody, _ := ioutil.ReadAll(result.Body) + assert.Equal(t, test.expectedResponse, resultBody, test.description+":body") + + resultHeaders := result.Header + assert.Equal(t, test.expectedHeaders, resultHeaders, test.description+":headers") + } +} diff --git a/endpoints/info/bidders_test.go b/endpoints/info/bidders_test.go index 15e5f77de23..e48dd3d0e8e 100644 --- a/endpoints/info/bidders_test.go +++ b/endpoints/info/bidders_test.go @@ -1,321 +1,89 @@ -package info_test +package info import ( - "encoding/json" - "errors" - "fmt" "io/ioutil" "net/http" "net/http/httptest" - "os" - "strings" "testing" - "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" "github.com/stretchr/testify/assert" - - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/info" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - yaml "gopkg.in/yaml.v2" ) -func TestGetBiddersNoAliases(t *testing.T) { - testGetBidders(t, map[string]string{}) -} - -func TestGetBiddersWithAliases(t *testing.T) { - aliases := map[string]string{ - "test1": "appnexus", - "test2": "rubicon", - "test3": "openx", - } - testGetBidders(t, aliases) -} - -func testGetBidders(t *testing.T, aliases map[string]string) { - endpoint := info.NewBiddersEndpoint(aliases) - - req, err := http.NewRequest("GET", "http://prebid-server.com/info/bidders", strings.NewReader("")) - if err != nil { - assert.FailNow(t, "Failed to create a GET /info/bidders request: %v", err) - } - - r := httptest.NewRecorder() - endpoint(r, req, nil) - - assert.Equal(t, http.StatusOK, r.Code, "GET /info/bidders returned bad status: %d", r.Code) - assert.Equal(t, "application/json", r.Header().Get("Content-Type"), "Bad /info/bidders content type. Expected application/json. Got %s", r.Header().Get("Content-Type")) - - bidderMap := openrtb_ext.BuildBidderNameHashSet() - - bodyBytes := r.Body.Bytes() - bidderSlice := make([]string, 0) - err = json.Unmarshal(bodyBytes, &bidderSlice) - assert.NoError(t, err, "Failed to unmarshal /info/bidders response: %v", err) - - for _, bidderName := range bidderSlice { - if _, ok := bidderMap[bidderName]; !ok { - assert.Contains(t, aliases, bidderName, "Response from /info/bidders contained unexpected BidderName: %s", bidderName) - } - } - - expectedBidderSliceLength := len(bidderMap) + len(aliases) - assert.Len(t, bidderSlice, expectedBidderSliceLength, "Response from /info/bidders did not match BidderMap. Expected %d elements. Got %d", expectedBidderSliceLength) -} - -// TestGetSpecificBidders validates all the GET /info/bidders/{bidderName} endpoints -func TestGetSpecificBidders(t *testing.T) { - // Setup: +func TestPrepareBiddersResponse(t *testing.T) { testCases := []struct { - status adapters.BidderStatus - description string + description string + givenBidders config.BidderInfos + givenAliases map[string]string + expected string }{ { - status: adapters.StatusActive, - description: "case 1 - bidder status is active", + description: "None", + givenBidders: config.BidderInfos{}, + givenAliases: nil, + expected: `[]`, }, { - status: adapters.StatusDisabled, - description: "case 2 - bidder status is disabled", + description: "Core Bidders Only - One", + givenBidders: config.BidderInfos{"a": {}}, + givenAliases: nil, + expected: `["a"]`, + }, + { + description: "Core Bidders Only - Many", + givenBidders: config.BidderInfos{"a": {}, "b": {}}, + givenAliases: nil, + expected: `["a","b"]`, + }, + { + description: "Core Bidders Only - Many Sorted", + givenBidders: config.BidderInfos{"z": {}, "a": {}}, + givenAliases: nil, + expected: `["a","z"]`, + }, + { + description: "With Aliases - One", + givenBidders: config.BidderInfos{"a": {}}, + givenAliases: map[string]string{"b": "b"}, + expected: `["a","b"]`, + }, + { + description: "With Aliases - Many", + givenBidders: config.BidderInfos{"a": {}}, + givenAliases: map[string]string{"b": "b", "c": "c"}, + expected: `["a","b","c"]`, + }, + { + description: "With Aliases - Sorted", + givenBidders: config.BidderInfos{"z": {}}, + givenAliases: map[string]string{"a": "a"}, + expected: `["a","z"]`, }, } - for _, tc := range testCases { - bidderDisabled := false - if tc.status == adapters.StatusDisabled { - bidderDisabled = true - } - cfg := blankAdapterConfigWithStatus(openrtb_ext.CoreBidderNames(), bidderDisabled) - bidderInfos := adapters.ParseBidderInfos(cfg, "../../static/bidder-info", openrtb_ext.CoreBidderNames()) - endpoint := info.NewBidderDetailsEndpoint(bidderInfos, map[string]string{}) - - for _, bidderName := range openrtb_ext.CoreBidderNames() { - req, err := http.NewRequest("GET", "http://prebid-server.com/info/bidders/"+string(bidderName), strings.NewReader("")) - if err != nil { - t.Errorf("Failed to create a GET /info/bidders request: %v", err) - continue - } - params := []httprouter.Param{{ - Key: "bidderName", - Value: string(bidderName), - }} - r := httptest.NewRecorder() - - // Execute: - endpoint(r, req, params) - - // Verify: - assert.Equal(t, http.StatusOK, r.Code, "GET /info/bidders/"+string(bidderName)+" returned a %d. Expected 200", r.Code, tc.description) - assert.Equal(t, "application/json", r.HeaderMap.Get("Content-Type"), "GET /info/bidders/"+string(bidderName)+" returned Content-Type %s. Expected application/json", r.HeaderMap.Get("Content-Type"), tc.description) - - var resBidderInfo adapters.BidderInfo - if err := json.Unmarshal(r.Body.Bytes(), &resBidderInfo); err != nil { - assert.FailNow(t, "Failed to unmarshal JSON from endpoints/info/bidders/%s: %v", bidderName, err, tc.description) - } - - assert.Equal(t, tc.status, resBidderInfo.Status, tc.description) - } - } -} - -func TestGetBidderAccuracyNoAliases(t *testing.T) { - testGetBidderAccuracy(t, "") -} - -func TestGetBidderAccuracyAliases(t *testing.T) { - testGetBidderAccuracy(t, "aliasedBidder") -} - -// TestGetBidderAccuracyAlias validates the output for an alias of a known file. -func testGetBidderAccuracy(t *testing.T, alias string) { - cfg := blankAdapterConfig(openrtb_ext.CoreBidderNames()) - bidderInfos := adapters.ParseBidderInfos(cfg, "../../adapters/adapterstest/bidder-info", []openrtb_ext.BidderName{openrtb_ext.BidderName("someBidder")}) - - aliases := map[string]string{} - bidder := "someBidder" - if len(alias) > 0 { - aliases[alias] = bidder - bidder = alias - } - - endpoint := info.NewBidderDetailsEndpoint(bidderInfos, aliases) - req, err := http.NewRequest("GET", "http://prebid-server.com/info/bidders/"+bidder, strings.NewReader("")) - assert.NoError(t, err, "Failed to create a GET /info/bidders request: %v", err) - params := []httprouter.Param{{ - Key: "bidderName", - Value: bidder, - }} - - r := httptest.NewRecorder() - endpoint(r, req, params) - - var fileData adapters.BidderInfo - if err := json.Unmarshal(r.Body.Bytes(), &fileData); err != nil { - assert.FailNow(t, "Failed to unmarshal JSON from endpoints/info/sample/someBidder.yaml: %v", err) - } - - assert.Equal(t, "some-email@domain.com", fileData.Maintainer.Email, "maintainer.email should be some-email@domain.com. Got %s", fileData.Maintainer.Email) - assert.Len(t, fileData.Capabilities.App.MediaTypes, 2, "Expected 2 supported mediaTypes on app. Got %d", len(fileData.Capabilities.App.MediaTypes)) - assert.Equal(t, openrtb_ext.BidType("banner"), fileData.Capabilities.App.MediaTypes[0], "capabilities.app.mediaTypes[0] should be banner. Got %s", fileData.Capabilities.App.MediaTypes[0]) - assert.Equal(t, openrtb_ext.BidType("native"), fileData.Capabilities.App.MediaTypes[1], "capabilities.app.mediaTypes[1] should be native. Got %s", fileData.Capabilities.App.MediaTypes[1]) - assert.Len(t, fileData.Capabilities.Site.MediaTypes, 3, "Expected 3 supported mediaTypes on app. Got %d", len(fileData.Capabilities.Site.MediaTypes)) - assert.Equal(t, openrtb_ext.BidType("banner"), fileData.Capabilities.Site.MediaTypes[0], "capabilities.app.mediaTypes[0] should be banner. Got %s", fileData.Capabilities.Site.MediaTypes[0]) - assert.Equal(t, openrtb_ext.BidType("video"), fileData.Capabilities.Site.MediaTypes[1], "capabilities.app.mediaTypes[1] should be video. Got %s", fileData.Capabilities.Site.MediaTypes[1]) - assert.Equal(t, openrtb_ext.BidType("native"), fileData.Capabilities.Site.MediaTypes[2], "capabilities.app.mediaTypes[2] should be native. Got %s", fileData.Capabilities.Site.MediaTypes[2]) - if len(alias) > 0 { - assert.Equal(t, "someBidder", fileData.AliasOf, "aliasOf should be \"someBidder\". Got \"%s\"", fileData.AliasOf) - } else { - assert.Zero(t, len(fileData.AliasOf), "aliasOf should be empty. Got \"%s\"", fileData.AliasOf) - } -} - -func TestGetUnknownBidder(t *testing.T) { - bidderInfos := adapters.BidderInfos(make(map[string]adapters.BidderInfo)) - endpoint := info.NewBidderDetailsEndpoint(bidderInfos, map[string]string{}) - req, err := http.NewRequest("GET", "http://prebid-server.com/info/bidders/someUnknownBidder", strings.NewReader("")) - if err != nil { - assert.FailNow(t, "Failed to create a GET /info/bidders/someUnknownBidder request: %v", err) - } - - params := []httprouter.Param{{ - Key: "bidderName", - Value: "someUnknownBidder", - }} - r := httptest.NewRecorder() - - endpoint(r, req, params) - assert.Equal(t, http.StatusNotFound, r.Code, "GET /info/bidders/* should return a 404 on unknown bidders. Got %d", r.Code) -} -func TestGetAllBidders(t *testing.T) { - cfg := blankAdapterConfig(openrtb_ext.CoreBidderNames()) - bidderInfos := adapters.ParseBidderInfos(cfg, "../../static/bidder-info", openrtb_ext.CoreBidderNames()) - endpoint := info.NewBidderDetailsEndpoint(bidderInfos, map[string]string{}) - req, err := http.NewRequest("GET", "http://prebid-server.com/info/bidders/all", strings.NewReader("")) - if err != nil { - assert.FailNow(t, "Failed to create a GET /info/bidders/someUnknownBidder request: %v", err) - } - params := []httprouter.Param{{ - Key: "bidderName", - Value: "all", - }} - r := httptest.NewRecorder() - - endpoint(r, req, params) - assert.Equal(t, http.StatusOK, r.Code, "GET /info/bidders/all returned a %d. Expected 200", r.Code) - assert.Equal(t, "application/json", r.HeaderMap.Get("Content-Type"), "GET /info/bidders/all returned Content-Type %s. Expected application/json", r.HeaderMap.Get("Content-Type")) - - var resBidderInfos map[string]adapters.BidderInfo - - if err := json.Unmarshal(r.Body.Bytes(), &resBidderInfos); err != nil { - assert.FailNow(t, "Failed to unmarshal JSON from endpoints/info/sample/someBidder.yaml: %v", err) - } - - assert.Len(t, resBidderInfos, len(bidderInfos), "GET /info/bidders/all should respond with all bidders info") -} - -// TestInfoFiles makes sure that static/bidder-info contains a .yaml file for every BidderName. -func TestInfoFiles(t *testing.T) { - fileInfos, err := ioutil.ReadDir("../../static/bidder-info") - if err != nil { - assert.FailNow(t, "Error reading the static/bidder-info directory: %v", err) - } - - // Make sure that files exist for each BidderName - for _, bidderName := range openrtb_ext.CoreBidderNames() { - _, err := os.Stat(fmt.Sprintf("../../static/bidder-info/%s.yaml", string(bidderName))) - assert.False(t, os.IsNotExist(err), "static/bidder-info/%s.yaml not found. Did you forget to create it?", bidderName) - } - - expectedFileInfosLength := len(openrtb_ext.CoreBidderNames()) - assert.Len(t, fileInfos, expectedFileInfosLength, "static/bidder-info contains %d files, but the BidderMap has %d entries. These two should be in sync.", len(fileInfos), expectedFileInfosLength) - - // Make sure that all the files have valid content - for _, fileInfo := range fileInfos { - infoFileData, err := os.Open(fmt.Sprintf("../../static/bidder-info/%s", fileInfo.Name())) - assert.NoError(t, err, "Unexpected error: %v", err) - - content, err := ioutil.ReadAll(infoFileData) - assert.NoError(t, err, "Failed to read static/bidder-info/%s: %v", fileInfo.Name(), err) - - var fileInfoContent adapters.BidderInfo - err = yaml.Unmarshal(content, &fileInfoContent) - assert.NoError(t, err, "Error interpreting content from static/bidder-info/%s: %v", fileInfo.Name(), err) - - err = validateInfo(&fileInfoContent) - assert.NoError(t, err, "Invalid content in static/bidder-info/%s: %v", fileInfo.Name(), err) - - } -} - -func validateInfo(info *adapters.BidderInfo) error { - if err := validateMaintainer(info.Maintainer); err != nil { - return err - } - - if err := validateCapabilities(info.Capabilities); err != nil { - return err - } - - return nil -} - -func validateCapabilities(info *adapters.CapabilitiesInfo) error { - if info == nil { - return errors.New("missing required field: capabilities") + for _, test := range testCases { + result, err := prepareBiddersResponse(test.givenBidders, test.givenAliases) + assert.NoError(t, err, test.description) + assert.Equal(t, []byte(test.expected), result, test.description) } - if info.App == nil && info.Site == nil { - return errors.New("at least one of capabilities.site or capabilities.app should exist") - } - if info.App != nil { - if err := validatePlatformInfo(info.App); err != nil { - return fmt.Errorf("capabilities.app failed validation: %v", err) - } - } - if info.Site != nil { - if err := validatePlatformInfo(info.Site); err != nil { - return fmt.Errorf("capabilities.site failed validation: %v", err) - } - } - return nil } -func validatePlatformInfo(info *adapters.PlatformInfo) error { - if info == nil { - return errors.New("we can't validate a nil platformInfo") - } - if len(info.MediaTypes) == 0 { - return errors.New("mediaTypes should be an array with at least one string element") - } +func TestBiddersHandler(t *testing.T) { + bidders := config.BidderInfos{"a": {}} + aliases := map[string]string{"b": "b"} - for index, mediaType := range info.MediaTypes { - if mediaType != "banner" && mediaType != "video" && mediaType != "native" && mediaType != "audio" { - return fmt.Errorf("unrecognized media type at index %d: %s", index, mediaType) - } - } + handler := NewBiddersEndpoint(bidders, aliases) - return nil -} + responseRecorder := httptest.NewRecorder() + handler(responseRecorder, nil, nil) -func validateMaintainer(info *adapters.MaintainerInfo) error { - if info == nil || info.Email == "" { - return errors.New("missing required field: maintainer.email") - } - return nil -} + result := responseRecorder.Result() + assert.Equal(t, result.StatusCode, http.StatusOK) -func blankAdapterConfig(bidderList []openrtb_ext.BidderName) map[string]config.Adapter { - return blankAdapterConfigWithStatus(bidderList, false) -} + resultBody, _ := ioutil.ReadAll(result.Body) + assert.Equal(t, []byte(`["a","b"]`), resultBody) -func blankAdapterConfigWithStatus(bidderList []openrtb_ext.BidderName, biddersAreDisabled bool) map[string]config.Adapter { - adapters := make(map[string]config.Adapter) - for _, b := range bidderList { - adapters[strings.ToLower(string(b))] = config.Adapter{ - Disabled: biddersAreDisabled, - } - } - return adapters + resultHeaders := result.Header + assert.Equal(t, http.Header{"Content-Type": []string{"application/json"}}, resultHeaders) } diff --git a/endpoints/openrtb2/amp_auction.go b/endpoints/openrtb2/amp_auction.go index f6cef770694..6767151f15f 100644 --- a/endpoints/openrtb2/amp_auction.go +++ b/endpoints/openrtb2/amp_auction.go @@ -11,34 +11,34 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/openrtb" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/amp" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" "github.com/buger/jsonparser" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/mxmCherry/openrtb/v15/openrtb2" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/amp" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/prebid/prebid-server/usersync" + "github.com/prebid/prebid-server/util/iputil" ) const defaultAmpRequestTimeoutMillis = 900 type AmpResponse struct { - Targeting map[string]string `json:"targeting"` - Debug *openrtb_ext.ExtResponseDebug `json:"debug,omitempty"` - Errors map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError `json:"errors,omitempty"` - Warnings map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError `json:"warnings,omitempty"` + Targeting map[string]string `json:"targeting"` + Debug *openrtb_ext.ExtResponseDebug `json:"debug,omitempty"` + Errors map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage `json:"errors,omitempty"` + Warnings map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage `json:"warnings,omitempty"` } // NewAmpEndpoint modifies the OpenRTB endpoint to handle AMP requests. This will basically modify the parsing @@ -239,13 +239,16 @@ func (deps *endpointDeps) AmpAuction(w http.ResponseWriter, r *http.Request, _ h ao.Errors = append(ao.Errors, fmt.Errorf("AMP response: failed to unpack OpenRTB response.ext, debug info cannot be forwarded: %v", eRErr)) } - warnings := make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError) + warnings := extResponse.Warnings + if warnings == nil { + warnings = make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage) + } for _, v := range errortypes.WarningOnly(errL) { - bidderErr := openrtb_ext.ExtBidderError{ + bidderErr := openrtb_ext.ExtBidderMessage{ Code: errortypes.ReadCode(v), Message: v.Error(), } - warnings[openrtb_ext.BidderNameGeneral] = append(warnings[openrtb_ext.BidderNameGeneral], bidderErr) + warnings[openrtb_ext.BidderReservedGeneral] = append(warnings[openrtb_ext.BidderReservedGeneral], bidderErr) } // Now JSONify the targets for the AMP response. @@ -286,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) { @@ -310,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) @@ -369,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. @@ -420,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, }} @@ -447,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 } @@ -461,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 { @@ -503,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 { @@ -528,22 +531,23 @@ func readPolicy(consent string) (privacy.PolicyWriter, error) { return ccpa.ConsentWriter{consent}, nil } - return privacy.NilPolicyWriter{}, &errortypes.InvalidPrivacyConsent{ - Message: fmt.Sprintf("Consent '%s' is not recognized as either CCPA or GDPR TCF.", consent), + return privacy.NilPolicyWriter{}, &errortypes.Warning{ + Message: fmt.Sprintf("Consent '%s' is not recognized as either CCPA or GDPR TCF.", consent), + WarningCode: errortypes.InvalidPrivacyConsentWarningCode, } } // 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 cbff32413ba..079b9adb6d4 100644 --- a/endpoints/openrtb2/amp_auction_test.go +++ b/endpoints/openrtb2/amp_auction_test.go @@ -11,15 +11,15 @@ import ( "strconv" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - - "github.com/PubMatic-OpenWrap/openrtb" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" gometrics "github.com/rcrowley/go-metrics" "github.com/stretchr/testify/assert" ) @@ -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 @@ -395,103 +395,119 @@ func TestCCPAConsent(t *testing.T) { } } -func TestNoConsent(t *testing.T) { - // Build Request - bid, err := getTestBidRequest(true, nil, true, nil) - if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) +func TestConsentWarnings(t *testing.T) { + type inputTest struct { + regs *openrtb_ext.ExtRegs + invalidConsentURL bool + expectedWarnings map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage } + invalidConsent := "invalid" - // Simulated Stored Request Backend - stored := map[string]json.RawMessage{"1": json.RawMessage(bid)} + bidderWarning := openrtb_ext.ExtBidderMessage{ + Code: 10003, + Message: "debug turned off for bidder", + } + invalidCCPAWarning := openrtb_ext.ExtBidderMessage{ + Code: 10001, + Message: "Consent '" + invalidConsent + "' is not recognized as either CCPA or GDPR TCF.", + } + invalidConsentWarning := openrtb_ext.ExtBidderMessage{ + Code: 10001, + Message: "CCPA consent is invalid and will be ignored. (request.regs.ext.us_privacy must contain 4 characters)", + } - // Build Exchange Endpoint - mockExchange := &mockAmpExchange{} - endpoint, _ := NewAmpEndpoint( - mockExchange, - newParamsValidator(t), - &mockAmpStoredReqFetcher{stored}, - empty_fetcher.EmptyFetcher{}, - &config.Configuration{MaxRequestSize: maxSize}, - newTestMetrics(), - analyticsConf.NewPBSAnalytics(&config.Analytics{}), - map[string]string{}, - []byte{}, - openrtb_ext.BuildBidderMap(), - ) + testData := []inputTest{ + { + regs: nil, + invalidConsentURL: false, + expectedWarnings: nil, + }, + { + regs: nil, + invalidConsentURL: true, + expectedWarnings: map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage{openrtb_ext.BidderReservedGeneral: {invalidCCPAWarning}}, + }, + { + regs: &openrtb_ext.ExtRegs{USPrivacy: "invalid"}, + invalidConsentURL: true, + expectedWarnings: map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage{ + openrtb_ext.BidderReservedGeneral: {invalidCCPAWarning, invalidConsentWarning}, + openrtb_ext.BidderName("appnexus"): {bidderWarning}, + }, + }, + { + regs: &openrtb_ext.ExtRegs{USPrivacy: "1NYN"}, + invalidConsentURL: false, + expectedWarnings: map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage{openrtb_ext.BidderName("appnexus"): {bidderWarning}}, + }, + } - // Invoke Endpoint - request := httptest.NewRequest("GET", "/openrtb2/auction/amp?tag_id=1", nil) - responseRecorder := httptest.NewRecorder() - endpoint(responseRecorder, request, nil) + for _, testCase := range testData { - // Parse Response - var response AmpResponse - if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { - t.Fatalf("Error unmarshalling response: %s", err.Error()) - } + bid, err := getTestBidRequest(true, nil, testCase.regs == nil, testCase.regs) + if err != nil { + t.Fatalf("Failed to marshal the complete openrtb2.BidRequest object %v", err) + } - // Assert Result - result := mockExchange.lastRequest - assert.NotNil(t, result, "lastRequest") - assert.Nil(t, result.User, "lastRequest.User") - assert.Nil(t, result.Regs, "lastRequest.Regs") - assert.Equal(t, expectedErrorsFromHoldAuction, response.Errors) - assert.Empty(t, response.Warnings) -} + // Simulated Stored Request Backend + stored := map[string]json.RawMessage{"1": json.RawMessage(bid)} -func TestInvalidConsent(t *testing.T) { - // Build Request - bid, err := getTestBidRequest(true, nil, true, nil) - if err != nil { - t.Fatalf("Failed to marshal the complete openrtb.BidRequest object %v", err) - } + // Build Exchange Endpoint + var mockExchange exchange.Exchange + if testCase.regs != nil { + mockExchange = &mockAmpExchangeWarnings{} + } else { + mockExchange = &mockAmpExchange{} + } + endpoint, _ := NewAmpEndpoint( + mockExchange, + newParamsValidator(t), + &mockAmpStoredReqFetcher{stored}, + empty_fetcher.EmptyFetcher{}, + &config.Configuration{MaxRequestSize: maxSize}, + newTestMetrics(), + analyticsConf.NewPBSAnalytics(&config.Analytics{}), + map[string]string{}, + []byte{}, + openrtb_ext.BuildBidderMap(), + ) - // Simulated Stored Request Backend - stored := map[string]json.RawMessage{"1": json.RawMessage(bid)} + // Invoke Endpoint + var request *http.Request - // Build Exchange Endpoint - mockExchange := &mockAmpExchange{} - endpoint, _ := NewAmpEndpoint( - mockExchange, - newParamsValidator(t), - &mockAmpStoredReqFetcher{stored}, - empty_fetcher.EmptyFetcher{}, - &config.Configuration{MaxRequestSize: maxSize}, - newTestMetrics(), - analyticsConf.NewPBSAnalytics(&config.Analytics{}), - map[string]string{}, - []byte{}, - openrtb_ext.BuildBidderMap(), - ) + if testCase.invalidConsentURL { + request = httptest.NewRequest("GET", "/openrtb2/auction/amp?tag_id=1&consent_string="+invalidConsent, nil) - // Invoke Endpoint - invalidConsent := "invalid" - request := httptest.NewRequest("GET", "/openrtb2/auction/amp?tag_id=1&consent_string="+invalidConsent, nil) - responseRecorder := httptest.NewRecorder() - endpoint(responseRecorder, request, nil) + } else { + request = httptest.NewRequest("GET", "/openrtb2/auction/amp?tag_id=1", nil) + } - // Parse Response - var response AmpResponse - if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { - t.Fatalf("Error unmarshalling response: %s", err.Error()) - } + responseRecorder := httptest.NewRecorder() + endpoint(responseRecorder, request, nil) - // Assert Result - expectedWarnings := map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError{ - openrtb_ext.BidderNameGeneral: { - { - Code: 10001, - Message: "Consent '" + invalidConsent + "' is not recognized as either CCPA or GDPR TCF.", - }, - }, + // Parse Response + var response AmpResponse + if err := json.Unmarshal(responseRecorder.Body.Bytes(), &response); err != nil { + t.Fatalf("Error unmarshalling response: %s", err.Error()) + } + + // Assert Result + if testCase.regs == nil { + result := mockExchange.(*mockAmpExchange).lastRequest + assert.NotNil(t, result, "lastRequest") + assert.Nil(t, result.User, "lastRequest.User") + assert.Nil(t, result.Regs, "lastRequest.Regs") + assert.Equal(t, expectedErrorsFromHoldAuction, response.Errors) + if testCase.invalidConsentURL { + assert.Equal(t, testCase.expectedWarnings, response.Warnings) + } else { + assert.Empty(t, response.Warnings) + } + + } else { + assert.Equal(t, testCase.expectedWarnings, response.Warnings) + } } - result := mockExchange.lastRequest - assert.NotNil(t, result, "lastRequest") - assert.Nil(t, result.User, "lastRequest.User") - assert.Nil(t, result.Regs, "lastRequest.Regs") - assert.Equal(t, expectedErrorsFromHoldAuction, response.Errors) - assert.Equal(t, expectedWarnings, response.Warnings) } func TestNewAndLegacyConsentBothProvided(t *testing.T) { @@ -527,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 @@ -696,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) } @@ -781,7 +797,7 @@ func TestOverrideDimensions(t *testing.T) { formatOverrideSpec{ overrideWidth: 20, overrideHeight: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -792,7 +808,7 @@ func TestOverrideHeightNormalWidth(t *testing.T) { formatOverrideSpec{ width: 20, overrideHeight: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -803,7 +819,7 @@ func TestOverrideWidthNormalHeight(t *testing.T) { formatOverrideSpec{ overrideWidth: 20, height: 40, - expect: []openrtb.Format{{ + expect: []openrtb2.Format{{ W: 20, H: 40, }}, @@ -813,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, }, { @@ -828,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, }, { @@ -844,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, }}, @@ -854,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, }}, @@ -868,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) { @@ -926,10 +942,10 @@ 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.ExtBidderError = map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError{ +var expectedErrorsFromHoldAuction map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage = map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage{ openrtb_ext.BidderName("openx"): { { Code: 1, @@ -938,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"}}}`), }}, @@ -962,17 +978,32 @@ func (m *mockAmpExchange) HoldAuction(ctx context.Context, r exchange.AuctionReq return response, nil } +type mockAmpExchangeWarnings struct{} + +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"}}}`), + }}, + }}, + Ext: json.RawMessage(`{ "warnings": {"appnexus": [{"code": 10003, "message": "debug turned off for bidder"}] }}`), + } + return response, nil +} + 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, @@ -987,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", }, @@ -1003,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, @@ -1020,12 +1051,11 @@ func getTestBidRequest(nilUser bool, userExt *openrtb_ext.ExtUser, nilRegs bool, } if !nilRegs { - bidRequest.Regs = &openrtb.Regs{ + bidRequest.Regs = &openrtb2.Regs{ COPPA: 1, Ext: regsExtData, } } - return json.Marshal(bidRequest) } @@ -1034,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, }, }, @@ -1049,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, }, }, @@ -1060,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, }, }, @@ -1071,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: "", }, }, @@ -1083,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: "", }, }, @@ -1176,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, @@ -1205,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 fa48daf30ad..bc8946fa90c 100644 --- a/endpoints/openrtb2/auction.go +++ b/endpoints/openrtb2/auction.go @@ -13,28 +13,29 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/openrtb/native" - nativeRequests "github.com/PubMatic-OpenWrap/openrtb/native/request" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/PubMatic-OpenWrap/prebid-server/util/httputil" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" "github.com/gofrs/uuid" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/mxmCherry/openrtb/v15/native1" + nativeRequests "github.com/mxmCherry/openrtb/v15/native1/request" + "github.com/mxmCherry/openrtb/v15/openrtb2" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/lmt" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/prebid/prebid-server/usersync" + "github.com/prebid/prebid-server/util/httputil" + "github.com/prebid/prebid-server/util/iputil" "golang.org/x/net/publicsuffix" ) @@ -138,6 +139,7 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http if errortypes.ContainsFatalError(errL) && writeError(errL, w, &labels) { return } + warnings := errortypes.WarningOnly(errL) ctx := context.Background() @@ -178,6 +180,7 @@ func (deps *endpointDeps) Auction(w http.ResponseWriter, r *http.Request, _ http RequestType: labels.RType, StartTime: start, LegacyLabels: labels, + Warnings: warnings, } response, err := deps.ex.HoldAuction(ctx, auctionRequest, nil) @@ -220,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. @@ -264,6 +267,8 @@ func (deps *endpointDeps) parseRequest(httpRequest *http.Request) (req *openrtb. return } + lmt.ModifyForIOS(req) + errL := deps.validateRequest(req) if len(errL) > 0 { errs = append(errs, errL...) @@ -287,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\"")} @@ -335,10 +340,6 @@ func (deps *endpointDeps) validateRequest(req *openrtb.BidRequest) []error { if err := deps.validateEidPermissions(bidExt, aliases); err != nil { return []error{err} } - - if err := validateSChains(bidExt); err != nil { - return []error{err} - } } if (req.Site == nil && req.App == nil) || (req.Site != nil && req.App != nil) { @@ -361,11 +362,17 @@ 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 { - if _, invalidConsent := err.(*errortypes.InvalidPrivacyConsent); invalidConsent { - errL = append(errL, &errortypes.InvalidPrivacyConsent{Message: fmt.Sprintf("CCPA consent is invalid and will be ignored. (%v)", err)}) + if _, invalidConsent := err.(*errortypes.Warning); invalidConsent { + errL = append(errL, &errortypes.Warning{ + Message: fmt.Sprintf("CCPA consent is invalid and will be ignored. (%v)", err), + WarningCode: errortypes.InvalidPrivacyConsentWarningCode}) consentWriter := ccpa.ConsentWriter{Consent: ""} if err := consentWriter.Write(req); err != nil { return append(errL, fmt.Errorf("Unable to remove invalid CCPA consent from the request. (%v)", err)) @@ -394,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 { @@ -472,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)} } @@ -489,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 { @@ -513,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) } @@ -538,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 } @@ -581,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 { @@ -599,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 @@ -621,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 @@ -683,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 { @@ -724,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) } } @@ -745,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) @@ -763,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) } @@ -782,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) } @@ -807,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 } @@ -820,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)} @@ -831,19 +939,15 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]st return []error{err} } - // Also accept bidder exts within imp[...].ext.prebid.bidder - // NOTE: This is not part of the official API yet, so we are not expecting clients - // to migrate from imp[...].ext.${BIDDER} to imp[...].ext.prebid.bidder.${BIDDER} - // at this time - // https://github.com/PubMatic-OpenWrap/prebid-server/pull/846#issuecomment-476352224 - if rawPrebidExt, ok := bidderExts[openrtb_ext.PrebidExtKey]; ok { - var prebidExt openrtb_ext.ExtImpPrebid - if err := json.Unmarshal(rawPrebidExt, &prebidExt); err == nil && prebidExt.Bidder != nil { - for bidder, ext := range prebidExt.Bidder { + // Prefer bidder params from request.imp.ext.prebid.bidder.BIDDER over request.imp.ext.BIDDER + // to avoid confusion beteween prebid specific adapter config and other ext protocols. + if extPrebidJSON, ok := bidderExts[openrtb_ext.PrebidExtKey]; ok { + var extPrebid openrtb_ext.ExtImpPrebid + if err := json.Unmarshal(extPrebidJSON, &extPrebid); err == nil && extPrebid.Bidder != nil { + for bidder, ext := range extPrebid.Bidder { if ext == nil { continue } - bidderExts[bidder] = ext } } @@ -851,7 +955,6 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]st /* Process all the bidder exts in the request */ disabledBidders := []string{} - validationFailedBidders := []string{} otherExtElements := 0 for bidder, ext := range bidderExts { if isBidderToValidate(bidder) { @@ -861,10 +964,7 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]st } if bidderName, isValid := deps.bidderMap[coreBidder]; isValid { if err := deps.paramsValidator.Validate(bidderName, ext); err != nil { - validationFailedBidders = append(validationFailedBidders, bidder) - msg := fmt.Sprintf("request.imp[%d].ext.%s failed validation.\n%v", impIndex, coreBidder, err) - glog.Errorf("BidderSchemaValidationError: %s", msg) - errL = append(errL, &errortypes.BidderFailedSchemaValidation{Message: msg}) + return []error{fmt.Errorf("request.imp[%d].ext.%s failed validation.\n%v", impIndex, coreBidder, err)} } } else { if msg, isDisabled := deps.disabledBidders[bidder]; isDisabled { @@ -884,15 +984,6 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]st for _, bidder := range disabledBidders { delete(bidderExts, bidder) } - } - - if len(validationFailedBidders) > 0 { - for _, bidder := range validationFailedBidders { - delete(bidderExts, bidder) - } - } - - if len(disabledBidders) > 0 || len(validationFailedBidders) > 0 { extJSON, err := json.Marshal(bidderExts) if err != nil { return []error{err} @@ -907,13 +998,20 @@ func (deps *endpointDeps) validateImpExt(imp *openrtb.Imp, aliases map[string]st return errL } +// isBidderToValidate determines if the bidder name in request.imp[].prebid should be validated. func isBidderToValidate(bidder string) bool { - // PrebidExtKey is a special case for the prebid config section and is not considered a bidder. - - // FirstPartyDataContextExtKey is a special case for the first party data context section - // and is not considered a bidder. - - return bidder != openrtb_ext.PrebidExtKey && bidder != openrtb_ext.FirstPartyDataContextExtKey + switch openrtb_ext.BidderName(bidder) { + case openrtb_ext.BidderReservedContext: + return false + case openrtb_ext.BidderReservedData: + return false + case openrtb_ext.BidderReservedPrebid: + return false + case openrtb_ext.BidderReservedSKAdN: + return false + default: + return true + } } func (deps *endpointDeps) parseBidExt(ext json.RawMessage) (*openrtb_ext.ExtRequest, error) { @@ -928,18 +1026,23 @@ func (deps *endpointDeps) parseBidExt(ext json.RawMessage) (*openrtb_ext.ExtRequ } func (deps *endpointDeps) validateAliases(aliases map[string]string) error { - for thisAlias, coreBidder := range aliases { + for alias, coreBidder := range aliases { + if _, isCoreBidderDisabled := deps.disabledBidders[coreBidder]; isCoreBidderDisabled { + return fmt.Errorf("request.ext.prebid.aliases.%s refers to disabled bidder: %s", alias, coreBidder) + } + if _, isCoreBidder := deps.bidderMap[coreBidder]; !isCoreBidder { - return fmt.Errorf("request.ext.prebid.aliases.%s refers to unknown bidder: %s", thisAlias, coreBidder) + return fmt.Errorf("request.ext.prebid.aliases.%s refers to unknown bidder: %s", alias, coreBidder) } - if thisAlias == coreBidder { - return fmt.Errorf("request.ext.prebid.aliases.%s defines a no-op alias. Choose a different alias, or remove this entry.", thisAlias) + + if alias == coreBidder { + return fmt.Errorf("request.ext.prebid.aliases.%s defines a no-op alias. Choose a different alias, or remove this entry.", alias) } } return nil } -func (deps *endpointDeps) validateSite(site *openrtb.Site) error { +func (deps *endpointDeps) validateSite(site *openrtb2.Site) error { if site == nil { return nil } @@ -957,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 } @@ -978,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 { @@ -1032,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) } } @@ -1040,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 { @@ -1053,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 = "" @@ -1070,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) @@ -1085,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) @@ -1094,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 } @@ -1102,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 @@ -1127,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) { @@ -1287,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() } @@ -1307,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 { @@ -1370,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_benchmark_test.go b/endpoints/openrtb2/auction_benchmark_test.go index 89965db0430..e55ffd11093 100644 --- a/endpoints/openrtb2/auction_benchmark_test.go +++ b/endpoints/openrtb2/auction_benchmark_test.go @@ -7,15 +7,14 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/currency" + "github.com/prebid/prebid-server/currency" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" ) // dummyServer returns the header bidding test ad. This response was scraped from a real appnexus server response. @@ -60,8 +59,8 @@ func BenchmarkOpenrtbEndpoint(b *testing.B) { server := httptest.NewServer(http.HandlerFunc(dummyServer)) defer server.Close() - var infos adapters.BidderInfos - infos["appnexus"] = adapters.BidderInfo{Capabilities: &adapters.CapabilitiesInfo{Site: &adapters.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}}}} + var infos config.BidderInfos + infos["appnexus"] = config.BidderInfo{Capabilities: &config.CapabilitiesInfo{Site: &config.PlatformInfo{MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}}}} paramValidator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") if err != nil { return diff --git a/endpoints/openrtb2/auction_test.go b/endpoints/openrtb2/auction_test.go index 7e67770173c..75d0610cb34 100644 --- a/endpoints/openrtb2/auction_test.go +++ b/endpoints/openrtb2/auction_test.go @@ -17,20 +17,19 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - - "github.com/PubMatic-OpenWrap/openrtb" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/stored_requests" + "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/prebid/prebid-server/util/iputil" "github.com/stretchr/testify/assert" ) @@ -49,7 +48,7 @@ type testConfigValues struct { AliasJSON string `json:"aliases"` BlacklistedAccounts []string `json:"blacklistedAccts"` BlacklistedApps []string `json:"blacklistedApps"` - AdapterList []string `json:"disabledAdapters"` + DisabledAdapters []string `json:"disabledAdapters"` } func TestJsonSampleRequests(t *testing.T) { @@ -153,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) @@ -230,9 +229,9 @@ func (tc *testConfigValues) getBlackListedAccountMap() map[string]bool { func (tc *testConfigValues) getAdaptersConfigMap() map[string]config.Adapter { var adaptersConfig map[string]config.Adapter - if len(tc.AdapterList) > 0 { - adaptersConfig = make(map[string]config.Adapter, len(tc.AdapterList)) - for _, adapterName := range tc.AdapterList { + if len(tc.DisabledAdapters) > 0 { + adaptersConfig = make(map[string]config.Adapter, len(tc.DisabledAdapters)) + for _, adapterName := range tc.DisabledAdapters { adaptersConfig[adapterName] = config.Adapter{Disabled: true} } } @@ -242,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) @@ -253,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 } @@ -276,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}, }, }, }, @@ -627,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) @@ -643,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", }, } @@ -657,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 { @@ -758,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, }, }, @@ -780,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, }, }, @@ -790,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, }, }, @@ -812,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, }, }, @@ -824,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, }, }, @@ -838,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, }, }, @@ -852,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, }, }, @@ -942,11 +941,12 @@ func TestImplicitDNTEndToEnd(t *testing.T) { assert.Equal(t, test.expectedDNT, result.Device.DNT, test.description+":dnt") } } + 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,30 +1482,32 @@ 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"}`), }, } errL := deps.validateRequest(&req) - expectedWarning := errortypes.InvalidPrivacyConsent{Message: "CCPA consent is invalid and will be ignored. (request.regs.ext.us_privacy must contain 4 characters)"} + expectedWarning := errortypes.Warning{ + Message: "CCPA consent is invalid and will be ignored. (request.regs.ext.us_privacy must contain 4 characters)", + WarningCode: errortypes.InvalidPrivacyConsentWarningCode} assert.ElementsMatch(t, errL, []error{&expectedWarning}) assert.Empty(t, req.Regs.Ext, "Invalid Consent Removed From Request") @@ -1530,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"]} }`), @@ -1581,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", }, } @@ -1622,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"}}]}}`), @@ -1660,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, }, @@ -1673,7 +1675,7 @@ func TestGetAccountID(t *testing.T) { }, { description: "Only Publisher.Ext.Prebid.ParentAccount present", - pub: &openrtb.Publisher{ + pub: &openrtb2.Publisher{ ID: "", Ext: testPubExtJSON, }, @@ -1681,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, }, { @@ -1707,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: "", }, @@ -1725,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::", }, @@ -1737,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::", }, @@ -1749,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", }, @@ -1761,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", }, @@ -1783,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, }, }, @@ -1841,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":[]}]} } }`), @@ -2076,34 +2078,111 @@ func TestValidateBidders(t *testing.T) { } } +func TestIOS14EndToEnd(t *testing.T) { + exchange := &nobidExchange{} + + endpoint, _ := NewEndpoint( + exchange, + newParamsValidator(t), + &mockStoredReqFetcher{}, + empty_fetcher.EmptyFetcher{}, + &config.Configuration{MaxRequestSize: maxSize}, + newTestMetrics(), + analyticsConf.NewPBSAnalytics(&config.Analytics{}), + map[string]string{}, + []byte{}, + openrtb_ext.BuildBidderMap()) + + httpReq := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(validRequest(t, "app-ios140-no-ifa.json"))) + + endpoint(httptest.NewRecorder(), httpReq, nil) + + result := exchange.gotRequest + if !assert.NotEmpty(t, result, "request received by the exchange.") { + t.FailNow() + } + + var lmtOne int8 = 1 + assert.Equal(t, &lmtOne, result.Device.Lmt) +} + +func TestAuctionWarnings(t *testing.T) { + reqBody := validRequest(t, "us-privacy-invalid.json") + deps := &endpointDeps{ + &warningsCheckExchange{}, + newParamsValidator(t), + &mockStoredReqFetcher{}, + empty_fetcher.EmptyFetcher{}, + empty_fetcher.EmptyFetcher{}, + &config.Configuration{MaxRequestSize: int64(len(reqBody))}, + newTestMetrics(), + analyticsConf.NewPBSAnalytics(&config.Analytics{}), + map[string]string{}, + false, + []byte{}, + openrtb_ext.BuildBidderMap(), + nil, + nil, + hardcodedResponseIPValidator{response: true}, + } + + req := httptest.NewRequest("POST", "/openrtb2/auction", strings.NewReader(reqBody)) + recorder := httptest.NewRecorder() + + deps.Auction(recorder, req, nil) + + if recorder.Code != http.StatusOK { + t.Errorf("Endpoint should return a 200") + } + warnings := deps.ex.(*warningsCheckExchange).auctionRequest.Warnings + if !assert.Len(t, warnings, 1, "One warning should be returned from exchange") { + t.FailNow() + } + actualWarning := warnings[0].(*errortypes.Warning) + expectedMessage := "CCPA consent is invalid and will be ignored. (request.regs.ext.us_privacy must contain 4 characters)" + assert.Equal(t, expectedMessage, actualWarning.Message, "Warning message is incorrect") + + assert.Equal(t, errortypes.InvalidPrivacyConsentWarningCode, actualWarning.WarningCode, "Warning code is incorrect") +} + +// warningsCheckExchange is a well-behaved exchange which stores all incoming warnings. +type warningsCheckExchange struct { + auctionRequest exchange.AuctionRequest +} + +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 { @@ -2126,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)}}} } } } @@ -2143,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.") } @@ -2506,22 +2585,22 @@ 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: "", }}, }}, }, nil } -func getBidderInfos(cfg map[string]config.Adapter, biddersNames []openrtb_ext.BidderName) adapters.BidderInfos { - biddersInfos := make(adapters.BidderInfos) +func getBidderInfos(cfg map[string]config.Adapter, biddersNames []openrtb_ext.BidderName) config.BidderInfos { + biddersInfos := make(config.BidderInfos) for _, name := range biddersNames { adapterConfig, ok := cfg[string(name)] if !ok { @@ -2532,14 +2611,9 @@ func getBidderInfos(cfg map[string]config.Adapter, biddersNames []openrtb_ext.Bi return biddersInfos } -func newBidderInfo(cfg config.Adapter) adapters.BidderInfo { - status := adapters.StatusActive - if cfg.Disabled == true { - status = adapters.StatusDisabled - } - - return adapters.BidderInfo{ - Status: status, +func newBidderInfo(cfg config.Adapter) config.BidderInfo { + return config.BidderInfo{ + Enabled: !cfg.Disabled, } } diff --git a/endpoints/openrtb2/ctv/combination/adslot_combination_generator.go b/endpoints/openrtb2/ctv/combination/adslot_combination_generator.go index 8778cfe55e0..81a5a923eb6 100644 --- a/endpoints/openrtb2/ctv/combination/adslot_combination_generator.go +++ b/endpoints/openrtb2/ctv/combination/adslot_combination_generator.go @@ -3,7 +3,7 @@ package combination import ( "math/big" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) //generator holds all the combinations based diff --git a/endpoints/openrtb2/ctv/combination/adslot_combination_generator_test.go b/endpoints/openrtb2/ctv/combination/adslot_combination_generator_test.go index a9c72a8a5a8..b701a7f1c1f 100644 --- a/endpoints/openrtb2/ctv/combination/adslot_combination_generator_test.go +++ b/endpoints/openrtb2/ctv/combination/adslot_combination_generator_test.go @@ -6,8 +6,8 @@ import ( "os" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/openrtb2/ctv/combination/combination.go b/endpoints/openrtb2/ctv/combination/combination.go index e5c5e0c4b79..4f4f1987354 100644 --- a/endpoints/openrtb2/ctv/combination/combination.go +++ b/endpoints/openrtb2/ctv/combination/combination.go @@ -8,8 +8,8 @@ package combination import ( - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/openrtb_ext" ) // ICombination ... diff --git a/endpoints/openrtb2/ctv/combination/combination_test.go b/endpoints/openrtb2/ctv/combination/combination_test.go index 029cad0819b..14f32eddcb6 100644 --- a/endpoints/openrtb2/ctv/combination/combination_test.go +++ b/endpoints/openrtb2/ctv/combination/combination_test.go @@ -3,8 +3,8 @@ package combination import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/openrtb2/ctv/impressions/helper.go b/endpoints/openrtb2/ctv/impressions/helper.go index 23e57a3b349..7fba95d704d 100644 --- a/endpoints/openrtb2/ctv/impressions/helper.go +++ b/endpoints/openrtb2/ctv/impressions/helper.go @@ -3,8 +3,8 @@ package impressions import ( "math" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/openrtb_ext" ) // newConfig initializes the generator instance diff --git a/endpoints/openrtb2/ctv/impressions/impression_generator.go b/endpoints/openrtb2/ctv/impressions/impression_generator.go index eb195b39f56..5488a8dd6a6 100644 --- a/endpoints/openrtb2/ctv/impressions/impression_generator.go +++ b/endpoints/openrtb2/ctv/impressions/impression_generator.go @@ -1,7 +1,7 @@ package impressions import ( - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" ) // generator contains Pod Minimum Duration, Pod Maximum Duration, Slot Minimum Duration and Slot Maximum Duration diff --git a/endpoints/openrtb2/ctv/impressions/impressions.go b/endpoints/openrtb2/ctv/impressions/impressions.go index ab8294afc81..f810d9fd2a8 100644 --- a/endpoints/openrtb2/ctv/impressions/impressions.go +++ b/endpoints/openrtb2/ctv/impressions/impressions.go @@ -4,8 +4,8 @@ package impressions import ( - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/openrtb_ext" ) // Algorithm indicates type of algorithms supported diff --git a/endpoints/openrtb2/ctv/impressions/maximize_for_duration.go b/endpoints/openrtb2/ctv/impressions/maximize_for_duration.go index 77cd5a334c7..b51116744b6 100644 --- a/endpoints/openrtb2/ctv/impressions/maximize_for_duration.go +++ b/endpoints/openrtb2/ctv/impressions/maximize_for_duration.go @@ -1,8 +1,8 @@ package impressions import ( - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/openrtb_ext" ) // newMaximizeForDuration Constucts the generator object from openrtb_ext.VideoAdPod diff --git a/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go b/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go index 84f3304fb6d..2bb7323b0c1 100644 --- a/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go +++ b/endpoints/openrtb2/ctv/impressions/maximize_for_duration_test.go @@ -3,8 +3,8 @@ package impressions import ( "testing" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/impressions/testdata" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/impressions/testdata" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/openrtb2/ctv/impressions/min_max_algorithm.go b/endpoints/openrtb2/ctv/impressions/min_max_algorithm.go index b25d0783230..0d2f43301f2 100644 --- a/endpoints/openrtb2/ctv/impressions/min_max_algorithm.go +++ b/endpoints/openrtb2/ctv/impressions/min_max_algorithm.go @@ -7,8 +7,8 @@ import ( "strings" "sync" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/openrtb_ext" ) // keyDelim used as separator in forming key of maxExpectedDurationMap diff --git a/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go b/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go index 5928b430924..332e5d78e4c 100644 --- a/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go +++ b/endpoints/openrtb2/ctv/impressions/min_max_algorithm_test.go @@ -4,7 +4,7 @@ import ( "sort" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/impressions/testdata" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/impressions/testdata" "github.com/stretchr/testify/assert" ) diff --git a/endpoints/openrtb2/ctv/response/adpod_generator copy.go.bak b/endpoints/openrtb2/ctv/response/adpod_generator copy.go.bak index 0c3fc4b1a69..df5b7e36be0 100644 --- a/endpoints/openrtb2/ctv/response/adpod_generator copy.go.bak +++ b/endpoints/openrtb2/ctv/response/adpod_generator copy.go.bak @@ -4,7 +4,7 @@ import ( "context" "time" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) /********************* AdPodGenerator Functions *********************/ diff --git a/endpoints/openrtb2/ctv/response/adpod_generator.go b/endpoints/openrtb2/ctv/response/adpod_generator.go index 1f5eb3d3d2b..37758f7bbf6 100644 --- a/endpoints/openrtb2/ctv/response/adpod_generator.go +++ b/endpoints/openrtb2/ctv/response/adpod_generator.go @@ -5,13 +5,13 @@ import ( "sync" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/combination" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/constant" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/combination" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/constant" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" ) /********************* AdPodGenerator Functions *********************/ @@ -40,7 +40,7 @@ type highestCombination struct { //AdPodGenerator AdPodGenerator type AdPodGenerator struct { IAdPodGenerator - request *openrtb.BidRequest + request *openrtb2.BidRequest impIndex int buckets types.BidsBuckets comb combination.ICombination @@ -49,7 +49,7 @@ type AdPodGenerator struct { } //NewAdPodGenerator will generate adpod based on configuration -func NewAdPodGenerator(request *openrtb.BidRequest, impIndex int, buckets types.BidsBuckets, comb combination.ICombination, adpod *openrtb_ext.VideoAdPod, met metrics.MetricsEngine) *AdPodGenerator { +func NewAdPodGenerator(request *openrtb2.BidRequest, impIndex int, buckets types.BidsBuckets, comb combination.ICombination, adpod *openrtb_ext.VideoAdPod, met metrics.MetricsEngine) *AdPodGenerator { return &AdPodGenerator{ request: request, impIndex: impIndex, diff --git a/endpoints/openrtb2/ctv/response/adpod_generator_test.go b/endpoints/openrtb2/ctv/response/adpod_generator_test.go index ac18b316c85..f387d5bbe24 100644 --- a/endpoints/openrtb2/ctv/response/adpod_generator_test.go +++ b/endpoints/openrtb2/ctv/response/adpod_generator_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" ) func Test_findUniqueCombinations(t *testing.T) { @@ -27,38 +27,38 @@ func Test_findUniqueCombinations(t *testing.T) { data: [][]*types.Bid{ { { - Bid: &openrtb.Bid{ID: "3-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 6.339115524232314}, + Bid: &openrtb2.Bid{ID: "3-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 6.339115524232314}, DealTierSatisfied: true, }, { - Bid: &openrtb.Bid{ID: "4-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.532468782358357}, + Bid: &openrtb2.Bid{ID: "4-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.532468782358357}, DealTierSatisfied: true, }, { - Bid: &openrtb.Bid{ID: "7-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, + Bid: &openrtb2.Bid{ID: "7-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, DealTierSatisfied: false, }, { - Bid: &openrtb.Bid{ID: "8-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, + Bid: &openrtb2.Bid{ID: "8-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, DealTierSatisfied: false, }, }, //20 { { - Bid: &openrtb.Bid{ID: "2-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.4502433547413878}, + Bid: &openrtb2.Bid{ID: "2-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.4502433547413878}, DealTierSatisfied: true, }, { - Bid: &openrtb.Bid{ID: "1-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.329644588311827}, + Bid: &openrtb2.Bid{ID: "1-ed72b572-ba62-4220-abba-c19c0bf6346b", Price: 3.329644588311827}, DealTierSatisfied: true, }, { - Bid: &openrtb.Bid{ID: "5-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, + Bid: &openrtb2.Bid{ID: "5-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, DealTierSatisfied: false, }, { - Bid: &openrtb.Bid{ID: "6-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, + Bid: &openrtb2.Bid{ID: "6-VIDEO12-89A1-41F1-8708-978FD3C0912A", Price: 5}, DealTierSatisfied: false, }, }, //25 diff --git a/endpoints/openrtb2/ctv/types/adpod_types.go b/endpoints/openrtb2/ctv/types/adpod_types.go index a3348d7d816..6e46929547d 100644 --- a/endpoints/openrtb2/ctv/types/adpod_types.go +++ b/endpoints/openrtb2/ctv/types/adpod_types.go @@ -1,14 +1,14 @@ package types import ( - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/constant" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/constant" + "github.com/prebid/prebid-server/openrtb_ext" ) //Bid openrtb bid object with extra parameters type Bid struct { - *openrtb.Bid + *openrtb2.Bid Duration int FilterReasonCode constant.FilterReasonCode DealTierSatisfied bool @@ -22,8 +22,8 @@ type ExtCTVBidResponse struct { //BidResponseAdPodExt object for ctv bidresponse adpod object type BidResponseAdPodExt struct { - Response openrtb.BidResponse `json:"bidresponse,omitempty"` - Config map[string]*ImpData `json:"config,omitempty"` + Response openrtb2.BidResponse `json:"bidresponse,omitempty"` + Config map[string]*ImpData `json:"config,omitempty"` } //AdPodBid combination contains ImpBid diff --git a/endpoints/openrtb2/ctv/util/util.go b/endpoints/openrtb2/ctv/util/util.go index d80c89300cf..523fcf7ed61 100644 --- a/endpoints/openrtb2/ctv/util/util.go +++ b/endpoints/openrtb2/ctv/util/util.go @@ -8,13 +8,13 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/openrtb" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/openrtb2" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/constant" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/constant" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/openrtb_ext" ) func GetDurationWiseBidsBucket(bids []*types.Bid) types.BidsBuckets { @@ -93,7 +93,7 @@ func TimeTrack(start time.Time, name string) { // it is expected that bid.Ext contains prebid.targeting map // if value not present or any error occured empty value will be returned // along with error. -func GetTargeting(key openrtb_ext.TargetingKey, bidder openrtb_ext.BidderName, bid openrtb.Bid) (string, error) { +func GetTargeting(key openrtb_ext.TargetingKey, bidder openrtb_ext.BidderName, bid openrtb2.Bid) (string, error) { bidderSpecificKey := key.BidderKey(openrtb_ext.BidderName(bidder), 20) return jsonparser.GetString(bid.Ext, "prebid", "targeting", bidderSpecificKey) } diff --git a/endpoints/openrtb2/ctv/util/util_test.go b/endpoints/openrtb2/ctv/util/util_test.go index 0f49b04f6bb..8a351caad86 100644 --- a/endpoints/openrtb2/ctv/util/util_test.go +++ b/endpoints/openrtb2/ctv/util/util_test.go @@ -4,11 +4,11 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/openrtb2" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" "github.com/stretchr/testify/assert" ) @@ -144,7 +144,7 @@ func TestSortByDealPriority(t *testing.T) { newBid := func(bid testbid) *types.Bid { return &types.Bid{ - Bid: &openrtb.Bid{ + Bid: &openrtb2.Bid{ ID: bid.id, Price: bid.price, //Ext: json.RawMessage(`{"prebid":{ "dealTierSatisfied" : ` + bid.isDealBid + ` }}`), @@ -193,7 +193,7 @@ func TestGetTargeting(t *testing.T) { for _, test := range tests { t.Run(test.scenario, func(t *testing.T) { - bid := new(openrtb.Bid) + bid := new(openrtb2.Bid) bid.Ext = []byte(`{"prebid" : { "targeting" : ` + test.targeting + `}}`) value, err := GetTargeting(test.key, openrtb_ext.BidderName(test.bidder), *bid) if test.expectError { diff --git a/endpoints/openrtb2/ctv_auction.go b/endpoints/openrtb2/ctv_auction.go index 4e9d5b46438..fc46a622f98 100644 --- a/endpoints/openrtb2/ctv_auction.go +++ b/endpoints/openrtb2/ctv_auction.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "github.com/prebid/prebid-server/endpoints/events" "math" "net/http" "net/url" @@ -14,37 +15,36 @@ import ( "time" "github.com/PubMatic-OpenWrap/etree" - "github.com/PubMatic-OpenWrap/openrtb" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/events" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/combination" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/constant" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/impressions" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/response" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/types" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2/ctv/util" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" "github.com/buger/jsonparser" uuid "github.com/gofrs/uuid" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/mxmCherry/openrtb/v15/openrtb2" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/combination" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/constant" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/impressions" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/response" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/types" + "github.com/prebid/prebid-server/endpoints/openrtb2/ctv/util" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/usersync" + "github.com/prebid/prebid-server/util/iputil" ) //CTV Specific Endpoint type ctvEndpointDeps struct { endpointDeps - request *openrtb.BidRequest + request *openrtb2.BidRequest reqExt *openrtb_ext.ExtRequestAdPod impData []*types.ImpData - videoSeats []*openrtb.SeatBid //stores pure video impression bids + videoSeats []*openrtb2.SeatBid //stores pure video impression bids impIndices map[string]int isAdPodRequest bool @@ -102,8 +102,8 @@ func NewCTVEndpoint( func (deps *ctvEndpointDeps) CTVAuctionEndpoint(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { defer util.TimeTrack(time.Now(), "CTVAuctionEndpoint") - var request *openrtb.BidRequest - var response *openrtb.BidResponse + var request *openrtb2.BidRequest + var response *openrtb2.BidResponse var err error var errL []error @@ -246,13 +246,13 @@ func (deps *ctvEndpointDeps) CTVAuctionEndpoint(w http.ResponseWriter, r *http.R } } -func (deps *ctvEndpointDeps) holdAuction(request *openrtb.BidRequest, usersyncs *usersync.PBSCookie, account *config.Account, startTime time.Time) (*openrtb.BidResponse, error) { +func (deps *ctvEndpointDeps) holdAuction(request *openrtb2.BidRequest, usersyncs *usersync.PBSCookie, account *config.Account, startTime time.Time) (*openrtb2.BidResponse, error) { defer util.TimeTrack(time.Now(), fmt.Sprintf("Tid:%v CTVHoldAuction", deps.request.ID)) //Hold OpenRTB Standard Auction if len(request.Imp) == 0 { //Dummy Response Object - return &openrtb.BidResponse{ID: request.ID}, nil + return &openrtb2.BidResponse{ID: request.ID}, nil } auctionRequest := exchange.AuctionRequest{ @@ -269,7 +269,7 @@ func (deps *ctvEndpointDeps) holdAuction(request *openrtb.BidRequest, usersyncs /********************* BidRequest Processing *********************/ -func (deps *ctvEndpointDeps) init(req *openrtb.BidRequest) { +func (deps *ctvEndpointDeps) init(req *openrtb2.BidRequest) { deps.request = req deps.impData = make([]*types.ImpData, len(req.Imp)) deps.impIndices = make(map[string]int, len(req.Imp)) @@ -412,7 +412,7 @@ func (deps *ctvEndpointDeps) validateBidRequest() (err []error) { /********************* Creating CTV BidRequest *********************/ //createBidRequest will return new bid request with all things copy from bid request except impression objects -func (deps *ctvEndpointDeps) createBidRequest(req *openrtb.BidRequest) *openrtb.BidRequest { +func (deps *ctvEndpointDeps) createBidRequest(req *openrtb2.BidRequest) *openrtb2.BidRequest { ctvRequest := *req //get configurations for all impressions @@ -441,7 +441,7 @@ func (deps *ctvEndpointDeps) getAllAdPodImpsConfigs() { } //getAdPodImpsConfigs will return number of impressions configurations within adpod -func (deps *ctvEndpointDeps) getAdPodImpsConfigs(imp *openrtb.Imp, adpod *openrtb_ext.VideoAdPod) []*types.ImpAdPodConfig { +func (deps *ctvEndpointDeps) getAdPodImpsConfigs(imp *openrtb2.Imp, adpod *openrtb_ext.VideoAdPod) []*types.ImpAdPodConfig { selectedAlgorithm := impressions.MinMaxAlgorithm labels := metrics.PodLabels{AlgorithmName: impressions.MonitorKey[selectedAlgorithm], NoOfImpressions: new(int)} @@ -465,7 +465,7 @@ func (deps *ctvEndpointDeps) getAdPodImpsConfigs(imp *openrtb.Imp, adpod *openrt } //createImpressions will create multiple impressions based on adpod configurations -func (deps *ctvEndpointDeps) createImpressions() []openrtb.Imp { +func (deps *ctvEndpointDeps) createImpressions() []openrtb2.Imp { impCount := 0 for _, imp := range deps.impData { if nil == imp.ErrorCode { @@ -478,7 +478,7 @@ func (deps *ctvEndpointDeps) createImpressions() []openrtb.Imp { } count := 0 - imps := make([]openrtb.Imp, impCount) + imps := make([]openrtb2.Imp, impCount) for index, imp := range deps.request.Imp { if nil == deps.impData[index].ErrorCode { adPodConfig := deps.impData[index].Config @@ -499,7 +499,7 @@ func (deps *ctvEndpointDeps) createImpressions() []openrtb.Imp { } //newImpression will clone existing impression object and create video object with ImpAdPodConfig. -func newImpression(imp *openrtb.Imp, config *types.ImpAdPodConfig) *openrtb.Imp { +func newImpression(imp *openrtb2.Imp, config *types.ImpAdPodConfig) *openrtb2.Imp { video := *imp.Video video.MinDuration = config.MinDuration video.MaxDuration = config.MaxDuration @@ -517,15 +517,15 @@ func newImpression(imp *openrtb.Imp, config *types.ImpAdPodConfig) *openrtb.Imp /********************* Prebid BidResponse Processing *********************/ //validateBidResponse -func (deps *ctvEndpointDeps) validateBidResponse(req *openrtb.BidRequest, resp *openrtb.BidResponse) error { +func (deps *ctvEndpointDeps) validateBidResponse(req *openrtb2.BidRequest, resp *openrtb2.BidResponse) error { //remove bids withoug cat and adomain return nil } //getBids reads bids from bidresponse object -func (deps *ctvEndpointDeps) getBids(resp *openrtb.BidResponse) { - var vseat *openrtb.SeatBid +func (deps *ctvEndpointDeps) getBids(resp *openrtb2.BidResponse) { + var vseat *openrtb2.SeatBid result := make(map[string]*types.AdPodBid) for i := range resp.SeatBid { @@ -569,7 +569,7 @@ func (deps *ctvEndpointDeps) getBids(resp *openrtb.BidResponse) { if len(deps.impData[index].Config) == 0 { //adding pure video bids if vseat == nil { - vseat = &openrtb.SeatBid{ + vseat = &openrtb2.SeatBid{ Seat: seat.Seat, Group: seat.Group, Ext: seat.Ext, @@ -677,10 +677,10 @@ func (deps *ctvEndpointDeps) doAdPodExclusions() types.AdPodBids { /********************* Creating CTV BidResponse *********************/ //createBidResponse -func (deps *ctvEndpointDeps) createBidResponse(resp *openrtb.BidResponse, adpods types.AdPodBids) *openrtb.BidResponse { +func (deps *ctvEndpointDeps) createBidResponse(resp *openrtb2.BidResponse, adpods types.AdPodBids) *openrtb2.BidResponse { defer util.TimeTrack(time.Now(), fmt.Sprintf("Tid:%v createBidResponse", deps.request.ID)) - bidResp := &openrtb.BidResponse{ + bidResp := &openrtb2.BidResponse{ ID: resp.ID, Cur: resp.Cur, CustomData: resp.CustomData, @@ -692,15 +692,15 @@ func (deps *ctvEndpointDeps) createBidResponse(resp *openrtb.BidResponse, adpods return bidResp } -func (deps *ctvEndpointDeps) getBidResponseSeatBids(adpods types.AdPodBids) []openrtb.SeatBid { - seats := []openrtb.SeatBid{} +func (deps *ctvEndpointDeps) getBidResponseSeatBids(adpods types.AdPodBids) []openrtb2.SeatBid { + seats := []openrtb2.SeatBid{} //append pure video request seats for _, seat := range deps.videoSeats { seats = append(seats, *seat) } - var adpodSeat *openrtb.SeatBid + var adpodSeat *openrtb2.SeatBid for _, adpod := range adpods { if len(adpod.Bids) == 0 { continue @@ -709,7 +709,7 @@ func (deps *ctvEndpointDeps) getBidResponseSeatBids(adpods types.AdPodBids) []op bid := deps.getAdPodBid(adpod) if bid != nil { if nil == adpodSeat { - adpodSeat = &openrtb.SeatBid{ + adpodSeat = &openrtb2.SeatBid{ Seat: adpod.SeatName, } } @@ -723,7 +723,7 @@ func (deps *ctvEndpointDeps) getBidResponseSeatBids(adpods types.AdPodBids) []op } //getBidResponseExt will return extension object -func (deps *ctvEndpointDeps) getBidResponseExt(resp *openrtb.BidResponse) (data json.RawMessage) { +func (deps *ctvEndpointDeps) getBidResponseExt(resp *openrtb2.BidResponse) (data json.RawMessage) { var err error adpodExt := types.BidResponseAdPodExt{ @@ -789,7 +789,7 @@ func (deps *ctvEndpointDeps) getBidResponseExt(resp *openrtb.BidResponse) (data //getAdPodBid func (deps *ctvEndpointDeps) getAdPodBid(adpod *types.AdPodBid) *types.Bid { bid := types.Bid{ - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, } //TODO: Write single for loop to get all details @@ -810,7 +810,7 @@ func (deps *ctvEndpointDeps) getAdPodBid(adpod *types.AdPodBid) *types.Bid { } //getAdPodBidCreative get commulative adpod bid details -func getAdPodBidCreative(video *openrtb.Video, adpod *types.AdPodBid) *string { +func getAdPodBidCreative(video *openrtb2.Video, adpod *types.AdPodBid) *string { doc := etree.NewDocument() vast := doc.CreateElement(constant.VASTElement) sequenceNumber := 1 @@ -900,7 +900,7 @@ func getAdPodBidExtension(adpod *types.AdPodBid) json.RawMessage { //it will try to get the actual ad duration returned by the bidder using prebid.video.duration //if prebid.video.duration = 0 or there is error occured in determing it then //impress -func getAdDuration(bid openrtb.Bid, defaultDuration int64) int { +func getAdDuration(bid openrtb2.Bid, defaultDuration int64) int { duration, err := jsonparser.GetInt(bid.Ext, "prebid", "video", "duration") if nil != err || duration <= 0 { duration = defaultDuration @@ -908,7 +908,7 @@ func getAdDuration(bid openrtb.Bid, defaultDuration int64) int { return int(duration) } -func addTargetingKey(bid *openrtb.Bid, key openrtb_ext.TargetingKey, value string) error { +func addTargetingKey(bid *openrtb2.Bid, key openrtb_ext.TargetingKey, value string) error { if nil == bid { return errors.New("Invalid bid") } @@ -920,7 +920,7 @@ func addTargetingKey(bid *openrtb.Bid, key openrtb_ext.TargetingKey, value strin return err } -func adjustBidIDInVideoEventTrackers(doc *etree.Document, bid *openrtb.Bid) { +func adjustBidIDInVideoEventTrackers(doc *etree.Document, bid *openrtb2.Bid) { // adjusment: update bid.id with ctv module generated bid.id creatives := events.FindCreatives(doc) for _, creative := range creatives { diff --git a/endpoints/openrtb2/ctv_auction_test.go b/endpoints/openrtb2/ctv_auction_test.go index db3438accfb..f03312ead9c 100644 --- a/endpoints/openrtb2/ctv_auction_test.go +++ b/endpoints/openrtb2/ctv_auction_test.go @@ -3,13 +3,13 @@ package openrtb2 import ( "encoding/json" "fmt" + "github.com/PubMatic-OpenWrap/etree" "net/url" "strings" "testing" - "github.com/PubMatic-OpenWrap/etree" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -28,7 +28,7 @@ func TestGetAdDuration(t *testing.T) { } for _, test := range tests { t.Run(test.scenario, func(t *testing.T) { - bid := openrtb.Bid{ + bid := openrtb2.Bid{ Ext: []byte(`{"prebid" : {"video" : {"duration" : ` + test.adDuration + `}}}`), } assert.Equal(t, test.expect, getAdDuration(bid, int64(test.maxAdDuration))) @@ -49,7 +49,7 @@ func TestAddTargetingKeys(t *testing.T) { } for _, test := range tests { t.Run(test.scenario, func(t *testing.T) { - bid := new(openrtb.Bid) + bid := new(openrtb2.Bid) bid.Ext = []byte(test.bidExt) key := openrtb_ext.TargetingKey(test.key) assert.Nil(t, addTargetingKey(bid, key, test.value)) @@ -63,7 +63,7 @@ func TestAddTargetingKeys(t *testing.T) { func TestAdjustBidIDInVideoEventTrackers(t *testing.T) { type args struct { - modifiedBid *openrtb.Bid + modifiedBid *openrtb2.Bid } type want struct { eventURLMap map[string]string @@ -86,7 +86,7 @@ func TestAdjustBidIDInVideoEventTrackers(t *testing.T) { }, }, args: args{ - modifiedBid: &openrtb.Bid{ + modifiedBid: &openrtb2.Bid{ ID: "1-bid_123", AdM: ` diff --git a/endpoints/openrtb2/interstitial.go b/endpoints/openrtb2/interstitial.go index 2f9c48fcd79..1aa2a7fc890 100644 --- a/endpoints/openrtb2/interstitial.go +++ b/endpoints/openrtb2/interstitial.go @@ -4,13 +4,13 @@ import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/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 93d310525c8..1d7ad9e3d6b 100644 --- a/endpoints/openrtb2/interstitial_test.go +++ b/endpoints/openrtb2/interstitial_test.go @@ -4,17 +4,17 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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/disabled/bad/bad-alias.json b/endpoints/openrtb2/sample-requests/disabled/bad/bad-alias.json index f4379dc09a2..862393081e2 100644 --- a/endpoints/openrtb2/sample-requests/disabled/bad/bad-alias.json +++ b/endpoints/openrtb2/sample-requests/disabled/bad/bad-alias.json @@ -1,7 +1,7 @@ { "description": "Request comes with an alias to a disabled bidder, we should throw error", "config": { - "disabledAdapters": ["appnexus", "rubicon"] + "disabledAdapters": ["appnexus"] }, "mockBidRequest": { "id": "some-request-id", @@ -32,5 +32,5 @@ } }, "expectedReturnCode": 400, - "expectedErrorMessage": "Invalid request: request.ext.prebid.aliases.test1 refers to unknown bidder: appnexus\n" + "expectedErrorMessage": "Invalid request: request.ext.prebid.aliases.test1 refers to disabled bidder: appnexus\n" } diff --git a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json similarity index 64% rename from endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json rename to endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json index 74dede0857f..c36ae0cd41d 100644 --- a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-ext-bidder.json +++ b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-ext-bidder.json @@ -21,30 +21,29 @@ "appnexus": { "placementId": 12883451 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } }] }, "expectedBidResponse": { - "id":"some-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "appnexus-bid", - "impid": "", - "price": 0 - } - ], - "seat": "appnexus-bids" - } - ], - "bidid":"test bid id", - "nbr":0 + "id": "some-request-id", + "seatbid": [{ + "bid": [{ + "id": "appnexus-bid", + "impid": "", + "price": 0 + }], + "seat": "appnexus-bids" + }], + "bidid": "test bid id", + "nbr": 0 }, "expectedReturnCode": 200 -} +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json similarity index 67% rename from endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json rename to endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json index 41461813c40..ad6298db39a 100644 --- a/endpoints/openrtb2/sample-requests/first-party-data/valid-context-allowed-with-prebid-bidder.json +++ b/endpoints/openrtb2/sample-requests/first-party-data/valid-fpd-allowed-with-prebid-bidder.json @@ -25,30 +25,29 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } }] }, "expectedBidResponse": { - "id":"some-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "appnexus-bid", - "impid": "", - "price": 0 - } - ], - "seat": "appnexus-bids" - } - ], - "bidid":"test bid id", - "nbr":0 + "id": "some-request-id", + "seatbid": [{ + "bid": [{ + "id": "appnexus-bid", + "impid": "", + "price": 0 + }], + "seat": "appnexus-bids" + }], + "bidid": "test bid id", + "nbr": 0 }, "expectedReturnCode": 200 -} +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/invalid-native/context-type-content-incompatible-subtype.json b/endpoints/openrtb2/sample-requests/invalid-native/context-type-content-incompatible-subtype.json new file mode 100644 index 00000000000..4297aa7596b --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-native/context-type-content-incompatible-subtype.json @@ -0,0 +1,25 @@ +{ + "description": "Native bid request. Context type content (1) is incompatible with 'social' subcontext types (20~29). Return error", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":1,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request" +} diff --git a/endpoints/openrtb2/sample-requests/invalid-native/context-type-product-incompatible-subtype.json b/endpoints/openrtb2/sample-requests/invalid-native/context-type-product-incompatible-subtype.json new file mode 100644 index 00000000000..3193833658b --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-native/context-type-product-incompatible-subtype.json @@ -0,0 +1,27 @@ +{ + "description": "Native bid request. Context type product (3) is incompatible with 'social' subcontext types (10~19). Return error", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":3,\"contextsubtype\":11,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request" +} + + diff --git a/endpoints/openrtb2/sample-requests/invalid-native/context-type-social-incompatible-subtype.json b/endpoints/openrtb2/sample-requests/invalid-native/context-type-social-incompatible-subtype.json new file mode 100644 index 00000000000..4ecbf4498fb --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-native/context-type-social-incompatible-subtype.json @@ -0,0 +1,27 @@ +{ + "description": "Native bid request. Context type social (2) is incompatible with 'product' subcontext types (30~39). Return error", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":2,\"contextsubtype\":31,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request" +} + + diff --git a/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-greater-than-max.json b/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-greater-than-max.json new file mode 100644 index 00000000000..9b422380edf --- /dev/null +++ b/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-greater-than-max.json @@ -0,0 +1,26 @@ +{ + "description": "Native bid request comes with a subcontext type greater than 500. Return error", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":1,\"contextsubtype\":550,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedReturnCode": 400, + "expectedErrorMessage": "Invalid request" +} + diff --git a/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-invalid.json b/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-invalid.json index 395e7034b0c..cdf4ef0c075 100644 --- a/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-invalid.json +++ b/endpoints/openrtb2/sample-requests/invalid-native/contextsubtype-invalid.json @@ -1,5 +1,5 @@ { - "description": "Bid request with invalid contextsubtype value inside the native.request field in its only imp element", + "description": "Native bid request comes with a contextsubtype greater than 32, 'ContextSubTypeProductReview'", "mockBidRequest": { "id": "req-id", "site": { @@ -10,7 +10,7 @@ { "id": "some-imp", "native": { - "request": "{\"context\":1,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + "request": "{\"context\":1,\"contextsubtype\":41,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" }, "ext": { "appnexus": { 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/sample-requests/valid-native/context-product-compatible-subtype.json b/endpoints/openrtb2/sample-requests/valid-native/context-product-compatible-subtype.json new file mode 100644 index 00000000000..dbf7b9c5e0d --- /dev/null +++ b/endpoints/openrtb2/sample-requests/valid-native/context-product-compatible-subtype.json @@ -0,0 +1,41 @@ +{ + "description": "Native bid request comes with a context type product (3) and compatible subcontext type", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":3,\"contextsubtype\":31,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedBidResponse": { + "id": "req-id", + "bidid": "test bid id", + "nbr": 0, + "seatbid": [ + { + "bid": [ + { + "id": "appnexus-bid", + "impid": "", + "price": 0 + } + ], + "seat": "appnexus-bids" + } + ] + }, + "expectedReturnCode": 200 +} diff --git a/endpoints/openrtb2/sample-requests/valid-native/context-social-compatible-subtype.json b/endpoints/openrtb2/sample-requests/valid-native/context-social-compatible-subtype.json new file mode 100644 index 00000000000..41fb833d770 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/valid-native/context-social-compatible-subtype.json @@ -0,0 +1,41 @@ +{ + "description": "Native bid request comes with a context type social (2) and compatible subcontext type", + "mockBidRequest": { + "id": "req-id", + "site": { + "page": "some.page.com" + }, + "tmax": 500, + "imp": [ + { + "id": "some-imp", + "native": { + "request": "{\"context\":2,\"contextsubtype\":21,\"plcmttype\":1,\"assets\":[{\"title\":{\"len\":90}},{\"img\":{\"hmin\":30,\"wmin\":20}},{\"video\":{\"mimes\":[\"video/mp4\"],\"minduration\":5,\"maxduration\":10,\"protocols\":[1]}},{\"data\":{\"type\":2}}]}" + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + } + ] + }, + "expectedBidResponse": { + "id": "req-id", + "bidid": "test bid id", + "nbr": 0, + "seatbid": [ + { + "bid": [ + { + "id": "appnexus-bid", + "impid": "", + "price": 0 + } + ], + "seat": "appnexus-bids" + } + ] + }, + "expectedReturnCode": 200 +} diff --git a/endpoints/openrtb2/sample-requests/valid-whole/exemplary/skadn.json b/endpoints/openrtb2/sample-requests/valid-whole/exemplary/skadn.json new file mode 100644 index 00000000000..e238f3c07c7 --- /dev/null +++ b/endpoints/openrtb2/sample-requests/valid-whole/exemplary/skadn.json @@ -0,0 +1,48 @@ +{ + "description": "The imp.ext.skadn field is valid for Apple's SKAdNetwork and should be exempt from bidder name validation.", + + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "some-imp-id", + "banner": { + "format": [{ + "w": 600, + "h": 500 + }, { + "w": 300, + "h": 600 + }] + }, + "ext": { + "prebid": { + "bidder": { + "appnexus": { + "placementId": 12883451 + } + } + }, + "skadn": { + "anyMember": "anyValue" + } + } + }] + }, + "expectedBidResponse": { + "id": "some-request-id", + "seatbid": [{ + "bid": [{ + "id": "appnexus-bid", + "impid": "", + "price": 0 + }], + "seat": "appnexus-bids" + }], + "bidid": "test bid id", + "nbr": 0 + }, + "expectedReturnCode": 200 +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/valid-whole/supplementary/app-ios140-no-ifa.json b/endpoints/openrtb2/sample-requests/valid-whole/supplementary/app-ios140-no-ifa.json new file mode 100644 index 00000000000..41c27877f4f --- /dev/null +++ b/endpoints/openrtb2/sample-requests/valid-whole/supplementary/app-ios140-no-ifa.json @@ -0,0 +1,34 @@ +{ + "description": "Well Formed iOS 14.0 App Request With Unspecified LMT + Empty IFA", + "mockBidRequest": { + "id": "some-request-id", + "app": { + "id": "some-app-id" + }, + "device": { + "os": "iOS", + "osv": "14.0", + "ifa": "" + }, + "imp": [{ + "id": "my-imp-id", + "banner": { + "format": [{ + "w": 300, + "h": 600 + }] + }, + "ext": { + "appnexus": { + "placementId": 12883451 + } + } + }] + }, + "expectedBidResponse": { + "id": "some-request-id", + "bidid": "test bid id", + "nbr": 0 + }, + "expectedReturnCode": 200 +} \ No newline at end of file diff --git a/endpoints/openrtb2/sample-requests/valid-whole/supplementary/us-privacy-invalid.json b/endpoints/openrtb2/sample-requests/valid-whole/supplementary/us-privacy-invalid.json new file mode 100644 index 00000000000..2ccdfb7ccdc --- /dev/null +++ b/endpoints/openrtb2/sample-requests/valid-whole/supplementary/us-privacy-invalid.json @@ -0,0 +1,52 @@ +{ + "description": "Well formed amp request with invalid CCPA consent value", + "mockBidRequest": { + "id": "b9c97a4b-cbc4-483d-b2c4-58a19ed5cfc5", + "site": { + "page": "prebid.org", + "publisher": { + "id": "a3de7af2-a86a-4043-a77b-c7e86744155e" + } + }, + "source": { + "tid": "b9c97a4b-cbc4-483d-b2c4-58a19ed5cfc5" + }, + "tmax": 1000, + "imp": [ + { + "id": "/19968336/header-bid-tag-0", + "ext": { + "appnexus": { + "placementId": 12883451 + } + }, + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 300 + } + ] + } + } + ], + "regs": { + "ext": { + "us_privacy": "{invalid}" + } + }, + "user": { + "ext": {} + } + }, + "expectedBidResponse": { + "id":"b9c97a4b-cbc4-483d-b2c4-58a19ed5cfc5", + "bidid":"test bid id", + "nbr":0 + }, + "expectedReturnCode": 200 +} diff --git a/endpoints/openrtb2/video_auction.go b/endpoints/openrtb2/video_auction.go index 1c1846a7c9d..2ab3bbb0829 100644 --- a/endpoints/openrtb2/video_auction.go +++ b/endpoints/openrtb2/video_auction.go @@ -14,24 +14,24 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" "github.com/gofrs/uuid" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/util/iputil" - "github.com/PubMatic-OpenWrap/openrtb" - accountService "github.com/PubMatic-OpenWrap/prebid-server/account" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + accountService "github.com/prebid/prebid-server/account" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/usersync" ) var defaultRequestTimeout int64 = 5000 @@ -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 9bcf6522ec6..9ede7147686 100644 --- a/endpoints/openrtb2/video_auction_test.go +++ b/endpoints/openrtb2/video_auction_test.go @@ -12,15 +12,15 @@ import ( "strings" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/analytics" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" "github.com/stretchr/testify/assert" ) @@ -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/endpoints/setuid.go b/endpoints/setuid.go index b6832951625..4bff02acf37 100644 --- a/endpoints/setuid.go +++ b/endpoints/setuid.go @@ -9,13 +9,13 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/usersync" ) const ( diff --git a/endpoints/setuid_test.go b/endpoints/setuid_test.go index 2b46fddecd0..0d68c15bea8 100644 --- a/endpoints/setuid_test.go +++ b/endpoints/setuid_test.go @@ -10,17 +10,17 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/usersync" "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + metricsConf "github.com/prebid/prebid-server/metrics/config" ) func TestSetUIDEndpoint(t *testing.T) { @@ -439,7 +439,7 @@ func (g *mockPermsSetUID) BidderSyncAllowed(ctx context.Context, bidder openrtb_ return false, nil } -func (g *mockPermsSetUID) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string) (bool, bool, bool, error) { +func (g *mockPermsSetUID) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal gdpr.Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return g.allowPI, g.allowPI, g.allowPI, nil } @@ -462,8 +462,3 @@ func (s fakeSyncer) FamilyName() string { func (s fakeSyncer) GetUsersyncInfo(privacyPolicies privacy.Policies) (*usersync.UsersyncInfo, error) { return nil, nil } - -// GDPRVendorID implements the Usersyncer interface with a no-op. -func (s fakeSyncer) GDPRVendorID() uint16 { - return 0 -} diff --git a/errortypes/aggregate.go b/errortypes/aggregate.go index d58bcea7c25..272e255c246 100644 --- a/errortypes/aggregate.go +++ b/errortypes/aggregate.go @@ -5,22 +5,22 @@ import ( "strconv" ) -// AggregateErrors represents one or more errors. -type AggregateErrors struct { +// AggregateError represents one or more errors. +type AggregateError struct { Message string Errors []error } -// NewAggregateErrors builds a AggregateErrors struct. -func NewAggregateErrors(msg string, errs []error) AggregateErrors { - return AggregateErrors{ +// NewAggregateError builds a AggregateError struct. +func NewAggregateError(msg string, errs []error) AggregateError { + return AggregateError{ Message: msg, Errors: errs, } } // Error implements the standard error interface. -func (e AggregateErrors) Error() string { +func (e AggregateError) Error() string { if len(e.Errors) == 0 { return "" } diff --git a/errortypes/aggregate_test.go b/errortypes/aggregate_test.go index 82af9b8901d..2d4ce21b493 100644 --- a/errortypes/aggregate_test.go +++ b/errortypes/aggregate_test.go @@ -7,7 +7,7 @@ import ( "github.com/influxdata/influxdb/pkg/testing/assert" ) -func TestAggregateErrors(t *testing.T) { +func TestAggregateError(t *testing.T) { var testCases = []struct { description string message string @@ -35,7 +35,7 @@ func TestAggregateErrors(t *testing.T) { } for _, test := range testCases { - err := NewAggregateErrors(test.message, test.errors) + err := NewAggregateError(test.message, test.errors) assert.Equal(t, test.expected, err.Error(), test.description) } } diff --git a/errortypes/code.go b/errortypes/code.go index 7f3833a46f1..2749b978006 100644 --- a/errortypes/code.go +++ b/errortypes/code.go @@ -11,13 +11,14 @@ const ( BidderTemporarilyDisabledErrorCode BlacklistedAcctErrorCode AcctRequiredErrorCode - BidderFailedSchemaValidationErrorCode ) // Defines numeric codes for well-known warnings. const ( UnknownWarningCode = 10999 InvalidPrivacyConsentWarningCode = iota + 10000 + AccountLevelDebugDisabledWarningCode + BidderLevelDebugDisabledWarningCode ) // Coder provides an error or warning code with severity. diff --git a/errortypes/errortypes.go b/errortypes/errortypes.go index 353463611b7..1fed2d7da6e 100644 --- a/errortypes/errortypes.go +++ b/errortypes/errortypes.go @@ -167,7 +167,8 @@ func (err *BidderTemporarilyDisabled) Severity() Severity { // Warning is a generic non-fatal error. type Warning struct { - Message string + Message string + WarningCode int } func (err *Warning) Error() string { @@ -175,45 +176,9 @@ func (err *Warning) Error() string { } func (err *Warning) Code() int { - return UnknownWarningCode + return err.WarningCode } func (err *Warning) Severity() Severity { return SeverityWarning } - -// InvalidPrivacyConsent is a warning for when the privacy consent string is invalid and is ignored. -type InvalidPrivacyConsent struct { - Message string -} - -func (err *InvalidPrivacyConsent) Error() string { - return err.Message -} - -func (err *InvalidPrivacyConsent) Code() int { - return InvalidPrivacyConsentWarningCode -} - -func (err *InvalidPrivacyConsent) Severity() Severity { - return SeverityWarning -} - -// BidderFailedSchemaValidation is used at the request validation step, -// when the bidder parameters fail the schema validation, we want to -// continue processing the request and still return an error message. -type BidderFailedSchemaValidation struct { - Message string -} - -func (err *BidderFailedSchemaValidation) Error() string { - return err.Message -} - -func (err *BidderFailedSchemaValidation) Code() int { - return BidderFailedSchemaValidationErrorCode -} - -func (err *BidderFailedSchemaValidation) Severity() Severity { - return SeverityWarning -} diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index ca6f1fb0868..e3924e5b8cc 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -1,103 +1,113 @@ package exchange import ( - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - ttx "github.com/PubMatic-OpenWrap/prebid-server/adapters/33across" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/acuityads" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adform" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adgeneration" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adhese" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adkernel" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adkernelAdn" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adman" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/admixer" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adocean" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adoppler" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adot" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adpone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adprime" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adtarget" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adtelligent" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/advangelists" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/aja" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/amx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/applogy" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/appnexus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/audienceNetwork" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/avocet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/beachfront" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/beintoo" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/between" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/brightroll" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/colossus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/connectad" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/consumable" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/conversant" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/cpmstar" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/datablocks" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/decenterads" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/deepintent" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/dmx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/emx_digital" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/engagebdr" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/eplanning" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gamma" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gamoshi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/grid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gumgum" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/improvedigital" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/inmobi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/invibes" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ix" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/kidoz" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/krushmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/kubient" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lockerdome" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/logicad" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lunamedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/marsmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/mgid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/mobfoxpb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/mobilefuse" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/nanointeractive" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ninthdecimal" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/nobid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/openx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/orbidder" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pubmatic" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pubnative" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pulsepoint" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/revcontent" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rhythmone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rtbhouse" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rubicon" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sharethrough" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/silvermob" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smaato" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartadserver" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartyads" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/somoaudience" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sonobi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sovrn" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/spotx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/synacormedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/tappx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/telaria" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/triplelift" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/triplelift_native" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ucfunnel" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/unruly" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/valueimpression" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/verizonmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/visx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/vrtcal" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yeahmobi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldlab" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldmo" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/zeroclickfraud" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + ttx "github.com/prebid/prebid-server/adapters/33across" + "github.com/prebid/prebid-server/adapters/acuityads" + "github.com/prebid/prebid-server/adapters/adform" + "github.com/prebid/prebid-server/adapters/adgeneration" + "github.com/prebid/prebid-server/adapters/adhese" + "github.com/prebid/prebid-server/adapters/adkernel" + "github.com/prebid/prebid-server/adapters/adkernelAdn" + "github.com/prebid/prebid-server/adapters/adman" + "github.com/prebid/prebid-server/adapters/admixer" + "github.com/prebid/prebid-server/adapters/adocean" + "github.com/prebid/prebid-server/adapters/adoppler" + "github.com/prebid/prebid-server/adapters/adot" + "github.com/prebid/prebid-server/adapters/adpone" + "github.com/prebid/prebid-server/adapters/adprime" + "github.com/prebid/prebid-server/adapters/adtarget" + "github.com/prebid/prebid-server/adapters/adtelligent" + "github.com/prebid/prebid-server/adapters/advangelists" + "github.com/prebid/prebid-server/adapters/adxcg" + "github.com/prebid/prebid-server/adapters/adyoulike" + "github.com/prebid/prebid-server/adapters/aja" + "github.com/prebid/prebid-server/adapters/amx" + "github.com/prebid/prebid-server/adapters/applogy" + "github.com/prebid/prebid-server/adapters/appnexus" + "github.com/prebid/prebid-server/adapters/audienceNetwork" + "github.com/prebid/prebid-server/adapters/avocet" + "github.com/prebid/prebid-server/adapters/beachfront" + "github.com/prebid/prebid-server/adapters/beintoo" + "github.com/prebid/prebid-server/adapters/between" + "github.com/prebid/prebid-server/adapters/bidmachine" + "github.com/prebid/prebid-server/adapters/brightroll" + "github.com/prebid/prebid-server/adapters/colossus" + "github.com/prebid/prebid-server/adapters/connectad" + "github.com/prebid/prebid-server/adapters/consumable" + "github.com/prebid/prebid-server/adapters/conversant" + "github.com/prebid/prebid-server/adapters/cpmstar" + "github.com/prebid/prebid-server/adapters/criteo" + "github.com/prebid/prebid-server/adapters/datablocks" + "github.com/prebid/prebid-server/adapters/decenterads" + "github.com/prebid/prebid-server/adapters/deepintent" + "github.com/prebid/prebid-server/adapters/dmx" + "github.com/prebid/prebid-server/adapters/emx_digital" + "github.com/prebid/prebid-server/adapters/engagebdr" + "github.com/prebid/prebid-server/adapters/eplanning" + "github.com/prebid/prebid-server/adapters/epom" + "github.com/prebid/prebid-server/adapters/gamma" + "github.com/prebid/prebid-server/adapters/gamoshi" + "github.com/prebid/prebid-server/adapters/grid" + "github.com/prebid/prebid-server/adapters/gumgum" + "github.com/prebid/prebid-server/adapters/improvedigital" + "github.com/prebid/prebid-server/adapters/inmobi" + "github.com/prebid/prebid-server/adapters/invibes" + "github.com/prebid/prebid-server/adapters/ix" + "github.com/prebid/prebid-server/adapters/jixie" + "github.com/prebid/prebid-server/adapters/kidoz" + "github.com/prebid/prebid-server/adapters/krushmedia" + "github.com/prebid/prebid-server/adapters/kubient" + "github.com/prebid/prebid-server/adapters/lockerdome" + "github.com/prebid/prebid-server/adapters/logicad" + "github.com/prebid/prebid-server/adapters/lunamedia" + "github.com/prebid/prebid-server/adapters/marsmedia" + "github.com/prebid/prebid-server/adapters/mgid" + "github.com/prebid/prebid-server/adapters/mobfoxpb" + "github.com/prebid/prebid-server/adapters/mobilefuse" + "github.com/prebid/prebid-server/adapters/nanointeractive" + "github.com/prebid/prebid-server/adapters/ninthdecimal" + "github.com/prebid/prebid-server/adapters/nobid" + "github.com/prebid/prebid-server/adapters/onetag" + "github.com/prebid/prebid-server/adapters/openx" + "github.com/prebid/prebid-server/adapters/orbidder" + "github.com/prebid/prebid-server/adapters/outbrain" + "github.com/prebid/prebid-server/adapters/pangle" + "github.com/prebid/prebid-server/adapters/pubmatic" + "github.com/prebid/prebid-server/adapters/pubnative" + "github.com/prebid/prebid-server/adapters/pulsepoint" + "github.com/prebid/prebid-server/adapters/revcontent" + "github.com/prebid/prebid-server/adapters/rhythmone" + "github.com/prebid/prebid-server/adapters/rtbhouse" + "github.com/prebid/prebid-server/adapters/rubicon" + "github.com/prebid/prebid-server/adapters/sharethrough" + "github.com/prebid/prebid-server/adapters/silvermob" + "github.com/prebid/prebid-server/adapters/smaato" + "github.com/prebid/prebid-server/adapters/smartadserver" + "github.com/prebid/prebid-server/adapters/smartrtb" + "github.com/prebid/prebid-server/adapters/smartyads" + "github.com/prebid/prebid-server/adapters/somoaudience" + "github.com/prebid/prebid-server/adapters/sonobi" + "github.com/prebid/prebid-server/adapters/sovrn" + "github.com/prebid/prebid-server/adapters/spotx" + "github.com/prebid/prebid-server/adapters/synacormedia" + "github.com/prebid/prebid-server/adapters/tappx" + "github.com/prebid/prebid-server/adapters/telaria" + "github.com/prebid/prebid-server/adapters/triplelift" + "github.com/prebid/prebid-server/adapters/triplelift_native" + "github.com/prebid/prebid-server/adapters/ucfunnel" + "github.com/prebid/prebid-server/adapters/unicorn" + "github.com/prebid/prebid-server/adapters/unruly" + "github.com/prebid/prebid-server/adapters/valueimpression" + "github.com/prebid/prebid-server/adapters/verizonmedia" + "github.com/prebid/prebid-server/adapters/visx" + "github.com/prebid/prebid-server/adapters/vrtcal" + "github.com/prebid/prebid-server/adapters/yeahmobi" + "github.com/prebid/prebid-server/adapters/yieldlab" + "github.com/prebid/prebid-server/adapters/yieldmo" + "github.com/prebid/prebid-server/adapters/yieldone" + "github.com/prebid/prebid-server/adapters/zeroclickfraud" + "github.com/prebid/prebid-server/openrtb_ext" ) // Adapter registration is kept in this separate file for ease of use and to aid @@ -122,6 +132,8 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderAdtarget: adtarget.Builder, openrtb_ext.BidderAdtelligent: adtelligent.Builder, openrtb_ext.BidderAdvangelists: advangelists.Builder, + openrtb_ext.BidderAdxcg: adxcg.Builder, + openrtb_ext.BidderAdyoulike: adyoulike.Builder, openrtb_ext.BidderAJA: aja.Builder, openrtb_ext.BidderAMX: amx.Builder, openrtb_ext.BidderApplogy: applogy.Builder, @@ -131,12 +143,14 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderBeachfront: beachfront.Builder, openrtb_ext.BidderBeintoo: beintoo.Builder, openrtb_ext.BidderBetween: between.Builder, + openrtb_ext.BidderBidmachine: bidmachine.Builder, openrtb_ext.BidderBrightroll: brightroll.Builder, openrtb_ext.BidderColossus: colossus.Builder, openrtb_ext.BidderConnectAd: connectad.Builder, openrtb_ext.BidderConsumable: consumable.Builder, openrtb_ext.BidderConversant: conversant.Builder, openrtb_ext.BidderCpmstar: cpmstar.Builder, + openrtb_ext.BidderCriteo: criteo.Builder, openrtb_ext.BidderDatablocks: datablocks.Builder, openrtb_ext.BidderDecenterAds: decenterads.Builder, openrtb_ext.BidderDeepintent: deepintent.Builder, @@ -144,6 +158,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderEmxDigital: emx_digital.Builder, openrtb_ext.BidderEngageBDR: engagebdr.Builder, openrtb_ext.BidderEPlanning: eplanning.Builder, + openrtb_ext.BidderEpom: epom.Builder, openrtb_ext.BidderGamma: gamma.Builder, openrtb_ext.BidderGamoshi: gamoshi.Builder, openrtb_ext.BidderGrid: grid.Builder, @@ -152,6 +167,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderInMobi: inmobi.Builder, openrtb_ext.BidderInvibes: invibes.Builder, openrtb_ext.BidderIx: ix.Builder, + openrtb_ext.BidderJixie: jixie.Builder, openrtb_ext.BidderKidoz: kidoz.Builder, openrtb_ext.BidderKrushmedia: krushmedia.Builder, openrtb_ext.BidderKubient: kubient.Builder, @@ -166,8 +182,11 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderNanoInteractive: nanointeractive.Builder, openrtb_ext.BidderNinthDecimal: ninthdecimal.Builder, openrtb_ext.BidderNoBid: nobid.Builder, + openrtb_ext.BidderOneTag: onetag.Builder, openrtb_ext.BidderOpenx: openx.Builder, openrtb_ext.BidderOrbidder: orbidder.Builder, + openrtb_ext.BidderOutbrain: outbrain.Builder, + openrtb_ext.BidderPangle: pangle.Builder, openrtb_ext.BidderPubmatic: pubmatic.Builder, openrtb_ext.BidderPubnative: pubnative.Builder, openrtb_ext.BidderPulsepoint: pulsepoint.Builder, @@ -190,7 +209,9 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderTelaria: telaria.Builder, openrtb_ext.BidderTriplelift: triplelift.Builder, openrtb_ext.BidderTripleliftNative: triplelift_native.Builder, + openrtb_ext.BidderTrustX: grid.Builder, openrtb_ext.BidderUcfunnel: ucfunnel.Builder, + openrtb_ext.BidderUnicorn: unicorn.Builder, openrtb_ext.BidderUnruly: unruly.Builder, openrtb_ext.BidderValueImpression: valueimpression.Builder, openrtb_ext.BidderVerizonMedia: verizonmedia.Builder, diff --git a/exchange/adapter_util.go b/exchange/adapter_util.go index 4cd9c6ddafd..8af6d11ad60 100644 --- a/exchange/adapter_util.go +++ b/exchange/adapter_util.go @@ -4,15 +4,15 @@ import ( "fmt" "net/http" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" + "github.com/prebid/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lifestreet" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/lifestreet" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) -func BuildAdapters(client *http.Client, cfg *config.Configuration, infos adapters.BidderInfos, me metrics.MetricsEngine) (map[openrtb_ext.BidderName]adaptedBidder, []error) { +func BuildAdapters(client *http.Client, cfg *config.Configuration, infos config.BidderInfos, me metrics.MetricsEngine) (map[openrtb_ext.BidderName]adaptedBidder, []error) { exchangeBidders := buildExchangeBiddersLegacy(cfg.Adapters, infos) exchangeBiddersModern, errs := buildExchangeBidders(cfg, infos, client, me) @@ -30,7 +30,7 @@ func BuildAdapters(client *http.Client, cfg *config.Configuration, infos adapter return exchangeBidders, nil } -func buildExchangeBidders(cfg *config.Configuration, infos adapters.BidderInfos, client *http.Client, me metrics.MetricsEngine) (map[openrtb_ext.BidderName]adaptedBidder, []error) { +func buildExchangeBidders(cfg *config.Configuration, infos config.BidderInfos, client *http.Client, me metrics.MetricsEngine) (map[openrtb_ext.BidderName]adaptedBidder, []error) { bidders, errs := buildBidders(cfg.Adapters, infos, newAdapterBuilders()) if len(errs) > 0 { return nil, errs @@ -50,7 +50,7 @@ func buildExchangeBidders(cfg *config.Configuration, infos adapters.BidderInfos, } -func buildBidders(adapterConfig map[string]config.Adapter, infos adapters.BidderInfos, builders map[openrtb_ext.BidderName]adapters.Builder) (map[openrtb_ext.BidderName]adapters.Bidder, []error) { +func buildBidders(adapterConfig map[string]config.Adapter, infos config.BidderInfos, builders map[openrtb_ext.BidderName]adapters.Builder) (map[openrtb_ext.BidderName]adapters.Bidder, []error) { bidders := make(map[openrtb_ext.BidderName]adapters.Bidder) var errs []error @@ -78,14 +78,14 @@ func buildBidders(adapterConfig map[string]config.Adapter, infos adapters.Bidder continue } - if info.Status == adapters.StatusActive { + if info.Enabled { bidderInstance, builderErr := builder(bidderName, cfg) if builderErr != nil { errs = append(errs, fmt.Errorf("%v: %v", bidder, builderErr)) continue } - bidderWithInfoEnforcement := adapters.EnforceBidderInfo(bidderInstance, info) + bidderWithInfoEnforcement := adapters.BuildInfoAwareBidder(bidderInstance, info) bidders[bidderName] = bidderWithInfoEnforcement } @@ -94,11 +94,11 @@ func buildBidders(adapterConfig map[string]config.Adapter, infos adapters.Bidder return bidders, errs } -func buildExchangeBiddersLegacy(adapterConfig map[string]config.Adapter, infos adapters.BidderInfos) map[openrtb_ext.BidderName]adaptedBidder { +func buildExchangeBiddersLegacy(adapterConfig map[string]config.Adapter, infos config.BidderInfos) map[openrtb_ext.BidderName]adaptedBidder { bidders := make(map[openrtb_ext.BidderName]adaptedBidder, 2) // Lifestreet - if infos[string(openrtb_ext.BidderLifestreet)].Status == adapters.StatusActive { + if infos[string(openrtb_ext.BidderLifestreet)].Enabled { adapter := lifestreet.NewLifestreetLegacyAdapter(adapters.DefaultHTTPAdapterConfig, adapterConfig[string(openrtb_ext.BidderLifestreet)].Endpoint) bidders[openrtb_ext.BidderLifestreet] = adaptLegacyAdapter(adapter) } @@ -113,11 +113,11 @@ func wrapWithMiddleware(bidders map[openrtb_ext.BidderName]adaptedBidder) { } // GetActiveBidders returns a map of all active bidder names. -func GetActiveBidders(infos adapters.BidderInfos) map[string]openrtb_ext.BidderName { +func GetActiveBidders(infos config.BidderInfos) map[string]openrtb_ext.BidderName { activeBidders := make(map[string]openrtb_ext.BidderName) for name, info := range infos { - if info.Status != adapters.StatusDisabled { + if info.Enabled { activeBidders[name] = openrtb_ext.BidderName(name) } } @@ -126,13 +126,13 @@ func GetActiveBidders(infos adapters.BidderInfos) map[string]openrtb_ext.BidderN } // GetDisabledBiddersErrorMessages returns a map of error messages for disabled bidders. -func GetDisabledBiddersErrorMessages(infos adapters.BidderInfos) map[string]string { +func GetDisabledBiddersErrorMessages(infos config.BidderInfos) map[string]string { disabledBidders := make(map[string]string) - for bidderName, bidderInfo := range infos { - if bidderInfo.Status == adapters.StatusDisabled { - msg := fmt.Sprintf(`Bidder "%s" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`, bidderName) - disabledBidders[bidderName] = msg + for name, info := range infos { + if !info.Enabled { + msg := fmt.Sprintf(`Bidder "%s" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`, name) + disabledBidders[name] = msg } } diff --git a/exchange/adapter_util_test.go b/exchange/adapter_util_test.go index 05cdd7e9648..c9f1907d314 100644 --- a/exchange/adapter_util_test.go +++ b/exchange/adapter_util_test.go @@ -6,22 +6,21 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/appnexus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lifestreet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rubicon" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - metrics "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/appnexus" + "github.com/prebid/prebid-server/adapters/lifestreet" + "github.com/prebid/prebid-server/adapters/rubicon" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" + metrics "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) var ( - infoActive = adapters.BidderInfo{Status: adapters.StatusActive} - infoDisabled = adapters.BidderInfo{Status: adapters.StatusDisabled} - infoUnknown = adapters.BidderInfo{Status: adapters.StatusUnknown} + infoEnabled = config.BidderInfo{Enabled: true} + infoDisabled = config.BidderInfo{Enabled: false} ) func TestBuildAdaptersSuccess(t *testing.T) { @@ -30,16 +29,16 @@ func TestBuildAdaptersSuccess(t *testing.T) { "appnexus": {}, "lifestreet": {Endpoint: "anyEndpoint"}, }} - infos := map[string]adapters.BidderInfo{ - "appnexus": infoActive, - "lifestreet": infoActive, + infos := map[string]config.BidderInfo{ + "appnexus": infoEnabled, + "lifestreet": infoEnabled, } metricEngine := &metrics.DummyMetricsEngine{} bidders, errs := BuildAdapters(client, cfg, infos, metricEngine) appnexusBidder, _ := appnexus.Builder(openrtb_ext.BidderAppnexus, config.Adapter{}) - appnexusBidderWithInfo := adapters.EnforceBidderInfo(appnexusBidder, infoActive) + appnexusBidderWithInfo := adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled) appnexusBidderAdapted := adaptBidder(appnexusBidderWithInfo, client, &config.Configuration{}, metricEngine, openrtb_ext.BidderAppnexus, nil) appnexusBidderValidated := addValidatedBidderMiddleware(appnexusBidderAdapted) @@ -58,7 +57,7 @@ func TestBuildAdaptersSuccess(t *testing.T) { func TestBuildAdaptersErrors(t *testing.T) { client := &http.Client{} cfg := &config.Configuration{Adapters: map[string]config.Adapter{"unknown": {}}} - infos := map[string]adapters.BidderInfo{} + infos := map[string]config.BidderInfo{} metricEngine := &metrics.DummyMetricsEngine{} bidders, errs := BuildAdapters(client, cfg, infos, metricEngine) @@ -76,24 +75,24 @@ func TestBuildExchangeBidders(t *testing.T) { metricEngine := &metrics.DummyMetricsEngine{} appnexusBidder, _ := appnexus.Builder(openrtb_ext.BidderAppnexus, config.Adapter{}) - appnexusBidderWithInfo := adapters.EnforceBidderInfo(appnexusBidder, infoActive) + appnexusBidderWithInfo := adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled) appnexusBidderAdapted := adaptBidder(appnexusBidderWithInfo, client, &config.Configuration{}, metricEngine, openrtb_ext.BidderAppnexus, nil) rubiconBidder, _ := rubicon.Builder(openrtb_ext.BidderRubicon, config.Adapter{}) - rubiconBidderWithInfo := adapters.EnforceBidderInfo(rubiconBidder, infoActive) + rubiconBidderWithInfo := adapters.BuildInfoAwareBidder(rubiconBidder, infoEnabled) rubiconBidderAdapted := adaptBidder(rubiconBidderWithInfo, client, &config.Configuration{}, metricEngine, openrtb_ext.BidderRubicon, nil) testCases := []struct { description string adapterConfig map[string]config.Adapter - bidderInfos map[string]adapters.BidderInfo + bidderInfos map[string]config.BidderInfo expectedBidders map[openrtb_ext.BidderName]adaptedBidder expectedErrors []error }{ { description: "Invalid - Builder Errors", adapterConfig: map[string]config.Adapter{"appnexus": {}, "unknown": {}}, - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, expectedErrors: []error{ errors.New("appnexus: bidder info not found"), errors.New("unknown: unknown bidder"), @@ -102,13 +101,13 @@ func TestBuildExchangeBidders(t *testing.T) { { description: "Success - None", adapterConfig: map[string]config.Adapter{}, - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, expectedBidders: map[openrtb_ext.BidderName]adaptedBidder{}, }, { description: "Success - One", adapterConfig: map[string]config.Adapter{"appnexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, expectedBidders: map[openrtb_ext.BidderName]adaptedBidder{ openrtb_ext.BidderAppnexus: appnexusBidderAdapted, }, @@ -116,7 +115,7 @@ func TestBuildExchangeBidders(t *testing.T) { { description: "Success - Many", adapterConfig: map[string]config.Adapter{"appnexus": {}, "rubicon": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive, "rubicon": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled, "rubicon": infoEnabled}, expectedBidders: map[openrtb_ext.BidderName]adaptedBidder{ openrtb_ext.BidderAppnexus: appnexusBidderAdapted, openrtb_ext.BidderRubicon: rubiconBidderAdapted, @@ -145,7 +144,7 @@ func TestBuildBidders(t *testing.T) { testCases := []struct { description string adapterConfig map[string]config.Adapter - bidderInfos map[string]adapters.BidderInfo + bidderInfos map[string]config.BidderInfo builders map[openrtb_ext.BidderName]adapters.Builder expectedBidders map[openrtb_ext.BidderName]adapters.Bidder expectedErrors []error @@ -153,7 +152,7 @@ func TestBuildBidders(t *testing.T) { { description: "Invalid - Unknown Bidder", adapterConfig: map[string]config.Adapter{"unknown": {}}, - bidderInfos: map[string]adapters.BidderInfo{"unknown": infoActive}, + bidderInfos: map[string]config.BidderInfo{"unknown": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder}, expectedErrors: []error{ errors.New("unknown: unknown bidder"), @@ -162,7 +161,7 @@ func TestBuildBidders(t *testing.T) { { description: "Invalid - No Bidder Info", adapterConfig: map[string]config.Adapter{"appnexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder}, expectedErrors: []error{ errors.New("appnexus: bidder info not found"), @@ -171,7 +170,7 @@ func TestBuildBidders(t *testing.T) { { description: "Invalid - No Builder", adapterConfig: map[string]config.Adapter{"appnexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{}, expectedErrors: []error{ errors.New("appnexus: builder not registered"), @@ -180,7 +179,7 @@ func TestBuildBidders(t *testing.T) { { description: "Success - Builder Error", adapterConfig: map[string]config.Adapter{"appnexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilderWithError}, expectedErrors: []error{ errors.New("appnexus: anyError"), @@ -189,62 +188,53 @@ func TestBuildBidders(t *testing.T) { { description: "Success - None", adapterConfig: map[string]config.Adapter{}, - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, builders: map[openrtb_ext.BidderName]adapters.Builder{}, }, { description: "Success - One", adapterConfig: map[string]config.Adapter{"appnexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder}, expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderAppnexus: adapters.EnforceBidderInfo(appnexusBidder, infoActive), + openrtb_ext.BidderAppnexus: adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled), }, }, { description: "Success - Many", adapterConfig: map[string]config.Adapter{"appnexus": {}, "rubicon": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive, "rubicon": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled, "rubicon": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder, openrtb_ext.BidderRubicon: rubiconBuilder}, expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderAppnexus: adapters.EnforceBidderInfo(appnexusBidder, infoActive), - openrtb_ext.BidderRubicon: adapters.EnforceBidderInfo(rubiconBidder, infoActive), + openrtb_ext.BidderAppnexus: adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled), + openrtb_ext.BidderRubicon: adapters.BuildInfoAwareBidder(rubiconBidder, infoEnabled), }, }, { description: "Success - Ignores Legacy", adapterConfig: map[string]config.Adapter{"appnexus": {}, "lifestreet": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive, "lifestreet": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled, "lifestreet": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder, openrtb_ext.BidderLifestreet: inconsequentialBuilder}, expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderAppnexus: adapters.EnforceBidderInfo(appnexusBidder, infoActive), + openrtb_ext.BidderAppnexus: adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled), }, }, { description: "Success - Ignores Disabled", adapterConfig: map[string]config.Adapter{"appnexus": {}, "rubicon": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoDisabled, "rubicon": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled, "rubicon": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder, openrtb_ext.BidderRubicon: rubiconBuilder}, expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderRubicon: adapters.EnforceBidderInfo(rubiconBidder, infoActive), - }, - }, - { - description: "Success - Ignores Unknown State", - adapterConfig: map[string]config.Adapter{"appnexus": {}, "rubicon": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoUnknown, "rubicon": infoActive}, - builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder, openrtb_ext.BidderRubicon: rubiconBuilder}, - expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderRubicon: adapters.EnforceBidderInfo(rubiconBidder, infoActive), + openrtb_ext.BidderRubicon: adapters.BuildInfoAwareBidder(rubiconBidder, infoEnabled), }, }, { description: "Success - Ignores Adapter Config Case", adapterConfig: map[string]config.Adapter{"AppNexus": {}}, - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, builders: map[openrtb_ext.BidderName]adapters.Builder{openrtb_ext.BidderAppnexus: appnexusBuilder}, expectedBidders: map[openrtb_ext.BidderName]adapters.Bidder{ - openrtb_ext.BidderAppnexus: adapters.EnforceBidderInfo(appnexusBidder, infoActive), + openrtb_ext.BidderAppnexus: adapters.BuildInfoAwareBidder(appnexusBidder, infoEnabled), }, }, } @@ -270,25 +260,19 @@ func TestBuildExchangeBiddersLegacy(t *testing.T) { testCases := []struct { description string adapterConfig map[string]config.Adapter - bidderInfos map[string]adapters.BidderInfo + bidderInfos map[string]config.BidderInfo expected map[openrtb_ext.BidderName]adaptedBidder }{ { description: "Active", adapterConfig: map[string]config.Adapter{"lifestreet": cfg}, - bidderInfos: map[string]adapters.BidderInfo{"lifestreet": infoActive}, + bidderInfos: map[string]config.BidderInfo{"lifestreet": infoEnabled}, expected: map[openrtb_ext.BidderName]adaptedBidder{"lifestreet": expectedLifestreet}, }, { description: "Disabled", adapterConfig: map[string]config.Adapter{"lifestreet": cfg}, - bidderInfos: map[string]adapters.BidderInfo{"lifestreet": infoDisabled}, - expected: map[openrtb_ext.BidderName]adaptedBidder{}, - }, - { - description: "Unknown", - adapterConfig: map[string]config.Adapter{"lifestreet": cfg}, - bidderInfos: map[string]adapters.BidderInfo{"lifestreet": infoUnknown}, + bidderInfos: map[string]config.BidderInfo{"lifestreet": infoDisabled}, expected: map[openrtb_ext.BidderName]adaptedBidder{}, }, } @@ -318,33 +302,28 @@ func TestWrapWithMiddleware(t *testing.T) { func TestGetActiveBidders(t *testing.T) { testCases := []struct { description string - bidderInfos map[string]adapters.BidderInfo + bidderInfos map[string]config.BidderInfo expected map[string]openrtb_ext.BidderName }{ { description: "None", - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, expected: map[string]openrtb_ext.BidderName{}, }, { - description: "Active", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + description: "Enabled", + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, expected: map[string]openrtb_ext.BidderName{"appnexus": openrtb_ext.BidderAppnexus}, }, { description: "Disabled", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoDisabled}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled}, expected: map[string]openrtb_ext.BidderName{}, }, - { - description: "Unknown", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoUnknown}, - expected: map[string]openrtb_ext.BidderName{"appnexus": openrtb_ext.BidderAppnexus}, - }, { description: "Mixed", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoDisabled, "openx": infoActive, "rubicon": infoUnknown}, - expected: map[string]openrtb_ext.BidderName{"openx": openrtb_ext.BidderOpenx, "rubicon": openrtb_ext.BidderRubicon}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled, "openx": infoEnabled}, + expected: map[string]openrtb_ext.BidderName{"openx": openrtb_ext.BidderOpenx}, }, } @@ -357,34 +336,29 @@ func TestGetActiveBidders(t *testing.T) { func TestGetDisabledBiddersErrorMessages(t *testing.T) { testCases := []struct { description string - bidderInfos map[string]adapters.BidderInfo + bidderInfos map[string]config.BidderInfo expected map[string]string }{ { description: "None", - bidderInfos: map[string]adapters.BidderInfo{}, + bidderInfos: map[string]config.BidderInfo{}, expected: map[string]string{}, }, { - description: "Active", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoActive}, + description: "Enabled", + bidderInfos: map[string]config.BidderInfo{"appnexus": infoEnabled}, expected: map[string]string{}, }, { description: "Disabled", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoDisabled}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled}, expected: map[string]string{ "appnexus": `Bidder "appnexus" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`, }, }, - { - description: "Unknown", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoUnknown}, - expected: map[string]string{}, - }, { description: "Mixed", - bidderInfos: map[string]adapters.BidderInfo{"appnexus": infoDisabled, "openx": infoActive, "rubicon": infoUnknown}, + bidderInfos: map[string]config.BidderInfo{"appnexus": infoDisabled, "openx": infoEnabled}, expected: map[string]string{"appnexus": `Bidder "appnexus" has been disabled on this instance of Prebid Server. Please work with the PBS host to enable this bidder again.`}, }, } @@ -397,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 } @@ -405,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 43fea247950..f2c37f7a8bd 100644 --- a/exchange/auction.go +++ b/exchange/auction.go @@ -10,11 +10,11 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" uuid "github.com/gofrs/uuid" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" ) type DebugLog struct { @@ -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 { wrapperVASTTemplate := `` + `prebid.org wrapper` + `` + @@ -362,7 +362,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 a3ef7eab077..1730309287c 100644 --- a/exchange/auction_test.go +++ b/exchange/auction_test.go @@ -11,17 +11,17 @@ import ( "strconv" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/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) @@ -49,7 +49,7 @@ func TestMakeVASTAdmContainsURI(t *testing.T) { `` + `` + `` - bid := &openrtb.Bid{ + bid := &openrtb2.Bid{ AdM: url, } vast := makeVAST(bid) @@ -282,45 +282,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, }, @@ -500,7 +500,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"` @@ -514,7 +514,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 b426fce9322..59ef92cbff4 100644 --- a/exchange/bidder.go +++ b/exchange/bidder.go @@ -12,18 +12,18 @@ import ( "net/http/httptrace" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config/util" - "github.com/PubMatic-OpenWrap/prebid-server/currency" "github.com/golang/glog" - - "github.com/PubMatic-OpenWrap/openrtb" - nativeRequests "github.com/PubMatic-OpenWrap/openrtb/native/request" - nativeResponse "github.com/PubMatic-OpenWrap/openrtb/native/response" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config/util" + "github.com/prebid/prebid-server/currency" + + nativeRequests "github.com/mxmCherry/openrtb/v15/native1/request" + nativeResponse "github.com/mxmCherry/openrtb/v15/native1/response" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" "golang.org/x/net/context/ctxhttp" ) @@ -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. @@ -61,19 +61,21 @@ type adaptedBidder interface { // pbsOrtbBid.bidEvents is set by exchange when event tracking is enabled // 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 +// pbsOrtbBid.generatedBidID is unique bid id generated by prebid server if generate bid id option is enabled in config type pbsOrtbBid struct { - bid *openrtb.Bid + bid *openrtb2.Bid bidType openrtb_ext.BidType bidTargets map[string]string bidVideo *openrtb_ext.ExtBidPrebidVideo bidEvents *openrtb_ext.ExtBidPrebidEvents dealPriority int dealTierSatisfied bool + generatedBidID string } // 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 @@ -83,17 +85,13 @@ type pbsOrtbSeatBid struct { // httpCalls is the list of debugging info. It should only be populated if the request.test == 1. // This will become response.ext.debug.httpcalls.{bidder} on the final Response. httpCalls []*openrtb_ext.ExtHttpCall - // ext contains the extension for this seatbid. - // if len(bids) > 0, this will become response.seatbid[i].ext.{bidder} on the final OpenRTB response. - // if len(bids) == 0, this will be ignored because the OpenRTB spec doesn't allow a SeatBid with 0 Bids. - ext json.RawMessage } // adaptBidder converts an adapters.Bidder into an exchange.adaptedBidder. // // The name refers to the "Adapter" architecture pattern, and should not be confused with a Prebid "Adapter" // (which is being phased out and replaced by Bidder for OpenRTB auctions) -func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName, debugInfo *adapters.DebugInfo) adaptedBidder { +func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Configuration, me metrics.MetricsEngine, name openrtb_ext.BidderName, debugInfo *config.DebugInfo) adaptedBidder { return &bidderAdapter{ Bidder: bidder, BidderName: name, @@ -102,12 +100,12 @@ func adaptBidder(bidder adapters.Bidder, client *http.Client, cfg *config.Config config: bidderAdapterConfig{ Debug: cfg.Debug, DisableConnMetrics: cfg.Metrics.Disabled.AdapterConnectionMetrics, - DebugInfo: adapters.DebugInfo{Allow: parseDebugInfo(debugInfo)}, + DebugInfo: config.DebugInfo{Allow: parseDebugInfo(debugInfo)}, }, } } -func parseDebugInfo(info *adapters.DebugInfo) bool { +func parseDebugInfo(info *config.DebugInfo) bool { if info == nil { return true } @@ -125,10 +123,10 @@ type bidderAdapter struct { type bidderAdapterConfig struct { Debug config.Debug DisableConnMetrics bool - DebugInfo adapters.DebugInfo + 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 { @@ -168,9 +166,17 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi // - debugContextKey (url param) in true // - account debug is allowed // - bidder debug is allowed - if accountDebugAllowed && bidder.config.DebugInfo.Allow { - if debugInfo := ctx.Value(DebugContextKey); debugInfo != nil && debugInfo.(bool) { - seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) + if debugInfo := ctx.Value(DebugContextKey); debugInfo != nil && debugInfo.(bool) { + if accountDebugAllowed { + if bidder.config.DebugInfo.Allow { + seatBid.httpCalls = append(seatBid.httpCalls, makeExt(httpInfo)) + } else { + debugDisabledWarning := errortypes.Warning{ + WarningCode: errortypes.BidderLevelDebugDisabledWarningCode, + Message: "debug turned off for bidder", + } + errs = append(errs, &debugDisabledWarning) + } } } @@ -228,7 +234,6 @@ func (bidder *bidderAdapter) requestBid(ctx context.Context, request *openrtb.Bi bid: bidResponse.Bids[i].Bid, bidType: bidResponse.Bids[i].BidType, bidVideo: bidResponse.Bids[i].BidVideo, - bidTargets: bidResponse.Bids[i].BidTargets, dealPriority: bidResponse.Bids[i].DealPriority, }) } @@ -245,7 +250,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 { @@ -275,13 +280,16 @@ func addNativeTypes(bid *openrtb.Bid, request *openrtb.BidRequest) (*nativeRespo func setAssetTypes(asset nativeResponse.Asset, nativePayload nativeRequests.Request) error { if asset.Img != nil { - if tempAsset, err := getAssetByID(asset.ID, nativePayload.Assets); err == nil { + if asset.ID == nil { + return errors.New("Response Image asset doesn't have an ID") + } + if tempAsset, err := getAssetByID(*asset.ID, nativePayload.Assets); err == nil { if tempAsset.Img != nil { if tempAsset.Img.Type != 0 { asset.Img.Type = tempAsset.Img.Type } } else { - return fmt.Errorf("Response has an Image asset with ID:%d present that doesn't exist in the request", asset.ID) + return fmt.Errorf("Response has an Image asset with ID:%d present that doesn't exist in the request", *asset.ID) } } else { return err @@ -289,13 +297,16 @@ func setAssetTypes(asset nativeResponse.Asset, nativePayload nativeRequests.Requ } if asset.Data != nil { - if tempAsset, err := getAssetByID(asset.ID, nativePayload.Assets); err == nil { + if asset.ID == nil { + return errors.New("Response Data asset doesn't have an ID") + } + if tempAsset, err := getAssetByID(*asset.ID, nativePayload.Assets); err == nil { if tempAsset.Data != nil { if tempAsset.Data.Type != 0 { asset.Data.Type = tempAsset.Data.Type } } else { - return fmt.Errorf("Response has a Data asset with ID:%d present that doesn't exist in the request", asset.ID) + return fmt.Errorf("Response has a Data asset with ID:%d present that doesn't exist in the request", *asset.ID) } } else { return err @@ -304,7 +315,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 @@ -322,25 +333,30 @@ func getAssetByID(id int64, assets []nativeRequests.Asset) (nativeRequests.Asset return nativeRequests.Asset{}, fmt.Errorf("Unable to find asset with ID:%d in the request", id) } +var authorizationHeader = http.CanonicalHeaderKey("authorization") + +func filterHeader(h http.Header) http.Header { + clone := h.Clone() + clone.Del(authorizationHeader) + return clone +} + // makeExt transforms information about the HTTP call into the contract class for the PBS response. func makeExt(httpInfo *httpCallInfo) *openrtb_ext.ExtHttpCall { - if httpInfo.err == nil { - return &openrtb_ext.ExtHttpCall{ - Uri: httpInfo.request.Uri, - RequestBody: string(httpInfo.request.Body), - ResponseBody: string(httpInfo.response.Body), - Status: httpInfo.response.StatusCode, - RequestHeaders: httpInfo.request.Headers, - } - } else if httpInfo.request == nil { - return &openrtb_ext.ExtHttpCall{} - } else { - return &openrtb_ext.ExtHttpCall{ - Uri: httpInfo.request.Uri, - RequestBody: string(httpInfo.request.Body), - RequestHeaders: httpInfo.request.Headers, + ext := &openrtb_ext.ExtHttpCall{} + + if httpInfo != nil && httpInfo.request != nil { + ext.Uri = httpInfo.request.Uri + ext.RequestBody = string(httpInfo.request.Body) + ext.RequestHeaders = filterHeader(httpInfo.request.Headers) + + if httpInfo.err == nil && httpInfo.response != nil { + ext.ResponseBody = string(httpInfo.response.Body) + ext.Status = httpInfo.response.StatusCode } } + + return ext } // doRequest makes a request, handles the response, and returns the data needed by the diff --git a/exchange/bidder_test.go b/exchange/bidder_test.go index 66f976c0b66..6db249ec6ed 100644 --- a/exchange/bidder_test.go +++ b/exchange/bidder_test.go @@ -15,19 +15,19 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - metricsConfig "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + nativeRequests "github.com/mxmCherry/openrtb/v15/native1/request" + nativeResponse "github.com/mxmCherry/openrtb/v15/native1/response" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/metrics" + metricsConfig "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - - nativeRequests "github.com/PubMatic-OpenWrap/openrtb/native/request" - nativeResponse "github.com/PubMatic-OpenWrap/openrtb/native/response" ) // TestSingleBidder makes sure that the following things work if the Bidder needs only one request. @@ -36,13 +36,13 @@ import ( // 2. The returned values are correct for a non-test bid. func TestSingleBidder(t *testing.T) { type aTest struct { - debugInfo *adapters.DebugInfo + debugInfo *config.DebugInfo httpCallsLen int } testCases := []*aTest{ - {&adapters.DebugInfo{Allow: false}, 0}, - {&adapters.DebugInfo{Allow: true}, 1}, + {&config.DebugInfo{Allow: false}, 0}, + {&config.DebugInfo{Allow: true}, 1}, } respStatus := 200 @@ -71,18 +71,17 @@ func TestSingleBidder(t *testing.T) { ctx = context.WithValue(ctx, DebugContextKey, true) for _, test := range testCases { - 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, @@ -95,7 +94,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 { @@ -109,9 +108,13 @@ func TestSingleBidder(t *testing.T) { } // Make sure the returned values are what we expect - if len(errs) != 0 { + if len(errortypes.FatalOnly(errs)) != 0 { t.Errorf("bidder.Bid returned %d errors. Expected 0", len(errs)) } + + if !test.debugInfo.Allow && len(errortypes.WarningOnly(errs)) != 1 { + t.Errorf("bidder.Bid returned %d warnings. Expected 1", len(errs)) + } if len(seatBid.bids) != len(mockBidderResponse.Bids) { t.Fatalf("Expected %d bids. Got %d", len(mockBidderResponse.Bids), len(seatBid.bids)) } @@ -135,11 +138,49 @@ func TestSingleBidder(t *testing.T) { if len(seatBid.httpCalls) != test.httpCallsLen { t.Errorf("The bidder shouldn't log HttpCalls when request.test == 0. Found %d", len(seatBid.httpCalls)) } + } +} - if len(seatBid.ext) != 0 { - t.Errorf("The bidder shouldn't define any seatBid.ext. Got %s", string(seatBid.ext)) - } +func TestRequestBidRemovesSensitiveHeaders(t *testing.T) { + server := httptest.NewServer(mockHandler(200, "getBody", "responseJson")) + defer server.Close() + + requestHeaders := http.Header{} + requestHeaders.Add("Content-Type", "application/json") + requestHeaders.Add("Authorization", "anySecret") + + bidderImpl := &goodSingleBidder{ + httpRequest: &adapters.RequestData{ + Method: "POST", + Uri: server.URL, + Body: []byte("requestJson"), + Headers: requestHeaders, + }, + bidResponse: &adapters.BidderResponse{ + Bids: []*adapters.TypedBid{}, + }, } + + debugInfo := &config.DebugInfo{Allow: true} + ctx := context.Background() + ctx = context.WithValue(ctx, DebugContextKey, true) + + bidder := adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, debugInfo) + currencyConverter := currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) + seatBid, errs := bidder.requestBid(ctx, &openrtb2.BidRequest{}, "test", 1, currencyConverter.Rates(), &adapters.ExtraRequestInfo{}, true) + + expectedHttpCalls := []*openrtb_ext.ExtHttpCall{ + { + Uri: server.URL, + RequestBody: "requestJson", + RequestHeaders: map[string][]string{"Content-Type": {"application/json"}}, + ResponseBody: "responseJson", + Status: 200, + }, + } + + assert.Empty(t, errs) + assert.ElementsMatch(t, seatBid.httpCalls, expectedHttpCalls) } // TestMultiBidder makes sure all the requests get sent, and the responses processed. @@ -157,11 +198,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, }, }, @@ -184,7 +225,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.") @@ -514,7 +555,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, @@ -555,7 +596,7 @@ func TestMultiCurrencies(t *testing.T) { seatBid, errs := bidder.requestBid( context.Background(), - &openrtb.BidRequest{}, + &openrtb2.BidRequest{}, "test", 1, currencyConverter.Rates(), @@ -680,7 +721,7 @@ func TestMultiCurrencies_RateConverterNotSet(t *testing.T) { mockBidderResponses[i] = &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeBanner, }, }, @@ -700,7 +741,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(), @@ -843,7 +884,7 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { { Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{}, + Bid: &openrtb2.Bid{}, BidType: openrtb_ext.BidTypeBanner, }, }, @@ -871,7 +912,7 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { ) seatBid, errs := bidder.requestBid( context.Background(), - &openrtb.BidRequest{ + &openrtb2.BidRequest{ Cur: tc.bidRequestCurrencies, }, "test", @@ -891,86 +932,204 @@ func TestMultiCurrencies_RequestCurrencyPick(t *testing.T) { } } -// TestBadResponseLogging makes sure that openrtb_ext works properly on malformed HTTP requests. -func TestBadRequestLogging(t *testing.T) { - info := &httpCallInfo{ - err: errors.New("Bad request"), - } - ext := makeExt(info) - if ext.Uri != "" { - t.Errorf("The URI should be empty. Got %s", ext.Uri) - } - if ext.RequestBody != "" { - t.Errorf("The request body should be empty. Got %s", ext.RequestBody) - } - if ext.ResponseBody != "" { - t.Errorf("The response body should be empty. Got %s", ext.ResponseBody) - } - if ext.Status != 0 { - t.Errorf("The Status code should be 0. Got %d", ext.Status) - } - if len(ext.RequestHeaders) > 0 { - t.Errorf("The request headers should be empty. Got %s", ext.RequestHeaders) - } -} - -// TestBadResponseLogging makes sure that openrtb_ext works properly if we don't get a sensible HTTP response. -func TestBadResponseLogging(t *testing.T) { - info := &httpCallInfo{ - request: &adapters.RequestData{ - Uri: "test.com", - Body: []byte("request body"), - Headers: http.Header{ - "header-1": []string{"value-1"}, +func TestMakeExt(t *testing.T) { + testCases := []struct { + description string + given *httpCallInfo + expected *openrtb_ext.ExtHttpCall + }{ + { + description: "Nil", + given: nil, + expected: &openrtb_ext.ExtHttpCall{}, + }, + { + description: "Empty", + given: &httpCallInfo{ + err: nil, + response: nil, + request: nil, }, + expected: &openrtb_ext.ExtHttpCall{}, + }, + { + description: "Request & Response - No Error", + given: &httpCallInfo{ + err: nil, + request: &adapters.RequestData{ + Uri: "requestUri", + Body: []byte("requestBody"), + Headers: makeHeader(map[string][]string{"Key1": {"value1", "value2"}}), + }, + response: &adapters.ResponseData{ + Body: []byte("responseBody"), + StatusCode: 999, + }, + }, + expected: &openrtb_ext.ExtHttpCall{ + Uri: "requestUri", + RequestBody: "requestBody", + RequestHeaders: map[string][]string{"Key1": {"value1", "value2"}}, + ResponseBody: "responseBody", + Status: 999, + }, + }, + { + description: "Request & Response - No Error with Authorization removal", + given: &httpCallInfo{ + err: nil, + request: &adapters.RequestData{ + Uri: "requestUri", + Body: []byte("requestBody"), + Headers: makeHeader(map[string][]string{"Key1": {"value1", "value2"}, "Authorization": {"secret"}}), + }, + response: &adapters.ResponseData{ + Body: []byte("responseBody"), + StatusCode: 999, + }, + }, + expected: &openrtb_ext.ExtHttpCall{ + Uri: "requestUri", + RequestBody: "requestBody", + RequestHeaders: map[string][]string{"Key1": {"value1", "value2"}}, + ResponseBody: "responseBody", + Status: 999, + }, + }, + { + description: "Request & Response - No Error with nil header", + given: &httpCallInfo{ + err: nil, + request: &adapters.RequestData{ + Uri: "requestUri", + Body: []byte("requestBody"), + Headers: nil, + }, + response: &adapters.ResponseData{ + Body: []byte("responseBody"), + StatusCode: 999, + }, + }, + expected: &openrtb_ext.ExtHttpCall{ + Uri: "requestUri", + RequestBody: "requestBody", + RequestHeaders: nil, + ResponseBody: "responseBody", + Status: 999, + }, + }, + { + description: "Request & Response - Error", + given: &httpCallInfo{ + err: errors.New("error"), + request: &adapters.RequestData{ + Uri: "requestUri", + Body: []byte("requestBody"), + Headers: makeHeader(map[string][]string{"Key1": {"value1", "value2"}}), + }, + response: &adapters.ResponseData{ + Body: []byte("responseBody"), + StatusCode: 999, + }, + }, + expected: &openrtb_ext.ExtHttpCall{ + Uri: "requestUri", + RequestBody: "requestBody", + RequestHeaders: map[string][]string{"Key1": {"value1", "value2"}}, + }, + }, + { + description: "Request Only", + given: &httpCallInfo{ + err: nil, + request: &adapters.RequestData{ + Uri: "requestUri", + Body: []byte("requestBody"), + Headers: makeHeader(map[string][]string{"Key1": {"value1", "value2"}}), + }, + response: nil, + }, + expected: &openrtb_ext.ExtHttpCall{ + Uri: "requestUri", + RequestBody: "requestBody", + RequestHeaders: map[string][]string{"Key1": {"value1", "value2"}}, + }, + }, { + description: "Response Only", + given: &httpCallInfo{ + err: nil, + response: &adapters.ResponseData{ + Body: []byte("responseBody"), + StatusCode: 999, + }, + }, + expected: &openrtb_ext.ExtHttpCall{}, }, - err: errors.New("Bad response"), - } - ext := makeExt(info) - if ext.Uri != info.request.Uri { - t.Errorf("The URI should be test.com. Got %s", ext.Uri) - } - if ext.RequestBody != string(info.request.Body) { - t.Errorf("The request body should be empty. Got %s", ext.RequestBody) - } - if ext.ResponseBody != "" { - t.Errorf("The response body should be empty. Got %s", ext.ResponseBody) } - if ext.Status != 0 { - t.Errorf("The Status code should be 0. Got %d", ext.Status) + + for _, test := range testCases { + result := makeExt(test.given) + assert.Equal(t, test.expected, result, test.description) } - assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"header-1:value-1\"") } -// TestSuccessfulResponseLogging makes sure that openrtb_ext works properly if the HTTP request is successful. -func TestSuccessfulResponseLogging(t *testing.T) { - info := &httpCallInfo{ - request: &adapters.RequestData{ - Uri: "test.com", - Body: []byte("request body"), - Headers: http.Header{ - "header-1": []string{"value-1", "value-2"}, - }, +func TestFilterHeader(t *testing.T) { + testCases := []struct { + description string + given http.Header + expected http.Header + }{ + { + description: "Nil", + given: nil, + expected: nil, }, - response: &adapters.ResponseData{ - StatusCode: 200, - Body: []byte("response body"), + { + description: "Empty", + given: http.Header{}, + expected: http.Header{}, + }, + { + description: "One", + given: makeHeader(map[string][]string{"Key1": {"value1"}}), + expected: makeHeader(map[string][]string{"Key1": {"value1"}}), + }, + { + description: "Many", + given: makeHeader(map[string][]string{"Key1": {"value1"}, "Key2": {"value2a", "value2b"}}), + expected: makeHeader(map[string][]string{"Key1": {"value1"}, "Key2": {"value2a", "value2b"}}), + }, + { + description: "Authorization Header Omitted", + given: makeHeader(map[string][]string{"authorization": {"secret"}}), + expected: http.Header{}, + }, + { + description: "Authorization Header Omitted - Case Insensitive", + given: makeHeader(map[string][]string{"AuThOrIzAtIoN": {"secret"}}), + expected: http.Header{}, + }, + { + description: "Authorization Header Omitted + Other Keys", + given: makeHeader(map[string][]string{"authorization": {"secret"}, "Key1": {"value1"}}), + expected: makeHeader(map[string][]string{"Key1": {"value1"}}), }, } - ext := makeExt(info) - if ext.Uri != info.request.Uri { - t.Errorf("The URI should be test.com. Got %s", ext.Uri) - } - if ext.RequestBody != string(info.request.Body) { - t.Errorf("The request body should be \"request body\". Got %s", ext.RequestBody) - } - if ext.ResponseBody != string(info.response.Body) { - t.Errorf("The response body should be \"response body\". Got %s", ext.ResponseBody) + + for _, test := range testCases { + result := filterHeader(test.given) + assert.Equal(t, test.expected, result, test.description) } - if ext.Status != info.response.StatusCode { - t.Errorf("The Status code should be 0. Got %d", ext.Status) +} + +func makeHeader(v map[string][]string) http.Header { + h := http.Header{} + for key, values := range v { + for _, value := range values { + h.Add(key, value) + } } - assert.Equal(t, info.request.Headers, http.Header(ext.RequestHeaders), "The request headers should be \"%s\". Got %s", info.request.Headers, ext.RequestHeaders) + return h } func TestMobileNativeTypes(t *testing.T) { @@ -983,27 +1142,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, @@ -1016,21 +1175,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, @@ -1078,7 +1237,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.") } @@ -1099,7 +1258,7 @@ func TestSetAssetTypes(t *testing.T) { }{ { respAsset: nativeResponse.Asset{ - ID: 1, + ID: openrtb2.Int64Ptr(1), Img: &nativeResponse.Image{ URL: "http://some-url", }, @@ -1125,7 +1284,7 @@ func TestSetAssetTypes(t *testing.T) { }, { respAsset: nativeResponse.Asset{ - ID: 2, + ID: openrtb2.Int64Ptr(2), Data: &nativeResponse.Data{ Label: "some label", }, @@ -1151,7 +1310,7 @@ func TestSetAssetTypes(t *testing.T) { }, { respAsset: nativeResponse.Asset{ - ID: 1, + ID: openrtb2.Int64Ptr(1), Img: &nativeResponse.Image{ URL: "http://some-url", }, @@ -1171,7 +1330,7 @@ func TestSetAssetTypes(t *testing.T) { }, { respAsset: nativeResponse.Asset{ - ID: 2, + ID: openrtb2.Int64Ptr(2), Data: &nativeResponse.Data{ Label: "some label", }, @@ -1191,7 +1350,7 @@ func TestSetAssetTypes(t *testing.T) { }, { respAsset: nativeResponse.Asset{ - ID: 1, + ID: openrtb2.Int64Ptr(1), Img: &nativeResponse.Image{ URL: "http://some-url", }, @@ -1209,6 +1368,44 @@ func TestSetAssetTypes(t *testing.T) { expectedErr: "Response has an Image asset with ID:1 present that doesn't exist in the request", desc: "Assets with same ID in the req and resp are of different types", }, + { + respAsset: nativeResponse.Asset{ + Img: &nativeResponse.Image{ + URL: "http://some-url", + }, + }, + nativeReq: nativeRequests.Request{ + Assets: []nativeRequests.Asset{ + { + ID: 1, + Img: &nativeRequests.Image{ + Type: 2, + }, + }, + }, + }, + expectedErr: "Response Image asset doesn't have an ID", + desc: "Response Image without an ID", + }, + { + respAsset: nativeResponse.Asset{ + Data: &nativeResponse.Data{ + Label: "some label", + }, + }, + nativeReq: nativeRequests.Request{ + Assets: []nativeRequests.Asset{ + { + ID: 1, + Data: &nativeRequests.Data{ + Type: 2, + }, + }, + }, + }, + expectedErr: "Response Data asset doesn't have an ID", + desc: "Response Data asset without an ID", + }, } for _, test := range testCases { @@ -1261,7 +1458,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) @@ -1437,13 +1634,13 @@ func TestTimeoutNotificationOn(t *testing.T) { } func TestParseDebugInfoTrue(t *testing.T) { - debugInfo := &adapters.DebugInfo{Allow: true} + debugInfo := &config.DebugInfo{Allow: true} resDebugInfo := parseDebugInfo(debugInfo) assert.True(t, resDebugInfo, "Debug Allow value should be true") } func TestParseDebugInfoFalse(t *testing.T) { - debugInfo := &adapters.DebugInfo{Allow: false} + debugInfo := &config.DebugInfo{Allow: false} resDebugInfo := parseDebugInfo(debugInfo) assert.False(t, resDebugInfo, "Debug Allow value should be false") } @@ -1454,43 +1651,43 @@ func TestParseDebugInfoIsNil(t *testing.T) { } func wrapWithBidderInfo(bidder adapters.Bidder) adapters.Bidder { - bidderInfo := adapters.BidderInfo{ - Status: adapters.StatusActive, - Capabilities: &adapters.CapabilitiesInfo{ - App: &adapters.PlatformInfo{ + bidderInfo := config.BidderInfo{ + Enabled: true, + Capabilities: &config.CapabilitiesInfo{ + App: &config.PlatformInfo{ MediaTypes: []openrtb_ext.BidType{openrtb_ext.BidTypeBanner}, }, }, } - return adapters.EnforceBidderInfo(bidder, bidderInfo) + return adapters.BuildInfoAwareBidder(bidder, bidderInfo) } 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)) @@ -1500,7 +1697,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) @@ -1509,18 +1706,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.")} } @@ -1530,11 +1727,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.")} } @@ -1544,11 +1741,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 9ea357336fa..3d2eb0b8e42 100644 --- a/exchange/bidder_validate_bids.go +++ b/exchange/bidder_validate_bids.go @@ -6,10 +6,10 @@ import ( "fmt" "strings" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/openrtb_ext" goCurrency "golang.org/x/text/currency" ) @@ -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 a2ec026f5d7..3bb43559856 100644 --- a/exchange/bidder_validate_bids_test.go +++ b/exchange/bidder_validate_bids_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -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.go b/exchange/events.go index 128b6778364..45ed458841d 100644 --- a/exchange/events.go +++ b/exchange/events.go @@ -2,16 +2,15 @@ package exchange import ( "encoding/json" + "github.com/mxmCherry/openrtb/v15/openrtb2" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/events" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - jsonpatch "github.com/evanphx/json-patch" + "github.com/evanphx/json-patch" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/endpoints/events" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" ) // eventTracking has configuration fields needed for adding event tracking to an auction response @@ -21,12 +20,12 @@ type eventTracking struct { enabledForRequest bool auctionTimestampMs int64 integration metrics.DemandSource // web app amp - bidderInfos adapters.BidderInfos + bidderInfos config.BidderInfos externalURL string } // getEventTracking creates an eventTracking object from the different configuration sources -func getEventTracking(requestExtPrebid *openrtb_ext.ExtRequestPrebid, ts time.Time, account *config.Account, bidderInfos adapters.BidderInfos, externalURL string) *eventTracking { +func getEventTracking(requestExtPrebid *openrtb_ext.ExtRequestPrebid, ts time.Time, account *config.Account, bidderInfos config.BidderInfos, externalURL string) *eventTracking { return &eventTracking{ accountID: account.ID, enabledForAccount: account.EventsEnabled, @@ -39,7 +38,7 @@ func getEventTracking(requestExtPrebid *openrtb_ext.ExtRequestPrebid, ts time.Ti } // modifyBidsForEvents adds bidEvents and modifies VAST AdM if necessary. -func (ev *eventTracking) modifyBidsForEvents(seatBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, req *openrtb.BidRequest, trackerURL string) map[openrtb_ext.BidderName]*pbsOrtbSeatBid { +func (ev *eventTracking) modifyBidsForEvents(seatBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, req *openrtb2.BidRequest, trackerURL string) map[openrtb_ext.BidderName]*pbsOrtbSeatBid { for bidderName, seatBid := range seatBids { // modifyingVastXMLAllowed := ev.isModifyingVASTXMLAllowed(bidderName.String()) for _, pbsBid := range seatBid.bids { @@ -58,14 +57,18 @@ func (ev *eventTracking) isModifyingVASTXMLAllowed(bidderName string) bool { } // modifyBidVAST injects event Impression url if needed, otherwise returns original VAST string -func (ev *eventTracking) modifyBidVAST(pbsBid *pbsOrtbBid, bidderName openrtb_ext.BidderName, req *openrtb.BidRequest, trackerURL string) { +func (ev *eventTracking) modifyBidVAST(pbsBid *pbsOrtbBid, bidderName openrtb_ext.BidderName, req *openrtb2.BidRequest, trackerURL string) { bid := pbsBid.bid if pbsBid.bidType != openrtb_ext.BidTypeVideo || len(bid.AdM) == 0 && len(bid.NURL) == 0 { return } vastXML := makeVAST(bid) + bidID := bid.ID + if len(pbsBid.generatedBidID) > 0 { + bidID = pbsBid.generatedBidID + } if ev.isModifyingVASTXMLAllowed(bidderName.String()) { // condition added for ow fork - if newVastXML, ok := events.ModifyVastXmlString(ev.externalURL, vastXML, bid.ID, bidderName.String(), ev.accountID, ev.auctionTimestampMs); ok { + if newVastXML, ok := events.ModifyVastXmlString(ev.externalURL, vastXML, bidID, bidderName.String(), ev.accountID, ev.auctionTimestampMs); ok { bid.AdM = newVastXML } } @@ -111,10 +114,14 @@ func (ev *eventTracking) makeBidExtEvents(pbsBid *pbsOrtbBid, bidderName openrtb // makeEventURL returns an analytics event url for the requested type (win or imp) func (ev *eventTracking) makeEventURL(evType analytics.EventType, pbsBid *pbsOrtbBid, bidderName openrtb_ext.BidderName) string { + bidId := pbsBid.bid.ID + if len(pbsBid.generatedBidID) > 0 { + bidId = pbsBid.generatedBidID + } return events.EventRequestToUrl(ev.externalURL, &analytics.EventRequest{ Type: evType, - BidID: pbsBid.bid.ID, + BidID: bidId, Bidder: string(bidderName), AccountID: ev.accountID, Timestamp: ev.auctionTimestampMs, diff --git a/exchange/events_test.go b/exchange/events_test.go index a5e7d719510..c865a56f5bc 100644 --- a/exchange/events_test.go +++ b/exchange/events_test.go @@ -1,12 +1,12 @@ package exchange import ( + "github.com/prebid/prebid-server/config" "strings" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -15,6 +15,7 @@ func Test_eventsData_makeBidExtEvents(t *testing.T) { enabledForAccount bool enabledForRequest bool bidType openrtb_ext.BidType + generatedBidId string } tests := []struct { name string @@ -23,7 +24,7 @@ func Test_eventsData_makeBidExtEvents(t *testing.T) { }{ { name: "banner: events enabled for request, disabled for account", - args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, want: &openrtb_ext.ExtBidPrebidEvents{ Win: "http://localhost/event?t=win&b=BID-1&a=123456&bidder=openx&ts=1234567890", Imp: "http://localhost/event?t=imp&b=BID-1&a=123456&bidder=openx&ts=1234567890", @@ -31,7 +32,7 @@ func Test_eventsData_makeBidExtEvents(t *testing.T) { }, { name: "banner: events enabled for account, disabled for request", - args: args{enabledForAccount: true, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: true, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, want: &openrtb_ext.ExtBidPrebidEvents{ Win: "http://localhost/event?t=win&b=BID-1&a=123456&bidder=openx&ts=1234567890", Imp: "http://localhost/event?t=imp&b=BID-1&a=123456&bidder=openx&ts=1234567890", @@ -39,19 +40,27 @@ func Test_eventsData_makeBidExtEvents(t *testing.T) { }, { name: "banner: events disabled for account and request", - args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, want: nil, }, { name: "video: events enabled for account and request", - args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeVideo}, + args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeVideo, generatedBidId: ""}, want: nil, }, { name: "video: events disabled for account and request", - args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeVideo}, + args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeVideo, generatedBidId: ""}, want: nil, }, + { + name: "banner: use generated bid id", + args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner, generatedBidId: "randomId"}, + want: &openrtb_ext.ExtBidPrebidEvents{ + Win: "http://localhost/event?t=win&b=randomId&a=123456&bidder=openx&ts=1234567890", + Imp: "http://localhost/event?t=imp&b=randomId&a=123456&bidder=openx&ts=1234567890", + }, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -62,7 +71,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, generatedBidID: tt.args.generatedBidId} assert.Equal(t, tt.want, evData.makeBidExtEvents(bid, openrtb_ext.BidderOpenx)) }) } @@ -73,6 +82,7 @@ func Test_eventsData_modifyBidJSON(t *testing.T) { enabledForAccount bool enabledForRequest bool bidType openrtb_ext.BidType + generatedBidId string } tests := []struct { name string @@ -82,40 +92,46 @@ func Test_eventsData_modifyBidJSON(t *testing.T) { }{ { name: "banner: events enabled for request, disabled for account", - args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, jsonBytes: []byte(`{"ID": "something"}`), want: []byte(`{"ID": "something", "wurl": "http://localhost/event?t=win&b=BID-1&a=123456&bidder=openx&ts=1234567890"}`), }, { name: "banner: events enabled for account, disabled for request", - args: args{enabledForAccount: true, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: true, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, jsonBytes: []byte(`{"ID": "something"}`), want: []byte(`{"ID": "something", "wurl": "http://localhost/event?t=win&b=BID-1&a=123456&bidder=openx&ts=1234567890"}`), }, { name: "banner: events disabled for account and request", - args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, jsonBytes: []byte(`{"ID": "something"}`), want: []byte(`{"ID": "something"}`), }, { name: "video: events disabled for account and request", - args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeVideo}, + args: args{enabledForAccount: false, enabledForRequest: false, bidType: openrtb_ext.BidTypeVideo, generatedBidId: ""}, jsonBytes: []byte(`{"ID": "something"}`), want: []byte(`{"ID": "something"}`), }, { name: "video: events enabled for account and request", - args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeVideo}, + args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeVideo, generatedBidId: ""}, jsonBytes: []byte(`{"ID": "something"}`), want: []byte(`{"ID": "something"}`), }, { name: "banner: broken json expected to fail patching", - args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner}, + args: args{enabledForAccount: true, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner, generatedBidId: ""}, jsonBytes: []byte(`broken json`), want: nil, }, + { + name: "banner: generate bid id enabled", + args: args{enabledForAccount: false, enabledForRequest: true, bidType: openrtb_ext.BidTypeBanner, generatedBidId: "randomID"}, + jsonBytes: []byte(`{"ID": "something"}`), + want: []byte(`{"ID": "something", "wurl":"http://localhost/event?t=win&b=randomID&a=123456&bidder=openx&ts=1234567890"}`), + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -126,7 +142,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, generatedBidID: tt.args.generatedBidId} modifiedJSON, err := evData.modifyBidJSON(bid, openrtb_ext.BidderOpenx, tt.jsonBytes) if tt.want != nil { assert.NoError(t, err, "Unexpected error") @@ -141,8 +157,8 @@ func Test_eventsData_modifyBidJSON(t *testing.T) { func TestModifyBidVAST(t *testing.T) { type args struct { - bidReq *openrtb.BidRequest - bid *openrtb.Bid + bidReq *openrtb2.BidRequest + bid *openrtb2.Bid } type want struct { tags []string @@ -155,10 +171,10 @@ func TestModifyBidVAST(t *testing.T) { { name: "empty_adm", // expect adm contain vast tag with tracking events and VASTAdTagURI nurl contents args: args{ - bidReq: &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ID: "123", Video: &openrtb.Video{}}}, + bidReq: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ID: "123", Video: &openrtb2.Video{}}}, }, - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ AdM: "", NURL: "nurl_contents", ImpID: "123", @@ -186,10 +202,10 @@ func TestModifyBidVAST(t *testing.T) { { name: "adm_containing_url", // expect adm contain vast tag with tracking events and VASTAdTagURI adm url (previous value) contents args: args{ - bidReq: &openrtb.BidRequest{ - Imp: []openrtb.Imp{{ID: "123", Video: &openrtb.Video{}}}, + bidReq: &openrtb2.BidRequest{ + Imp: []openrtb2.Imp{{ID: "123", Video: &openrtb2.Video{}}}, }, - bid: &openrtb.Bid{ + bid: &openrtb2.Bid{ AdM: "http://vast_tag_inline.xml", NURL: "nurl_contents", ImpID: "123", @@ -218,9 +234,9 @@ func TestModifyBidVAST(t *testing.T) { for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { ev := eventTracking{ - bidderInfos: adapters.BidderInfos{ - "somebidder": adapters.BidderInfo{ - ModifyingVastXmlAllowed: false, + bidderInfos: config.BidderInfos{ + "somebidder": config.BidderInfo{ + ModifyingVastXmlAllowed: true, }, }, } @@ -233,7 +249,7 @@ func TestModifyBidVAST(t *testing.T) { } } -func validator(t *testing.T, b *openrtb.Bid, expectedTags []string) { +func validator(t *testing.T, b *openrtb2.Bid, expectedTags []string) { adm := b.AdM assert.NotNil(t, adm) assert.NotEmpty(t, adm) diff --git a/exchange/exchange.go b/exchange/exchange.go index f474531523e..d9462ef2f2c 100644 --- a/exchange/exchange.go +++ b/exchange/exchange.go @@ -14,18 +14,19 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/stored_requests" + + "github.com/gofrs/uuid" "github.com/golang/glog" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/prebid_cache_client" ) type ContextKey string @@ -39,7 +40,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. @@ -51,7 +52,7 @@ type IdFetcher interface { type exchange struct { adapterMap map[openrtb_ext.BidderName]adaptedBidder - bidderInfo adapters.BidderInfos + bidderInfo config.BidderInfos me metrics.MetricsEngine cache prebid_cache_client.Client cacheTime time.Duration @@ -61,13 +62,15 @@ type exchange struct { UsersyncIfAmbiguous bool privacyConfig config.Privacy categoriesFetcher stored_requests.CategoryFetcher + bidIDGenerator BidIDGenerator trakerURL string } // Container to pass out response ext data from the GetAllBids goroutines back into the main thread type seatResponseExtra struct { ResponseTimeMillis int - Errors []openrtb_ext.ExtBidderError + Errors []openrtb_ext.ExtBidderMessage + Warnings []openrtb_ext.ExtBidderMessage // httpCalls is the list of debugging info. It should only be populated if the request.test == 1. // This will become response.ext.debug.httpcalls.{bidder} on the final Response. HttpCalls []*openrtb_ext.ExtHttpCall @@ -79,7 +82,25 @@ type bidResponseWrapper struct { bidder openrtb_ext.BidderName } -func NewExchange(adapters map[openrtb_ext.BidderName]adaptedBidder, cache prebid_cache_client.Client, cfg *config.Configuration, metricsEngine metrics.MetricsEngine, infos adapters.BidderInfos, gDPR gdpr.Permissions, currencyConverter *currency.RateConverter, categoriesFetcher stored_requests.CategoryFetcher) Exchange { +type BidIDGenerator interface { + New() (string, error) + Enabled() bool +} + +type bidIDGenerator struct { + enabled bool +} + +func (big *bidIDGenerator) Enabled() bool { + return big.enabled +} + +func (big *bidIDGenerator) New() (string, error) { + rawUuid, err := uuid.NewV4() + return rawUuid.String(), err +} + +func NewExchange(adapters map[openrtb_ext.BidderName]adaptedBidder, cache prebid_cache_client.Client, cfg *config.Configuration, metricsEngine metrics.MetricsEngine, infos config.BidderInfos, gDPR gdpr.Permissions, currencyConverter *currency.RateConverter, categoriesFetcher stored_requests.CategoryFetcher) Exchange { return &exchange{ adapterMap: adapters, bidderInfo: infos, @@ -96,6 +117,7 @@ func NewExchange(adapters map[openrtb_ext.BidderName]adaptedBidder, cache prebid GDPR: cfg.GDPR, LMT: cfg.LMT, }, + bidIDGenerator: &bidIDGenerator{cfg.GenerateBidID}, trakerURL: cfg.TrackerURL, } } @@ -103,11 +125,12 @@ 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 StartTime time.Time + Warnings []error // LegacyLabels is included here for temporary compatability with cleanOpenRTBRequests // in HoldAuction until we get to factoring it away. Do not use for anything new. @@ -117,13 +140,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 { @@ -140,9 +163,9 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * debugLog = &DebugLog{Enabled: false} } - debugInfo := getDebugInfo(r.BidRequest, requestExt) + requestDebugInfo := getDebugInfo(r.BidRequest, requestExt) - debugInfo = debugInfo && r.Account.DebugAllow + debugInfo := requestDebugInfo && r.Account.DebugAllow debugLog.Enabled = debugLog.Enabled && r.Account.DebugAllow if debugInfo { @@ -157,7 +180,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * usersyncIfAmbiguous := e.parseUsersyncIfAmbiguous(r.BidRequest) // Slice of BidRequests, each a copy of the original cleaned to only contain bidder data for the named bidder - bidderRequests, privacyLabels, errs := cleanOpenRTBRequests(ctx, r, requestExt, e.gDPR, usersyncIfAmbiguous, e.privacyConfig) + bidderRequests, privacyLabels, errs := cleanOpenRTBRequests(ctx, r, requestExt, e.gDPR, usersyncIfAmbiguous, e.privacyConfig, &r.Account) e.me.RecordRequestPrivacy(privacyLabels) @@ -183,7 +206,7 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * //If includebrandcategory is present in ext then CE feature is on. if requestExt.Prebid.Targeting != nil && requestExt.Prebid.Targeting.IncludeBrandCategory != nil { var rejections []string - bidCategory, adapterBids, rejections, err = applyCategoryMapping(ctx, r.BidRequest, requestExt, adapterBids, e.categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err = applyCategoryMapping(ctx, requestExt, adapterBids, e.categoriesFetcher, targData) if err != nil { return nil, fmt.Errorf("Error in category mapping : %s", err.Error()) } @@ -192,6 +215,17 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * } } + if e.bidIDGenerator.Enabled() { + for _, seatBid := range adapterBids { + for _, pbsBid := range seatBid.bids { + pbsBid.generatedBidID, err = e.bidIDGenerator.New() + if err != nil { + errs = append(errs, errors.New("Error generating bid.ext.prebid.bidid")) + } + } + } + } + evTracking := getEventTracking(&requestExt.Prebid, r.StartTime, &r.Account, e.bidderInfo, e.externalURL) adapterBids = evTracking.modifyBidsForEvents(adapterBids, r.BidRequest, e.trakerURL) @@ -238,13 +272,29 @@ func (e *exchange) HoldAuction(ctx context.Context, r AuctionRequest, debugLog * } } + if !r.Account.DebugAllow && requestDebugInfo { + accountDebugDisabledWarning := openrtb_ext.ExtBidderMessage{ + Code: errortypes.AccountLevelDebugDisabledWarningCode, + Message: "debug turned off for account", + } + bidResponseExt.Warnings[openrtb_ext.BidderReservedGeneral] = append(bidResponseExt.Warnings[openrtb_ext.BidderReservedGeneral], accountDebugDisabledWarning) + } + + for _, warning := range r.Warnings { + generalWarning := openrtb_ext.ExtBidderMessage{ + Code: errortypes.ReadCode(warning), + Message: warning.Error(), + } + bidResponseExt.Warnings[openrtb_ext.BidderReservedGeneral] = append(bidResponseExt.Warnings[openrtb_ext.BidderReservedGeneral], generalWarning) + } + // Build the response 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 @@ -265,7 +315,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, @@ -278,7 +328,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) @@ -299,7 +349,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 { @@ -362,7 +412,6 @@ func (e *exchange) getAllBids( adapterExtra := make(map[openrtb_ext.BidderName]*seatResponseExtra, len(bidderRequests)) chBids := make(chan *bidResponseWrapper, len(bidderRequests)) bidsFound := false - bidIDsCollision := false for _, bidder := range bidderRequests { // Here we actually call the adapters and collect the bids. @@ -400,20 +449,17 @@ func (e *exchange) getAllBids( // Timing statistics e.me.RecordAdapterTime(bidderRequest.BidderLabels, time.Since(start)) - serr := errsToBidderErrors(err) bidderRequest.BidderLabels.AdapterBids = bidsToMetric(brw.adapterBids) bidderRequest.BidderLabels.AdapterErrors = errorsToMetric(err) // Append any bid validation errors to the error list - ae.Errors = serr + ae.Errors = errsToBidderErrors(err) + ae.Warnings = errsToBidderWarnings(err) brw.adapterExtra = ae if bids != nil { for _, bid := range bids.bids { var cpm = float64(bid.bid.Price * 1000) e.me.RecordAdapterPrice(bidderRequest.BidderLabels, cpm) e.me.RecordAdapterBidReceived(bidderRequest.BidderLabels, bid.bidType, bid.bid.AdM != "") - if bid.bidType == openrtb_ext.BidTypeVideo && bid.bidVideo != nil && bid.bidVideo.Duration > 0 { - e.me.RecordAdapterVideoBidDuration(bidderRequest.BidderLabels, bid.bidVideo.Duration) - } } } chBids <- brw @@ -433,14 +479,9 @@ func (e *exchange) getAllBids( if !bidsFound && adapterBids[brw.bidder] != nil && len(adapterBids[brw.bidder].bids) > 0 { bidsFound = true - bidIDsCollision = recordAdaptorDuplicateBidIDs(e.me, adapterBids) } - - } - if bidIDsCollision { - // record this request count this request if bid collision is detected - e.me.RecordRequestHavingDuplicateBidID() } + return adapterBids, adapterExtra, bidsFound } @@ -505,29 +546,45 @@ func errorsToMetric(errs []error) map[metrics.AdapterError]struct{} { return ret } -func errsToBidderErrors(errs []error) []openrtb_ext.ExtBidderError { - serr := make([]openrtb_ext.ExtBidderError, len(errs)) - for i := 0; i < len(errs); i++ { - serr[i].Code = errortypes.ReadCode(errs[i]) - serr[i].Message = errs[i].Error() +func errsToBidderErrors(errs []error) []openrtb_ext.ExtBidderMessage { + sErr := make([]openrtb_ext.ExtBidderMessage, 0) + for _, err := range errortypes.FatalOnly(errs) { + newErr := openrtb_ext.ExtBidderMessage{ + Code: errortypes.ReadCode(err), + Message: err.Error(), + } + sErr = append(sErr, newErr) } - return serr + + return sErr +} + +func errsToBidderWarnings(errs []error) []openrtb_ext.ExtBidderMessage { + sWarn := make([]openrtb_ext.ExtBidderMessage, 0) + for _, warn := range errortypes.WarningOnly(errs) { + newErr := openrtb_ext.ExtBidderMessage{ + Code: errortypes.ReadCode(warn), + Message: warn.Error(), + } + sWarn = append(sWarn, newErr) + } + return sWarn } // 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 { @@ -554,7 +611,7 @@ func encodeBidResponseExt(bidResponseExt *openrtb_ext.ExtBidResponse) ([]byte, e return buffer.Bytes(), err } -func applyCategoryMapping(ctx context.Context, bidRequest *openrtb.BidRequest, requestExt *openrtb_ext.ExtRequest, seatBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, categoriesFetcher stored_requests.CategoryFetcher, targData *targetData) (map[string]string, map[openrtb_ext.BidderName]*pbsOrtbSeatBid, []string, error) { +func applyCategoryMapping(ctx context.Context, requestExt *openrtb_ext.ExtRequest, seatBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, categoriesFetcher stored_requests.CategoryFetcher, targData *targetData) (map[string]string, map[openrtb_ext.BidderName]*pbsOrtbSeatBid, []string, error) { res := make(map[string]string) type bidDedupe struct { @@ -566,8 +623,6 @@ func applyCategoryMapping(ctx context.Context, bidRequest *openrtb.BidRequest, r dedupe := make(map[string]bidDedupe) - impMap := make(map[string]*openrtb.Imp) - // applyCategoryMapping doesn't get called unless // requestExt.Prebid.Targeting != nil && requestExt.Prebid.Targeting.IncludeBrandCategory != nil brandCatExt := requestExt.Prebid.Targeting.IncludeBrandCategory @@ -582,11 +637,6 @@ func applyCategoryMapping(ctx context.Context, bidRequest *openrtb.BidRequest, r var rejections []string var translateCategories = true - //Maintaining BidRequest Impression Map - for i := range bidRequest.Imp { - impMap[bidRequest.Imp[i].ID] = &bidRequest.Imp[i] - } - if includeBrandCategory && brandCatExt.WithCategory { if brandCatExt.TranslateCategories != nil { translateCategories = *brandCatExt.TranslateCategories @@ -663,12 +713,6 @@ func applyCategoryMapping(ctx context.Context, bidRequest *openrtb.BidRequest, r break } } - } else if newDur == 0 { - if imp, ok := impMap[bid.bid.ImpID]; ok { - if nil != imp.Video && imp.Video.MaxDuration > 0 { - newDur = int(imp.Video.MaxDuration) - } - } } var categoryDuration string @@ -685,51 +729,49 @@ func applyCategoryMapping(ctx context.Context, bidRequest *openrtb.BidRequest, r categoryDuration = fmt.Sprintf("%s_%s", categoryDuration, bidderName.String()) } - if false == brandCatExt.SkipDedup { - if dupe, ok := dedupe[dupeKey]; ok { + if dupe, ok := dedupe[dupeKey]; ok { - dupeBidPrice, err := strconv.ParseFloat(dupe.bidPrice, 64) - if err != nil { - dupeBidPrice = 0 - } - currBidPrice, err := strconv.ParseFloat(pb, 64) - if err != nil { - currBidPrice = 0 - } - if dupeBidPrice == currBidPrice { - if rand.Intn(100) < 50 { - dupeBidPrice = -1 - } else { - currBidPrice = -1 - } + dupeBidPrice, err := strconv.ParseFloat(dupe.bidPrice, 64) + if err != nil { + dupeBidPrice = 0 + } + currBidPrice, err := strconv.ParseFloat(pb, 64) + if err != nil { + currBidPrice = 0 + } + if dupeBidPrice == currBidPrice { + if rand.Intn(100) < 50 { + dupeBidPrice = -1 + } else { + currBidPrice = -1 } + } - if dupeBidPrice < currBidPrice { - if dupe.bidderName == bidderName { - // An older bid from the current bidder - bidsToRemove = append(bidsToRemove, dupe.bidIndex) + if dupeBidPrice < currBidPrice { + if dupe.bidderName == bidderName { + // An older bid from the current bidder + bidsToRemove = append(bidsToRemove, dupe.bidIndex) + rejections = updateRejections(rejections, dupe.bidID, "Bid was deduplicated") + } else { + // An older bid from a different seatBid we've already finished with + oldSeatBid := (seatBids)[dupe.bidderName] + if len(oldSeatBid.bids) == 1 { + seatBidsToRemove = append(seatBidsToRemove, dupe.bidderName) rejections = updateRejections(rejections, dupe.bidID, "Bid was deduplicated") } else { - // An older bid from a different seatBid we've already finished with - oldSeatBid := (seatBids)[dupe.bidderName] - if len(oldSeatBid.bids) == 1 { - seatBidsToRemove = append(seatBidsToRemove, dupe.bidderName) - rejections = updateRejections(rejections, dupe.bidID, "Bid was deduplicated") - } else { - oldSeatBid.bids = append(oldSeatBid.bids[:dupe.bidIndex], oldSeatBid.bids[dupe.bidIndex+1:]...) - } + oldSeatBid.bids = append(oldSeatBid.bids[:dupe.bidIndex], oldSeatBid.bids[dupe.bidIndex+1:]...) } - delete(res, dupe.bidID) - } else { - // Remove this bid - bidsToRemove = append(bidsToRemove, bidInd) - rejections = updateRejections(rejections, bidID, "Bid was deduplicated") - continue } + delete(res, dupe.bidID) + } else { + // Remove this bid + bidsToRemove = append(bidsToRemove, bidInd) + rejections = updateRejections(rejections, bidID, "Bid was deduplicated") + continue } - dedupe[dupeKey] = bidDedupe{bidderName: bidderName, bidIndex: bidInd, bidID: bidID, bidPrice: pb} } res[bidID] = categoryDuration + dedupe[dupeKey] = bidDedupe{bidderName: bidderName, bidIndex: bidInd, bidID: bidID, bidPrice: pb} } if len(bidsToRemove) > 0 { @@ -775,7 +817,8 @@ func getPrimaryAdServer(adServerId int) (string, error) { func (e *exchange) makeExtBidResponse(adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid, adapterExtra map[openrtb_ext.BidderName]*seatResponseExtra, r AuctionRequest, debugInfo bool, errList []error) *openrtb_ext.ExtBidResponse { req := r.BidRequest bidResponseExt := &openrtb_ext.ExtBidResponse{ - Errors: make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderError, len(adapterBids)), + Errors: make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage, len(adapterBids)), + Warnings: make(map[openrtb_ext.BidderName][]openrtb_ext.ExtBidderMessage, len(adapterBids)), ResponseTimeMillis: make(map[openrtb_ext.BidderName]int, len(adapterBids)), RequestTimeoutMillis: req.TMax, } @@ -797,6 +840,9 @@ func (e *exchange) makeExtBidResponse(adapterBids map[openrtb_ext.BidderName]*pb if debugInfo && len(responseExtra.HttpCalls) > 0 { bidResponseExt.Debug.HttpCalls[bidderName] = responseExtra.HttpCalls } + if len(responseExtra.Warnings) > 0 { + bidResponseExt.Warnings[bidderName] = responseExtra.Warnings + } // Only make an entry for bidder errors if the bidder reported any. if len(responseExtra.Errors) > 0 { bidResponseExt.Errors[bidderName] = responseExtra.Errors @@ -813,26 +859,10 @@ 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 := new(openrtb.SeatBid) - seatBid.Seat = adapter.String() - // Prebid cannot support roadblocking - seatBid.Group = 0 - - if len(adapterBid.ext) > 0 { - sbExt := ExtSeatBid{ - Bidder: adapterBid.ext, - } - - ext, err := json.Marshal(sbExt) - if err != nil { - extError := openrtb_ext.ExtBidderError{ - Code: errortypes.ReadCode(err), - Message: fmt.Sprintf("Error writing SeatBid.Ext: %s", err.Error()), - } - adapterExtra[adapter].Errors = append(adapterExtra[adapter].Errors, extError) - } - seatBid.Ext = ext +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 } var errList []error @@ -844,42 +874,58 @@ func (e *exchange) makeSeatBid(adapterBid *pbsOrtbSeatBid, adapter openrtb_ext.B return seatBid } -// Create the Bid array inside of SeatBid -func (e *exchange) makeBid(Bids []*pbsOrtbBid, auc *auction, returnCreative bool) ([]openrtb.Bid, []error) { - bids := make([]openrtb.Bid, 0, len(Bids)) - errList := make([]error, 0, 1) - for _, thisBid := range Bids { - bidExt := &openrtb_ext.ExtBid{ - Bidder: thisBid.bid.Ext, - Prebid: &openrtb_ext.ExtBidPrebid{ - Targeting: thisBid.bidTargets, - Type: thisBid.bidType, - Video: thisBid.bidVideo, - Events: thisBid.bidEvents, - DealPriority: thisBid.dealPriority, - DealTierSatisfied: thisBid.dealTierSatisfied, - }, - } - if cacheInfo, found := e.getBidCacheInfo(thisBid, auc); found { - bidExt.Prebid.Cache = &openrtb_ext.ExtBidPrebidCache{ +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 { + bidExtPrebid := &openrtb_ext.ExtBidPrebid{ + DealPriority: bid.dealPriority, + DealTierSatisfied: bid.dealTierSatisfied, + Events: bid.bidEvents, + Targeting: bid.bidTargets, + Type: bid.bidType, + Video: bid.bidVideo, + BidId: bid.generatedBidID, + } + + if cacheInfo, found := e.getBidCacheInfo(bid, auc); found { + bidExtPrebid.Cache = &openrtb_ext.ExtBidPrebidCache{ Bids: &cacheInfo, } } - ext, err := json.Marshal(bidExt) - if err != nil { - errList = append(errList, err) + + if bidExtJSON, err := makeBidExtJSON(bid.bid.Ext, bidExtPrebid); err != nil { + errs = append(errs, err) } else { - bids = append(bids, *thisBid.bid) - bids[len(bids)-1].Ext = ext + result = append(result, *bid.bid) + resultBid := &result[len(result)-1] + resultBid.Ext = bidExtJSON if !returnCreative { - bids[len(bids)-1].AdM = "" + resultBid.AdM = "" } } } - return bids, errList + return result, errs } -// 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)`, +func makeBidExtJSON(ext json.RawMessage, prebid *openrtb_ext.ExtBidPrebid) (json.RawMessage, error) { + // no existing bid.ext. generate a bid.ext with just our prebid section populated. + if len(ext) == 0 { + bidExt := &openrtb_ext.ExtBid{Prebid: prebid} + return json.Marshal(bidExt) + } + + // update existing bid.ext with our prebid section. if bid.ext.prebid already exists, it will be overwritten. + var extMap map[string]interface{} + if err := json.Unmarshal(ext, &extMap); err != nil { + return nil, err + } + extMap[openrtb_ext.PrebidExtKey] = prebid + return json.Marshal(extMap) +} + +// 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) @@ -939,26 +985,3 @@ func listBiddersWithRequests(bidderRequests []BidderRequest) []openrtb_ext.Bidde return liveAdapters } - -// recordAdaptorDuplicateBidIDs finds the bid.id collisions for each bidder and records them with metrics engine -// it returns true if collosion(s) is/are detected in any of the bidder's bids -func recordAdaptorDuplicateBidIDs(metricsEngine metrics.MetricsEngine, adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid) bool { - bidIDCollisionFound := false - if nil == adapterBids { - return false - } - for bidder, bid := range adapterBids { - bidIDColisionMap := make(map[string]int, len(adapterBids[bidder].bids)) - for _, thisBid := range bid.bids { - if collisions, ok := bidIDColisionMap[thisBid.bid.ID]; ok { - bidIDCollisionFound = true - bidIDColisionMap[thisBid.bid.ID]++ - glog.Warningf("Bid.id %v :: %v collision(s) [imp.id = %v] for bidder '%v'", thisBid.bid.ID, collisions, thisBid.bid.ImpID, string(bidder)) - metricsEngine.RecordAdapterDuplicateBidID(string(bidder), 1) - } else { - bidIDColisionMap[thisBid.bid.ID] = 1 - } - } - } - return bidIDCollisionFound -} diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index 6362741a6b8..c18f4533966 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -15,19 +15,20 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - metricsConfig "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - pbc "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/file_fetcher" - - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + metricsConf "github.com/prebid/prebid-server/metrics/config" + metricsConfig "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" + pbc "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/backends/file_fetcher" + "github.com/buger/jsonparser" "github.com/stretchr/testify/assert" "github.com/yudai/gojsondiff" @@ -52,7 +53,11 @@ func TestNewExchange(t *testing.T) { }, } - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", knownAdapters) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -70,19 +75,19 @@ 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 -// as specified in https://github.com/PubMatic-OpenWrap/prebid-server/issues/465 +// as specified in https://github.com/prebid/prebid-server/issues/465 // 2) Initialize a new exchange with said configuration // 3) Build all the parameters e.buildBidResponse(ctx.Background(), liveA... ) needs including the -// sample request as specified in https://github.com/PubMatic-OpenWrap/prebid-server/issues/465 +// sample request as specified in https://github.com/prebid/prebid-server/issues/465 // 4) Build a BidResponse struct using exchange.buildBidResponse(ctx.Background(), liveA... ) // 5) Assert we have no '&' characters in the response that exchange.buildBidResponse returns func TestCharacterEscape(t *testing.T) { /* 1) Adapter with a '& char in its endpoint property */ - /* https://github.com/PubMatic-OpenWrap/prebid-server/issues/465 */ + /* https://github.com/prebid/prebid-server/issues/465 */ cfg := &config.Configuration{ Adapters: make(map[string]config.Adapter, 1), } @@ -96,7 +101,11 @@ func TestCharacterEscape(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(handlerNoBidServer)) defer server.Close() - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -114,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/PubMatic-OpenWrap/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}`), @@ -133,7 +142,7 @@ func TestCharacterEscape(t *testing.T) { adapterExtra := make(map[openrtb_ext.BidderName]*seatResponseExtra, 1) adapterExtra["appnexus"] = &seatResponseExtra{ ResponseTimeMillis: 5, - Errors: []openrtb_ext.ExtBidderError{{Code: 999, Message: "Post ib.adnxs.com/openrtb2?query1&query2: unsupported protocol scheme \"\""}}, + Errors: []openrtb_ext.ExtBidderMessage{{Code: 999, Message: "Post ib.adnxs.com/openrtb2?query1&query2: unsupported protocol scheme \"\""}}, } var errList []error @@ -154,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 @@ -172,59 +181,68 @@ func TestDebugBehaviour(t *testing.T) { } type aTest struct { - desc string - in inTest - out outTest - debugData debugData + desc string + in inTest + out outTest + debugData debugData + generateWarnings bool } testCases := []aTest{ { - desc: "test flag equals zero, ext debug flag false, no debug info expected", - in: inTest{test: 0, debug: false}, - out: outTest{debugInfoIncluded: false}, - debugData: debugData{true, true}, + desc: "test flag equals zero, ext debug flag false, no debug info expected", + in: inTest{test: 0, debug: false}, + out: outTest{debugInfoIncluded: false}, + debugData: debugData{true, true}, + generateWarnings: false, }, { - desc: "test flag equals zero, ext debug flag true, debug info expected", - in: inTest{test: 0, debug: true}, - out: outTest{debugInfoIncluded: true}, - debugData: debugData{true, true}, + desc: "test flag equals zero, ext debug flag true, debug info expected", + in: inTest{test: 0, debug: true}, + out: outTest{debugInfoIncluded: true}, + debugData: debugData{true, true}, + generateWarnings: false, }, { - desc: "test flag equals 1, ext debug flag false, debug info expected", - in: inTest{test: 1, debug: false}, - out: outTest{debugInfoIncluded: true}, - debugData: debugData{true, true}, + desc: "test flag equals 1, ext debug flag false, debug info expected", + in: inTest{test: 1, debug: false}, + out: outTest{debugInfoIncluded: true}, + debugData: debugData{true, true}, + generateWarnings: false, }, { - desc: "test flag equals 1, ext debug flag true, debug info expected", - in: inTest{test: 1, debug: true}, - out: outTest{debugInfoIncluded: true}, - debugData: debugData{true, true}, + desc: "test flag equals 1, ext debug flag true, debug info expected", + in: inTest{test: 1, debug: true}, + out: outTest{debugInfoIncluded: true}, + debugData: debugData{true, true}, + generateWarnings: false, }, { - desc: "test flag not equal to 0 nor 1, ext debug flag false, no debug info expected", - in: inTest{test: 2, debug: false}, - out: outTest{debugInfoIncluded: false}, - debugData: debugData{true, true}, + desc: "test flag not equal to 0 nor 1, ext debug flag false, no debug info expected", + in: inTest{test: 2, debug: false}, + out: outTest{debugInfoIncluded: false}, + debugData: debugData{true, true}, + generateWarnings: false, }, { - desc: "test flag not equal to 0 nor 1, ext debug flag true, debug info expected", - in: inTest{test: -1, debug: true}, - out: outTest{debugInfoIncluded: true}, - debugData: debugData{true, true}, + desc: "test flag not equal to 0 nor 1, ext debug flag true, debug info expected", + in: inTest{test: -1, debug: true}, + out: outTest{debugInfoIncluded: true}, + debugData: debugData{true, true}, + generateWarnings: true, }, { - desc: "test account level debug disabled", - in: inTest{test: -1, debug: true}, - out: outTest{debugInfoIncluded: false}, - debugData: debugData{true, false}, + desc: "test account level debug disabled", + in: inTest{test: -1, debug: true}, + out: outTest{debugInfoIncluded: false}, + debugData: debugData{true, false}, + generateWarnings: true, }, { - desc: "test bidder level debug disabled", - in: inTest{test: -1, debug: true}, - out: outTest{debugInfoIncluded: false}, - debugData: debugData{false, true}, + desc: "test bidder level debug disabled", + in: inTest{test: -1, debug: true}, + out: outTest{debugInfoIncluded: false}, + debugData: debugData{false, true}, + generateWarnings: true, }, } @@ -235,20 +253,20 @@ func TestDebugBehaviour(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(noBidServer)) defer server.Close() - categoriesFetcher, error := newCategoryFetcher("./test/category-mapping") - if error != nil { - t.Errorf("Failed to create a category Fetcher: %v", error) + categoriesFetcher, err := newCategoryFetcher("./test/category-mapping") + if err != nil { + 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, } @@ -277,7 +295,7 @@ func TestDebugBehaviour(t *testing.T) { for _, test := range testCases { e.adapterMap = map[openrtb_ext.BidderName]adaptedBidder{ - openrtb_ext.BidderAppnexus: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &adapters.DebugInfo{Allow: test.debugData.bidderLevelDebugAllowed}), + openrtb_ext.BidderAppnexus: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &config.DebugInfo{Allow: test.debugData.bidderLevelDebugAllowed}), } //request level debug key @@ -297,6 +315,13 @@ func TestDebugBehaviour(t *testing.T) { UserSyncs: &emptyUsersync{}, StartTime: time.Now(), } + if test.generateWarnings { + var errL []error + errL = append(errL, &errortypes.Warning{ + Message: fmt.Sprintf("CCPA consent test warning."), + WarningCode: errortypes.InvalidPrivacyConsentWarningCode}) + auctionRequest.Warnings = errL + } // Run test outBidResponse, err := e.HoldAuction(ctx, auctionRequest, nil) @@ -331,6 +356,35 @@ func TestDebugBehaviour(t *testing.T) { } else { assert.Nil(t, actualExt.Debug, "%s. ext.debug.httpcalls array should not be empty", "With bidder level debug disable option http calls should be empty") } + + if test.out.debugInfoIncluded && !test.debugData.accountLevelDebugAllowed { + assert.Len(t, actualExt.Warnings, 1, "warnings should have one warning") + assert.NotNil(t, actualExt.Warnings["general"], "general warning should be present") + assert.Equal(t, "debug turned off for account", actualExt.Warnings["general"][0].Message, "account debug disabled message should be present") + } + + if !test.out.debugInfoIncluded && test.in.debug && test.debugData.accountLevelDebugAllowed { + if test.generateWarnings { + assert.Len(t, actualExt.Warnings, 2, "warnings should have one warning") + } else { + assert.Len(t, actualExt.Warnings, 1, "warnings should have one warning") + } + assert.NotNil(t, actualExt.Warnings["appnexus"], "bidder warning should be present") + assert.Equal(t, "debug turned off for bidder", actualExt.Warnings["appnexus"][0].Message, "account debug disabled message should be present") + } + + if test.generateWarnings { + assert.NotNil(t, actualExt.Warnings["general"], "general warning should be present") + CCPAWarningPresent := false + for _, warn := range actualExt.Warnings["general"] { + if warn.Code == errortypes.InvalidPrivacyConsentWarningCode { + CCPAWarningPresent = true + break + } + } + assert.True(t, CCPAWarningPresent, "CCPA Warning should be present") + } + } } @@ -385,18 +439,18 @@ func TestTwoBiddersDebugDisabledAndEnabled(t *testing.T) { e.currencyConverter = currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) e.categoriesFetcher = categoriesFetcher - debugLog := DebugLog{} + 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, } @@ -411,8 +465,8 @@ func TestTwoBiddersDebugDisabledAndEnabled(t *testing.T) { } e.adapterMap = map[openrtb_ext.BidderName]adaptedBidder{ - openrtb_ext.BidderAppnexus: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &adapters.DebugInfo{Allow: testCase.bidder1DebugEnabled}), - openrtb_ext.BidderTelaria: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &adapters.DebugInfo{Allow: testCase.bidder2DebugEnabled}), + openrtb_ext.BidderAppnexus: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &config.DebugInfo{Allow: testCase.bidder1DebugEnabled}), + openrtb_ext.BidderTelaria: adaptBidder(bidderImpl, server.Client(), &config.Configuration{}, &metricsConfig.DummyMetricsEngine{}, openrtb_ext.BidderAppnexus, &config.DebugInfo{Allow: testCase.bidder2DebugEnabled}), } // Run test outBidResponse, err := e.HoldAuction(context.Background(), auctionRequest, &debugLog) @@ -583,7 +637,7 @@ func TestReturnCreativeEndToEnd(t *testing.T) { bidResponse: &adapters.BidderResponse{ Bids: []*adapters.TypedBid{ { - Bid: &openrtb.Bid{AdM: sampleAd}, + Bid: &openrtb2.Bid{AdM: sampleAd}, }, }, }, @@ -598,16 +652,17 @@ func TestReturnCreativeEndToEnd(t *testing.T) { e.gDPR = gdpr.AlwaysAllow{} e.currencyConverter = currency.NewRateConverter(&http.Client{}, "", time.Duration(0)) e.categoriesFetcher = categoriesFetcher + e.bidIDGenerator = &mockBidIDGenerator{false, false} // 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 @@ -680,7 +735,11 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(handlerNoBidServer)) defer server.Close() - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -692,7 +751,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: "", @@ -724,7 +783,7 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { }, } auc := &auction{ - cacheIds: map[*openrtb.Bid]string{ + cacheIds: map[*openrtb2.Bid]string{ bids[0]: testUUID, }, } @@ -750,7 +809,7 @@ func TestGetBidCacheInfoEndToEnd(t *testing.T) { adapterExtra := map[openrtb_ext.BidderName]*seatResponseExtra{ bidderName: { ResponseTimeMillis: 5, - Errors: []openrtb_ext.ExtBidderError{ + Errors: []openrtb_ext.ExtBidderMessage{ { Code: 999, Message: "Post ib.adnxs.com/openrtb2?query1&query2: unsupported protocol scheme \"\"", @@ -758,14 +817,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, @@ -780,9 +839,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 } }}`), @@ -796,11 +855,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": "" }`), }, @@ -829,7 +888,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 { @@ -852,12 +911,13 @@ func TestBidReturnsCreative(t *testing.T) { // Test set up sampleBids := []*pbsOrtbBid{ { - bid: sampleOpenrtbBid, - bidType: openrtb_ext.BidTypeBanner, - bidTargets: map[string]string{}, + bid: sampleOpenrtbBid, + bidType: openrtb_ext.BidTypeBanner, + bidTargets: map[string]string{}, + generatedBidID: "randomId", }, } - 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)) @@ -896,7 +956,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 @@ -914,7 +974,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", @@ -925,7 +985,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", @@ -946,7 +1006,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", @@ -954,7 +1014,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: "", @@ -963,7 +1023,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: "", @@ -974,7 +1034,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: "", @@ -985,7 +1045,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: "", @@ -1029,7 +1089,11 @@ func TestBidResponseCurrency(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(handlerNoBidServer)) defer server.Close() - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -1041,15 +1105,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}`), @@ -1061,7 +1125,7 @@ func TestBidResponseCurrency(t *testing.T) { var errList []error - sampleBid := &openrtb.Bid{ + sampleBid := &openrtb2.Bid{ ID: "some-imp-id", Price: 9.517803, W: 300, @@ -1069,10 +1133,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, @@ -1083,13 +1147,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{ { @@ -1100,7 +1164,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "USD", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: sampleSeatBid, Cur: "USD", @@ -1116,7 +1180,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "USD", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: emptySeatBid, Cur: "", @@ -1132,7 +1196,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: sampleSeatBid, Cur: "", @@ -1148,7 +1212,7 @@ func TestBidResponseCurrency(t *testing.T) { currency: "", }, }, - expectedBidResponse: &openrtb.BidResponse{ + expectedBidResponse: &openrtb2.BidResponse{ ID: "some-request-id", SeatBid: emptySeatBid, Cur: "", @@ -1203,7 +1267,11 @@ func TestRaceIntegration(t *testing.T) { ExtraAdapterInfo: "{\"video_endpoint\":\"" + server.URL + "\"}", } - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -1219,7 +1287,7 @@ func TestRaceIntegration(t *testing.T) { debugLog := DebugLog{} ex := NewExchange(adapters, &wellBehavedCache{}, cfg, &metricsConf.DummyMetricsEngine{}, biddersInfo, gdpr.AlwaysAllow{}, currencyConverter, &nilCategoryFetcher{}).(*exchange) - _, err := ex.HoldAuction(context.Background(), auctionRequest, &debugLog) + _, err = ex.HoldAuction(context.Background(), auctionRequest, &debugLog) if err != nil { t.Errorf("HoldAuction returned unexpected error: %v", err) } @@ -1239,39 +1307,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, }, { @@ -1281,7 +1349,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, @@ -1301,7 +1369,11 @@ func TestPanicRecovery(t *testing.T) { Adapters: blankAdapterConfig(openrtb_ext.CoreBidderNames()), } - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(&http.Client{}, cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -1329,14 +1401,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", }, }, @@ -1387,7 +1459,11 @@ func TestPanicRecoveryHighLevel(t *testing.T) { } cfg.Adapters["audiencenetwork"] = config.Adapter{Disabled: true} - biddersInfo := adapters.ParseBidderInfos(cfg.Adapters, "../static/bidder-info", openrtb_ext.CoreBidderNames()) + biddersInfo, err := config.LoadBidderInfoFromDisk("../static/bidder-info", cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + t.Fatal(err) + } + adapters, adaptersErr := BuildAdapters(server.Client(), cfg, biddersInfo, &metricsConf.DummyMetricsEngine{}) if adaptersErr != nil { t.Fatalf("Error intializing adapters: %v", adaptersErr) @@ -1405,23 +1481,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, }, { @@ -1439,7 +1515,7 @@ func TestPanicRecoveryHighLevel(t *testing.T) { UserSyncs: &emptyUsersync{}, } debugLog := DebugLog{} - _, err := e.HoldAuction(context.Background(), auctionRequest, &debugLog) + _, err = e.HoldAuction(context.Background(), auctionRequest, &debugLog) if err != nil { t.Errorf("HoldAuction returned unexpected error: %v", err) } @@ -1551,8 +1627,11 @@ func runSpec(t *testing.T, filename string, spec *exchangeSpec) { EEACountriesMap: eeac, }, } - - ex := newExchangeForTests(t, filename, spec.OutgoingRequests, aliases, privacyConfig) + bidIdGenerator := &mockBidIDGenerator{} + if spec.BidIDGenerator != nil { + *bidIdGenerator = *spec.BidIDGenerator + } + ex := newExchangeForTests(t, filename, spec.OutgoingRequests, aliases, privacyConfig, bidIdGenerator) biddersInAuction := findBiddersInAuction(t, filename, &spec.IncomingRequest.OrtbRequest) debugLog := &DebugLog{} if spec.DebugLog != nil { @@ -1608,11 +1687,10 @@ func runSpec(t *testing.T, filename string, spec *exchangeSpec) { if spec.IncomingRequest.OrtbRequest.Test == 1 { //compare debug info diffJson(t, "Debug info modified", bid.Ext, spec.Response.Ext) - } } -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 @@ -1628,7 +1706,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 @@ -1649,9 +1727,9 @@ func extractResponseTimes(t *testing.T, context string, bid *openrtb.BidResponse } } -func newExchangeForTests(t *testing.T, filename string, expectations map[string]*bidderSpec, aliases map[string]string, privacyConfig config.Privacy) Exchange { +func newExchangeForTests(t *testing.T, filename string, expectations map[string]*bidderSpec, aliases map[string]string, privacyConfig config.Privacy, bidIDGenerator BidIDGenerator) Exchange { bidderAdapters := make(map[openrtb_ext.BidderName]adaptedBidder, len(expectations)) - bidderInfos := make(adapters.BidderInfos, len(expectations)) + bidderInfos := make(config.BidderInfos, len(expectations)) for _, bidderName := range openrtb_ext.CoreBidderNames() { if spec, ok := expectations[string(bidderName)]; ok { bidderAdapters[bidderName] = &validatingBidder{ @@ -1661,7 +1739,7 @@ func newExchangeForTests(t *testing.T, filename string, expectations map[string] expectations: map[string]*bidderRequest{string(bidderName): spec.ExpectedRequest}, mockResponses: map[string]bidderResponse{string(bidderName): spec.MockResponse}, } - bidderInfos[string(bidderName)] = adapters.BidderInfo{ModifyingVastXmlAllowed: spec.ModifyingVastXmlAllowed} + bidderInfos[string(bidderName)] = config.BidderInfo{ModifyingVastXmlAllowed: spec.ModifyingVastXmlAllowed} } } @@ -1699,7 +1777,27 @@ func newExchangeForTests(t *testing.T, filename string, expectations map[string] categoriesFetcher: categoriesFetcher, bidderInfo: bidderInfos, externalURL: "http://localhost", + bidIDGenerator: bidIDGenerator, + } +} + +type mockBidIDGenerator struct { + GenerateBidID bool `json:"generateBidID"` + ReturnError bool `json:"returnError"` +} + +func (big *mockBidIDGenerator) Enabled() bool { + return big.GenerateBidID +} + +func (big *mockBidIDGenerator) New() (string, error) { + + if big.ReturnError { + err := errors.New("Test error generating bid.ext.prebid.bidid") + return "", err } + return "mock_uuid", nil + } func newExtRequest() openrtb_ext.ExtRequest { @@ -1764,7 +1862,6 @@ func TestCategoryMapping(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequest() targData := &targetData{ @@ -1780,15 +1877,15 @@ 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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, nil, 0, false} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, nil, 0, false, ""} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1797,12 +1894,12 @@ func TestCategoryMapping(t *testing.T) { &bid1_4, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 1, len(rejections), "There should be 1 bid rejection message") @@ -1821,7 +1918,6 @@ func TestCategoryMappingNoIncludeBrandCategory(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestNoBrandCat() targData := &targetData{ @@ -1836,15 +1932,15 @@ 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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, nil, 0, false} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30, PrimaryCategory: "AdapterOverride"}, nil, 0, false, ""} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 50}, nil, 0, false, ""} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1853,12 +1949,12 @@ func TestCategoryMappingNoIncludeBrandCategory(t *testing.T) { &bid1_4, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be no bid rejection messages") @@ -1877,7 +1973,6 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestTranslateCategories(nil) targData := &targetData{ @@ -1892,13 +1987,13 @@ 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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1906,12 +2001,12 @@ func TestCategoryMappingTranslateCategoriesNil(t *testing.T) { &bid1_3, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 1, len(rejections), "There should be 1 bid rejection message") @@ -1960,7 +2055,6 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) { } translateCategories := false - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestTranslateCategories(&translateCategories) targData := &targetData{ @@ -1975,13 +2069,13 @@ 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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} innerBids := []*pbsOrtbBid{ &bid1_1, @@ -1989,12 +2083,12 @@ func TestCategoryMappingTranslateCategoriesFalse(t *testing.T) { &bid1_3, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be no bid rejection messages") @@ -2012,7 +2106,6 @@ func TestCategoryDedupe(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequest() targData := &targetData{ @@ -2026,17 +2119,17 @@ 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_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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} - bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} + bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} selectedBids := make(map[string]int) expectedCategories := map[string]string{ @@ -2060,12 +2153,12 @@ func TestCategoryDedupe(t *testing.T) { &bid1_5, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 3, len(rejections), "There should be 2 bid rejection messages") @@ -2093,7 +2186,6 @@ func TestNoCategoryDedupe(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestNoBrandCat() targData := &targetData{ @@ -2106,17 +2198,17 @@ 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_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} - bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} - bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} - bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false} + 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, ""} + bid1_3 := pbsOrtbBid{&bid3, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} + bid1_4 := pbsOrtbBid{&bid4, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} + bid1_5 := pbsOrtbBid{&bid5, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: 30}, nil, 0, false, ""} selectedBids := make(map[string]int) expectedCategories := map[string]string{ @@ -2141,12 +2233,12 @@ func TestNoCategoryDedupe(t *testing.T) { &bid1_5, } - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} bidderName1 := openrtb_ext.BidderName("appnexus") adapterBids[bidderName1] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.Equal(t, nil, err, "Category mapping error should be empty") assert.Equal(t, 2, len(rejections), "There should be 2 bid rejection messages") @@ -2175,7 +2267,6 @@ func TestCategoryMappingBidderName(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequest() requestExt.Prebid.Targeting.AppendBidderNames = true @@ -2190,11 +2281,11 @@ 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} + 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, ""} innerBids1 := []*pbsOrtbBid{ &bid1_1, @@ -2203,16 +2294,16 @@ func TestCategoryMappingBidderName(t *testing.T) { &bid1_2, } - seatBid1 := pbsOrtbSeatBid{innerBids1, "USD", nil, nil} + seatBid1 := pbsOrtbSeatBid{bids: innerBids1, currency: "USD"} bidderName1 := openrtb_ext.BidderName("bidder1") - seatBid2 := pbsOrtbSeatBid{innerBids2, "USD", nil, nil} + seatBid2 := pbsOrtbSeatBid{bids: innerBids2, currency: "USD"} bidderName2 := openrtb_ext.BidderName("bidder2") adapterBids[bidderName1] = &seatBid1 adapterBids[bidderName2] = &seatBid2 - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.NoError(t, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be 0 bid rejection messages") @@ -2230,7 +2321,6 @@ func TestCategoryMappingBidderNameNoCategories(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestNoBrandCat() requestExt.Prebid.Targeting.AppendBidderNames = true @@ -2245,11 +2335,11 @@ 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} + 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, ""} innerBids1 := []*pbsOrtbBid{ &bid1_1, @@ -2258,16 +2348,16 @@ func TestCategoryMappingBidderNameNoCategories(t *testing.T) { &bid1_2, } - seatBid1 := pbsOrtbSeatBid{innerBids1, "USD", nil, nil} + seatBid1 := pbsOrtbSeatBid{bids: innerBids1, currency: "USD"} bidderName1 := openrtb_ext.BidderName("bidder1") - seatBid2 := pbsOrtbSeatBid{innerBids2, "USD", nil, nil} + seatBid2 := pbsOrtbSeatBid{bids: innerBids2, currency: "USD"} bidderName2 := openrtb_ext.BidderName("bidder2") adapterBids[bidderName1] = &seatBid1 adapterBids[bidderName2] = &seatBid2 - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.NoError(t, err, "Category mapping error should be empty") assert.Empty(t, rejections, "There should be 0 bid rejection messages") @@ -2303,7 +2393,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 @@ -2311,7 +2401,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, @@ -2322,7 +2412,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, @@ -2333,7 +2423,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, @@ -2344,7 +2434,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}, }, @@ -2360,17 +2450,15 @@ func TestBidRejectionErrors(t *testing.T) { innerBids := []*pbsOrtbBid{} for _, bid := range test.bids { currentBid := pbsOrtbBid{ - bid, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: test.duration}, nil, 0, false, - } + bid, "video", nil, &openrtb_ext.ExtBidPrebidVideo{Duration: test.duration}, nil, 0, false, ""} innerBids = append(innerBids, ¤tBid) } - bidRequest := &openrtb.BidRequest{} - seatBid := pbsOrtbSeatBid{innerBids, "USD", nil, nil} + seatBid := pbsOrtbSeatBid{bids: innerBids, currency: "USD"} adapterBids[bidderName] = &seatBid - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &test.reqExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &test.reqExt, adapterBids, categoriesFetcher, targData) if len(test.expectedCatDur) > 0 { // Bid deduplication case @@ -2394,7 +2482,6 @@ func TestCategoryMappingTwoBiddersOneBidEachNoCategorySamePrice(t *testing.T) { t.Errorf("Failed to create a category Fetcher: %v", error) } - bidRequest := &openrtb.BidRequest{} requestExt := newExtRequestTranslateCategories(nil) targData := &targetData{ @@ -2408,11 +2495,11 @@ 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} + 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, ""} innerBidsApn1 := []*pbsOrtbBid{ &bid1_Apn1, @@ -2425,16 +2512,16 @@ func TestCategoryMappingTwoBiddersOneBidEachNoCategorySamePrice(t *testing.T) { for i := 1; i < 10; i++ { adapterBids := make(map[openrtb_ext.BidderName]*pbsOrtbSeatBid) - seatBidApn1 := pbsOrtbSeatBid{innerBidsApn1, "USD", nil, nil} + seatBidApn1 := pbsOrtbSeatBid{bids: innerBidsApn1, currency: "USD"} bidderNameApn1 := openrtb_ext.BidderName("appnexus1") - seatBidApn2 := pbsOrtbSeatBid{innerBidsApn2, "USD", nil, nil} + seatBidApn2 := pbsOrtbSeatBid{bids: innerBidsApn2, currency: "USD"} bidderNameApn2 := openrtb_ext.BidderName("appnexus2") adapterBids[bidderNameApn1] = &seatBidApn1 adapterBids[bidderNameApn2] = &seatBidApn2 - bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, bidRequest, &requestExt, adapterBids, categoriesFetcher, targData) + bidCategory, adapterBids, rejections, err := applyCategoryMapping(nil, &requestExt, adapterBids, categoriesFetcher, targData) assert.NoError(t, err, "Category mapping error should be empty") assert.Len(t, rejections, 1, "There should be 1 bid rejection message") @@ -2529,9 +2616,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, @@ -2539,7 +2626,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"], } @@ -2565,20 +2652,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"}}}`)}, }, }, @@ -2588,8 +2675,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"}}}`)}, }, @@ -2601,8 +2688,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"}}`)}, }, @@ -2706,7 +2793,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"], } @@ -2718,50 +2805,6 @@ func TestUpdateHbPbCatDur(t *testing.T) { } } -func TestRecordAdaptorDuplicateBidIDs(t *testing.T) { - type bidderCollisions = map[string]int - testCases := []struct { - scenario string - bidderCollisions *bidderCollisions // represents no of collisions detected for bid.id at bidder level for given request - hasCollision bool - }{ - {scenario: "invalid collision value", bidderCollisions: &map[string]int{"bidder-1": -1}, hasCollision: false}, - {scenario: "no collision", bidderCollisions: &map[string]int{"bidder-1": 0}, hasCollision: false}, - {scenario: "one collision", bidderCollisions: &map[string]int{"bidder-1": 1}, hasCollision: false}, - {scenario: "multiple collisions", bidderCollisions: &map[string]int{"bidder-1": 2}, hasCollision: true}, // when 2 collisions it counter will be 1 - {scenario: "multiple bidders", bidderCollisions: &map[string]int{"bidder-1": 2, "bidder-2": 4}, hasCollision: true}, - {scenario: "multiple bidders with bidder-1 no collision", bidderCollisions: &map[string]int{"bidder-1": 1, "bidder-2": 4}, hasCollision: true}, - {scenario: "no bidders", bidderCollisions: nil, hasCollision: false}, - } - testEngine := metricsConf.NewMetricsEngine(&config.Configuration{}, nil) - - for _, testcase := range testCases { - var adapterBids map[openrtb_ext.BidderName]*pbsOrtbSeatBid - if nil == testcase.bidderCollisions { - break - } - adapterBids = make(map[openrtb_ext.BidderName]*pbsOrtbSeatBid) - for bidder, collisions := range *testcase.bidderCollisions { - bids := make([]*pbsOrtbBid, 0) - testBidID := "bid_id_for_bidder_" + bidder - // add bids as per collisions value - bidCount := 0 - for ; bidCount < collisions; bidCount++ { - bids = append(bids, &pbsOrtbBid{ - bid: &openrtb.Bid{ - ID: testBidID, - }, - }) - } - if nil == adapterBids[openrtb_ext.BidderName(bidder)] { - adapterBids[openrtb_ext.BidderName(bidder)] = new(pbsOrtbSeatBid) - } - adapterBids[openrtb_ext.BidderName(bidder)].bids = bids - } - assert.Equal(t, testcase.hasCollision, recordAdaptorDuplicateBidIDs(testEngine, adapterBids)) - } -} - type exchangeSpec struct { GDPREnabled bool `json:"gdpr_enabled"` IncomingRequest exchangeRequest `json:"incomingRequest"` @@ -2773,17 +2816,18 @@ type exchangeSpec struct { DebugLog *DebugLog `json:"debuglog,omitempty"` EventsEnabled bool `json:"events_enabled,omitempty"` StartTime int64 `json:"start_time_ms,omitempty"` + BidIDGenerator *mockBidIDGenerator `json:"bidIDGenerator,omitempty"` } 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 { @@ -2793,8 +2837,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 { @@ -2813,8 +2857,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 @@ -2838,7 +2882,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 { @@ -2881,7 +2925,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 { @@ -2896,7 +2940,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 @@ -2919,8 +2963,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 { @@ -3017,7 +3061,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/exchangetest/append-bidder-names.json b/exchange/exchangetest/append-bidder-names.json index dbab99b238b..507aee1a103 100644 --- a/exchange/exchangetest/append-bidder-names.json +++ b/exchange/exchangetest/append-bidder-names.json @@ -216,4 +216,4 @@ } } } -} +} \ No newline at end of file diff --git a/exchange/exchangetest/bid-ext-prebid-collision.json b/exchange/exchangetest/bid-ext-prebid-collision.json new file mode 100644 index 00000000000..054671ce8d2 --- /dev/null +++ b/exchange/exchangetest/bid-ext-prebid-collision.json @@ -0,0 +1,90 @@ +{ + "description": "Verifies bid.ext values are left alone from the adapter, except for overwriting bid.ext.prebid if the adapter ext includes a collision.", + + "incomingRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "my-imp-id", + "video": { + "mimes": ["video/mp4"] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + }] + } + }, + "outgoingRequests": { + "appnexus": { + "expectRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "my-imp-id", + "video": { + "mimes": ["video/mp4"] + }, + "ext": { + "bidder": { + "placementId": 1 + } + } + }] + }, + "bidAdjustment": 1.0 + }, + "mockResponse": { + "pbsSeatBid": { + "pbsBids": [{ + "ortbBid": { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "ext": { + "someField": "someValue", + "prebid": { + "willBeOverwritten": "by core logic" + } + } + }, + "bidType": "video" + }] + } + } + } + }, + "response": { + "bids": { + "id": "some-request-id", + "seatbid": [{ + "seat": "appnexus", + "bid": [{ + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "ext": { + "someField": "someValue", + "prebid": { + "type": "video" + } + } + }] + }] + } + } +} \ No newline at end of file diff --git a/exchange/exchangetest/bid-ext.json b/exchange/exchangetest/bid-ext.json new file mode 100644 index 00000000000..8211ac88eac --- /dev/null +++ b/exchange/exchangetest/bid-ext.json @@ -0,0 +1,87 @@ +{ + "description": "Verifies bid.ext values are left alone from the adapter, except for adding in bid.ext.prebid.", + + "incomingRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "my-imp-id", + "video": { + "mimes": ["video/mp4"] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + }] + } + }, + "outgoingRequests": { + "appnexus": { + "expectRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [{ + "id": "my-imp-id", + "video": { + "mimes": ["video/mp4"] + }, + "ext": { + "bidder": { + "placementId": 1 + } + } + }] + }, + "bidAdjustment": 1.0 + }, + "mockResponse": { + "pbsSeatBid": { + "pbsBids": [{ + "ortbBid": { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "ext": { + "someField": "someValue" + } + }, + "bidType": "video" + }] + } + } + } + }, + "response": { + "bids": { + "id": "some-request-id", + "seatbid": [{ + "seat": "appnexus", + "bid": [{ + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "ext": { + "someField": "someValue", + "prebid": { + "type": "video" + } + } + }] + }] + } + } +} \ No newline at end of file diff --git a/exchange/exchangetest/bid-id-invalid.json b/exchange/exchangetest/bid-id-invalid.json new file mode 100644 index 00000000000..17d3a3ec4d8 --- /dev/null +++ b/exchange/exchangetest/bid-id-invalid.json @@ -0,0 +1,161 @@ +{ + "bidIDGenerator": { + "generateBidID": true, + "returnError": true + }, + "incomingRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [ + { + "id": "my-imp-id", + "video": { + "mimes": [ + "video/mp4" + ] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + } + ], + "test": 1, + "ext": { + "prebid": { + "targeting": { + "includebrandcategory": { + "primaryadserver": 1, + "publisher": "", + "withcategory": true + }, + "appendbiddernames": true + } + } + } + }, + "usersyncs": { + "appnexus": "123" + } + }, + "outgoingRequests": { + "appnexus": { + "mockResponse": { + "pbsSeatBid": { + "pbsBids": [ + { + "ortbBid": { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "cat": [ + "IAB1-1" + ] + }, + "bidType": "video", + "bidVideo": { + "duration": 30, + "PrimaryCategory": "" + } + } + ] + } + } + } + }, + "response": { + "bids": { + "id": "some-request-id", + "seatbid": [ + { + "seat": "appnexus", + "bid": [ + { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "cat": [ + "IAB1-1" + ], + "ext": { + "prebid": { + "type": "video", + "targeting": { + "hb_bidder": "appnexus", + "hb_bidder_appnexus": "appnexus", + "hb_cache_host": "www.pbcserver.com", + "hb_cache_host_appnex": "www.pbcserver.com", + "hb_cache_path": "/pbcache/endpoint", + "hb_cache_path_appnex": "/pbcache/endpoint", + "hb_pb": "0.20", + "hb_pb_appnexus": "0.20", + "hb_pb_cat_dur": "0.20_VideoGames_0s_appnexus", + "hb_pb_cat_dur_appnex": "0.20_VideoGames_0s_appnexus", + "hb_size": "200x250", + "hb_size_appnexus": "200x250" + } + } + } + } + ] + } + ] + }, + "ext": { + "debug": { + "resolvedrequest": { + "id": "some-request-id", + "imp": [ + { + "id": "my-imp-id", + "video": { + "mimes": [ + "video/mp4" + ] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + } + ], + "site": { + "page": "test.somepage.com" + }, + "test": 1, + "ext": { + "prebid": { + "targeting": { + "includebrandcategory": { + "primaryadserver": 1, + "publisher": "", + "withcategory": true + }, + "appendbiddernames": true + } + } + } + } + }, + "errors": { + "prebid": [ + { + "code": 999, + "message": "Error generating bid.ext.prebid.bidid" + } + ] + } + } + } +} \ No newline at end of file diff --git a/exchange/exchangetest/bid-id-valid.json b/exchange/exchangetest/bid-id-valid.json new file mode 100644 index 00000000000..8da6410e8d8 --- /dev/null +++ b/exchange/exchangetest/bid-id-valid.json @@ -0,0 +1,154 @@ +{ + "bidIDGenerator": { + "generateBidID": true, + "returnError": false + }, + "incomingRequest": { + "ortbRequest": { + "id": "some-request-id", + "site": { + "page": "test.somepage.com" + }, + "imp": [ + { + "id": "my-imp-id", + "video": { + "mimes": [ + "video/mp4" + ] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + } + ], + "test": 1, + "ext": { + "prebid": { + "targeting": { + "includebrandcategory": { + "primaryadserver": 1, + "publisher": "", + "withcategory": true + }, + "appendbiddernames": true + } + } + } + }, + "usersyncs": { + "appnexus": "123" + } + }, + "outgoingRequests": { + "appnexus": { + "mockResponse": { + "pbsSeatBid": { + "pbsBids": [ + { + "ortbBid": { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "cat": [ + "IAB1-1" + ] + }, + "bidType": "video", + "bidVideo": { + "duration": 30, + "PrimaryCategory": "" + } + } + ] + } + } + } + }, + "response": { + "bids": { + "id": "some-request-id", + "seatbid": [ + { + "seat": "appnexus", + "bid": [ + { + "id": "apn-bid", + "impid": "my-imp-id", + "price": 0.3, + "w": 200, + "h": 250, + "crid": "creative-1", + "cat": [ + "IAB1-1" + ], + "ext": { + "prebid": { + "bidid": "mock_uuid", + "type": "video", + "targeting": { + "hb_bidder": "appnexus", + "hb_bidder_appnexus": "appnexus", + "hb_cache_host": "www.pbcserver.com", + "hb_cache_host_appnex": "www.pbcserver.com", + "hb_cache_path": "/pbcache/endpoint", + "hb_cache_path_appnex": "/pbcache/endpoint", + "hb_pb": "0.20", + "hb_pb_appnexus": "0.20", + "hb_pb_cat_dur": "0.20_VideoGames_0s_appnexus", + "hb_pb_cat_dur_appnex": "0.20_VideoGames_0s_appnexus", + "hb_size": "200x250", + "hb_size_appnexus": "200x250" + } + } + } + } + ] + } + ] + }, + "ext": { + "debug": { + "resolvedrequest": { + "id": "some-request-id", + "imp": [ + { + "id": "my-imp-id", + "video": { + "mimes": [ + "video/mp4" + ] + }, + "ext": { + "appnexus": { + "placementId": 1 + } + } + } + ], + "site": { + "page": "test.somepage.com" + }, + "test": 1, + "ext": { + "prebid": { + "targeting": { + "includebrandcategory": { + "primaryadserver": 1, + "publisher": "", + "withcategory": true + }, + "appendbiddernames": true + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/exchange/exchangetest/debuglog_disabled.json b/exchange/exchangetest/debuglog_disabled.json index cc66a1f524d..e95b556b7ec 100644 --- a/exchange/exchangetest/debuglog_disabled.json +++ b/exchange/exchangetest/debuglog_disabled.json @@ -224,4 +224,4 @@ } } } -} +} \ No newline at end of file diff --git a/exchange/exchangetest/debuglog_enabled.json b/exchange/exchangetest/debuglog_enabled.json index e7b59945e0e..851bda69097 100644 --- a/exchange/exchangetest/debuglog_enabled.json +++ b/exchange/exchangetest/debuglog_enabled.json @@ -224,4 +224,4 @@ } } } -} +} \ No newline at end of file diff --git a/exchange/exchangetest/events-vast-account-off-request-on.json b/exchange/exchangetest/events-vast-account-off-request-on.json index 6e29ccdf749..13afb8409af 100644 --- a/exchange/exchangetest/events-vast-account-off-request-on.json +++ b/exchange/exchangetest/events-vast-account-off-request-on.json @@ -1,6 +1,10 @@ { "events_enabled": false, "start_time_ms": 1234567890, + "bidIDGenerator": { + "generateBidID": true, + "returnError": false + }, "incomingRequest": { "ortbRequest": { "id": "some-request-id", @@ -105,6 +109,7 @@ "crid": "creative-4", "ext": { "prebid": { + "bidid": "mock_uuid", "type": "video" } } @@ -116,7 +121,7 @@ "bid": [ { "id": "winning-bid", - "adm": "prebid.org wrapper", + "adm": "prebid.org wrapper", "nurl": "http://domain.com/winning-bid", "impid": "my-imp-id", "price": 0.71, @@ -125,6 +130,7 @@ "crid": "creative-1", "ext": { "prebid": { + "bidid": "mock_uuid", "type": "video", "targeting": { "hb_bidder": "appnexus", @@ -139,7 +145,7 @@ }, { "id": "losing-bid", - "adm": "prebid.org wrapper", + "adm": "prebid.org wrapper", "nurl": "http://domain.com/losing-bid", "impid": "my-imp-id", "price": 0.21, @@ -148,6 +154,7 @@ "crid": "creative-2", "ext": { "prebid": { + "bidid": "mock_uuid", "type": "video" } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json b/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json index 8004c3c2646..df0e4e33ea5 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-multiple-bidders.json @@ -25,9 +25,12 @@ "siteId": 2, "zoneId": 3 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -57,9 +60,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -107,9 +113,12 @@ "siteId": 2, "zoneId": 3 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json b/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json similarity index 90% rename from exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json rename to exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json index d62afccf426..ea4a980c63f 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-multiple-prebid-bidders.json @@ -29,9 +29,12 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -61,10 +64,12 @@ "bidder": { "placementId": 1 }, - "prebid": {}, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -112,10 +117,12 @@ "siteId": 2, "zoneId": 3 }, - "prebid": {}, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json b/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json index 6f0bab9529c..7e2c4b9a16d 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-one-bidder.json @@ -20,9 +20,12 @@ "appnexus": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -52,9 +55,12 @@ "bidder": { "placementId": 1 }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json b/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json index 1610b9ea47e..f1977426591 100644 --- a/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json +++ b/exchange/exchangetest/firstpartydata-imp-ext-one-prebid-bidder.json @@ -24,9 +24,12 @@ } } }, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } @@ -56,10 +59,12 @@ "bidder": { "placementId": 1 }, - "prebid": {}, + "data": { + "keywords": "prebid server example" + }, "context": { "data": { - "keywords": "prebid server example" + "keywords": "another prebid server example" } } } diff --git a/exchange/gdpr.go b/exchange/gdpr.go index 6b6a073bb23..208ce0fdb0b 100644 --- a/exchange/gdpr.go +++ b/exchange/gdpr.go @@ -3,12 +3,12 @@ package exchange import ( "encoding/json" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" + "github.com/mxmCherry/openrtb/v15/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 e767c269b3b..e44dc9702fb 100644 --- a/exchange/gdpr_test.go +++ b/exchange/gdpr_test.go @@ -4,31 +4,31 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/gdpr" "github.com/stretchr/testify/assert" ) 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 dac7c7b59f6..0e7d1590686 100644 --- a/exchange/legacy.go +++ b/exchange/legacy.go @@ -6,13 +6,13 @@ import ( "errors" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/buger/jsonparser" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" ) // AdaptLegacyAdapter turns a bidder.Adapter into an adaptedBidder. @@ -34,7 +34,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 @@ -59,7 +59,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} @@ -73,7 +73,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 @@ -135,7 +135,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, @@ -146,7 +146,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 } @@ -156,14 +156,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 { @@ -190,7 +190,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{ @@ -211,7 +211,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 @@ -226,8 +226,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 { @@ -251,7 +251,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, }) @@ -333,12 +333,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 2474fda50e1..cbb5fda4fcc 100644 --- a/exchange/legacy_test.go +++ b/exchange/legacy_test.go @@ -9,46 +9,46 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/pbs" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/buger/jsonparser" jsonpatch "github.com/evanphx/json-patch" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/pbs" + "github.com/prebid/prebid-server/usersync" ) 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/price_granularity.go b/exchange/price_granularity.go index ffcce061465..242d420f1fc 100644 --- a/exchange/price_granularity.go +++ b/exchange/price_granularity.go @@ -4,7 +4,7 @@ import ( "math" "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // GetPriceBucket is the externally facing function for computing CPM buckets diff --git a/exchange/price_granularity_test.go b/exchange/price_granularity_test.go index 6dccc677b7b..13840838ba7 100644 --- a/exchange/price_granularity_test.go +++ b/exchange/price_granularity_test.go @@ -4,7 +4,7 @@ import ( "math" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/exchange/seatbid.go b/exchange/seatbid.go deleted file mode 100644 index b675127410e..00000000000 --- a/exchange/seatbid.go +++ /dev/null @@ -1,8 +0,0 @@ -package exchange - -import "encoding/json" - -// ExtSeatBid defines the contract for bidresponse.seatbid.ext -type ExtSeatBid struct { - Bidder json.RawMessage `json:"bidder,omitempty"` -} diff --git a/exchange/targeting.go b/exchange/targeting.go index 31db7114f67..c4710f826f0 100644 --- a/exchange/targeting.go +++ b/exchange/targeting.go @@ -3,8 +3,8 @@ package exchange import ( "strconv" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" ) const MaxKeyLength = 20 @@ -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 "" } @@ -104,4 +104,4 @@ func (targData *targetData) addBidderKeys(keys map[string]string, bidderKeys map keys[index] = element } } -} +} \ No newline at end of file diff --git a/exchange/targeting_test.go b/exchange/targeting_test.go index e6db921529c..aa07ed0c77b 100644 --- a/exchange/targeting_test.go +++ b/exchange/targeting_test.go @@ -8,22 +8,22 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" + "github.com/prebid/prebid-server/gdpr" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - metricsConfig "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" + metricsConf "github.com/prebid/prebid-server/metrics/config" + metricsConfig "github.com/prebid/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "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() @@ -95,18 +95,19 @@ func runTargetingAuction(t *testing.T, mockBids map[openrtb_ext.BidderName][]*op currencyConverter: currency.NewRateConverter(&http.Client{}, "", time.Duration(0)), UsersyncIfAmbiguous: false, categoriesFetcher: categoriesFetcher, + bidIDGenerator: &mockBidIDGenerator{false, false}, } 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 +129,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 +137,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 +167,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 +179,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 +190,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 +200,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 +211,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 +222,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 +234,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 +260,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 +397,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 13de8ab4f5b..38d21751f8f 100644 --- a/exchange/utils.go +++ b/exchange/utils.go @@ -6,17 +6,17 @@ import ( "fmt" "math/rand" + "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/go-gdpr/vendorconsent" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/privacy" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/lmt" "github.com/buger/jsonparser" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/lmt" ) var integrationTypeMap = map[metrics.RequestType]config.IntegrationType{ @@ -57,10 +57,12 @@ func cleanOpenRTBRequests(ctx context.Context, requestExt *openrtb_ext.ExtRequest, gDPR gdpr.Permissions, usersyncIfAmbiguous bool, - privacyConfig config.Privacy) (bidderRequests []BidderRequest, privacyLabels metrics.PrivacyLabels, errs []error) { + privacyConfig config.Privacy, + account *config.Account) (bidderRequests []BidderRequest, privacyLabels metrics.PrivacyLabels, errs []error) { - impsByBidder, errs := splitImps(req.BidRequest.Imp) - if len(errs) > 0 { + impsByBidder, err := splitImps(req.BidRequest.Imp) + if err != nil { + errs = []error{err} return } @@ -121,8 +123,17 @@ func cleanOpenRTBRequests(ctx context.Context, // GDPR if gdprEnforced { + weakVendorEnforcement := false + if account != nil { + for _, vendor := range account.GDPR.BasicEnforcementVendors { + if vendor == string(bidderRequest.BidderCoreName) { + weakVendorEnforcement = true + break + } + } + } var publisherID = req.LegacyLabels.PubID - _, geo, id, err := gDPR.PersonalInfoAllowed(ctx, bidderRequest.BidderCoreName, publisherID, gdprSignal, consent) + _, geo, id, err := gDPR.PersonalInfoAllowed(ctx, bidderRequest.BidderCoreName, publisherID, gdprSignal, consent, weakVendorEnforcement) if err == nil { privacyEnforcement.GDPRGeo = !geo privacyEnforcement.GDPRID = !id @@ -152,7 +163,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 @@ -171,7 +182,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), @@ -203,7 +214,7 @@ func getBidderExts(reqExt *openrtb_ext.ExtRequest) (map[string]map[string]interf 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)) @@ -239,6 +250,8 @@ func getAuctionBidderRequests(req AuctionRequest, reqCopy := *req.BidRequest reqCopy.Imp = imps + reqCopy.Ext = reqExt + prepareSource(&reqCopy, bidder, sChainsByBidder) if len(bidderExt) != 0 { @@ -286,7 +299,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 } @@ -296,7 +309,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 @@ -316,7 +329,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, @@ -329,7 +342,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 } @@ -371,106 +384,104 @@ 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) { - impExts, err := parseImpExts(imps) - if err != nil { - return nil, []error{err} - } +func splitImps(imps []openrtb2.Imp) (map[string][]openrtb2.Imp, error) { + bidderImps := make(map[string][]openrtb2.Imp) - splitImps := make(map[string][]openrtb.Imp, len(imps)) - var errList []error + for i, imp := range imps { + var impExt map[string]json.RawMessage + if err := json.Unmarshal(imp.Ext, &impExt); err != nil { + return nil, fmt.Errorf("invalid json for imp[%d]: %v", i, err) + } - for i := 0; i < len(imps); i++ { - imp := imps[i] - impExt := impExts[i] + var impExtPrebid map[string]json.RawMessage + if impExtPrebidJSON, exists := impExt[openrtb_ext.PrebidExtKey]; exists { + // validation already performed by impExt unmarshal. no error is possible here, proven by tests. + json.Unmarshal(impExtPrebidJSON, &impExtPrebid) + } - var firstPartyDataContext json.RawMessage - if context, exists := impExt[openrtb_ext.FirstPartyDataContextExtKey]; exists { - firstPartyDataContext = context + var impExtPrebidBidder map[string]json.RawMessage + if impExtPrebidBidderJSON, exists := impExtPrebid[openrtb_ext.PrebidExtBidderKey]; exists { + // validation already performed by impExt unmarshal. no error is possible here, proven by tests. + json.Unmarshal(impExtPrebidBidderJSON, &impExtPrebidBidder) } - rawPrebidExt, ok := impExt[openrtb_ext.PrebidExtKey] + sanitizedImpExt, err := createSanitizedImpExt(impExt, impExtPrebid) + if err != nil { + return nil, fmt.Errorf("unable to remove other bidder fields for imp[%d]: %v", i, err) + } - if ok { - var prebidExt openrtb_ext.ExtImpPrebid + for bidder, bidderExt := range extractBidderExts(impExt, impExtPrebidBidder) { + impCopy := imp - if err := json.Unmarshal(rawPrebidExt, &prebidExt); err == nil && prebidExt.Bidder != nil { - if errs := sanitizedImpCopy(&imp, prebidExt.Bidder, rawPrebidExt, firstPartyDataContext, &splitImps); errs != nil { - errList = append(errList, errs...) - } + sanitizedImpExt[openrtb_ext.PrebidExtBidderKey] = bidderExt - continue + impExtJSON, err := json.Marshal(sanitizedImpExt) + if err != nil { + return nil, fmt.Errorf("unable to remove other bidder fields for imp[%d]: cannot marshal ext: %v", i, err) } - } + impCopy.Ext = impExtJSON - if errs := sanitizedImpCopy(&imp, impExt, rawPrebidExt, firstPartyDataContext, &splitImps); errs != nil { - errList = append(errList, errs...) + bidderImps[bidder] = append(bidderImps[bidder], impCopy) } } - return splitImps, nil + return bidderImps, nil } -// sanitizedImpCopy returns a copy of imp with its ext filtered so that only "prebid", "context", and bidder params exist. -// It will not mutate the input imp. -// This function will write the new imps to the output map passed in -func sanitizedImpCopy(imp *openrtb.Imp, - bidderExts map[string]json.RawMessage, - rawPrebidExt json.RawMessage, - firstPartyDataContext json.RawMessage, - out *map[string][]openrtb.Imp) []error { - - var prebidExt map[string]json.RawMessage - var errs []error - - if err := json.Unmarshal(rawPrebidExt, &prebidExt); err == nil { - // Remove the entire bidder field. We will already have the content we need in bidderExts. We - // don't want to include other demand partners' bidder params in the sanitized imp. - if _, hasBidderField := prebidExt["bidder"]; hasBidderField { - delete(prebidExt, "bidder") +func createSanitizedImpExt(impExt, impExtPrebid map[string]json.RawMessage) (map[string]json.RawMessage, error) { + sanitizedImpExt := make(map[string]json.RawMessage, 3) - var err error - if rawPrebidExt, err = json.Marshal(prebidExt); err != nil { - errs = append(errs, err) - } + delete(impExtPrebid, openrtb_ext.PrebidExtBidderKey) + if len(impExtPrebid) > 0 { + if impExtPrebidJSON, err := json.Marshal(impExtPrebid); err == nil { + sanitizedImpExt[openrtb_ext.PrebidExtKey] = impExtPrebidJSON + } else { + return nil, fmt.Errorf("cannot marshal ext.prebid: %v", err) } } - for bidder, ext := range bidderExts { - if bidder == openrtb_ext.PrebidExtKey || bidder == openrtb_ext.FirstPartyDataContextExtKey { - continue - } + if v, exists := impExt[openrtb_ext.FirstPartyDataExtKey]; exists { + sanitizedImpExt[openrtb_ext.FirstPartyDataExtKey] = v + } - impCopy := *imp - newExt := make(map[string]json.RawMessage, 3) + if v, exists := impExt[openrtb_ext.FirstPartyDataContextExtKey]; exists { + sanitizedImpExt[openrtb_ext.FirstPartyDataContextExtKey] = v + } - newExt["bidder"] = ext + if v, exists := impExt[openrtb_ext.SKAdNExtKey]; exists { + sanitizedImpExt[openrtb_ext.SKAdNExtKey] = v + } - if rawPrebidExt != nil { - newExt[openrtb_ext.PrebidExtKey] = rawPrebidExt - } + return sanitizedImpExt, nil +} - if len(firstPartyDataContext) > 0 { - newExt[openrtb_ext.FirstPartyDataContextExtKey] = firstPartyDataContext - } +func extractBidderExts(impExt, impExtPrebidBidders map[string]json.RawMessage) map[string]json.RawMessage { + bidderExts := make(map[string]json.RawMessage) - rawExt, err := json.Marshal(newExt) - if err != nil { - errs = append(errs, err) + // prefer imp.ext.prebid.bidder.BIDDER + for bidder, bidderExt := range impExtPrebidBidders { + bidderExts[bidder] = bidderExt + } + + // fallback to imp.BIDDER + for bidder, bidderExt := range impExt { + if isSpecialField(bidder) { continue } - impCopy.Ext = rawExt - - otherImps, _ := (*out)[bidder] - (*out)[bidder] = append(otherImps, impCopy) + if _, exists := bidderExts[bidder]; !exists { + bidderExts[bidder] = bidderExt + } } - if len(errs) > 0 { - return errs - } + return bidderExts +} - return nil +func isSpecialField(bidder string) bool { + return bidder == openrtb_ext.FirstPartyDataContextExtKey || + bidder == openrtb_ext.FirstPartyDataExtKey || + bidder == openrtb_ext.SKAdNExtKey || + bidder == openrtb_ext.PrebidExtKey } // prepareUser changes req.User so that it's ready for the given bidder. @@ -478,7 +489,7 @@ func sanitizedImpCopy(imp *openrtb.Imp, // // 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 { @@ -492,9 +503,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, } } @@ -507,7 +518,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 @@ -594,7 +605,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 @@ -608,23 +619,8 @@ func resolveBidder(bidder string, aliases map[string]string) openrtb_ext.BidderN return openrtb_ext.BidderName(bidder) } -// parseImpExts does a partial-unmarshal of the imp[].Ext field. -// The keys in the returned map are expected to be "prebid", "context", CoreBidderNames, or Aliases for this request. -func parseImpExts(imps []openrtb.Imp) ([]map[string]json.RawMessage, error) { - exts := make([]map[string]json.RawMessage, len(imps)) - // Loop over every impression in the request - for i := 0; i < len(imps); i++ { - // Unpack each set of extensions found in the Imp array - err := json.Unmarshal(imps[i].Ext, &exts[i]) - if err != nil { - return nil, fmt.Errorf("Error unpacking extensions for Imp[%d]: %s", i, err.Error()) - } - } - return exts, nil -} - // 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 { @@ -657,7 +653,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 { @@ -720,7 +716,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 e222103e44c..55a0950aac6 100644 --- a/exchange/utils_test.go +++ b/exchange/utils_test.go @@ -7,12 +7,12 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/gdpr" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -32,7 +32,7 @@ func (p *permissionsMock) BidderSyncAllowed(ctx context.Context, bidder openrtb_ return true, nil } -func (p *permissionsMock) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdpr gdpr.Signal, consent string) (bool, bool, bool, error) { +func (p *permissionsMock) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdpr gdpr.Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return p.personalInfoAllowed, p.personalInfoAllowed, p.personalInfoAllowed, p.personalInfoAllowedError } @@ -55,6 +55,381 @@ func assertReq(t *testing.T, bidderRequests []BidderRequest, } } +func TestSplitImps(t *testing.T) { + testCases := []struct { + description string + givenImps []openrtb2.Imp + expectedImps map[string][]openrtb2.Imp + expectedError string + }{ + { + description: "Nil", + givenImps: nil, + expectedImps: map[string][]openrtb2.Imp{}, + expectedError: "", + }, + { + description: "Empty", + givenImps: []openrtb2.Imp{}, + expectedImps: map[string][]openrtb2.Imp{}, + expectedError: "", + }, + { + description: "1 Imp, 1 Bidder", + givenImps: []openrtb2.Imp{ + {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1ParamA":"imp1ValueA"}}}}`)}, + }, + expectedImps: map[string][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, + }, + }, + expectedError: "", + }, + { + description: "1 Imp, 2 Bidders", + givenImps: []openrtb2.Imp{ + {ID: "imp1", Ext: json.RawMessage(`{"prebid":{"bidder":{"bidderA":{"imp1ParamA":"imp1ValueA"},"bidderB":{"imp1ParamB":"imp1ValueB"}}}}`)}, + }, + expectedImps: map[string][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, + }, + "bidderB": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamB":"imp1ValueB"}}`)}, + }, + }, + expectedError: "", + }, + { + description: "2 Imps, 1 Bidders Each", + 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][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1ParamA":"imp1ValueA"}}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2ParamA":"imp2ValueA"}}`)}, + }, + }, + expectedError: "", + }, + { + description: "2 Imps, 2 Bidders Each", + 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][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"}}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"}}`)}, + }, + "bidderB": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramB":"imp1valueB"}}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramB":"imp2valueB"}}`)}, + }, + }, + expectedError: "", + }, + { + // This is a "happy path" integration test. Functionality is covered in detail by TestCreateSanitizedImpExt. + description: "Other Fields - 2 Imps, 2 Bidders Each", + 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][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"},"skadn":"imp1SkAdN"}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"},"skadn":"imp2SkAdN"}`)}, + }, + "bidderB": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramB":"imp1valueB"},"skadn":"imp1SkAdN"}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramB":"imp2valueB"},"skadn":"imp2SkAdN"}`)}, + }, + }, + expectedError: "", + }, + { + // 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: []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][]openrtb2.Imp{ + "bidderA": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramA":"imp1valueA"}}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramA":"imp2valueA"}}`)}, + }, + "bidderB": { + {ID: "imp1", Ext: json.RawMessage(`{"bidder":{"imp1paramB":"imp1valueB"}}`)}, + {ID: "imp2", Ext: json.RawMessage(`{"bidder":{"imp2paramB":"imp2valueB"}}`)}, + }, + }, + expectedError: "", + }, + { + description: "Malformed imp.ext", + 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: []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: []openrtb2.Imp{ + {ID: "imp1", Ext: json.RawMessage(`{"prebid": {"bidder": malformed}}`)}, + }, + expectedError: "invalid json for imp[0]: invalid character 'm' looking for beginning of value", + }, + } + + for _, test := range testCases { + imps, err := splitImps(test.givenImps) + + if test.expectedError == "" { + assert.NoError(t, err, test.description+":err") + } else { + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + + assert.Equal(t, test.expectedImps, imps, test.description+":imps") + } +} + +func TestCreateSanitizedImpExt(t *testing.T) { + testCases := []struct { + description string + givenImpExt map[string]json.RawMessage + givenImpExtPrebid map[string]json.RawMessage + expected map[string]json.RawMessage + expectedError string + }{ + { + description: "Nil", + givenImpExt: nil, + givenImpExtPrebid: nil, + expected: map[string]json.RawMessage{}, + expectedError: "", + }, + { + description: "Empty", + givenImpExt: map[string]json.RawMessage{}, + givenImpExtPrebid: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{}, + expectedError: "", + }, + { + description: "imp.ext.prebid - Bidders Only", + givenImpExt: map[string]json.RawMessage{ + "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{ + "bidder": json.RawMessage(`"anyBidder"`), + }, + expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + expectedError: "", + }, + { + description: "imp.ext.prebid - Bidders + Other Values", + givenImpExt: map[string]json.RawMessage{ + "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{ + "bidder": json.RawMessage(`"anyBidder"`), + "someOther": json.RawMessage(`"value"`), + }, + expected: map[string]json.RawMessage{ + "prebid": json.RawMessage(`{"someOther":"value"}`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + expectedError: "", + }, + { + description: "imp.ext", + givenImpExt: map[string]json.RawMessage{ + "anyBidder": json.RawMessage(`"anyBidderValues"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + expectedError: "", + }, + { + description: "imp.ext + imp.ext.prebid - Prebid Bidders Only", + givenImpExt: map[string]json.RawMessage{ + "anyBidder": json.RawMessage(`"anyBidderValues"`), + "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{ + "bidder": json.RawMessage(`"anyBidder"`), + }, + expected: map[string]json.RawMessage{ + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + expectedError: "", + }, + { + description: "imp.ext + imp.ext.prebid - Prebid Bidders + Other Values", + givenImpExt: map[string]json.RawMessage{ + "anyBidder": json.RawMessage(`"anyBidderValues"`), + "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{ + "bidder": json.RawMessage(`"anyBidder"`), + "someOther": json.RawMessage(`"value"`), + }, + expected: map[string]json.RawMessage{ + "prebid": json.RawMessage(`{"someOther":"value"}`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + expectedError: "", + }, + { + description: "Marshal Error - imp.ext.prebid", + givenImpExt: map[string]json.RawMessage{ + "prebid": json.RawMessage(`"ignoredInFavorOfSeparatelyUnmarshalledImpExtPrebid"`), + "data": json.RawMessage(`"anyData"`), + "context": json.RawMessage(`"anyContext"`), + "skadn": json.RawMessage(`"anySKAdNetwork"`), + }, + givenImpExtPrebid: map[string]json.RawMessage{ + "malformed": json.RawMessage(`json`), // String value without quotes. + }, + expected: nil, + expectedError: "cannot marshal ext.prebid: json: error calling MarshalJSON for type json.RawMessage: invalid character 'j' looking for beginning of value", + }, + } + + for _, test := range testCases { + result, err := createSanitizedImpExt(test.givenImpExt, test.givenImpExtPrebid) + + if test.expectedError == "" { + assert.NoError(t, err, test.description+":err") + } else { + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + + assert.Equal(t, test.expected, result, test.description) + } +} + +func TestExtractBidderExts(t *testing.T) { + bidderAJSON := json.RawMessage(`{"paramA":"valueA"}}`) + bidderBJSON := json.RawMessage(`{"paramB":"valueB"}}`) + + testCases := []struct { + description string + givenImpExt map[string]json.RawMessage + givenImpExtPrebidBidders map[string]json.RawMessage + expected map[string]json.RawMessage + }{ + { + description: "Nil", + givenImpExt: nil, + givenImpExtPrebidBidders: nil, + expected: map[string]json.RawMessage{}, + }, + { + description: "Empty", + givenImpExt: map[string]json.RawMessage{}, + givenImpExtPrebidBidders: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{}, + }, + { + description: "One - imp.ext.BIDDER", + givenImpExt: map[string]json.RawMessage{"bidderA": bidderAJSON}, + givenImpExtPrebidBidders: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON}, + }, + { + description: "Many - imp.ext.BIDDER", + givenImpExt: map[string]json.RawMessage{"bidderA": bidderAJSON, "bidderB": bidderBJSON}, + givenImpExtPrebidBidders: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON, "bidderB": bidderBJSON}, + }, + { + description: "Special Names Ignored - imp.ext.BIDDER", + givenImpExt: map[string]json.RawMessage{"prebid": json.RawMessage(`{"prebid":"value1"}}`), "context": json.RawMessage(`{"firstPartyData":"value2"}}`), "skadn": json.RawMessage(`{"skAdNetwork":"value3"}}`)}, + givenImpExtPrebidBidders: map[string]json.RawMessage{}, + expected: map[string]json.RawMessage{}, + }, + { + description: "One - imp.ext.prebid.bidder.BIDDER", + givenImpExt: map[string]json.RawMessage{}, + givenImpExtPrebidBidders: map[string]json.RawMessage{"bidderA": bidderAJSON}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON}, + }, + { + description: "Many - imp.ext.prebid.bidder.BIDDER", + givenImpExt: map[string]json.RawMessage{}, + givenImpExtPrebidBidders: map[string]json.RawMessage{"bidderA": bidderAJSON, "bidderB": bidderBJSON}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON, "bidderB": bidderBJSON}, + }, + { + description: "Special Names Not Treated Differently - imp.ext.prebid.bidder.BIDDER", + givenImpExt: map[string]json.RawMessage{}, + givenImpExtPrebidBidders: map[string]json.RawMessage{"prebid": json.RawMessage(`{"prebid":"value1"}}`), "context": json.RawMessage(`{"firstPartyData":"value2"}}`), "skadn": json.RawMessage(`{"skAdNetwork":"value3"}}`)}, + expected: map[string]json.RawMessage{"prebid": json.RawMessage(`{"prebid":"value1"}}`), "context": json.RawMessage(`{"firstPartyData":"value2"}}`), "skadn": json.RawMessage(`{"skAdNetwork":"value3"}}`)}, + }, + { + description: "Mixed - Both - imp.ext.BIDDER + imp.ext.prebid.bidder.BIDDER", + givenImpExt: map[string]json.RawMessage{"bidderA": bidderAJSON}, + givenImpExtPrebidBidders: map[string]json.RawMessage{"bidderB": bidderBJSON}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON, "bidderB": bidderBJSON}, + }, + { + description: "Mixed - Overwrites - imp.ext.BIDDER + imp.ext.prebid.bidder.BIDDER", + givenImpExt: map[string]json.RawMessage{"bidderA": json.RawMessage(`{"shouldBe":"Ignored"}}`)}, + givenImpExtPrebidBidders: map[string]json.RawMessage{"bidderA": bidderAJSON}, + expected: map[string]json.RawMessage{"bidderA": bidderAJSON}, + }, + } + + for _, test := range testCases { + result := extractBidderExts(test.givenImpExt, test.givenImpExtPrebidBidders) + assert.Equal(t, test.expected, result, test.description) + } +} + func TestCleanOpenRTBRequests(t *testing.T) { testCases := []struct { req AuctionRequest @@ -90,7 +465,7 @@ func TestCleanOpenRTBRequests(t *testing.T) { } for _, test := range testCases { - bidderRequests, _, err := cleanOpenRTBRequests(context.Background(), test.req, nil, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig) + bidderRequests, _, err := cleanOpenRTBRequests(context.Background(), test.req, nil, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig, nil) if test.hasError { assert.NotNil(t, err, "Error shouldn't be nil") } else { @@ -219,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 + `"}`), } @@ -247,7 +622,8 @@ func TestCleanOpenRTBRequestsCCPA(t *testing.T) { nil, &permissionsMock{personalInfoAllowed: true}, true, - privacyConfig) + privacyConfig, + nil) result := bidderRequests[0] assert.Nil(t, errs) @@ -273,7 +649,10 @@ func TestCleanOpenRTBRequestsCCPAErrors(t *testing.T) { description: "Invalid Consent", reqExt: json.RawMessage(`{"prebid":{"nosale":["*"]}}`), reqRegsExt: json.RawMessage(`{"us_privacy":"malformed"}`), - expectError: &errortypes.InvalidPrivacyConsent{"request.regs.ext.us_privacy must contain 4 characters"}, + expectError: &errortypes.Warning{ + Message: "request.regs.ext.us_privacy must contain 4 characters", + WarningCode: errortypes.InvalidPrivacyConsentWarningCode, + }, }, { description: "Invalid No Sale Bidders", @@ -286,7 +665,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) @@ -302,7 +681,7 @@ func TestCleanOpenRTBRequestsCCPAErrors(t *testing.T) { Enforce: true, }, } - _, _, errs := cleanOpenRTBRequests(context.Background(), auctionReq, &reqExtStruct, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig) + _, _, errs := cleanOpenRTBRequests(context.Background(), auctionReq, &reqExtStruct, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig, nil) assert.ElementsMatch(t, []error{test.expectError}, errs, test.description) } @@ -335,14 +714,14 @@ 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, UserSyncs: &emptyUsersync{}, } - bidderRequests, privacyLabels, errs := cleanOpenRTBRequests(context.Background(), auctionReq, nil, &permissionsMock{personalInfoAllowed: true}, true, config.Privacy{}) + bidderRequests, privacyLabels, errs := cleanOpenRTBRequests(context.Background(), auctionReq, nil, &permissionsMock{personalInfoAllowed: true}, true, config.Privacy{}, nil) result := bidderRequests[0] assert.Nil(t, errs) @@ -449,7 +828,7 @@ func TestCleanOpenRTBRequestsSChain(t *testing.T) { UserSyncs: &emptyUsersync{}, } - bidderRequests, _, errs := cleanOpenRTBRequests(context.Background(), auctionReq, extRequest, &permissionsMock{}, true, config.Privacy{}) + bidderRequests, _, errs := cleanOpenRTBRequests(context.Background(), auctionReq, extRequest, &permissionsMock{}, true, config.Privacy{}, nil) if test.hasError == true { assert.NotNil(t, errs) assert.Len(t, bidderRequests, 0) @@ -469,13 +848,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, @@ -490,7 +869,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, @@ -511,13 +890,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"), }, @@ -885,7 +1264,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 { @@ -900,7 +1279,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, }, { @@ -910,22 +1289,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, }, } @@ -1030,7 +1409,7 @@ func TestCleanOpenRTBRequestsLMT(t *testing.T) { }, } - results, privacyLabels, errs := cleanOpenRTBRequests(context.Background(), auctionReq, nil, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig) + results, privacyLabels, errs := cleanOpenRTBRequests(context.Background(), auctionReq, nil, &permissionsMock{personalInfoAllowed: true}, true, privacyConfig, nil) result := results[0] assert.Nil(t, errs) @@ -1215,7 +1594,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 + `}`), } @@ -1247,7 +1626,8 @@ func TestCleanOpenRTBRequestsGDPR(t *testing.T) { nil, &permissionsMock{personalInfoAllowed: !test.gdprScrub, personalInfoAllowedError: test.permissionsError}, test.userSyncIfAmbiguous, - privacyConfig) + privacyConfig, + nil) result := results[0] if test.expectError { @@ -1268,17 +1648,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", @@ -1286,21 +1666,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, }, { @@ -1314,35 +1694,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, }, { @@ -1591,8 +1971,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{ @@ -1603,8 +1983,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) @@ -1637,8 +2017,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{ @@ -1659,12 +2039,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{ @@ -1679,8 +2059,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{ @@ -1694,15 +2074,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/gdpr/gdpr.go b/gdpr/gdpr.go index 272bc1f21f0..616d0f0ae07 100644 --- a/gdpr/gdpr.go +++ b/gdpr/gdpr.go @@ -5,10 +5,10 @@ import ( "net/http" "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/prebid/go-gdpr/vendorlist" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" ) type Permissions interface { @@ -25,7 +25,7 @@ type Permissions interface { // Determines whether or not to send PI information to a bidder, or mask it out. // // If the consent string was nonsensical, the returned error will be an ErrorMalformedConsent. - PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string) (bool, bool, bool, error) + PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) } // Versions of the GDPR TCF technical specification. @@ -44,8 +44,8 @@ func NewPermissions(ctx context.Context, cfg config.GDPR, vendorIDs map[openrtb_ cfg: cfg, vendorIDs: vendorIDs, fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){ - tcf1SpecVersion: newVendorListFetcher(ctx, cfg, client, vendorListURLMaker, tcf1SpecVersion), - tcf2SpecVersion: newVendorListFetcher(ctx, cfg, client, vendorListURLMaker, tcf2SpecVersion)}, + tcf1SpecVersion: newVendorListFetcherTCF1(cfg), + tcf2SpecVersion: newVendorListFetcherTCF2(ctx, cfg, client, vendorListURLMaker)}, } if cfg.HostVendorID == 0 { diff --git a/gdpr/gdpr_test.go b/gdpr/gdpr_test.go index 81d3c6156f7..5048cf118f5 100644 --- a/gdpr/gdpr_test.go +++ b/gdpr/gdpr_test.go @@ -5,8 +5,8 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/gdpr/impl.go b/gdpr/impl.go index 8d9a357393d..55d1cd4aeb0 100644 --- a/gdpr/impl.go +++ b/gdpr/impl.go @@ -4,18 +4,18 @@ import ( "context" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/prebid/go-gdpr/api" tcf1constants "github.com/prebid/go-gdpr/consentconstants" consentconstants "github.com/prebid/go-gdpr/consentconstants/tcf2" "github.com/prebid/go-gdpr/vendorconsent" tcf2 "github.com/prebid/go-gdpr/vendorconsent/tcf2" "github.com/prebid/go-gdpr/vendorlist" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) // This file implements GDPR permissions for the app. -// For more info, see https://github.com/PubMatic-OpenWrap/prebid-server/issues/501 +// For more info, see https://github.com/prebid/prebid-server/issues/501 // // Nothing in this file is exported. Public APIs can be found in gdpr.go @@ -58,7 +58,12 @@ func (p *permissionsImpl) BidderSyncAllowed(ctx context.Context, bidder openrtb_ return false, nil } -func (p *permissionsImpl) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string) (allowPI bool, allowGeo bool, allowID bool, err error) { +func (p *permissionsImpl) PersonalInfoAllowed(ctx context.Context, + bidder openrtb_ext.BidderName, + PublisherID string, + gdprSignal Signal, + consent string, + weakVendorEnforcement bool) (allowPI bool, allowGeo bool, allowID bool, err error) { if _, ok := p.cfg.NonStandardPublisherMap[PublisherID]; ok { return true, true, true, nil } @@ -74,7 +79,7 @@ func (p *permissionsImpl) PersonalInfoAllowed(ctx context.Context, bidder openrt } if id, ok := p.vendorIDs[bidder]; ok { - return p.allowPI(ctx, id, consent) + return p.allowPI(ctx, id, consent, weakVendorEnforcement) } return p.defaultVendorPermissions() @@ -122,7 +127,7 @@ func (p *permissionsImpl) allowSync(ctx context.Context, vendorID uint16, consen err := fmt.Errorf("Unable to access TCF2 parsed consent") return false, err } - return p.checkPurpose(consent, vendor, vendorID, consentconstants.InfoStorageAccess), nil + return p.checkPurpose(consent, vendor, vendorID, consentconstants.InfoStorageAccess, false), nil } if vendor.Purpose(consentconstants.InfoStorageAccess) && parsedConsent.PurposeAllowed(consentconstants.InfoStorageAccess) && parsedConsent.VendorConsent(vendorID) { return true, nil @@ -130,7 +135,7 @@ func (p *permissionsImpl) allowSync(ctx context.Context, vendorID uint16, consen return false, nil } -func (p *permissionsImpl) allowPI(ctx context.Context, vendorID uint16, consent string) (bool, bool, bool, error) { +func (p *permissionsImpl) allowPI(ctx context.Context, vendorID uint16, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { parsedConsent, vendor, err := p.parseVendor(ctx, vendorID, consent) if err != nil { return false, false, false, err @@ -142,9 +147,9 @@ func (p *permissionsImpl) allowPI(ctx context.Context, vendorID uint16, consent if parsedConsent.Version() == 2 { if p.cfg.TCF2.Enabled { - return p.allowPITCF2(parsedConsent, vendor, vendorID) + return p.allowPITCF2(parsedConsent, vendor, vendorID, weakVendorEnforcement) } - if (vendor.Purpose(consentconstants.InfoStorageAccess) || vendor.LegitimateInterest(consentconstants.InfoStorageAccess)) && parsedConsent.PurposeAllowed(consentconstants.InfoStorageAccess) && (vendor.Purpose(consentconstants.PersonalizationProfile) || vendor.LegitimateInterest(consentconstants.PersonalizationProfile)) && parsedConsent.PurposeAllowed(consentconstants.PersonalizationProfile) && parsedConsent.VendorConsent(vendorID) { + if (vendor.Purpose(consentconstants.InfoStorageAccess) || vendor.LegitimateInterest(consentconstants.InfoStorageAccess) || weakVendorEnforcement) && parsedConsent.PurposeAllowed(consentconstants.InfoStorageAccess) && (vendor.Purpose(consentconstants.PersonalizationProfile) || vendor.LegitimateInterest(consentconstants.PersonalizationProfile) || weakVendorEnforcement) && parsedConsent.PurposeAllowed(consentconstants.PersonalizationProfile) && (parsedConsent.VendorConsent(vendorID) || weakVendorEnforcement) { return true, true, true, nil } } else { @@ -155,7 +160,7 @@ func (p *permissionsImpl) allowPI(ctx context.Context, vendorID uint16, consent return false, false, false, nil } -func (p *permissionsImpl) allowPITCF2(parsedConsent api.VendorConsents, vendor api.Vendor, vendorID uint16) (allowPI bool, allowGeo bool, allowID bool, err error) { +func (p *permissionsImpl) allowPITCF2(parsedConsent api.VendorConsents, vendor api.Vendor, vendorID uint16, weakVendorEnforcement bool) (allowPI bool, allowGeo bool, allowID bool, err error) { consent, ok := parsedConsent.(tcf2.ConsentMetadata) err = nil allowPI = false @@ -166,12 +171,12 @@ func (p *permissionsImpl) allowPITCF2(parsedConsent api.VendorConsents, vendor a return } if p.cfg.TCF2.SpecialPurpose1.Enabled { - allowGeo = consent.SpecialFeatureOptIn(1) && vendor.SpecialPurpose(1) + allowGeo = consent.SpecialFeatureOptIn(1) && (vendor.SpecialPurpose(1) || weakVendorEnforcement) } else { allowGeo = true } for i := 2; i <= 10; i++ { - if p.checkPurpose(consent, vendor, vendorID, tcf1constants.Purpose(i)) { + if p.checkPurpose(consent, vendor, vendorID, tcf1constants.Purpose(i), weakVendorEnforcement) { allowID = true break } @@ -179,13 +184,13 @@ func (p *permissionsImpl) allowPITCF2(parsedConsent api.VendorConsents, vendor a // Set to true so any purpose check can flip it to false allowPI = true if p.cfg.TCF2.Purpose1.Enabled { - allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.InfoStorageAccess) + allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.InfoStorageAccess, weakVendorEnforcement) } if p.cfg.TCF2.Purpose2.Enabled { - allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.BasicAdserving) + allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.BasicAdserving, weakVendorEnforcement) } if p.cfg.TCF2.Purpose7.Enabled { - allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.AdPerformance) + allowPI = allowPI && p.checkPurpose(consent, vendor, vendorID, consentconstants.AdPerformance, weakVendorEnforcement) } return } @@ -194,22 +199,24 @@ const pubRestrictNotAllowed = 0 const pubRestrictRequireConsent = 1 const pubRestrictRequireLegitInterest = 2 -func (p *permissionsImpl) checkPurpose(consent tcf2.ConsentMetadata, vendor api.Vendor, vendorID uint16, purpose tcf1constants.Purpose) bool { +func (p *permissionsImpl) checkPurpose(consent tcf2.ConsentMetadata, vendor api.Vendor, vendorID uint16, purpose tcf1constants.Purpose, weakVendorEnforcement bool) bool { if purpose == consentconstants.InfoStorageAccess && p.cfg.TCF2.PurposeOneTreatment.Enabled && consent.PurposeOneTreatment() { return p.cfg.TCF2.PurposeOneTreatment.AccessAllowed } if consent.CheckPubRestriction(uint8(purpose), pubRestrictNotAllowed, vendorID) { return false } + + purposeAllowed := consent.PurposeAllowed(purpose) && (weakVendorEnforcement || (vendor.Purpose(purpose) && consent.VendorConsent(vendorID))) + legitInterest := consent.PurposeLITransparency(purpose) && (weakVendorEnforcement || (vendor.LegitimateInterest(purpose) && consent.VendorLegitInterest(vendorID))) + if consent.CheckPubRestriction(uint8(purpose), pubRestrictRequireConsent, vendorID) { - return vendor.PurposeStrict(purpose) && consent.PurposeAllowed(purpose) && consent.VendorConsent(vendorID) + return purposeAllowed } if consent.CheckPubRestriction(uint8(purpose), pubRestrictRequireLegitInterest, vendorID) { // Need LITransparency here - return vendor.LegitimateInterestStrict(purpose) && consent.PurposeLITransparency(purpose) && consent.VendorLegitInterest(vendorID) + return legitInterest } - purposeAllowed := vendor.Purpose(purpose) && consent.PurposeAllowed(purpose) && consent.VendorConsent(vendorID) - legitInterest := vendor.LegitimateInterest(purpose) && consent.PurposeLITransparency(purpose) && consent.VendorLegitInterest(vendorID) return purposeAllowed || legitInterest } @@ -258,7 +265,7 @@ func (a AlwaysAllow) BidderSyncAllowed(ctx context.Context, bidder openrtb_ext.B return true, nil } -func (a AlwaysAllow) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string) (bool, bool, bool, error) { +func (a AlwaysAllow) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return true, true, true, nil } @@ -273,6 +280,6 @@ func (a AlwaysFail) BidderSyncAllowed(ctx context.Context, bidder openrtb_ext.Bi return false, nil } -func (a AlwaysFail) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string) (bool, bool, bool, error) { +func (a AlwaysFail) PersonalInfoAllowed(ctx context.Context, bidder openrtb_ext.BidderName, PublisherID string, gdprSignal Signal, consent string, weakVendorEnforcement bool) (bool, bool, bool, error) { return false, false, false, nil } diff --git a/gdpr/impl_test.go b/gdpr/impl_test.go index 1977c4cf62e..b13d469a955 100644 --- a/gdpr/impl_test.go +++ b/gdpr/impl_test.go @@ -6,8 +6,8 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/prebid/go-gdpr/vendorlist" "github.com/prebid/go-gdpr/vendorlist2" @@ -175,13 +175,14 @@ func TestAllowPersonalInfo(t *testing.T) { consent := "BOS2bx5OS2bx5ABABBAAABoAAAABBwAA" tests := []struct { - description string - bidderName openrtb_ext.BidderName - publisherID string - userSyncIfAmbiguous bool - gdpr Signal - consent string - allowPI bool + description string + bidderName openrtb_ext.BidderName + publisherID string + userSyncIfAmbiguous bool + gdpr Signal + consent string + allowPI bool + weakVendorEnforcement bool }{ { description: "Allow PI - Non standard publisher", @@ -285,7 +286,7 @@ func TestAllowPersonalInfo(t *testing.T) { for _, tt := range tests { perms.cfg.UsersyncIfAmbiguous = tt.userSyncIfAmbiguous - allowPI, _, _, err := perms.PersonalInfoAllowed(context.Background(), tt.bidderName, tt.publisherID, tt.gdpr, tt.consent) + allowPI, _, _, err := perms.PersonalInfoAllowed(context.Background(), tt.bidderName, tt.publisherID, tt.gdpr, tt.consent, tt.weakVendorEnforcement) assert.Nil(t, err, tt.description) assert.Equal(t, tt.allowPI, allowPI, tt.description) @@ -317,6 +318,12 @@ func buildTCF2VendorList34() tcf2VendorList { Purposes: []int{2, 4, 7}, SpecialPurposes: []int{1}, }, + "20": { + ID: 20, + Purposes: []int{1}, + LegIntPurposes: []int{2, 7}, + FlexiblePurposes: []int{2, 7}, + }, "32": { ID: 32, Purposes: []int{1, 2, 4, 7}, @@ -337,12 +344,13 @@ var tcf2Config = config.GDPR{ } type tcf2TestDef struct { - description string - bidder openrtb_ext.BidderName - consent string - allowPI bool - allowGeo bool - allowID bool + description string + bidder openrtb_ext.BidderName + consent string + allowPI bool + allowGeo bool + allowID bool + weakVendorEnforcement bool } func TestAllowPersonalInfoTCF2(t *testing.T) { @@ -353,11 +361,13 @@ func TestAllowPersonalInfoTCF2(t *testing.T) { openrtb_ext.BidderAppnexus: 2, openrtb_ext.BidderPubmatic: 6, openrtb_ext.BidderRubicon: 8, + openrtb_ext.BidderOpenx: 20, }, fetchVendorList: map[uint8]func(ctx context.Context, id uint16) (vendorlist.VendorList, error){ tcf1SpecVersion: nil, tcf2SpecVersion: listFetcher(map[uint16]vendorlist.VendorList{ 34: parseVendorListDataV2(t, vendorListData), + 74: parseVendorListDataV2(t, vendorListData), }), }, } @@ -373,6 +383,15 @@ func TestAllowPersonalInfoTCF2(t *testing.T) { allowGeo: false, allowID: false, }, + { + description: "Appnexus vendor test, insufficient purposes claimed, basic enforcement", + bidder: openrtb_ext.BidderAppnexus, + consent: "COzTVhaOzTVhaGvAAAENAiCIAP_AAH_AAAAAAEEUACCKAAA", + allowPI: true, + allowGeo: true, + allowID: true, + weakVendorEnforcement: true, + }, { description: "Pubmatic vendor test, flex purposes claimed", bidder: openrtb_ext.BidderPubmatic, @@ -389,10 +408,21 @@ func TestAllowPersonalInfoTCF2(t *testing.T) { allowGeo: false, allowID: true, }, + { + // This requires publisher restrictions on any claimed purposes, 2-10. Vendor must declare all claimed purposes + // as flex with legit interest as primary. + // Using vendor 20 for this. + description: "OpenX vendor test, Specific purposes/LIs claimed, no geo claimed, Publisher restrictions apply", + bidder: openrtb_ext.BidderOpenx, + consent: "CPAavcCPAavcCAGABCFRBKCsAP_AAH_AAAqIHFNf_X_fb3_j-_59_9t0eY1f9_7_v-0zjgeds-8Nyd_X_L8X5mM7vB36pq4KuR4Eu3LBAQdlHOHcTUmw6IkVqTPsbk2Mr7NKJ7PEinMbe2dYGH9_n9XT_ZKY79_____7__-_____7_f__-__3_vp9V---wOJAIMBAUAgAEMAAQIFCIQAAQhiQAAAABBCIBQJIAEqgAWVwEdoIEACAxAQgQAgBBQgwCAAQAAJKAgBACwQCAAiAQAAgAEAIAAEIAILACQEAAAEAJCAAiACECAgiAAg5DAgIgCCAFABAAAuJDACAMooASBAPGQGAAKAAqACGAEwALgAjgBlgDUAHZAPsA_ACMAFLAK2AbwBMQCbAFogLYAYEAw8BkQDOQGeAM-EQHwAVABWAC4AIYAZAAywBqADZAHYAPwAgABGAClgFPANYAdUA-QCGwEOgIvASIAmwBOwCkQFyAMCAYSAw8Bk4DOQGfCQAYADgBzgN_CQTgAEAALgAoACoAGQAOAAeABAACIAFQAMIAaABqADyAIYAigBMgCqAKwAWAAuABvADmAHoAQ0AiACJgEsAS4AmgBSgC3AGGAMgAZcA1ADVAGyAO8AewA-IB9gH6AQAAjABQQClgFPAL8AYoA1gBtADcAG8AOIAegA-QCGwEOgIqAReAkQBMQCZQE2AJ2AUOApEBYoC2AFyALvAYEAwYBhIDDQGHgMiAZIAycBlwDOQGfANIAadA1gDWQoAEAYQaBIACoAKwAXABDADIAGWANQAbIA7AB-AEAAIKARgApYBT4C0ALSAawA3gB1QD5AIbAQ6Ai8BIgCbAE7AKRAXIAwIBhIDDwGMAMnAZyAzwBnwcAEAA4Bv4qA2ABQAFQAQwAmABcAEcAMsAagA7AB-AEYAKXAWgBaQDeAJBATEAmwBTYC2AFyAMCAYeAyIBnIDPAGfANyHQWQAFwAUABUADIAHAAQAAiABdADAAMYAaABqADwAH0AQwBFACZAFUAVgAsABcADEAGYAN4AcwA9ACGAERAJYAmABNACjAFKALEAW4AwwBkADKAGiANQAbIA3wB3gD2gH2AfoBGACVAFBAKeAWKAtAC0gFzALyAX4AxQBuADiQHTAdQA9ACGwEOgIiAReAkEBIgCbAE7AKHAU0AqwBYsC2ALZAXAAuQBdoC7wGEgMNAYeAxIBjADHgGSAMnAZUAywBlwDOQGfANEgaQBpIDSwGnANYAbGPABAIqAb-QgZgALAAoABkAEQALgAYgBDACYAFUALgAYgAzABvAD0AI4AWIAygBqADfAHfAPsA_ACMAFBAKGAU-AtAC0gF-AMUAdQA9ACQQEiAJsAU0AsUBaMC2ALaAXAAuQBdoDDwGJAMiAZOAzkBngDPgGiANJAaWA4AlAyAAQAAsACgAGQAOAAigBgAGIAPAAiABMACqAFwAMQAZgA2gCGgEQARIAowBSgC3AGEAMoAaoA2QB3gD8AIwAU-AtAC0gGKANwAcQA6gCHQEXgJEATYAsUBbAC7QGHgMiAZOAywBnIDPAGfANIAawA4AmACARUA38pBBAAXABQAFQAMgAcABAACKAGAAYwA0ADUAHkAQwBFACYAFIAKoAWAAuABiADMAHMAQwAiABRgClAFiALcAZQA0QBqgDZAHfAPsA_ACMAFBAKGAVsAuYBeQDaAG4APQAh0BF4CRAE2AJ2AUOApoBWwCxQFsALgAXIAu0BhoDDwGMAMiAZIAycBlwDOQGeAM-gaQBpMDWANZAbGVABAA-Ab-A.YAAAAAAAAAAA", + allowPI: true, + allowGeo: false, + allowID: true, + }, } for _, td := range testDefs { - allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent) + allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent, td.weakVendorEnforcement) assert.NoErrorf(t, err, "Error processing PersonalInfoAllowed for %s", td.description) assert.EqualValuesf(t, td.allowPI, allowPI, "AllowPI failure on %s", td.description) assert.EqualValuesf(t, td.allowGeo, allowGeo, "AllowGeo failure on %s", td.description) @@ -418,7 +448,7 @@ func TestAllowPersonalInfoWhitelistTCF2(t *testing.T) { } // Assert that an item that otherwise would not be allowed PI access, gets approved because it is found in the GDPR.NonStandardPublishers array perms.cfg.NonStandardPublisherMap = map[string]struct{}{"appNexusAppID": {}} - allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), openrtb_ext.BidderAppnexus, "appNexusAppID", SignalYes, "COzTVhaOzTVhaGvAAAENAiCIAP_AAH_AAAAAAEEUACCKAAA") + allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), openrtb_ext.BidderAppnexus, "appNexusAppID", SignalYes, "COzTVhaOzTVhaGvAAAENAiCIAP_AAH_AAAAAAEEUACCKAAA", false) assert.NoErrorf(t, err, "Error processing PersonalInfoAllowed") assert.EqualValuesf(t, true, allowPI, "AllowPI failure") assert.EqualValuesf(t, true, allowGeo, "AllowGeo failure") @@ -472,7 +502,7 @@ func TestAllowPersonalInfoTCF2PubRestrict(t *testing.T) { } for _, td := range testDefs { - allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent) + allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent, td.weakVendorEnforcement) assert.NoErrorf(t, err, "Error processing PersonalInfoAllowed for %s", td.description) assert.EqualValuesf(t, td.allowPI, allowPI, "AllowPI failure on %s", td.description) assert.EqualValuesf(t, td.allowGeo, allowGeo, "AllowGeo failure on %s", td.description) @@ -528,7 +558,7 @@ func TestAllowPersonalInfoTCF2PurposeOneTrue(t *testing.T) { } for _, td := range testDefs { - allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent) + allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent, td.weakVendorEnforcement) assert.NoErrorf(t, err, "Error processing PersonalInfoAllowed for %s", td.description) assert.EqualValuesf(t, td.allowPI, allowPI, "AllowPI failure on %s", td.description) assert.EqualValuesf(t, td.allowGeo, allowGeo, "AllowGeo failure on %s", td.description) @@ -585,7 +615,7 @@ func TestAllowPersonalInfoTCF2PurposeOneFalse(t *testing.T) { } for _, td := range testDefs { - allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent) + allowPI, allowGeo, allowID, err := perms.PersonalInfoAllowed(context.Background(), td.bidder, "", SignalYes, td.consent, td.weakVendorEnforcement) assert.NoErrorf(t, err, "Error processing PersonalInfoAllowed for %s", td.description) assert.EqualValuesf(t, td.allowPI, allowPI, "AllowPI failure on %s", td.description) assert.EqualValuesf(t, td.allowGeo, allowGeo, "AllowGeo failure on %s", td.description) diff --git a/gdpr/vendorlist-fetching.go b/gdpr/vendorlist-fetching.go index 61fa166d212..bc7eab40647 100644 --- a/gdpr/vendorlist-fetching.go +++ b/gdpr/vendorlist-fetching.go @@ -10,11 +10,11 @@ import ( "sync/atomic" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" "github.com/golang/glog" "github.com/prebid/go-gdpr/api" "github.com/prebid/go-gdpr/vendorlist" "github.com/prebid/go-gdpr/vendorlist2" + "github.com/prebid/prebid-server/config" "golang.org/x/net/context/ctxhttp" ) @@ -22,34 +22,44 @@ type saveVendors func(uint16, api.VendorList) // This file provides the vendorlist-fetching function for Prebid Server. // -// For more info, see https://github.com/PubMatic-OpenWrap/prebid-server/issues/504 +// For more info, see https://github.com/prebid/prebid-server/issues/504 // // Nothing in this file is exported. Public APIs can be found in gdpr.go -func newVendorListFetcher(initCtx context.Context, cfg config.GDPR, client *http.Client, urlMaker func(uint16, uint8) string, tcfSpecVersion uint8) func(ctx context.Context, id uint16) (vendorlist.VendorList, error) { - var fallback api.VendorList - - if tcfSpecVersion == tcf1SpecVersion && len(cfg.TCF1.FallbackGVLPath) == 0 { - return func(ctx context.Context, vendorListVersion uint16) (vendorlist.VendorList, error) { +func newVendorListFetcherTCF1(cfg config.GDPR) func(ctx context.Context, id uint16) (vendorlist.VendorList, error) { + if len(cfg.TCF1.FallbackGVLPath) == 0 { + return func(_ context.Context, vendorListVersion uint16) (vendorlist.VendorList, error) { return nil, makeVendorListNotFoundError(vendorListVersion) } } - if tcfSpecVersion == tcf1SpecVersion { - fallback = loadFallbackGVL(cfg.TCF1.FallbackGVLPath) + fallback := loadFallbackGVLForTCF1(cfg.TCF1.FallbackGVLPath) + return func(_ context.Context, _ uint16) (vendorlist.VendorList, error) { + return fallback, nil + } +} - return func(ctx context.Context, vendorListVersion uint16) (vendorlist.VendorList, error) { - return fallback, nil - } +func loadFallbackGVLForTCF1(fallbackGVLPath string) vendorlist.VendorList { + fallbackContents, err := ioutil.ReadFile(fallbackGVLPath) + if err != nil { + glog.Fatalf("Error reading from file %s: %v", fallbackGVLPath, err) + } + + fallback, err := vendorlist.ParseEagerly(fallbackContents) + if err != nil { + glog.Fatalf("Error processing default GVL from %s: %v", fallbackGVLPath, err) } + return fallback +} - cacheSave, cacheLoad := newVendorListCache(fallback) +func newVendorListFetcherTCF2(initCtx context.Context, cfg config.GDPR, client *http.Client, urlMaker func(uint16) string) func(ctx context.Context, id uint16) (vendorlist.VendorList, error) { + cacheSave, cacheLoad := newVendorListCache() preloadContext, cancel := context.WithTimeout(initCtx, cfg.Timeouts.InitTimeout()) defer cancel() - preloadCache(preloadContext, client, urlMaker, cacheSave, tcfSpecVersion) + preloadCache(preloadContext, client, urlMaker, cacheSave) - saveOneRateLimited := newOccasionalSaver(cfg.Timeouts.ActiveTimeout(), tcfSpecVersion) + saveOneRateLimited := newOccasionalSaver(cfg.Timeouts.ActiveTimeout()) return func(ctx context.Context, vendorListVersion uint16) (vendorlist.VendorList, error) { // Attempt To Load From Cache if list := cacheLoad(vendorListVersion); list != nil { @@ -58,7 +68,7 @@ func newVendorListFetcher(initCtx context.Context, cfg config.GDPR, client *http // Attempt To Download // - May not add to cache immediately. - saveOneRateLimited(ctx, client, urlMaker(vendorListVersion, tcfSpecVersion), cacheSave) + saveOneRateLimited(ctx, client, urlMaker(vendorListVersion), cacheSave) // Attempt To Load From Cache Again // - May have been added by the call to saveOneRateLimited. @@ -66,11 +76,6 @@ func newVendorListFetcher(initCtx context.Context, cfg config.GDPR, client *http return list, nil } - // Attempt To Use Hardcoded Fallback - if fallback != nil { - return fallback, nil - } - // Give Up return nil, makeVendorListNotFoundError(vendorListVersion) } @@ -81,27 +86,24 @@ func makeVendorListNotFoundError(vendorListVersion uint16) error { } // preloadCache saves all the known versions of the vendor list for future use. -func preloadCache(ctx context.Context, client *http.Client, urlMaker func(uint16, uint8) string, saver saveVendors, tcfSpecVersion uint8) { - latestVersion := saveOne(ctx, client, urlMaker(0, tcfSpecVersion), saver, tcfSpecVersion) +func preloadCache(ctx context.Context, client *http.Client, urlMaker func(uint16) string, saver saveVendors) { + latestVersion := saveOne(ctx, client, urlMaker(0), saver) - for i := uint16(1); i < latestVersion; i++ { - saveOne(ctx, client, urlMaker(i, tcfSpecVersion), saver, tcfSpecVersion) + // The GVL for TCF2 has no vendors defined in its first version. It's very unlikely to be used, so don't preload it. + firstVersionToLoad := uint16(2) + + for i := firstVersionToLoad; i < latestVersion; i++ { + saveOne(ctx, client, urlMaker(i), saver) } } // Make a URL which can be used to fetch a given version of the Global Vendor List. If the version is 0, // this will fetch the latest version. -func vendorListURLMaker(vendorListVersion uint16, tcfSpecVersion uint8) string { - if tcfSpecVersion == tcf2SpecVersion { - if vendorListVersion == 0 { - return "https://vendor-list.consensu.org/v2/vendor-list.json" - } - return "https://vendor-list.consensu.org/v2/archives/vendor-list-v" + strconv.Itoa(int(vendorListVersion)) + ".json" - } +func vendorListURLMaker(vendorListVersion uint16) string { if vendorListVersion == 0 { - return "https://vendor-list.consensu.org/vendorlist.json" + return "https://vendor-list.consensu.org/v2/vendor-list.json" } - return "https://vendor-list.consensu.org/v-" + strconv.Itoa(int(vendorListVersion)) + "/vendorlist.json" + return "https://vendor-list.consensu.org/v2/archives/vendor-list-v" + strconv.Itoa(int(vendorListVersion)) + ".json" } // newOccasionalSaver returns a wrapped version of saveOne() which only activates every few minutes. @@ -109,7 +111,7 @@ func vendorListURLMaker(vendorListVersion uint16, tcfSpecVersion uint8) string { // The goal here is to update quickly when new versions of the VendorList are released, but not wreck // server performance if a bad CMP starts sending us malformed consent strings that advertize a version // that doesn't exist yet. -func newOccasionalSaver(timeout time.Duration, tcfSpecVersion uint8) func(ctx context.Context, client *http.Client, url string, saver saveVendors) { +func newOccasionalSaver(timeout time.Duration) func(ctx context.Context, client *http.Client, url string, saver saveVendors) { lastSaved := &atomic.Value{} lastSaved.Store(time.Time{}) @@ -120,13 +122,13 @@ func newOccasionalSaver(timeout time.Duration, tcfSpecVersion uint8) func(ctx co if timeSinceLastSave.Minutes() > 10 { withTimeout, cancel := context.WithTimeout(ctx, timeout) defer cancel() - saveOne(withTimeout, client, url, saver, tcfSpecVersion) + saveOne(withTimeout, client, url, saver) lastSaved.Store(now) } } } -func saveOne(ctx context.Context, client *http.Client, url string, saver saveVendors, tcfSpecVersion uint8) uint16 { +func saveOne(ctx context.Context, client *http.Client, url string, saver saveVendors) uint16 { req, err := http.NewRequest("GET", url, nil) if err != nil { glog.Errorf("Failed to build GET %s request. Cookie syncs may be affected: %v", url, err) @@ -150,11 +152,7 @@ func saveOne(ctx context.Context, client *http.Client, url string, saver saveVen return 0 } var newList api.VendorList - if tcfSpecVersion == tcf2SpecVersion { - newList, err = vendorlist2.ParseEagerly(respBody) - } else { - newList, err = vendorlist.ParseEagerly(respBody) - } + newList, err = vendorlist2.ParseEagerly(respBody) if err != nil { glog.Errorf("GET %s returned malformed JSON. Cookie syncs may be affected. Error was %v. Body was %s", url, err, string(respBody)) return 0 @@ -164,7 +162,7 @@ func saveOne(ctx context.Context, client *http.Client, url string, saver saveVen return newList.Version() } -func newVendorListCache(fallbackVL api.VendorList) (save func(vendorListVersion uint16, list api.VendorList), load func(vendorListVersion uint16) api.VendorList) { +func newVendorListCache() (save func(vendorListVersion uint16, list api.VendorList), load func(vendorListVersion uint16) api.VendorList) { cache := &sync.Map{} save = func(vendorListVersion uint16, list api.VendorList) { @@ -180,16 +178,3 @@ func newVendorListCache(fallbackVL api.VendorList) (save func(vendorListVersion } return } - -func loadFallbackGVL(fallbackGVLPath string) vendorlist.VendorList { - fallbackContents, err := ioutil.ReadFile(fallbackGVLPath) - if err != nil { - glog.Fatalf("Error reading from file %s: %v", fallbackGVLPath, err) - } - - fallback, err := vendorlist.ParseEagerly(fallbackContents) - if err != nil { - glog.Fatalf("Error processing default GVL from %s: %v", fallbackGVLPath, err) - } - return fallback -} diff --git a/gdpr/vendorlist-fetching_test.go b/gdpr/vendorlist-fetching_test.go index cd97b300883..27f1bc3b996 100644 --- a/gdpr/vendorlist-fetching_test.go +++ b/gdpr/vendorlist-fetching_test.go @@ -10,8 +10,8 @@ import ( "github.com/stretchr/testify/assert" - "github.com/PubMatic-OpenWrap/prebid-server/config" "github.com/prebid/go-gdpr/consentconstants" + "github.com/prebid/prebid-server/config" ) func TestTCF1FetcherInitialLoad(t *testing.T) { @@ -66,67 +66,13 @@ func TestTCF1FetcherInitialLoad(t *testing.T) { } for _, test := range testCases { - runTest(t, test, tcf1SpecVersion, server) - } -} - -func TestTCF2FetcherInitialLoad(t *testing.T) { - // Loads two vendor lists during initialization by setting the latest vendor list version to 2. - // Ensures TCF1 fetch settings have no effect on TCF2. - - server := httptest.NewServer(http.HandlerFunc(mockServer(serverSettings{ - vendorListLatestVersion: 2, - vendorLists: map[int]string{ - 1: tcf2VendorList1, - 2: tcf2VendorList2, - }, - }))) - defer server.Close() - - testCases := []test{ - { - description: "Fallback - Vendor List 1", - setup: testSetup{ - enableTCF1Fallback: true, - vendorListVersion: 1, - }, - expected: vendorList1Expected, - }, - { - description: "Fallback - Vendor List 2", - setup: testSetup{ - enableTCF1Fallback: true, - vendorListVersion: 2, - }, - expected: vendorList2Expected, - }, - { - description: "No Fallback - Vendor List 1", - setup: testSetup{ - enableTCF1Fallback: false, - vendorListVersion: 1, - }, - expected: vendorList1Expected, - }, - { - description: "No Fallback - Vendor List 2", - setup: testSetup{ - enableTCF1Fallback: false, - vendorListVersion: 2, - }, - expected: vendorList2Expected, - }, - } - - for _, test := range testCases { - runTest(t, test, tcf2SpecVersion, server) + runTestTCF1(t, test, server) } } func TestTCF2FetcherDynamicLoadListExists(t *testing.T) { // Loads the first vendor list during initialization by setting the latest vendor list version to 1. // All other vendor lists will be dynamically loaded. - // Ensures TCF1 fetch settings have no effect on TCF2. server := httptest.NewServer(http.HandlerFunc(mockServer(serverSettings{ vendorListLatestVersion: 1, @@ -137,34 +83,20 @@ func TestTCF2FetcherDynamicLoadListExists(t *testing.T) { }))) defer server.Close() - testCases := []test{ - { - description: "Fallback - Vendor List 2", - setup: testSetup{ - enableTCF1Fallback: true, - vendorListVersion: 2, - }, - expected: vendorList2Expected, - }, - { - description: "No Fallback - Vendor List 2", - setup: testSetup{ - enableTCF1Fallback: false, - vendorListVersion: 2, - }, - expected: vendorList2Expected, + test := test{ + description: "Dynamic Load - List Exists", + setup: testSetup{ + vendorListVersion: 2, }, + expected: vendorList2Expected, } - for _, test := range testCases { - runTest(t, test, tcf2SpecVersion, server) - } + runTestTCF2(t, test, server) } func TestTCF2FetcherDynamicLoadListDoesntExist(t *testing.T) { // Loads the first vendor list during initialization by setting the latest vendor list version to 1. // All other vendor list load attempts will be done dynamically. - // Ensures TCF1 fetch settings have no effect on TCF2. server := httptest.NewServer(http.HandlerFunc(mockServer(serverSettings{ vendorListLatestVersion: 1, @@ -174,32 +106,17 @@ func TestTCF2FetcherDynamicLoadListDoesntExist(t *testing.T) { }))) defer server.Close() - testCases := []test{ - { - description: "Fallback - Vendor Doesn't Exist", - setup: testSetup{ - enableTCF1Fallback: true, - vendorListVersion: 2, - }, - expected: testExpected{ - errorMessage: "gdpr vendor list version 2 does not exist, or has not been loaded yet. Try again in a few minutes", - }, + test := test{ + description: "No Fallback - Vendor Doesn't Exist", + setup: testSetup{ + vendorListVersion: 2, }, - { - description: "No Fallback - Vendor Doesn't Exist", - setup: testSetup{ - enableTCF1Fallback: false, - vendorListVersion: 2, - }, - expected: testExpected{ - errorMessage: "gdpr vendor list version 2 does not exist, or has not been loaded yet. Try again in a few minutes", - }, + expected: testExpected{ + errorMessage: "gdpr vendor list version 2 does not exist, or has not been loaded yet. Try again in a few minutes", }, } - for _, test := range testCases { - runTest(t, test, tcf2SpecVersion, server) - } + runTestTCF2(t, test, server) } func TestTCF2FetcherThrottling(t *testing.T) { @@ -222,7 +139,7 @@ func TestTCF2FetcherThrottling(t *testing.T) { }))) defer server.Close() - fetcher := newVendorListFetcher(context.Background(), testConfig(), server.Client(), testURLMaker(server), tcf2SpecVersion) + fetcher := newVendorListFetcherTCF2(context.Background(), testConfig(), server.Client(), testURLMaker(server)) // Dynamically Load List 2 Successfully _, errList1 := fetcher(context.Background(), 2) @@ -243,7 +160,7 @@ func TestTCF2MalformedVendorlist(t *testing.T) { }))) defer server.Close() - fetcher := newVendorListFetcher(context.Background(), testConfig(), server.Client(), testURLMaker(server), tcf2SpecVersion) + fetcher := newVendorListFetcherTCF2(context.Background(), testConfig(), server.Client(), testURLMaker(server)) _, err := fetcher(context.Background(), 1) // Fetching should fail since vendor list could not be unmarshalled. @@ -254,9 +171,9 @@ func TestTCF2ServerUrlInvalid(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) server.Close() - invalidURLGenerator := func(uint16, uint8) string { return " http://invalid-url-has-leading-whitespace" } + invalidURLGenerator := func(uint16) string { return " http://invalid-url-has-leading-whitespace" } - fetcher := newVendorListFetcher(context.Background(), testConfig(), server.Client(), invalidURLGenerator, tcf2SpecVersion) + fetcher := newVendorListFetcherTCF2(context.Background(), testConfig(), server.Client(), invalidURLGenerator) _, err := fetcher(context.Background(), 1) assert.EqualError(t, err, "gdpr vendor list version 1 does not exist, or has not been loaded yet. Try again in a few minutes") @@ -266,7 +183,7 @@ func TestTCF2ServerUnavailable(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) server.Close() - fetcher := newVendorListFetcher(context.Background(), testConfig(), server.Client(), testURLMaker(server), tcf2SpecVersion) + fetcher := newVendorListFetcherTCF2(context.Background(), testConfig(), server.Client(), testURLMaker(server)) _, err := fetcher(context.Background(), 1) assert.EqualError(t, err, "gdpr vendor list version 1 does not exist, or has not been loaded yet. Try again in a few minutes") @@ -275,38 +192,23 @@ func TestTCF2ServerUnavailable(t *testing.T) { func TestVendorListURLMaker(t *testing.T) { testCases := []struct { description string - tcfSpecVersion uint8 vendorListVersion uint16 expectedURL string }{ { - description: "TCF1 - Latest", - tcfSpecVersion: 1, - vendorListVersion: 0, // Forces latest version. - expectedURL: "https://vendor-list.consensu.org/vendorlist.json", - }, - { - description: "TCF1 - Specific", - tcfSpecVersion: 1, - vendorListVersion: 42, - expectedURL: "https://vendor-list.consensu.org/v-42/vendorlist.json", - }, - { - description: "TCF2 - Latest", - tcfSpecVersion: 2, - vendorListVersion: 0, // Forces latest version. + description: "Latest", + vendorListVersion: 0, expectedURL: "https://vendor-list.consensu.org/v2/vendor-list.json", }, { - description: "TCF2 - Specific", - tcfSpecVersion: 2, + description: "Specific", vendorListVersion: 42, expectedURL: "https://vendor-list.consensu.org/v2/archives/vendor-list-v42.json", }, } for _, test := range testCases { - result := vendorListURLMaker(test.vendorListVersion, test.tcfSpecVersion) + result := vendorListURLMaker(test.vendorListVersion) assert.Equal(t, test.expectedURL, result) } } @@ -321,12 +223,6 @@ var tcf2VendorList1 = tcf2MarshalVendorList(tcf2VendorList{ Vendors: map[string]*tcf2Vendor{"12": {ID: 12, Purposes: []int{2}}}, }) -var vendorList1Expected = testExpected{ - vendorListVersion: 1, - vendorID: 12, - vendorPurposes: map[int]bool{1: false, 2: true, 3: false}, -} - var tcf1VendorList2 = tcf1MarshalVendorList(tcf1VendorList{ VendorListVersion: 2, Vendors: []tcf1Vendor{{ID: 12, Purposes: []int{2, 3}}}, @@ -438,13 +334,31 @@ type testExpected struct { vendorPurposes map[int]bool } -func runTest(t *testing.T, test test, tcfSpecVersion uint8, server *httptest.Server) { +func runTestTCF1(t *testing.T, test test, server *httptest.Server) { config := testConfig() if test.setup.enableTCF1Fallback { config.TCF1.FallbackGVLPath = "../static/tcf1/fallback_gvl.json" } - fetcher := newVendorListFetcher(context.Background(), config, server.Client(), testURLMaker(server), tcfSpecVersion) + fetcher := newVendorListFetcherTCF1(config) + vendorList, err := fetcher(context.Background(), test.setup.vendorListVersion) + + if test.expected.errorMessage != "" { + assert.EqualError(t, err, test.expected.errorMessage, test.description+":error") + } else { + assert.NoError(t, err, test.description+":vendorlist") + assert.Equal(t, test.expected.vendorListVersion, vendorList.Version(), test.description+":vendorlistid") + vendor := vendorList.Vendor(test.expected.vendorID) + for id, expected := range test.expected.vendorPurposes { + result := vendor.Purpose(consentconstants.Purpose(id)) + assert.Equalf(t, expected, result, "%s:vendor-%d:purpose-%d", test.description, vendorList.Version(), id) + } + } +} + +func runTestTCF2(t *testing.T, test test, server *httptest.Server) { + config := testConfig() + fetcher := newVendorListFetcherTCF2(context.Background(), config, server.Client(), testURLMaker(server)) vendorList, err := fetcher(context.Background(), test.setup.vendorListVersion) if test.expected.errorMessage != "" { @@ -460,9 +374,9 @@ func runTest(t *testing.T, test test, tcfSpecVersion uint8, server *httptest.Ser } } -func testURLMaker(server *httptest.Server) func(uint16, uint8) string { +func testURLMaker(server *httptest.Server) func(uint16) string { url := server.URL - return func(vendorListVersion uint16, tcfSpecVersion uint8) string { + return func(vendorListVersion uint16) string { return url + "?version=" + strconv.Itoa(int(vendorListVersion)) } } diff --git a/go.mod b/go.mod index b64f13db2a1..057e92ee798 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/PubMatic-OpenWrap/prebid-server +module github.com/prebid/prebid-server go 1.14 @@ -8,7 +8,6 @@ require ( github.com/NYTimes/gziphandler v1.1.1 github.com/OneOfOne/xxhash v1.2.5 // indirect github.com/PubMatic-OpenWrap/etree v1.0.2-0.20210129100623-8f30cfecf9f4 - github.com/PubMatic-OpenWrap/openrtb v11.0.1-0.20200228131822-5216ebe65c0c+incompatible github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect github.com/blang/semver v3.5.1+incompatible @@ -30,8 +29,7 @@ require ( 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/onsi/ginkgo v1.10.1 // indirect - github.com/onsi/gomega v1.7.0 // indirect + github.com/mxmCherry/openrtb/v15 v15.0.0 github.com/pelletier/go-toml v1.2.0 // indirect github.com/prebid/go-gdpr v0.8.3 github.com/prometheus/client_golang v0.0.0-20180623155954-77e8f2ddcfed @@ -56,9 +54,9 @@ require ( github.com/yudai/gojsondiff v0.0.0-20170107030110-7b1b7adf999d github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect github.com/yudai/pp v2.0.1+incompatible // indirect - golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 - golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 // indirect - golang.org/x/text v0.3.0 - gopkg.in/yaml.v2 v2.2.2 + golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb + golang.org/x/text v0.3.3 + gopkg.in/yaml.v2 v2.4.0 ) + +replace github.com/mxmCherry/openrtb/v15 v15.0.0 => github.com/PubMatic-OpenWrap/openrtb/v15 v15.0.0-20210425134848-adbedb6f42c6 diff --git a/go.sum b/go.sum index 0b055532881..b94bfc2ee57 100644 --- a/go.sum +++ b/go.sum @@ -10,14 +10,10 @@ github.com/PubMatic-OpenWrap/etree v1.0.1 h1:Q8sZ99MuXKmAx2v4XThKjwlstgadZffiRbN github.com/PubMatic-OpenWrap/etree v1.0.1/go.mod h1:5Y8qgcuDoy3XXG907UXkGnVTwihF16rXyJa4zRT7hOE= github.com/PubMatic-OpenWrap/etree v1.0.2-0.20210129100623-8f30cfecf9f4 h1:EhiijwjoKTx7FVP8p2wwC/z4n5l4c8l2CGmsrFv2uhI= github.com/PubMatic-OpenWrap/etree v1.0.2-0.20210129100623-8f30cfecf9f4/go.mod h1:5Y8qgcuDoy3XXG907UXkGnVTwihF16rXyJa4zRT7hOE= -github.com/PubMatic-OpenWrap/openrtb v11.0.1-0.20200228131822-5216ebe65c0c+incompatible h1:BGwndVLu0ncwweHnofXzLo+SnRMe04Bq3KFfELLzif4= -github.com/PubMatic-OpenWrap/openrtb v11.0.1-0.20200228131822-5216ebe65c0c+incompatible/go.mod h1:Ply/+GFe6FLkPMLV8Yh8xW0MpqclQyVf7m4PRsnaLDY= +github.com/PubMatic-OpenWrap/openrtb/v15 v15.0.0-20210425134848-adbedb6f42c6 h1:HYFXG8R1mtbDYpwWPxtBXuQ8pfgndMlQd7opo+wSAbk= +github.com/PubMatic-OpenWrap/openrtb/v15 v15.0.0-20210425134848-adbedb6f42c6/go.mod h1:XMFHmDvfVyIhz5JGzvNXVt0afDLN2mrdYviUOKIYqAo= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= -github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= -github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= -github.com/beevik/etree v1.1.1-0.20200718192613-4a2f8b9d084c h1:uYq6BD31fkfeNKQmfLj7ODcEfkb5JLsKrXVSqgnfGg8= -github.com/beevik/etree v1.1.1-0.20200718192613-4a2f8b9d084c/go.mod h1:0yGO2rna3S9DkITDWHY1bMtcY4IJ4w+4S+EooZUR0bE= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= @@ -40,17 +36,29 @@ github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5 h1:Yzb9+7DP github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= github.com/evanphx/json-patch v0.0.0-20180720181644-f195058310bd h1:biTJQdqouE5by89AAffXG8++TY+9Fsdrg5rinbt3tHk= github.com/evanphx/json-patch v0.0.0-20180720181644-f195058310bd/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/uuid v3.2.0+incompatible h1:y12jRkkFxsd7GpqdSZ+/KCs/fJbqpEXSGd4+jfEaewE= github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/influxdata/influxdb v1.6.1 h1:OseoBlzI5ftNI/bczyxSWq6PKRCNEeiXvyWP/wS5fB0= github.com/influxdata/influxdb v1.6.1/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= @@ -70,11 +78,17 @@ 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/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.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.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= -github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.1 h1:foqVmeWDD6yYpK+Yz3fHyNIxFYNxswxqNFjSKe+vI54= +github.com/onsi/ginkgo v1.16.1/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.11.0 h1:+CqWgvj0OZycCaqclBD1pxKHAU+tOkHmQIWvDHq2aug= +github.com/onsi/gomega v1.11.0/go.mod h1:azGKhqFUon9Vuj0YmTfLSmx0FUwqXYSTl5re8lQLTUg= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -110,7 +124,6 @@ github.com/spf13/viper v1.1.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7Sr github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -128,30 +141,57 @@ github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3Ifn github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= 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-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb h1:eBmm0M9fYhWpKZLjQUUKka/LtIxf46G4fxeEz5KJr9U= +golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 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= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 h1:DH4skfRX4EBpamg7iV4ZlCpblAHI6s6TDM39bFZumv8= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091 h1:DMyOG0U+gKfu8JZzg2UQe9MeaC1X+xQWlAKcRnjxjCw= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= diff --git a/main.go b/main.go index 376fe31f254..294cc141169 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,17 @@ package prebidServer import ( + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/usersync" "math/rand" "net/http" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - pbc "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/router" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/PubMatic-OpenWrap/prebid-server/util/task" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/currency" + pbc "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/router" + "github.com/prebid/prebid-server/util/task" "github.com/golang/glog" "github.com/spf13/viper" @@ -20,7 +20,7 @@ import ( // Rev holds binary revision string // Set manually at build time using: // go build -ldflags "-X main.Rev=`git rev-parse --short HEAD`" -// Populated automatically at build / release time via .travis.yml +// Populated automatically at build / releases // `gox -os="linux" -arch="386" -output="{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X main.Rev=`git rev-parse --short HEAD`" -verbose ./...;` // See issue #559 var Rev string diff --git a/main_test.go b/main_test.go index f3b6748ba48..1d2ec332164 100644 --- a/main_test.go +++ b/main_test.go @@ -4,7 +4,7 @@ import ( "os" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/config" "github.com/stretchr/testify/assert" "github.com/spf13/viper" diff --git a/metrics/config/metrics.go b/metrics/config/metrics.go index 513fbd0ff53..70738f2fd1a 100644 --- a/metrics/config/metrics.go +++ b/metrics/config/metrics.go @@ -3,10 +3,10 @@ package config import ( "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - prometheusmetrics "github.com/PubMatic-OpenWrap/prebid-server/metrics/prometheus" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + prometheusmetrics "github.com/prebid/prebid-server/metrics/prometheus" + "github.com/prebid/prebid-server/openrtb_ext" gometrics "github.com/rcrowley/go-metrics" influxdb "github.com/vrischmann/go-metrics-influxdb" ) diff --git a/metrics/config/metrics_test.go b/metrics/config/metrics_test.go index 5465061d5a0..5b70b53bb1a 100644 --- a/metrics/config/metrics_test.go +++ b/metrics/config/metrics_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - mainConfig "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + mainConfig "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" gometrics "github.com/rcrowley/go-metrics" ) diff --git a/metrics/go_metrics.go b/metrics/go_metrics.go index a84a3ea8b74..dc4bc1f8217 100644 --- a/metrics/go_metrics.go +++ b/metrics/go_metrics.go @@ -5,9 +5,9 @@ import ( "sync" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/golang/glog" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" metrics "github.com/rcrowley/go-metrics" ) diff --git a/metrics/go_metrics_test.go b/metrics/go_metrics_test.go index 712e8d5254c..2d0b9097b11 100644 --- a/metrics/go_metrics_test.go +++ b/metrics/go_metrics_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" metrics "github.com/rcrowley/go-metrics" "github.com/stretchr/testify/assert" ) diff --git a/metrics/metrics.go b/metrics/metrics.go index 1908bca497b..4e6a6ea7275 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -3,7 +3,7 @@ package metrics import ( "time" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" ) // Labels defines the labels that can be attached to the metrics. diff --git a/metrics/metrics_mock.go b/metrics/metrics_mock.go index 51fb2b902fc..54b448bbe19 100644 --- a/metrics/metrics_mock.go +++ b/metrics/metrics_mock.go @@ -3,7 +3,7 @@ package metrics import ( "time" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/mock" ) diff --git a/metrics/prometheus/preload.go b/metrics/prometheus/preload.go index 0f2ada29e3a..f4dfe43469d 100644 --- a/metrics/prometheus/preload.go +++ b/metrics/prometheus/preload.go @@ -1,7 +1,7 @@ package prometheusmetrics import ( - "github.com/PubMatic-OpenWrap/prebid-server/metrics" + "github.com/prebid/prebid-server/metrics" "github.com/prometheus/client_golang/prometheus" ) diff --git a/metrics/prometheus/prometheus.go b/metrics/prometheus/prometheus.go index 015ec033d81..33b36fbb61c 100644 --- a/metrics/prometheus/prometheus.go +++ b/metrics/prometheus/prometheus.go @@ -4,9 +4,9 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/prometheus/client_golang/prometheus" ) @@ -415,6 +415,7 @@ func NewMetrics(cfg config.PrometheusMetrics, disabledMetrics config.DisabledMet "adapter_vidbid_dur", "Video Ad durations returned by the bidder", []string{adapterLabel}, []float64{4, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 120}) + preloadLabelValues(&metrics) return &metrics diff --git a/metrics/prometheus/prometheus_test.go b/metrics/prometheus/prometheus_test.go index c136b57c02b..9b4dc2aa09e 100644 --- a/metrics/prometheus/prometheus_test.go +++ b/metrics/prometheus/prometheus_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/prometheus/client_golang/prometheus" dto "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" diff --git a/metrics/prometheus/type_conversion.go b/metrics/prometheus/type_conversion.go index eff379e8b2c..0e5c80636db 100644 --- a/metrics/prometheus/type_conversion.go +++ b/metrics/prometheus/type_conversion.go @@ -3,8 +3,8 @@ package prometheusmetrics import ( "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/openrtb_ext" ) func actionsAsString() []string { diff --git a/openrtb_ext/bid.go b/openrtb_ext/bid.go index 8f4d7a094bb..a568392beba 100644 --- a/openrtb_ext/bid.go +++ b/openrtb_ext/bid.go @@ -23,6 +23,7 @@ type ExtBidPrebid struct { Type BidType `json:"type"` Video *ExtBidPrebidVideo `json:"video,omitempty"` Events *ExtBidPrebidEvents `json:"events,omitempty"` + BidId string `json:"bidid,omitempty"` } // ExtBidPrebidCache defines the contract for bidresponse.seatbid.bid[i].ext.prebid.cache diff --git a/openrtb_ext/bid_request_video.go b/openrtb_ext/bid_request_video.go index 13ec8eb4538..29e62da3d35 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/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/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/bidders.go b/openrtb_ext/bidders.go index 2cd2405ebfe..ef114914cd6 100755 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -17,12 +17,6 @@ const schemaDirectory = "static/bidder-params" // BidderName refers to a core bidder id or an alias id. type BidderName string -// BidderNameGeneral is reserved for non-bidder specific messages when using a map keyed on the bidder name. -const BidderNameGeneral = BidderName("general") - -// BidderNameContext is reserved for first party data. -const BidderNameContext = BidderName("context") - func (name BidderName) MarshalJSON() ([]byte, error) { return []byte(name), nil } @@ -34,6 +28,45 @@ func (name *BidderName) String() string { return string(*name) } +// Names of reserved bidders. These names may not be used by a core bidder or alias. +const ( + BidderReservedAll BidderName = "all" // Reserved for the /info/bidders/all endpoint. + BidderReservedContext BidderName = "context" // Reserved for first party data. + BidderReservedData BidderName = "data" // Reserved for first party data. + BidderReservedGeneral BidderName = "general" // Reserved for non-bidder specific messages when using a map keyed on the bidder name. + BidderReservedPrebid BidderName = "prebid" // Reserved for Prebid Server configuration. + BidderReservedSKAdN BidderName = "skadn" // Reserved for Apple's SKAdNetwork OpenRTB extension. +) + +// IsBidderNameReserved returns true if the specified name is a case insensitive match for a reserved bidder name. +func IsBidderNameReserved(name string) bool { + if strings.EqualFold(name, string(BidderReservedAll)) { + return true + } + + if strings.EqualFold(name, string(BidderReservedContext)) { + return true + } + + if strings.EqualFold(name, string(BidderReservedData)) { + return true + } + + if strings.EqualFold(name, string(BidderReservedGeneral)) { + return true + } + + if strings.EqualFold(name, string(BidderReservedSKAdN)) { + return true + } + + if strings.EqualFold(name, string(BidderReservedPrebid)) { + return true + } + + return false +} + // Names of core bidders. These names *must* match the bidder code in Prebid.js if an adapter also exists in that // project. You may *not* use the name 'general' as that is reserved for general error messages nor 'context' as // that is reserved for first party data. @@ -57,6 +90,8 @@ const ( BidderAdtarget BidderName = "adtarget" BidderAdtelligent BidderName = "adtelligent" BidderAdvangelists BidderName = "advangelists" + BidderAdxcg BidderName = "adxcg" + BidderAdyoulike BidderName = "adyoulike" BidderAJA BidderName = "aja" BidderAMX BidderName = "amx" BidderApplogy BidderName = "applogy" @@ -66,12 +101,14 @@ const ( BidderBeachfront BidderName = "beachfront" BidderBeintoo BidderName = "beintoo" BidderBetween BidderName = "between" + BidderBidmachine BidderName = "bidmachine" BidderBrightroll BidderName = "brightroll" BidderColossus BidderName = "colossus" BidderConnectAd BidderName = "connectad" BidderConsumable BidderName = "consumable" BidderConversant BidderName = "conversant" BidderCpmstar BidderName = "cpmstar" + BidderCriteo BidderName = "criteo" BidderDatablocks BidderName = "datablocks" BidderDmx BidderName = "dmx" BidderDecenterAds BidderName = "decenterads" @@ -79,6 +116,7 @@ const ( BidderEmxDigital BidderName = "emx_digital" BidderEngageBDR BidderName = "engagebdr" BidderEPlanning BidderName = "eplanning" + BidderEpom BidderName = "epom" BidderGamma BidderName = "gamma" BidderGamoshi BidderName = "gamoshi" BidderGrid BidderName = "grid" @@ -87,6 +125,7 @@ const ( BidderInMobi BidderName = "inmobi" BidderInvibes BidderName = "invibes" BidderIx BidderName = "ix" + BidderJixie BidderName = "jixie" BidderKidoz BidderName = "kidoz" BidderKrushmedia BidderName = "krushmedia" BidderKubient BidderName = "kubient" @@ -102,8 +141,11 @@ const ( BidderNanoInteractive BidderName = "nanointeractive" BidderNinthDecimal BidderName = "ninthdecimal" BidderNoBid BidderName = "nobid" + BidderOneTag BidderName = "onetag" BidderOpenx BidderName = "openx" BidderOrbidder BidderName = "orbidder" + BidderOutbrain BidderName = "outbrain" + BidderPangle BidderName = "pangle" BidderPubmatic BidderName = "pubmatic" BidderPubnative BidderName = "pubnative" BidderPulsepoint BidderName = "pulsepoint" @@ -126,7 +168,9 @@ const ( BidderTelaria BidderName = "telaria" BidderTriplelift BidderName = "triplelift" BidderTripleliftNative BidderName = "triplelift_native" + BidderTrustX BidderName = "trustx" BidderUcfunnel BidderName = "ucfunnel" + BidderUnicorn BidderName = "unicorn" BidderUnruly BidderName = "unruly" BidderValueImpression BidderName = "valueimpression" BidderVerizonMedia BidderName = "verizonmedia" @@ -159,6 +203,8 @@ func CoreBidderNames() []BidderName { BidderAdtarget, BidderAdtelligent, BidderAdvangelists, + BidderAdxcg, + BidderAdyoulike, BidderAJA, BidderAMX, BidderApplogy, @@ -168,12 +214,14 @@ func CoreBidderNames() []BidderName { BidderBeachfront, BidderBeintoo, BidderBetween, + BidderBidmachine, BidderBrightroll, BidderColossus, BidderConnectAd, BidderConsumable, BidderConversant, BidderCpmstar, + BidderCriteo, BidderDatablocks, BidderDecenterAds, BidderDeepintent, @@ -181,6 +229,7 @@ func CoreBidderNames() []BidderName { BidderEmxDigital, BidderEngageBDR, BidderEPlanning, + BidderEpom, BidderGamma, BidderGamoshi, BidderGrid, @@ -189,6 +238,7 @@ func CoreBidderNames() []BidderName { BidderInMobi, BidderInvibes, BidderIx, + BidderJixie, BidderKidoz, BidderKrushmedia, BidderKubient, @@ -204,8 +254,11 @@ func CoreBidderNames() []BidderName { BidderNanoInteractive, BidderNinthDecimal, BidderNoBid, + BidderOneTag, BidderOpenx, BidderOrbidder, + BidderOutbrain, + BidderPangle, BidderPubmatic, BidderPubnative, BidderPulsepoint, @@ -228,7 +281,9 @@ func CoreBidderNames() []BidderName { BidderTelaria, BidderTriplelift, BidderTripleliftNative, + BidderTrustX, BidderUcfunnel, + BidderUnicorn, BidderUnruly, BidderValueImpression, BidderVerizonMedia, @@ -252,6 +307,16 @@ func BuildBidderMap() map[string]BidderName { return lookup } +// BuildBidderStringSlice builds a slioce of strings for each BidderName. +func BuildBidderStringSlice() []string { + coreBidders := CoreBidderNames() + slice := make([]string, len(coreBidders)) + for i, name := range CoreBidderNames() { + slice[i] = string(name) + } + return slice +} + func BuildBidderNameHashSet() map[string]struct{} { hashSet := make(map[string]struct{}) for _, name := range CoreBidderNames() { diff --git a/openrtb_ext/bidders_test.go b/openrtb_ext/bidders_test.go index 9c4889c9779..26ebf7dc74b 100644 --- a/openrtb_ext/bidders_test.go +++ b/openrtb_ext/bidders_test.go @@ -2,114 +2,119 @@ package openrtb_ext import ( "encoding/json" - "os" "testing" "github.com/stretchr/testify/assert" "github.com/xeipuuv/gojsonschema" ) -// TestMain does the expensive setup so we don't keep re-reading the files in static/bidder-params for each test. -func TestMain(m *testing.M) { - bidderParams, err := NewBidderParamsValidator("../static/bidder-params") - if err != nil { - os.Exit(1) +func TestBidderParamValidatorValidate(t *testing.T) { + testSchemaLoader := gojsonschema.NewStringLoader(`{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Test Params", + "description": "Test Description", + "type": "object", + "properties": { + "placementId": { + "type": "integer", + "description": "An ID which identifies this placement of the impression." + }, + "optionalText": { + "type": "string", + "description": "Optional text for testing." + } + }, + "required": ["placementId"] + }`) + testSchema, err := gojsonschema.NewSchema(testSchemaLoader) + if !assert.NoError(t, err) { + t.FailNow() } - validator = bidderParams - os.Exit(m.Run()) -} - -var validator BidderParamValidator - -// TestBidderParamSchemas makes sure that the validator.Schema() function -// returns valid JSON for all known CoreBidderNames. -func TestBidderParamSchemas(t *testing.T) { - for _, bidderName := range CoreBidderNames() { - schema := validator.Schema(bidderName) - if schema == "" { - t.Errorf("No schema exists for bidder %s. Does static/bidder-params/%s.json exist?", bidderName, bidderName) - } - - if _, err := gojsonschema.NewBytesLoader([]byte(schema)).LoadJSON(); err != nil { - t.Errorf("static/bidder-params/%s.json does not have a valid json-schema. %v", bidderName, err) - } + testBidderName := BidderName("foo") + testValidator := bidderParamValidator{ + parsedSchemas: map[BidderName]*gojsonschema.Schema{ + testBidderName: testSchema, + }, } -} -// TestValidParams and TestInvalidParams overlap with adapters/appnexus/params_test... but those tests -// from the other packages don't show up in code coverage. -func TestValidParams(t *testing.T) { - if err := validator.Validate(BidderAppnexus, json.RawMessage(`{"placementId":123}`)); err != nil { - t.Errorf("These params should be valid. Error was: %v", err) + testCases := []struct { + description string + ext json.RawMessage + expectedError string + }{ + { + description: "Valid", + ext: json.RawMessage(`{"placementId":123}`), + expectedError: "", + }, + { + description: "Invalid - Wrong Type", + ext: json.RawMessage(`{"placementId":"stringInsteadOfInt"}`), + expectedError: "placementId: Invalid type. Expected: integer, given: string", + }, + { + description: "Invalid - Empty Object", + ext: json.RawMessage(`{}`), + expectedError: "placementId: placementId is required", + }, + { + description: "Malformed", + ext: json.RawMessage(`malformedJSON`), + expectedError: "invalid character 'm' looking for beginning of value", + }, } -} -func TestInvalidParams(t *testing.T) { - if err := validator.Validate(BidderAppnexus, json.RawMessage(`{}`)); err == nil { - t.Error("These params should be invalid.") + for _, test := range testCases { + err := testValidator.Validate(testBidderName, test.ext) + if test.expectedError == "" { + assert.NoError(t, err, test.description) + } else { + assert.EqualError(t, err, test.expectedError, test.description) + } } } -func TestBidderListDoesNotDefineGeneral(t *testing.T) { - assert.NotContains(t, CoreBidderNames(), BidderNameGeneral) -} - -func TestBidderListDoesNotDefineContext(t *testing.T) { - assert.NotContains(t, CoreBidderNames(), BidderNameContext) -} - -// TestBidderUniquenessGatekeeping acts as a gatekeeper of bidder name uniqueness. If this test fails -// when you're building a new adapter, please consider choosing a different bidder name to maintain the -// current uniqueness threshold, or else start a discussion in the PR. -func TestBidderUniquenessGatekeeping(t *testing.T) { - // Get List Of Bidders - // - Exclude duplicates of adapters for the same bidder, as it's unlikely a publisher will use both. - var bidders []string - for _, bidder := range CoreBidderNames() { - if bidder != BidderTripleliftNative && bidder != BidderAdkernelAdn { - bidders = append(bidders, string(bidder)) - } +func TestBidderParamValidatorSchema(t *testing.T) { + testValidator := bidderParamValidator{ + schemaContents: map[BidderName]string{ + BidderName("foo"): "foo content", + BidderName("bar"): "bar content", + }, } - currentThreshold := 6 - measuredThreshold := minUniquePrefixLength(bidders) - - assert.NotZero(t, measuredThreshold, "BidderMap contains duplicate bidder name values.") - assert.LessOrEqual(t, measuredThreshold, currentThreshold) -} + result := testValidator.Schema(BidderName("bar")) -// minUniquePrefixLength measures the minimun amount of characters needed to uniquely identify -// one of the strings, or returns 0 if there are duplicates. -func minUniquePrefixLength(b []string) int { - targetingKeyMaxLength := 20 - for prefixLength := 1; prefixLength <= targetingKeyMaxLength; prefixLength++ { - if uniqueForPrefixLength(b, prefixLength) { - return prefixLength - } - } - return 0 + assert.Equal(t, "bar content", result) } -func uniqueForPrefixLength(b []string, prefixLength int) bool { - m := make(map[string]struct{}) - - if prefixLength <= 0 { - return false +func TestIsBidderNameReserved(t *testing.T) { + testCases := []struct { + bidder string + expected bool + }{ + {"all", true}, + {"aLl", true}, + {"ALL", true}, + {"context", true}, + {"CONTEXT", true}, + {"conTExt", true}, + {"data", true}, + {"DATA", true}, + {"DaTa", true}, + {"general", true}, + {"gEnErAl", true}, + {"GENERAL", true}, + {"skadn", true}, + {"skADN", true}, + {"SKADN", true}, + {"prebid", true}, + {"PREbid", true}, + {"PREBID", true}, + {"notreserved", false}, } - for i, n := range b { - ns := string(n) - - if len(ns) > prefixLength { - ns = ns[0:prefixLength] - } - - m[ns] = struct{}{} - - if len(m) != i+1 { - return false - } + for _, test := range testCases { + result := IsBidderNameReserved(test.bidder) + assert.Equal(t, test.expected, result, test.bidder) } - - return true } diff --git a/openrtb_ext/bidders_validate_test.go b/openrtb_ext/bidders_validate_test.go new file mode 100644 index 00000000000..2ee3dd7d806 --- /dev/null +++ b/openrtb_ext/bidders_validate_test.go @@ -0,0 +1,99 @@ +package openrtb_ext + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/xeipuuv/gojsonschema" +) + +// TestMain does the expensive setup so we don't keep re-reading the files in static/bidder-params for each test. +func TestMain(m *testing.M) { + bidderParams, err := NewBidderParamsValidator("../static/bidder-params") + if err != nil { + os.Exit(1) + } + validator = bidderParams + os.Exit(m.Run()) +} + +var validator BidderParamValidator + +// TestBidderParamSchemas makes sure that the validator.Schema() function +// returns valid JSON for all known CoreBidderNames. +func TestBidderParamSchemas(t *testing.T) { + for _, bidderName := range CoreBidderNames() { + schema := validator.Schema(bidderName) + if schema == "" { + t.Errorf("No schema exists for bidder %s. Does static/bidder-params/%s.json exist?", bidderName, bidderName) + } + + if _, err := gojsonschema.NewBytesLoader([]byte(schema)).LoadJSON(); err != nil { + t.Errorf("static/bidder-params/%s.json does not have a valid json-schema. %v", bidderName, err) + } + } +} + +func TestBidderNamesValid(t *testing.T) { + for _, bidder := range CoreBidderNames() { + isReserved := IsBidderNameReserved(string(bidder)) + assert.False(t, isReserved, "bidder %v conflicts with a reserved name", bidder) + } +} + +// TestBidderUniquenessGatekeeping acts as a gatekeeper of bidder name uniqueness. If this test fails +// when you're building a new adapter, please consider choosing a different bidder name to maintain the +// current uniqueness threshold, or else start a discussion in the PR. +func TestBidderUniquenessGatekeeping(t *testing.T) { + // Get List Of Bidders + // - Exclude duplicates of adapters for the same bidder, as it's unlikely a publisher will use both. + var bidders []string + for _, bidder := range CoreBidderNames() { + if bidder != BidderTripleliftNative && bidder != BidderAdkernelAdn { + bidders = append(bidders, string(bidder)) + } + } + + currentThreshold := 6 + measuredThreshold := minUniquePrefixLength(bidders) + + assert.NotZero(t, measuredThreshold, "BidderMap contains duplicate bidder name values.") + assert.LessOrEqual(t, measuredThreshold, currentThreshold) +} + +// minUniquePrefixLength measures the minimun amount of characters needed to uniquely identify +// one of the strings, or returns 0 if there are duplicates. +func minUniquePrefixLength(b []string) int { + targetingKeyMaxLength := 20 + for prefixLength := 1; prefixLength <= targetingKeyMaxLength; prefixLength++ { + if uniqueForPrefixLength(b, prefixLength) { + return prefixLength + } + } + return 0 +} + +func uniqueForPrefixLength(b []string, prefixLength int) bool { + m := make(map[string]struct{}) + + if prefixLength <= 0 { + return false + } + + for i, n := range b { + ns := string(n) + + if len(ns) > prefixLength { + ns = ns[0:prefixLength] + } + + m[ns] = struct{}{} + + if len(m) != i+1 { + return false + } + } + + return true +} diff --git a/openrtb_ext/deal_tier.go b/openrtb_ext/deal_tier.go index e882235d01e..8aeedb81a5e 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/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 717e0703466..29d58d6c071 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/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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/device.go b/openrtb_ext/device.go index afbea276988..cc06f3806cf 100644 --- a/openrtb_ext/device.go +++ b/openrtb_ext/device.go @@ -1,25 +1,74 @@ package openrtb_ext import ( + "encoding/json" + "errors" "strconv" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" "github.com/buger/jsonparser" + "github.com/prebid/prebid-server/errortypes" ) // PrebidExtKey represents the prebid extension key used in requests const PrebidExtKey = "prebid" +// PrebidExtBidderKey represents the field name within request.imp.ext.prebid reserved for bidder params. +const PrebidExtBidderKey = "bidder" + // ExtDevice defines the contract for bidrequest.device.ext type ExtDevice struct { + // Attribute: + // atts + // Type: + // integer; optional - iOS Only + // Description: + // iOS app tracking authorization status. + // Extension Spec: + // https://github.com/InteractiveAdvertisingBureau/openrtb/blob/master/extensions/community_extensions/skadnetwork.md + ATTS *IOSAppTrackingStatus `json:"atts"` + + // Attribute: + // prebid + // Type: + // object; optional + // Description: + // Prebid extensions for the Device object. Prebid ExtDevicePrebid `json:"prebid"` } -// Pointer to interstitial so we do not force it to exist +// IOSAppTrackingStatus describes the values for iOS app tracking authorization status. +type IOSAppTrackingStatus int + +// Values of the IOSAppTrackingStatus enumeration. +const ( + IOSAppTrackingStatusNotDetermined IOSAppTrackingStatus = 0 + IOSAppTrackingStatusRestricted IOSAppTrackingStatus = 1 + IOSAppTrackingStatusDenied IOSAppTrackingStatus = 2 + IOSAppTrackingStatusAuthorized IOSAppTrackingStatus = 3 +) + +// IsKnownIOSAppTrackingStatus returns true if the value is a known iOS app tracking authorization status. +func IsKnownIOSAppTrackingStatus(v int64) bool { + switch IOSAppTrackingStatus(v) { + case IOSAppTrackingStatusNotDetermined: + return true + case IOSAppTrackingStatusRestricted: + return true + case IOSAppTrackingStatusDenied: + return true + case IOSAppTrackingStatusAuthorized: + return true + default: + return false + } +} + +// ExtDevicePrebid defines the contract for bidrequest.device.ext.prebid type ExtDevicePrebid struct { Interstitial *ExtDeviceInt `json:"interstitial"` } +// ExtDeviceInt defines the contract for bidrequest.device.ext.prebid.interstitial type ExtDeviceInt struct { MinWidthPerc uint64 `json:"minwidtheperc"` MinHeightPerc uint64 `json:"minheightperc"` @@ -49,3 +98,26 @@ func (edi *ExtDeviceInt) UnmarshalJSON(b []byte) error { } return nil } + +// ParseDeviceExtATTS parses the ATTS value from the request.device.ext OpenRTB field. +func ParseDeviceExtATTS(deviceExt json.RawMessage) (*IOSAppTrackingStatus, error) { + v, err := jsonparser.GetInt(deviceExt, "atts") + + // node not found error + if err == jsonparser.KeyPathNotFoundError { + return nil, nil + } + + // unexpected parse error + if err != nil { + return nil, err + } + + // invalid value error + if !IsKnownIOSAppTrackingStatus(v) { + return nil, errors.New("invalid status") + } + + status := IOSAppTrackingStatus(v) + return &status, nil +} diff --git a/openrtb_ext/device_test.go b/openrtb_ext/device_test.go index b4c85bcc0b0..1a3dbe8e2f4 100644 --- a/openrtb_ext/device_test.go +++ b/openrtb_ext/device_test.go @@ -1,15 +1,14 @@ -package openrtb_ext_test +package openrtb_ext import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) func TestInvalidDeviceExt(t *testing.T) { - var s openrtb_ext.ExtDevice + var s ExtDevice assert.EqualError(t, json.Unmarshal([]byte(`{"prebid":{"interstitial":{"minheightperc":0}}}`), &s), "request.device.ext.prebid.interstitial.minwidthperc must be a number between 0 and 100") assert.EqualError(t, json.Unmarshal([]byte(`{"prebid":{"interstitial":{"minwidthperc":105}}}`), &s), "request.device.ext.prebid.interstitial.minwidthperc must be a number between 0 and 100") assert.EqualError(t, json.Unmarshal([]byte(`{"prebid":{"interstitial":{"minwidthperc":true,"minheightperc":0}}}`), &s), "request.device.ext.prebid.interstitial.minwidthperc must be a number between 0 and 100") @@ -23,7 +22,7 @@ func TestInvalidDeviceExt(t *testing.T) { } func TestValidDeviceExt(t *testing.T) { - var s openrtb_ext.ExtDevice + var s ExtDevice assert.NoError(t, json.Unmarshal([]byte(`{"prebid":{}}`), &s)) assert.Nil(t, s.Prebid.Interstitial) assert.NoError(t, json.Unmarshal([]byte(`{}`), &s)) @@ -32,3 +31,79 @@ func TestValidDeviceExt(t *testing.T) { assert.EqualValues(t, 75, s.Prebid.Interstitial.MinWidthPerc) assert.EqualValues(t, 60, s.Prebid.Interstitial.MinHeightPerc) } + +func TestIsKnownIOSAppTrackingStatus(t *testing.T) { + valid := []int64{0, 1, 2, 3} + invalid := []int64{-1, 4} + + for _, v := range valid { + assert.True(t, IsKnownIOSAppTrackingStatus(v)) + } + + for _, v := range invalid { + assert.False(t, IsKnownIOSAppTrackingStatus(v)) + } +} + +func TestParseDeviceExtATTS(t *testing.T) { + authorized := IOSAppTrackingStatusAuthorized + + tests := []struct { + description string + givenExt json.RawMessage + expectedStatus *IOSAppTrackingStatus + expectedError string + }{ + { + description: "Nil", + givenExt: nil, + expectedStatus: nil, + }, + { + description: "Empty", + givenExt: json.RawMessage(``), + expectedStatus: nil, + }, + { + description: "Empty Object", + givenExt: json.RawMessage(`{}`), + expectedStatus: nil, + }, + { + description: "Valid", + givenExt: json.RawMessage(`{"atts":3}`), + expectedStatus: &authorized, + }, + { + description: "Invalid Value", + givenExt: json.RawMessage(`{"atts":5}`), + expectedStatus: nil, + expectedError: "invalid status", + }, + { + // This test case produces an error with the standard Go library, but jsonparser doesn't + // return an error for malformed JSON. It treats this case the same as not being found. + description: "Malformed - Standard Test Case", + givenExt: json.RawMessage(`malformed`), + expectedStatus: nil, + }, + { + description: "Malformed - Wrong Type", + givenExt: json.RawMessage(`{"atts":"1"}`), + expectedStatus: nil, + expectedError: "Value is not a number: 1", + }, + } + + for _, test := range tests { + status, err := ParseDeviceExtATTS(test.givenExt) + + if test.expectedError == "" { + assert.NoError(t, err, test.description+":err") + } else { + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + + assert.Equal(t, test.expectedStatus, status, test.description+":status") + } +} diff --git a/openrtb_ext/imp_adyoulike.go b/openrtb_ext/imp_adyoulike.go new file mode 100644 index 00000000000..67a94123734 --- /dev/null +++ b/openrtb_ext/imp_adyoulike.go @@ -0,0 +1,18 @@ +package openrtb_ext + +// ExtImpAdyoulike defines the contract for bidrequest.imp[i].ext.adyoulike +type ExtImpAdyoulike struct { + // placementId, only mandatory field + PlacementId string `json:"placement"` + + // Id of the forced campaign + Campaign string `json:"campaign"` + // Id of the forced track + Track string `json:"track"` + // Id of the forced creative + Creative string `json:"creative"` + // Context of the campaign values [SSP|AdServer] + Source string `json:"source"` + // Abitrary Id used for debug purpose + Debug string `json:"debug"` +} diff --git a/openrtb_ext/imp_bidmachine.go b/openrtb_ext/imp_bidmachine.go new file mode 100644 index 00000000000..20491d25aca --- /dev/null +++ b/openrtb_ext/imp_bidmachine.go @@ -0,0 +1,7 @@ +package openrtb_ext + +type ExtImpBidmachine struct { + Host string `json:"host"` + Path string `json:"path"` + SellerID string `json:"seller_id"` +} diff --git a/openrtb_ext/imp_criteo.go b/openrtb_ext/imp_criteo.go new file mode 100644 index 00000000000..e200aace496 --- /dev/null +++ b/openrtb_ext/imp_criteo.go @@ -0,0 +1,7 @@ +package openrtb_ext + +// ExtImpCriteo defines the contract for bidrequest.imp[i].ext.criteo +type ExtImpCriteo struct { + ZoneID int64 `json:"zoneId"` + NetworkID int64 `json:"networkId"` +} diff --git a/openrtb_ext/imp_epom.go b/openrtb_ext/imp_epom.go new file mode 100644 index 00000000000..a99f60ef368 --- /dev/null +++ b/openrtb_ext/imp_epom.go @@ -0,0 +1,4 @@ +package openrtb_ext + +type ImpExtEpom struct { +} diff --git a/openrtb_ext/imp_gumgum.go b/openrtb_ext/imp_gumgum.go index 7959e1cccc3..56b000a6acf 100644 --- a/openrtb_ext/imp_gumgum.go +++ b/openrtb_ext/imp_gumgum.go @@ -1,5 +1,14 @@ package openrtb_ext +// ExtImpGumGum defines the contract for bidrequest.imp[i].ext.gumgum +// Either Zone or PubId must be present, others are optional parameters type ExtImpGumGum struct { - Zone string `json:"zone"` + Zone string `json:"zone,omitempty"` + PubID float64 `json:"pubId,omitempty"` + IrisID string `json:"irisid,omitempty"` +} + +// ExtImpGumGumVideo defines the contract for bidresponse.seatbid.bid[i].ext.gumgum.video +type ExtImpGumGumVideo struct { + IrisID string `json:"irisid,omitempty"` } diff --git a/openrtb_ext/imp_jixie.go b/openrtb_ext/imp_jixie.go new file mode 100644 index 00000000000..8fa0570c56b --- /dev/null +++ b/openrtb_ext/imp_jixie.go @@ -0,0 +1,8 @@ +package openrtb_ext + +type ExtImpJixie struct { + Unit string `json:"unit"` + AccountId string `json:"accountid,omitempty"` + JxProp1 string `json:"jxprop1,omitempty"` + JxProp2 string `json:"jxprop2,omitempty"` +} diff --git a/openrtb_ext/imp_onetag.go b/openrtb_ext/imp_onetag.go new file mode 100644 index 00000000000..47d06ed4873 --- /dev/null +++ b/openrtb_ext/imp_onetag.go @@ -0,0 +1,10 @@ +package openrtb_ext + +import ( + "encoding/json" +) + +type ExtImpOnetag struct { + PubId string `json:"pubId"` + Ext json.RawMessage `json:"ext"` +} diff --git a/openrtb_ext/imp_outbrain.go b/openrtb_ext/imp_outbrain.go new file mode 100644 index 00000000000..634f29481c1 --- /dev/null +++ b/openrtb_ext/imp_outbrain.go @@ -0,0 +1,15 @@ +package openrtb_ext + +// ExtImpOutbrain defines the contract for bidrequest.imp[i].ext.outbrain +type ExtImpOutbrain struct { + Publisher ExtImpOutbrainPublisher `json:"publisher"` + TagId string `json:"tagid"` + BCat []string `json:"bcat"` + BAdv []string `json:"badv"` +} + +type ExtImpOutbrainPublisher struct { + Id string `json:"id"` + Name string `json:"name"` + Domain string `json:"domain"` +} diff --git a/openrtb_ext/imp_pangle.go b/openrtb_ext/imp_pangle.go new file mode 100644 index 00000000000..cc32dcf1d01 --- /dev/null +++ b/openrtb_ext/imp_pangle.go @@ -0,0 +1,5 @@ +package openrtb_ext + +type ImpExtPangle struct { + Token string `json:"token"` +} diff --git a/openrtb_ext/imp_unicorn.go b/openrtb_ext/imp_unicorn.go new file mode 100644 index 00000000000..ad75414caa5 --- /dev/null +++ b/openrtb_ext/imp_unicorn.go @@ -0,0 +1,9 @@ +package openrtb_ext + +// ExtImpUnicorn defines the contract for bidrequest.imp[i].ext.unicorn +type ExtImpUnicorn struct { + PlacementID string `json:"placementId,omitempty"` + PublisherID int `json:"publisherId,omitempty"` + MediaID string `json:"mediaId"` + AccountID int `json:"accountId"` +} diff --git a/openrtb_ext/request.go b/openrtb_ext/request.go index 57bef59d711..8d6e6d13546 100644 --- a/openrtb_ext/request.go +++ b/openrtb_ext/request.go @@ -5,9 +5,15 @@ import ( "errors" ) -// FirstPartyDataContextExtKey defines the field name within bidrequest.ext reserved -// for first party data support. -const FirstPartyDataContextExtKey string = "context" +// FirstPartyDataExtKey defines a field name within request.ext and request.imp.ext reserved for first party data. +const FirstPartyDataExtKey = "data" + +// FirstPartyDataContextExtKey defines a field name within request.ext and request.imp.ext reserved for first party data. +const FirstPartyDataContextExtKey = "context" + +// SKAdNExtKey defines the field name within request.ext reserved for Apple's SKAdNetwork. +const SKAdNExtKey = "skadn" + const MaxDecimalFigures int = 15 // ExtRequest defines the contract for bidrequest.ext diff --git a/openrtb_ext/response.go b/openrtb_ext/response.go index f2119f2c871..1c7177daf49 100644 --- a/openrtb_ext/response.go +++ b/openrtb_ext/response.go @@ -1,14 +1,13 @@ package openrtb_ext -import ( - "github.com/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/openrtb2" // ExtBidResponse defines the contract for bidresponse.ext type ExtBidResponse struct { Debug *ExtResponseDebug `json:"debug,omitempty"` // Errors defines the contract for bidresponse.ext.errors - Errors map[BidderName][]ExtBidderError `json:"errors,omitempty"` + Errors map[BidderName][]ExtBidderMessage `json:"errors,omitempty"` + Warnings map[BidderName][]ExtBidderMessage `json:"warnings,omitempty"` // ResponseTimeMillis defines the contract for bidresponse.ext.responsetimemillis ResponseTimeMillis map[BidderName]int `json:"responsetimemillis,omitempty"` // RequestTimeoutMillis returns the timeout used in the auction. @@ -26,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} @@ -47,8 +46,8 @@ type ExtUserSync struct { Type UserSyncType `json:"type"` } -// ExtBidderError defines an error object to be returned, consiting of a machine readable error code, and a human readable error message string. -type ExtBidderError struct { +// ExtBidderMessage defines an error object to be returned, consiting of a machine readable error code, and a human readable error message string. +type ExtBidderMessage struct { Code int `json:"code"` Message string `json:"message"` } diff --git a/openrtb_ext/site_test.go b/openrtb_ext/site_test.go index 0d41e0c02ce..67ec6cc4f99 100644 --- a/openrtb_ext/site_test.go +++ b/openrtb_ext/site_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/pbs/pbsrequest.go b/pbs/pbsrequest.go index bd07a6c558b..52840d95d9c 100644 --- a/pbs/pbsrequest.go +++ b/pbs/pbsrequest.go @@ -10,14 +10,14 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/cache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/PubMatic-OpenWrap/prebid-server/util/httputil" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" - - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/cache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/usersync" + "github.com/prebid/prebid-server/util/httputil" + "github.com/prebid/prebid-server/util/iputil" + "github.com/blang/semver" "github.com/buger/jsonparser" "github.com/golang/glog" @@ -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"` + 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/pbsrequest_test.go b/pbs/pbsrequest_test.go index 566057473b8..52cd6153323 100644 --- a/pbs/pbsrequest_test.go +++ b/pbs/pbsrequest_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/config" "github.com/magiconair/properties/assert" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/config" ) const mimeVideoMp4 = "video/mp4" 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/pbs/usersync.go b/pbs/usersync.go index f50933b2434..4cac3544804 100644 --- a/pbs/usersync.go +++ b/pbs/usersync.go @@ -9,13 +9,13 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/server/ssl" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/server/ssl" + "github.com/prebid/prebid-server/usersync" ) // Recaptcha code from https://github.com/haisum/recaptcha/blob/master/recaptcha.go diff --git a/prebid_cache_client/client.go b/prebid_cache_client/client.go index 8d363e147bd..730d54b0acb 100644 --- a/prebid_cache_client/client.go +++ b/prebid_cache_client/client.go @@ -12,8 +12,8 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" "github.com/buger/jsonparser" "github.com/golang/glog" @@ -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/client_test.go b/prebid_cache_client/client_test.go index c4eeca82b8f..1ba30a6faab 100644 --- a/prebid_cache_client/client_test.go +++ b/prebid_cache_client/client_test.go @@ -10,9 +10,9 @@ import ( "strconv" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + metricsConf "github.com/prebid/prebid-server/metrics/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/prebid_cache_client/prebid_cache.go b/prebid_cache_client/prebid_cache.go index d19e8f1c9a6..842eb5b19d4 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 4ef412fd3ef..41f1c39447b 100644 --- a/privacy/ccpa/consentwriter.go +++ b/privacy/ccpa/consentwriter.go @@ -1,8 +1,6 @@ package ccpa -import ( - "github.com/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/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 1e491d9d167..d59428626b8 100644 --- a/privacy/ccpa/consentwriter_test.go +++ b/privacy/ccpa/consentwriter_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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.go b/privacy/ccpa/parsedpolicy.go index 52977104716..7b9c2d1fa7c 100644 --- a/privacy/ccpa/parsedpolicy.go +++ b/privacy/ccpa/parsedpolicy.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" + "github.com/prebid/prebid-server/errortypes" ) const ( @@ -43,7 +43,10 @@ func (p Policy) Parse(validBidders map[string]struct{}) (ParsedPolicy, error) { consentOptOut, err := parseConsent(p.Consent) if err != nil { msg := fmt.Sprintf("request.regs.ext.us_privacy %s", err.Error()) - return ParsedPolicy{}, &errortypes.InvalidPrivacyConsent{Message: msg} + return ParsedPolicy{}, &errortypes.Warning{ + Message: msg, + WarningCode: errortypes.InvalidPrivacyConsentWarningCode, + } } noSaleForAllBidders, noSaleSpecificBidders, err := parseNoSaleBidders(p.NoSaleBidders, validBidders) diff --git a/privacy/ccpa/parsedpolicy_test.go b/privacy/ccpa/parsedpolicy_test.go index 4fa9f92684d..33563b50567 100644 --- a/privacy/ccpa/parsedpolicy_test.go +++ b/privacy/ccpa/parsedpolicy_test.go @@ -3,7 +3,7 @@ package ccpa import ( "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 3f5dd25c6bc..d57ba8deaa4 100644 --- a/privacy/ccpa/policy.go +++ b/privacy/ccpa/policy.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" - "github.com/PubMatic-OpenWrap/openrtb" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" ) // Policy represents the CCPA regulatory information from an OpenRTB bid request. @@ -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 c1fdd9cd903..416ebffa31a 100644 --- a/privacy/ccpa/policy_test.go +++ b/privacy/ccpa/policy_test.go @@ -4,21 +4,21 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 47c1f0d03dd..ab2f64a691b 100644 --- a/privacy/enforcement.go +++ b/privacy/enforcement.go @@ -1,8 +1,6 @@ package privacy -import ( - "github.com/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/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 a5e41c83198..61899e4d60e 100644 --- a/privacy/enforcement_test.go +++ b/privacy/enforcement_test.go @@ -3,7 +3,7 @@ package privacy import ( "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 f1cc2ce12f7..ca784b7a5c1 100644 --- a/privacy/gdpr/consentwriter.go +++ b/privacy/gdpr/consentwriter.go @@ -3,9 +3,8 @@ package gdpr import ( "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" ) // 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 65df8051d02..5753442fa01 100644 --- a/privacy/gdpr/consentwriter_test.go +++ b/privacy/gdpr/consentwriter_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 new file mode 100644 index 00000000000..55e1764c8c2 --- /dev/null +++ b/privacy/lmt/ios.go @@ -0,0 +1,67 @@ +package lmt + +import ( + "strings" + + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/util/iosutil" +) + +var ( + int8Zero int8 = 0 + int8One int8 = 1 +) + +// ModifyForIOS modifies the request's LMT flag based on iOS version and identity. +func ModifyForIOS(req *openrtb2.BidRequest) { + modifiers := map[iosutil.VersionClassification]modifier{ + iosutil.Version140: modifyForIOS14X, + iosutil.Version141: modifyForIOS14X, + iosutil.Version142OrGreater: modifyForIOS142OrGreater, + } + modifyForIOS(req, modifiers) +} + +func modifyForIOS(req *openrtb2.BidRequest, modifiers map[iosutil.VersionClassification]modifier) { + if !isRequestForIOS(req) { + return + } + + versionClassification := iosutil.DetectVersionClassification(req.Device.OSV) + if modifier, ok := modifiers[versionClassification]; ok { + modifier(req) + } +} + +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 *openrtb2.BidRequest) + +func modifyForIOS14X(req *openrtb2.BidRequest) { + if req.Device.IFA == "" || req.Device.IFA == "00000000-0000-0000-0000-000000000000" { + req.Device.Lmt = &int8One + } else { + req.Device.Lmt = &int8Zero + } +} + +func modifyForIOS142OrGreater(req *openrtb2.BidRequest) { + atts, err := openrtb_ext.ParseDeviceExtATTS(req.Device.Ext) + if err != nil || atts == nil { + return + } + + switch *atts { + case openrtb_ext.IOSAppTrackingStatusNotDetermined: + req.Device.Lmt = &int8Zero + case openrtb_ext.IOSAppTrackingStatusRestricted: + req.Device.Lmt = &int8One + case openrtb_ext.IOSAppTrackingStatusDenied: + req.Device.Lmt = &int8One + case openrtb_ext.IOSAppTrackingStatusAuthorized: + req.Device.Lmt = &int8Zero + } +} diff --git a/privacy/lmt/ios_test.go b/privacy/lmt/ios_test.go new file mode 100644 index 00000000000..2caec1be64c --- /dev/null +++ b/privacy/lmt/ios_test.go @@ -0,0 +1,276 @@ +package lmt + +import ( + "encoding/json" + "testing" + + "github.com/mxmCherry/openrtb/v15/openrtb2" + "github.com/prebid/prebid-server/util/iosutil" + "github.com/stretchr/testify/assert" +) + +// TestModifyForIOS is a simple spot check end-to-end test for the integration of all functional components. +func TestModifyForIOS(t *testing.T) { + testCases := []struct { + description string + givenRequest *openrtb2.BidRequest + expectedLMT *int8 + }{ + { + description: "13.0", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "13.0", IFA: "", Lmt: nil}, + }, + expectedLMT: nil, + }, + { + description: "14.0", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "14.0", IFA: "", Lmt: nil}, + }, + expectedLMT: openrtb2.Int8Ptr(1), + }, + } + + for _, test := range testCases { + ModifyForIOS(test.givenRequest) + assert.Equal(t, test.expectedLMT, test.givenRequest.Device.Lmt, test.description) + } +} + +func TestModifyForIOSHelper(t *testing.T) { + testCases := []struct { + description string + givenRequest *openrtb2.BidRequest + expectedModifier140Called bool + expectedModifier142Called bool + }{ + { + description: "Valid 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: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "14.2"}, + }, + expectedModifier140Called: false, + expectedModifier142Called: true, + }, + { + description: "Invalid Version", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS", OSV: "invalid"}, + }, + expectedModifier140Called: false, + expectedModifier142Called: false, + }, + { + description: "Invalid OS", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "invalid", OSV: "14.0"}, + }, + expectedModifier140Called: false, + expectedModifier142Called: false, + }, + { + description: "Invalid Nil Device", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: nil, + }, + expectedModifier140Called: false, + expectedModifier142Called: false, + }, + } + + for _, test := range testCases { + modifierIOS140Called := false + modifierIOS140 := func(req *openrtb2.BidRequest) { modifierIOS140Called = true } + + modifierIOS142Called := false + modifierIOS142 := func(req *openrtb2.BidRequest) { modifierIOS142Called = true } + + modifiers := map[iosutil.VersionClassification]modifier{ + iosutil.Version140: modifierIOS140, + iosutil.Version142OrGreater: modifierIOS142, + } + + modifyForIOS(test.givenRequest, modifiers) + + assert.Equal(t, test.expectedModifier140Called, modifierIOS140Called, test.description) + assert.Equal(t, test.expectedModifier142Called, modifierIOS142Called, test.description) + } +} + +func TestIsRequestForIOS(t *testing.T) { + testCases := []struct { + description string + givenRequest *openrtb2.BidRequest + expected bool + }{ + { + description: "Valid", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "iOS"}, + }, + expected: true, + }, + { + description: "Valid - OS Case Insensitive", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "IOS"}, + }, + expected: true, + }, + { + description: "Invalid - Nil Request", + givenRequest: nil, + expected: false, + }, + { + description: "Invalid - Nil App", + givenRequest: &openrtb2.BidRequest{ + App: nil, + Device: &openrtb2.Device{OS: "iOS"}, + }, + expected: false, + }, + { + description: "Invalid - Nil Device", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: nil, + }, + expected: false, + }, + { + description: "Invalid - Empty OS", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: ""}, + }, + expected: false, + }, + { + description: "Invalid - Wrong OS", + givenRequest: &openrtb2.BidRequest{ + App: &openrtb2.App{}, + Device: &openrtb2.Device{OS: "Android"}, + }, + expected: false, + }, + } + + for _, test := range testCases { + result := isRequestForIOS(test.givenRequest) + assert.Equal(t, test.expected, result, test.description) + } +} + +func TestModifyForIOS14X(t *testing.T) { + testCases := []struct { + description string + givenDevice openrtb2.Device + expectedLMT *int8 + }{ + { + description: "IFA Empty", + givenDevice: openrtb2.Device{IFA: "", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + { + description: "IFA Zero UUID", + givenDevice: openrtb2.Device{IFA: "00000000-0000-0000-0000-000000000000", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + { + description: "IFA Populated", + givenDevice: openrtb2.Device{IFA: "any-real-value", Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), + }, + { + description: "Overwrites Existing", + givenDevice: openrtb2.Device{IFA: "", Lmt: openrtb2.Int8Ptr(0)}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + } + + for _, test := range testCases { + request := &openrtb2.BidRequest{Device: &test.givenDevice} + modifyForIOS14X(request) + assert.Equal(t, test.expectedLMT, request.Device.Lmt, test.description) + } +} + +func TestModifyForIOS142OrGreater(t *testing.T) { + testCases := []struct { + description string + givenDevice openrtb2.Device + expectedLMT *int8 + }{ + { + description: "Not Determined", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":0}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), + }, + { + description: "Restricted", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":1}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + { + description: "Denied", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":2}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + { + description: "Authorized", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: nil}, + expectedLMT: openrtb2.Int8Ptr(0), + }, + { + description: "Overwrites Existing", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":3}`), Lmt: openrtb2.Int8Ptr(1)}, + expectedLMT: openrtb2.Int8Ptr(0), + }, + { + description: "Invalid Value - Unknown", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: nil}, + expectedLMT: nil, + }, + { + description: "Invalid Value - Unknown - Does Not Overwrite Existing", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":4}`), Lmt: openrtb2.Int8Ptr(1)}, + expectedLMT: openrtb2.Int8Ptr(1), + }, + { + description: "Invalid Value - Missing", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{}`), Lmt: nil}, + expectedLMT: nil, + }, + { + description: "Invalid Value - Wrong Type", + givenDevice: openrtb2.Device{Ext: json.RawMessage(`{"atts":"wrong type"}`), Lmt: nil}, + expectedLMT: nil, + }, + } + + for _, test := range testCases { + 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 5f23b9a3eef..0f2829254a2 100644 --- a/privacy/lmt/policy.go +++ b/privacy/lmt/policy.go @@ -1,8 +1,6 @@ package lmt -import ( - "github.com/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/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 9d0e3b6aa9a..f475d2fb702 100644 --- a/privacy/lmt/policy_test.go +++ b/privacy/lmt/policy_test.go @@ -3,7 +3,7 @@ package lmt import ( "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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/policies.go b/privacy/policies.go index a1c3fca49be..bc844a4e463 100644 --- a/privacy/policies.go +++ b/privacy/policies.go @@ -1,9 +1,9 @@ package privacy import ( - "github.com/PubMatic-OpenWrap/prebid-server/privacy/ccpa" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/gdpr" - "github.com/PubMatic-OpenWrap/prebid-server/privacy/lmt" + "github.com/prebid/prebid-server/privacy/ccpa" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/prebid/prebid-server/privacy/lmt" ) // Policies represents the privacy regulations for an OpenRTB bid request. diff --git a/privacy/scrubber.go b/privacy/scrubber.go index aea5c9008f4..edaa5bb07c6 100644 --- a/privacy/scrubber.go +++ b/privacy/scrubber.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strings" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 4d989e1c5a1..9207315f593 100644 --- a/privacy/scrubber_test.go +++ b/privacy/scrubber_test.go @@ -4,12 +4,12 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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 a68a158ced8..0f04a52f292 100644 --- a/privacy/writer.go +++ b/privacy/writer.go @@ -1,18 +1,16 @@ package privacy -import ( - "github.com/PubMatic-OpenWrap/openrtb" -) +import "github.com/mxmCherry/openrtb/v15/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 754e6ffe2c9..f5b02387124 100644 --- a/privacy/writer_test.go +++ b/privacy/writer_test.go @@ -4,16 +4,16 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/openrtb" + "github.com/mxmCherry/openrtb/v15/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/admin.go b/router/admin.go index ba4f25f585b..b66bf55a5d6 100644 --- a/router/admin.go +++ b/router/admin.go @@ -5,8 +5,8 @@ import ( "net/http/pprof" "time" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/endpoints" ) func Admin(revision string, rateConverter *currency.RateConverter, rateConverterFetchingInterval time.Duration) *http.ServeMux { diff --git a/router/aspects/request_timeout_handler.go b/router/aspects/request_timeout_handler.go index 9c51b9b8570..39a4341f995 100644 --- a/router/aspects/request_timeout_handler.go +++ b/router/aspects/request_timeout_handler.go @@ -5,9 +5,9 @@ import ( "strconv" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" ) func QueuedRequestTimeout(f httprouter.Handle, reqTimeoutHeaders config.RequestTimeoutHeaders, metricsEngine metrics.MetricsEngine, requestType metrics.RequestType) httprouter.Handle { diff --git a/router/aspects/request_timeout_handler_test.go b/router/aspects/request_timeout_handler_test.go index 3d6fa34e5bd..26e546dcd40 100644 --- a/router/aspects/request_timeout_handler_test.go +++ b/router/aspects/request_timeout_handler_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" "github.com/stretchr/testify/assert" ) diff --git a/router/router.go b/router/router.go index eb69f5fafd1..e79e9782f89 100644 --- a/router/router.go +++ b/router/router.go @@ -6,47 +6,47 @@ import ( "database/sql" "encoding/json" "fmt" + "github.com/prebid/prebid-server/analytics" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/usersync" + "github.com/prometheus/client_golang/prometheus" "io/ioutil" "net/http" "path/filepath" "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/analytics" - "github.com/PubMatic-OpenWrap/prebid-server/currency" - "github.com/PubMatic-OpenWrap/prebid-server/errortypes" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" - "github.com/prometheus/client_golang/prometheus" - - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - - "github.com/PubMatic-OpenWrap/prebid-server/adapters" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adform" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/appnexus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/conversant" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ix" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lifestreet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pubmatic" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pulsepoint" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rubicon" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sovrn" - analyticsConf "github.com/PubMatic-OpenWrap/prebid-server/analytics/config" - "github.com/PubMatic-OpenWrap/prebid-server/cache" - "github.com/PubMatic-OpenWrap/prebid-server/cache/dummycache" - "github.com/PubMatic-OpenWrap/prebid-server/cache/filecache" - "github.com/PubMatic-OpenWrap/prebid-server/cache/postgrescache" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints" - "github.com/PubMatic-OpenWrap/prebid-server/endpoints/openrtb2" - "github.com/PubMatic-OpenWrap/prebid-server/exchange" - "github.com/PubMatic-OpenWrap/prebid-server/gdpr" - metricsConf "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - pbc "github.com/PubMatic-OpenWrap/prebid-server/prebid_cache_client" - "github.com/PubMatic-OpenWrap/prebid-server/server/ssl" - storedRequestsConf "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/config" - "github.com/PubMatic-OpenWrap/prebid-server/usersync/usersyncers" + "github.com/prebid/prebid-server/currency" + "github.com/prebid/prebid-server/errortypes" + + "github.com/prebid/prebid-server/metrics" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/adapters/adform" + "github.com/prebid/prebid-server/adapters/appnexus" + "github.com/prebid/prebid-server/adapters/conversant" + "github.com/prebid/prebid-server/adapters/ix" + "github.com/prebid/prebid-server/adapters/lifestreet" + "github.com/prebid/prebid-server/adapters/pubmatic" + "github.com/prebid/prebid-server/adapters/pulsepoint" + "github.com/prebid/prebid-server/adapters/rubicon" + "github.com/prebid/prebid-server/adapters/sovrn" + analyticsConf "github.com/prebid/prebid-server/analytics/config" + "github.com/prebid/prebid-server/cache" + "github.com/prebid/prebid-server/cache/dummycache" + "github.com/prebid/prebid-server/cache/filecache" + "github.com/prebid/prebid-server/cache/postgrescache" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/endpoints" + "github.com/prebid/prebid-server/endpoints/openrtb2" + "github.com/prebid/prebid-server/exchange" + "github.com/prebid/prebid-server/gdpr" + metricsConf "github.com/prebid/prebid-server/metrics/config" + "github.com/prebid/prebid-server/openrtb_ext" + pbc "github.com/prebid/prebid-server/prebid_cache_client" + "github.com/prebid/prebid-server/server/ssl" + storedRequestsConf "github.com/prebid/prebid-server/stored_requests/config" + "github.com/prebid/prebid-server/usersync/usersyncers" "github.com/golang/glog" "github.com/julienschmidt/httprouter" @@ -192,7 +192,6 @@ type Router struct { } func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *Router, err error) { - const schemaDirectory = "/home/http/GO_SERVER/dmhbserver/static/bidder-params" const infoDirectory = "/home/http/GO_SERVER/dmhbserver/static/bidder-info" @@ -252,84 +251,91 @@ func New(cfg *config.Configuration, rateConvertor *currency.RateConverter) (r *R } p, _ := filepath.Abs(infoDirectory) - bidderInfos := adapters.ParseBidderInfos(cfg.Adapters, p, openrtb_ext.CoreBidderNames()) + bidderInfos, err := config.LoadBidderInfoFromDisk(p, cfg.Adapters, openrtb_ext.BuildBidderStringSlice()) + if err != nil { + glog.Fatal(err) + } g_activeBidders = exchange.GetActiveBidders(bidderInfos) g_disabledBidders = exchange.GetDisabledBiddersErrorMessages(bidderInfos) - _, g_defReqJSON = readDefaultRequest(cfg.DefReqConfig) + defaultAliases, defReqJSON := readDefaultRequest(cfg.DefReqConfig) + if err := validateDefaultAliases(defaultAliases); err != nil { + glog.Fatal(err) + } + + g_defReqJSON = defReqJSON g_syncers = usersyncers.NewSyncerMap(cfg) - g_gdprPerms = gdpr.NewPermissions(context.Background(), cfg.GDPR, adapters.GDPRAwareSyncerIDs(g_syncers), generalHttpClient) + gvlVendorIDs := bidderInfos.ToGVLVendorIDMap() + g_gdprPerms = gdpr.NewPermissions(context.Background(), cfg.GDPR, gvlVendorIDs, generalHttpClient) exchanges = newExchangeMap(cfg) g_cacheClient = pbc.NewClient(cacheHttpClient, &cfg.CacheURL, &cfg.ExtCacheURL, g_metrics) adapters, adaptersErrs := exchange.BuildAdapters(generalHttpClient, cfg, bidderInfos, r.MetricsEngine) if len(adaptersErrs) > 0 { - errs := errortypes.NewAggregateErrors("Failed to initialize adapters", adaptersErrs) + errs := errortypes.NewAggregateError("Failed to initialize adapters", adaptersErrs) glog.Fatalf("%v", errs) } g_ex = exchange.NewExchange(adapters, g_cacheClient, cfg, g_metrics, bidderInfos, g_gdprPerms, rateConvertor, g_categoriesFetcher) - /* - 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) - } + /*openrtbEndpoint, err := openrtb2.NewEndpoint(theExchange, paramsValidator, fetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders) + if err != nil { + 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) + ampEndpoint, err := openrtb2.NewAmpEndpoint(theExchange, paramsValidator, ampFetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders) + if err != nil { + glog.Fatalf("Failed to create the amp endpoint handler. %v", err) + } - if err != nil { - glog.Fatalf("Failed to create the amp endpoint handler. %v", err) - } + videoEndpoint, err := openrtb2.NewVideoEndpoint(theExchange, paramsValidator, fetcher, videoFetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders, cacheClient) + if err != nil { + glog.Fatalf("Failed to create the video endpoint handler. %v", err) + } - videoEndpoint, err := openrtb2.NewVideoEndpoint(theExchange, paramsValidator, fetcher, videoFetcher, accounts, cfg, r.MetricsEngine, pbsAnalytics, disabledBidders, defReqJSON, activeBidders, cacheClient) - if err != nil { - glog.Fatalf("Failed to create the video endpoint handler. %v", err) - } + requestTimeoutHeaders := config.RequestTimeoutHeaders{} + if cfg.RequestTimeoutHeaders != requestTimeoutHeaders { + videoEndpoint = aspects.QueuedRequestTimeout(videoEndpoint, cfg.RequestTimeoutHeaders, r.MetricsEngine, metrics.ReqTypeVideo) + } - requestTimeoutHeaders := config.RequestTimeoutHeaders{} - if cfg.RequestTimeoutHeaders != requestTimeoutHeaders { - videoEndpoint = aspects.QueuedRequestTimeout(videoEndpoint, cfg.RequestTimeoutHeaders, r.MetricsEngine, metrics.ReqTypeVideo) - } + r.POST("/auction", endpoints.Auction(cfg, syncers, gdprPerms, r.MetricsEngine, dataCache, exchanges)) + r.POST("/openrtb2/auction", openrtbEndpoint) + r.POST("/openrtb2/video", videoEndpoint) + r.GET("/openrtb2/amp", ampEndpoint) + r.GET("/info/bidders", infoEndpoints.NewBiddersEndpoint(bidderInfos, defaultAliases)) + r.GET("/info/bidders/:bidderName", infoEndpoints.NewBiddersDetailEndpoint(bidderInfos, cfg.Adapters, defaultAliases)) + r.GET("/bidders/params", NewJsonDirectoryServer(schemaDirectory, paramsValidator, defaultAliases)) + r.POST("/cookie_sync", endpoints.NewCookieSyncEndpoint(syncers, cfg, gdprPerms, r.MetricsEngine, pbsAnalytics, activeBidders)) + r.GET("/status", endpoints.NewStatusEndpoint(cfg.StatusResponse)) + r.GET("/", serveIndex) + r.ServeFiles("/static/*filepath", http.Dir("static")) + + // vtrack endpoint + if cfg.VTrack.Enabled { + vtrackEndpoint := events.NewVTrackEndpoint(cfg, accounts, cacheClient, bidderInfos) + r.POST("/vtrack", vtrackEndpoint) + } - r.POST("/auction", endpoints.Auction(cfg, syncers, gdprPerms, r.MetricsEngine, dataCache, exchanges)) - r.POST("/openrtb2/auction", openrtbEndpoint) - r.POST("/openrtb2/video", videoEndpoint) - r.GET("/openrtb2/amp", ampEndpoint) - r.GET("/info/bidders", infoEndpoints.NewBiddersEndpoint(defaultAliases)) - r.GET("/info/bidders/:bidderName", infoEndpoints.NewBidderDetailsEndpoint(bidderInfos, defaultAliases)) - r.GET("/bidders/params", NewJsonDirectoryServer(schemaDirectory, paramsValidator, defaultAliases)) - r.POST("/cookie_sync", endpoints.NewCookieSyncEndpoint(syncers, cfg, gdprPerms, r.MetricsEngine, pbsAnalytics, activeBidders)) - r.GET("/status", endpoints.NewStatusEndpoint(cfg.StatusResponse)) - r.GET("/", serveIndex) - r.ServeFiles("/static/*filepath", http.Dir("static")) - - // vtrack endpoint - if cfg.VTrack.Enabled { - vtrackEndpoint := events.NewVTrackEndpoint(cfg, accounts, cacheClient, bidderInfos) - r.POST("/vtrack", vtrackEndpoint) - } + // event endpoint + eventEndpoint := events.NewEventEndpoint(cfg, accounts, pbsAnalytics) + r.GET("/event", eventEndpoint) - // event endpoint - eventEndpoint := events.NewEventEndpoint(cfg, accounts, pbsAnalytics) - r.GET("/event", eventEndpoint) + userSyncDeps := &pbs.UserSyncDeps{ + HostCookieConfig: &(cfg.HostCookie), + ExternalUrl: cfg.ExternalURL, + RecaptchaSecret: cfg.RecaptchaSecret, + MetricsEngine: r.MetricsEngine, + PBSAnalytics: pbsAnalytics, + } - userSyncDeps := &pbs.UserSyncDeps{ - HostCookieConfig: &(cfg.HostCookie), - ExternalUrl: cfg.ExternalURL, - RecaptchaSecret: cfg.RecaptchaSecret, - MetricsEngine: r.MetricsEngine, - PBSAnalytics: pbsAnalytics, - } + r.GET("/setuid", endpoints.NewSetUIDEndpoint(cfg.HostCookie, syncers, gdprPerms, pbsAnalytics, r.MetricsEngine)) + r.GET("/getuids", endpoints.NewGetUIDsEndpoint(cfg.HostCookie)) + r.POST("/optout", userSyncDeps.OptOut) + r.GET("/optout", userSyncDeps.OptOut)*/ - r.GET("/setuid", endpoints.NewSetUIDEndpoint(cfg.HostCookie, syncers, gdprPerms, pbsAnalytics, r.MetricsEngine)) - r.GET("/getuids", endpoints.NewGetUIDsEndpoint(cfg.HostCookie)) - r.POST("/optout", userSyncDeps.OptOut) - r.GET("/optout", userSyncDeps.OptOut) - */ return r, nil } @@ -453,3 +459,19 @@ func GetPrometheusRegistry() *prometheus.Registry { return mEngine.PrometheusMetrics.Registry } + +func validateDefaultAliases(aliases map[string]string) error { + var errs []error + + for alias := range aliases { + if openrtb_ext.IsBidderNameReserved(alias) { + errs = append(errs, fmt.Errorf("alias %s is a reserved bidder name and cannot be used", alias)) + } + } + + if len(errs) > 0 { + return errortypes.NewAggregateError("default request alias errors", errs) + } + + return nil +} diff --git a/router/router_test.go b/router/router_test.go index ded8a964ea7..e64129cc8a7 100644 --- a/router/router_test.go +++ b/router/router_test.go @@ -8,8 +8,8 @@ import ( "os" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) @@ -180,5 +180,43 @@ func TestLoadDefaultAliasesNoInfo(t *testing.T) { assert.JSONEq(t, string(expectedJSON), string(aliasJSON)) assert.Equal(t, expectedAliases, defAliases) +} + +func TestValidateDefaultAliases(t *testing.T) { + var testCases = []struct { + description string + givenAliases map[string]string + expectedError string + }{ + { + description: "None", + givenAliases: map[string]string{}, + expectedError: "", + }, + { + description: "Valid", + givenAliases: map[string]string{"aAlias": "a"}, + expectedError: "", + }, + { + description: "Invalid", + givenAliases: map[string]string{"all": "a"}, + expectedError: "default request alias errors (1 error):\n 1: alias all is a reserved bidder name and cannot be used\n", + }, + { + description: "Mixed", + givenAliases: map[string]string{"aAlias": "a", "all": "a"}, + expectedError: "default request alias errors (1 error):\n 1: alias all is a reserved bidder name and cannot be used\n", + }, + } + + for _, test := range testCases { + err := validateDefaultAliases(test.givenAliases) + if test.expectedError == "" { + assert.NoError(t, err, test.description) + } else { + assert.EqualError(t, err, test.expectedError, test.description) + } + } } diff --git a/server/listener.go b/server/listener.go index f172ad7d961..c1f57723da3 100644 --- a/server/listener.go +++ b/server/listener.go @@ -5,8 +5,8 @@ import ( "strings" "time" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" "github.com/golang/glog" + "github.com/prebid/prebid-server/metrics" ) // monitorableListener tracks any opened connections in the metrics. diff --git a/server/listener_test.go b/server/listener_test.go index 58f3d42d95a..f91dbddbc54 100644 --- a/server/listener_test.go +++ b/server/listener_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" gometrics "github.com/rcrowley/go-metrics" ) diff --git a/server/prometheus.go b/server/prometheus.go index 8001234faa2..4b9f7037d0a 100644 --- a/server/prometheus.go +++ b/server/prometheus.go @@ -7,9 +7,9 @@ import ( "github.com/golang/glog" "github.com/prometheus/client_golang/prometheus/promhttp" - "github.com/PubMatic-OpenWrap/prebid-server/config" - metricsconfig "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" - prometheusMetrics "github.com/PubMatic-OpenWrap/prebid-server/metrics/prometheus" + "github.com/prebid/prebid-server/config" + metricsconfig "github.com/prebid/prebid-server/metrics/config" + prometheusMetrics "github.com/prebid/prebid-server/metrics/prometheus" ) func newPrometheusServer(cfg *config.Configuration, metrics *metricsconfig.DetailedMetricsEngine) *http.Server { diff --git a/server/server.go b/server/server.go index 0b1aa76b63b..46b7e5ae610 100644 --- a/server/server.go +++ b/server/server.go @@ -12,10 +12,10 @@ import ( "time" "github.com/NYTimes/gziphandler" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - metricsconfig "github.com/PubMatic-OpenWrap/prebid-server/metrics/config" "github.com/golang/glog" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + metricsconfig "github.com/prebid/prebid-server/metrics/config" ) // Listen blocks forever, serving PBS requests on the given port. This will block forever, until the process is shut down. diff --git a/server/server_test.go b/server/server_test.go index 3d6d5684e96..e7ef593a4b5 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" + "github.com/prebid/prebid-server/config" ) func TestNewAdminServer(t *testing.T) { diff --git a/static/bidder-info/33across.yaml b/static/bidder-info/33across.yaml index e3eea765556..044cfe140b2 100644 --- a/static/bidder-info/33across.yaml +++ b/static/bidder-info/33across.yaml @@ -1,5 +1,6 @@ maintainer: email: "headerbidding@33across.com" +gvlVendorID: 58 capabilities: site: mediaTypes: diff --git a/static/bidder-info/acuityads.yaml b/static/bidder-info/acuityads.yaml index 9da1446d918..9539e36b91e 100644 --- a/static/bidder-info/acuityads.yaml +++ b/static/bidder-info/acuityads.yaml @@ -1,5 +1,6 @@ maintainer: email: "integrations@acuityads.com" +gvlVendorID: 231 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adform.yaml b/static/bidder-info/adform.yaml index 4dce10b9af8..461714ac44d 100644 --- a/static/bidder-info/adform.yaml +++ b/static/bidder-info/adform.yaml @@ -1,5 +1,6 @@ maintainer: email: "scope.sspp@adform.com" +gvlVendorID: 50 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adkernel.yaml b/static/bidder-info/adkernel.yaml index 26f8c322ddc..a78b3cde498 100644 --- a/static/bidder-info/adkernel.yaml +++ b/static/bidder-info/adkernel.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid-dev@adkernel.com" +gvlVendorID: 14 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adkernelAdn.yaml b/static/bidder-info/adkernelAdn.yaml index fd47367db7c..1f54f8e5a8f 100644 --- a/static/bidder-info/adkernelAdn.yaml +++ b/static/bidder-info/adkernelAdn.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid-dev@adkernel.com" +gvlVendorID: 14 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adman.yaml b/static/bidder-info/adman.yaml index 932ef2e4242..2db7c07584c 100644 --- a/static/bidder-info/adman.yaml +++ b/static/bidder-info/adman.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@admanmedia.com" +gvlVendorID: 149 capabilities: app: mediaTypes: diff --git a/static/bidder-info/admixer.yaml b/static/bidder-info/admixer.yaml index 64ad2024058..9faf0eb3a3e 100644 --- a/static/bidder-info/admixer.yaml +++ b/static/bidder-info/admixer.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@admixer.net" +gvlVendorID: 511 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adocean.yaml b/static/bidder-info/adocean.yaml index 2f31fe92eaf..b3a23718a5a 100644 --- a/static/bidder-info/adocean.yaml +++ b/static/bidder-info/adocean.yaml @@ -1,5 +1,6 @@ maintainer: email: "aoteam@gemius.com" +gvlVendorID: 328 capabilities: site: mediaTypes: diff --git a/static/bidder-info/adpone.yaml b/static/bidder-info/adpone.yaml index 969983a12f6..7c5b473770b 100644 --- a/static/bidder-info/adpone.yaml +++ b/static/bidder-info/adpone.yaml @@ -1,5 +1,6 @@ maintainer: email: "tech@adpone.com" +gvlVendorID: 799 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adtelligent.yaml b/static/bidder-info/adtelligent.yaml index 7a20d52b266..30f55ea912e 100644 --- a/static/bidder-info/adtelligent.yaml +++ b/static/bidder-info/adtelligent.yaml @@ -1,5 +1,6 @@ maintainer: email: "hb@adtelligent.com" +gvlVendorID: 410 capabilities: app: mediaTypes: diff --git a/static/bidder-info/adxcg.yaml b/static/bidder-info/adxcg.yaml new file mode 100644 index 00000000000..e5535ae7258 --- /dev/null +++ b/static/bidder-info/adxcg.yaml @@ -0,0 +1,13 @@ +maintainer: + email: "info@adxcg.com" +capabilities: + app: + mediaTypes: + - banner + - video + - native + site: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-info/adyoulike.yaml b/static/bidder-info/adyoulike.yaml new file mode 100644 index 00000000000..d9b23d6c1a1 --- /dev/null +++ b/static/bidder-info/adyoulike.yaml @@ -0,0 +1,10 @@ +maintainer: + email: "core@adyoulike.com" +gvlVendorID: 259 +modifyingVastXmlAllowed: true +capabilities: + site: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-info/amx.yaml b/static/bidder-info/amx.yaml index 3e20d2095f6..f9fdfbb4a41 100644 --- a/static/bidder-info/amx.yaml +++ b/static/bidder-info/amx.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@amxrtb.com" +gvlVendorID: 737 capabilities: site: mediaTypes: diff --git a/static/bidder-info/appnexus.yaml b/static/bidder-info/appnexus.yaml index f1e7ca23cfb..f2f4a1266df 100644 --- a/static/bidder-info/appnexus.yaml +++ b/static/bidder-info/appnexus.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid-server@xandr.com" +gvlVendorID: 32 capabilities: app: mediaTypes: diff --git a/static/bidder-info/avocet.yaml b/static/bidder-info/avocet.yaml index ea98982d69c..42147c96ebf 100644 --- a/static/bidder-info/avocet.yaml +++ b/static/bidder-info/avocet.yaml @@ -1,5 +1,6 @@ maintainer: email: "developers@avocet.io" +gvlVendorID: 63 capabilities: app: mediaTypes: diff --git a/static/bidder-info/beachfront.yaml b/static/bidder-info/beachfront.yaml index 335545ff1ee..06991698090 100644 --- a/static/bidder-info/beachfront.yaml +++ b/static/bidder-info/beachfront.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@beachfront.com" +gvlVendorID: 335 capabilities: app: mediaTypes: diff --git a/static/bidder-info/beintoo.yaml b/static/bidder-info/beintoo.yaml index fcca29220cf..905d89a44c4 100644 --- a/static/bidder-info/beintoo.yaml +++ b/static/bidder-info/beintoo.yaml @@ -1,5 +1,6 @@ maintainer: email: "adops@beintoo.com" +gvlVendorID: 618 capabilities: site: mediaTypes: diff --git a/static/bidder-info/between.yaml b/static/bidder-info/between.yaml index d317d275c59..71bd8ba6256 100644 --- a/static/bidder-info/between.yaml +++ b/static/bidder-info/between.yaml @@ -1,5 +1,6 @@ maintainer: email: "buying@betweenx.com" +gvlVendorID: 724 capabilities: site: mediaTypes: diff --git a/static/bidder-info/bidmachine.yaml b/static/bidder-info/bidmachine.yaml new file mode 100644 index 00000000000..6868125b6e6 --- /dev/null +++ b/static/bidder-info/bidmachine.yaml @@ -0,0 +1,8 @@ +maintainer: + email: hi@bidmachine.io +gvlVendorID: 736 +capabilities: + app: + mediaTypes: + - banner + - video \ No newline at end of file diff --git a/static/bidder-info/brightroll.yaml b/static/bidder-info/brightroll.yaml index f913be6da8c..a2ea0c74b77 100644 --- a/static/bidder-info/brightroll.yaml +++ b/static/bidder-info/brightroll.yaml @@ -1,5 +1,6 @@ maintainer: email: "dsp-supply-prebid@verizonmedia.com" +gvlVendorID: 25 capabilities: app: mediaTypes: diff --git a/static/bidder-info/connectad.yaml b/static/bidder-info/connectad.yaml index 1b3e593d78d..fa0ae4520fc 100644 --- a/static/bidder-info/connectad.yaml +++ b/static/bidder-info/connectad.yaml @@ -1,5 +1,6 @@ maintainer: email: "support@connectad.io" +gvlVendorID: 138 capabilities: app: mediaTypes: diff --git a/static/bidder-info/consumable.yaml b/static/bidder-info/consumable.yaml index f12ab2b4016..e9b5f72623c 100644 --- a/static/bidder-info/consumable.yaml +++ b/static/bidder-info/consumable.yaml @@ -1,5 +1,6 @@ maintainer: email: "naffis@consumable.com" +gvlVendorID: 591 capabilities: app: mediaTypes: diff --git a/static/bidder-info/conversant.yaml b/static/bidder-info/conversant.yaml index 017f0e0c57e..aa3d3822802 100644 --- a/static/bidder-info/conversant.yaml +++ b/static/bidder-info/conversant.yaml @@ -1,5 +1,6 @@ maintainer: email: "CNVR_PublisherIntegration@conversantmedia.com" +gvlVendorID: 24 capabilities: app: mediaTypes: diff --git a/static/bidder-info/criteo.yaml b/static/bidder-info/criteo.yaml new file mode 100644 index 00000000000..b27e1fae369 --- /dev/null +++ b/static/bidder-info/criteo.yaml @@ -0,0 +1,10 @@ +maintainer: + email: "pi-direct@criteo.com" +gvlVendorID: 91 +capabilities: + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner \ No newline at end of file diff --git a/static/bidder-info/deepintent.yaml b/static/bidder-info/deepintent.yaml index 490e161c8d2..a8f17a55d6f 100644 --- a/static/bidder-info/deepintent.yaml +++ b/static/bidder-info/deepintent.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebiddev@deepintent.com" +gvlVendorID: 541 capabilities: app: mediaTypes: diff --git a/static/bidder-info/dmx.yaml b/static/bidder-info/dmx.yaml index 3ecb452f7f6..d29d699daeb 100644 --- a/static/bidder-info/dmx.yaml +++ b/static/bidder-info/dmx.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@districtm.net" +gvlVendorID: 144 capabilities: site: mediaTypes: diff --git a/static/bidder-info/emx_digital.yaml b/static/bidder-info/emx_digital.yaml index 49a068093eb..ec0d090fb4c 100644 --- a/static/bidder-info/emx_digital.yaml +++ b/static/bidder-info/emx_digital.yaml @@ -1,5 +1,6 @@ maintainer: email: "adops@emxdigital.com" +gvlVendorID: 183 capabilities: site: mediaTypes: diff --git a/static/bidder-info/engagebdr.yaml b/static/bidder-info/engagebdr.yaml index 57c359e451d..fd08367acc7 100644 --- a/static/bidder-info/engagebdr.yaml +++ b/static/bidder-info/engagebdr.yaml @@ -1,5 +1,6 @@ maintainer: email: "tech@engagebdr.com" +gvlVendorID: 62 capabilities: app: mediaTypes: diff --git a/static/bidder-info/eplanning.yaml b/static/bidder-info/eplanning.yaml index 907523d3eb3..ab0b7609dbb 100644 --- a/static/bidder-info/eplanning.yaml +++ b/static/bidder-info/eplanning.yaml @@ -1,5 +1,6 @@ maintainer: email: "producto@e-planning.net" +gvlVendorID: 90 capabilities: app: mediaTypes: diff --git a/static/bidder-info/epom.yaml b/static/bidder-info/epom.yaml new file mode 100644 index 00000000000..32afa346c9e --- /dev/null +++ b/static/bidder-info/epom.yaml @@ -0,0 +1,14 @@ +maintainer: + email: "support@epom.com" +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - native + site: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-info/gamoshi.yaml b/static/bidder-info/gamoshi.yaml index c3ed3ff10e4..0cfd495762f 100644 --- a/static/bidder-info/gamoshi.yaml +++ b/static/bidder-info/gamoshi.yaml @@ -1,5 +1,6 @@ maintainer: email: "dev@gamoshi.com" +gvlVendorID: 644 capabilities: app: mediaTypes: diff --git a/static/bidder-info/grid.yaml b/static/bidder-info/grid.yaml index 325421a2c05..31c7b7320e3 100644 --- a/static/bidder-info/grid.yaml +++ b/static/bidder-info/grid.yaml @@ -1,5 +1,6 @@ maintainer: email: "grid-tech@themediagrid.com" +gvlVendorID: 686 capabilities: app: mediaTypes: diff --git a/static/bidder-info/gumgum.yaml b/static/bidder-info/gumgum.yaml index 6ba563b4c1c..bfefe63ab40 100644 --- a/static/bidder-info/gumgum.yaml +++ b/static/bidder-info/gumgum.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@gumgum.com" +gvlVendorID: 61 capabilities: site: mediaTypes: diff --git a/static/bidder-info/improvedigital.yaml b/static/bidder-info/improvedigital.yaml index 7983cbc1a61..f7fea4a8402 100644 --- a/static/bidder-info/improvedigital.yaml +++ b/static/bidder-info/improvedigital.yaml @@ -1,11 +1,14 @@ maintainer: email: "hb@azerion.com" +gvlVendorID: 253 capabilities: app: mediaTypes: - banner - video + - native site: mediaTypes: - banner - video + - native diff --git a/static/bidder-info/invibes.yaml b/static/bidder-info/invibes.yaml index 1432529787e..45184fb9f65 100644 --- a/static/bidder-info/invibes.yaml +++ b/static/bidder-info/invibes.yaml @@ -1,5 +1,6 @@ maintainer: email: "system_operations@invibes.com" +gvlVendorID: 436 capabilities: site: mediaTypes: diff --git a/static/bidder-info/ix.yaml b/static/bidder-info/ix.yaml index 2f00ceb952f..1e89c72e5bb 100644 --- a/static/bidder-info/ix.yaml +++ b/static/bidder-info/ix.yaml @@ -1,5 +1,6 @@ maintainer: email: "pdu-supply-prebid@indexexchange.com" +gvlVendorID: 10 capabilities: app: mediaTypes: diff --git a/static/bidder-info/jixie.yaml b/static/bidder-info/jixie.yaml new file mode 100644 index 00000000000..ac38f313da1 --- /dev/null +++ b/static/bidder-info/jixie.yaml @@ -0,0 +1,8 @@ +maintainer: + email: contact@jixie.io +modifyingVastXmlAllowed: true +capabilities: + site: + mediaTypes: + - banner + - video diff --git a/static/bidder-info/lifestreet.yaml b/static/bidder-info/lifestreet.yaml index 139d55990b9..34dc4eca2d9 100644 --- a/static/bidder-info/lifestreet.yaml +++ b/static/bidder-info/lifestreet.yaml @@ -1,5 +1,6 @@ maintainer: email: "mobile.tech@lifestreet.com" +gvlVendorID: 67 capabilities: app: mediaTypes: diff --git a/static/bidder-info/mediafuse.yaml b/static/bidder-info/mediafuse.yaml index 112f67fe556..98611402905 100644 --- a/static/bidder-info/mediafuse.yaml +++ b/static/bidder-info/mediafuse.yaml @@ -1,5 +1,6 @@ maintainer: email: "support@mediafuse.com" +gvlVendorID: 411 capabilities: app: mediaTypes: diff --git a/static/bidder-info/mgid.yaml b/static/bidder-info/mgid.yaml index f8ba6db60b1..bddb8b8598e 100644 --- a/static/bidder-info/mgid.yaml +++ b/static/bidder-info/mgid.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@mgid.com" +gvlVendorID: 358 capabilities: app: mediaTypes: diff --git a/static/bidder-info/nanointeractive.yaml b/static/bidder-info/nanointeractive.yaml index 244e7602950..d199e9e8ff5 100644 --- a/static/bidder-info/nanointeractive.yaml +++ b/static/bidder-info/nanointeractive.yaml @@ -1,5 +1,6 @@ maintainer: email: "development@nanointeractive.com" +gvlVendorID: 72 capabilities: app: mediaTypes: diff --git a/static/bidder-info/nobid.yaml b/static/bidder-info/nobid.yaml index 51a55de46bc..89f2a28abcd 100644 --- a/static/bidder-info/nobid.yaml +++ b/static/bidder-info/nobid.yaml @@ -1,5 +1,6 @@ maintainer: email: "developers@nobid.io" +gvlVendorID: 816 capabilities: site: mediaTypes: diff --git a/static/bidder-info/onetag.yaml b/static/bidder-info/onetag.yaml new file mode 100644 index 00000000000..697ef04d5a1 --- /dev/null +++ b/static/bidder-info/onetag.yaml @@ -0,0 +1,14 @@ +maintainer: + email: devops@onetag.com +gvlVendorID: 241 +capabilities: + app: + mediaTypes: + - banner + - video + - native + site: + mediaTypes: + - banner + - video + - native \ No newline at end of file diff --git a/static/bidder-info/openx.yaml b/static/bidder-info/openx.yaml index 96ef8616c96..709f3db0147 100644 --- a/static/bidder-info/openx.yaml +++ b/static/bidder-info/openx.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@openx.com" +gvlVendorID: 69 capabilities: app: mediaTypes: diff --git a/static/bidder-info/orbidder.yaml b/static/bidder-info/orbidder.yaml index c683087d197..467093c1256 100644 --- a/static/bidder-info/orbidder.yaml +++ b/static/bidder-info/orbidder.yaml @@ -1,9 +1,7 @@ maintainer: email: "realtime-siggi@otto.de" +gvlVendorID: 559 capabilities: app: mediaTypes: - banner - site: - mediaTypes: - - banner \ No newline at end of file diff --git a/static/bidder-info/outbrain.yaml b/static/bidder-info/outbrain.yaml new file mode 100644 index 00000000000..e38ec915f49 --- /dev/null +++ b/static/bidder-info/outbrain.yaml @@ -0,0 +1,12 @@ +maintainer: + email: prog-ops-team@outbrain.com +gvlVendorID: 164 +capabilities: + app: + mediaTypes: + - banner + - native + site: + mediaTypes: + - banner + - native diff --git a/static/bidder-info/pangle.yaml b/static/bidder-info/pangle.yaml new file mode 100644 index 00000000000..3ac3a0ced0f --- /dev/null +++ b/static/bidder-info/pangle.yaml @@ -0,0 +1,9 @@ +maintainer: + email: pangle_dsp@bytedance.com +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-info/pubmatic.yaml b/static/bidder-info/pubmatic.yaml index 4009d439352..45c0418af8a 100644 --- a/static/bidder-info/pubmatic.yaml +++ b/static/bidder-info/pubmatic.yaml @@ -1,5 +1,6 @@ maintainer: email: "header-bidding@pubmatic.com" +gvlVendorID: 76 capabilities: app: mediaTypes: diff --git a/static/bidder-info/pulsepoint.yaml b/static/bidder-info/pulsepoint.yaml index 056a0bf3d7c..bda03efd99c 100644 --- a/static/bidder-info/pulsepoint.yaml +++ b/static/bidder-info/pulsepoint.yaml @@ -1,5 +1,6 @@ maintainer: email: "ExchangeTeam@pulsepoint.com" +gvlVendorID: 81 capabilities: app: mediaTypes: diff --git a/static/bidder-info/rhythmone.yaml b/static/bidder-info/rhythmone.yaml index 89da6cfea35..852344db3e3 100644 --- a/static/bidder-info/rhythmone.yaml +++ b/static/bidder-info/rhythmone.yaml @@ -1,5 +1,6 @@ maintainer: email: "support@rhythmone.com" +gvlVendorID: 36 capabilities: app: mediaTypes: diff --git a/static/bidder-info/rtbhouse.yaml b/static/bidder-info/rtbhouse.yaml index f15af6ca2e1..12744fdc75e 100644 --- a/static/bidder-info/rtbhouse.yaml +++ b/static/bidder-info/rtbhouse.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@rtbhouse.com" +gvlVendorID: 16 capabilities: site: mediaTypes: diff --git a/static/bidder-info/rubicon.yaml b/static/bidder-info/rubicon.yaml index 40848e3ec25..0f19ddb9627 100644 --- a/static/bidder-info/rubicon.yaml +++ b/static/bidder-info/rubicon.yaml @@ -1,5 +1,6 @@ maintainer: email: "header-bidding@rubiconproject.com" +gvlVendorID: 52 capabilities: app: mediaTypes: diff --git a/static/bidder-info/sharethrough.yaml b/static/bidder-info/sharethrough.yaml index 09530be508c..45dceb94d22 100644 --- a/static/bidder-info/sharethrough.yaml +++ b/static/bidder-info/sharethrough.yaml @@ -1,5 +1,6 @@ maintainer: email: "pubgrowth.engineering@sharethrough.com" +gvlVendorID: 80 capabilities: app: mediaTypes: diff --git a/static/bidder-info/smartadserver.yaml b/static/bidder-info/smartadserver.yaml index 626b7dac00d..f22c7149ff7 100644 --- a/static/bidder-info/smartadserver.yaml +++ b/static/bidder-info/smartadserver.yaml @@ -1,5 +1,6 @@ maintainer: email: "support@smartadserver.com" +gvlVendorID: 45 capabilities: app: mediaTypes: diff --git a/static/bidder-info/somoaudience.yaml b/static/bidder-info/somoaudience.yaml index 17156c18039..83b64e5c58e 100644 --- a/static/bidder-info/somoaudience.yaml +++ b/static/bidder-info/somoaudience.yaml @@ -1,5 +1,6 @@ maintainer: email: "publishers@somoaudience.com" +gvlVendorID: 341 capabilities: app: mediaTypes: diff --git a/static/bidder-info/sonobi.yaml b/static/bidder-info/sonobi.yaml index 6d39319a9f5..22a0a158306 100644 --- a/static/bidder-info/sonobi.yaml +++ b/static/bidder-info/sonobi.yaml @@ -1,5 +1,6 @@ maintainer: email: "apex.prebid@sonobi.com" +gvlVendorID: 104 capabilities: site: mediaTypes: diff --git a/static/bidder-info/sovrn.yaml b/static/bidder-info/sovrn.yaml index c62d61df8d8..4c6251bdf57 100644 --- a/static/bidder-info/sovrn.yaml +++ b/static/bidder-info/sovrn.yaml @@ -1,5 +1,6 @@ maintainer: email: "sovrnoss@sovrn.com" +gvlVendorID: 13 capabilities: app: mediaTypes: diff --git a/static/bidder-info/tappx.yaml b/static/bidder-info/tappx.yaml index 4c8d1560f27..eb655aa6a0c 100644 --- a/static/bidder-info/tappx.yaml +++ b/static/bidder-info/tappx.yaml @@ -1,7 +1,12 @@ maintainer: email: "tappx@tappx.com" +gvlVendorID: 628 capabilities: app: mediaTypes: - banner - video + site: + mediaTypes: + - banner + - video \ No newline at end of file diff --git a/static/bidder-info/telaria.yaml b/static/bidder-info/telaria.yaml index 43e8707a17b..736fb9720b3 100644 --- a/static/bidder-info/telaria.yaml +++ b/static/bidder-info/telaria.yaml @@ -1,5 +1,6 @@ maintainer: email: "github@telaria.com" +gvlVendorID: 202 capabilities: app: mediaTypes: diff --git a/static/bidder-info/triplelift.yaml b/static/bidder-info/triplelift.yaml index 2b9ff8d5675..fe0ad8b2203 100644 --- a/static/bidder-info/triplelift.yaml +++ b/static/bidder-info/triplelift.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@triplelift.com" +gvlVendorID: 28 capabilities: app: mediaTypes: diff --git a/static/bidder-info/triplelift_native.yaml b/static/bidder-info/triplelift_native.yaml index abe91659935..40d9be8f294 100644 --- a/static/bidder-info/triplelift_native.yaml +++ b/static/bidder-info/triplelift_native.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@triplelift.com" +gvlVendorID: 28 capabilities: app: mediaTypes: diff --git a/static/bidder-info/trustx.yaml b/static/bidder-info/trustx.yaml new file mode 100644 index 00000000000..6cfdd9fa465 --- /dev/null +++ b/static/bidder-info/trustx.yaml @@ -0,0 +1,12 @@ +maintainer: + email: "grid-tech@themediagrid.com" +gvlVendorID: 686 +capabilities: + app: + mediaTypes: + - banner + - video + site: + mediaTypes: + - banner + - video diff --git a/static/bidder-info/ucfunnel.yaml b/static/bidder-info/ucfunnel.yaml index 288b0b3f1b8..e6be68a0261 100644 --- a/static/bidder-info/ucfunnel.yaml +++ b/static/bidder-info/ucfunnel.yaml @@ -1,5 +1,6 @@ maintainer: email: "support@ucfunnel.com" +gvlVendorID: 607 capabilities: app: mediaTypes: diff --git a/static/bidder-info/unicorn.yaml b/static/bidder-info/unicorn.yaml new file mode 100644 index 00000000000..f1b5a4e7f3e --- /dev/null +++ b/static/bidder-info/unicorn.yaml @@ -0,0 +1,6 @@ +maintainer: + email: prebid@unicorn.inc +capabilities: + app: + mediaTypes: + - banner \ No newline at end of file diff --git a/static/bidder-info/unruly.yaml b/static/bidder-info/unruly.yaml index 01ed3774118..e31ea600b3e 100644 --- a/static/bidder-info/unruly.yaml +++ b/static/bidder-info/unruly.yaml @@ -1,5 +1,6 @@ maintainer: email: "adspaces@unrulygroup.com" +gvlVendorID: 162 capabilities: site: mediaTypes: diff --git a/static/bidder-info/verizonmedia.yaml b/static/bidder-info/verizonmedia.yaml index c00f2158d4b..0b4642fcb6a 100644 --- a/static/bidder-info/verizonmedia.yaml +++ b/static/bidder-info/verizonmedia.yaml @@ -1,5 +1,6 @@ maintainer: email: "dsp-supply-prebid@verizonmedia.com" +gvlVendorID: 25 capabilities: app: mediaTypes: diff --git a/static/bidder-info/visx.yaml b/static/bidder-info/visx.yaml index b6a16e4c2d0..789ce478bea 100644 --- a/static/bidder-info/visx.yaml +++ b/static/bidder-info/visx.yaml @@ -1,5 +1,6 @@ maintainer: email: "supply.partners@yoc.com" +gvlVendorID: 154 capabilities: site: mediaTypes: diff --git a/static/bidder-info/yieldlab.yaml b/static/bidder-info/yieldlab.yaml index 654e6c749cb..3030d8a1d42 100644 --- a/static/bidder-info/yieldlab.yaml +++ b/static/bidder-info/yieldlab.yaml @@ -1,5 +1,6 @@ maintainer: email: "solutions@yieldlab.de" +gvlVendorID: 70 capabilities: site: mediaTypes: diff --git a/static/bidder-info/yieldmo.yaml b/static/bidder-info/yieldmo.yaml index 64cda519acd..b1385acbebc 100644 --- a/static/bidder-info/yieldmo.yaml +++ b/static/bidder-info/yieldmo.yaml @@ -1,5 +1,6 @@ maintainer: email: "prebid@yieldmo.com" +gvlVendorID: 173 capabilities: app: mediaTypes: diff --git a/static/bidder-params/adform.json b/static/bidder-params/adform.json index f0b8c7a6be0..6c8a67732d5 100644 --- a/static/bidder-params/adform.json +++ b/static/bidder-params/adform.json @@ -25,7 +25,7 @@ }, "cdims": { "type": "string", - "description": "Comma-separated creative dimentions.", + "description": "Comma-separated creative dimensions.", "pattern": "(^\\d+x\\d+)(,\\d+x\\d+)*$" }, "minp": { diff --git a/static/bidder-params/adxcg.json b/static/bidder-params/adxcg.json new file mode 100644 index 00000000000..3f89234359d --- /dev/null +++ b/static/bidder-params/adxcg.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adxcg Adapter Params", + "description": "A schema which validates params accepted by the Adxcg adapter", + "type": "object", + "properties": { + "adzoneid": { + "type": "string", + "minLength": 1, + "description": "An ID which identifies the placement selling the impression" + } + }, + "required": ["adzoneid"] +} diff --git a/static/bidder-params/adyoulike.json b/static/bidder-params/adyoulike.json new file mode 100644 index 00000000000..448de344739 --- /dev/null +++ b/static/bidder-params/adyoulike.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "AdYouLike Adapter Params", + "description": "A schema which validates params accepted by the AdYouLike adapter", + "type": "object", + "properties": { + "placement": { + "type": "string", + "description": "Placement Id" + }, + "campaign": { + "type": "string", + "description": "Id of a forced campaign" + }, + "track": { + "type": "string", + "description": "Id of a forced Track" + }, + "creative": { + "type": "string", + "description": "Id of a forced creative" + }, + "source": { + "type": "string", + "description": "context of the campaign" + }, + "debug": { + "type": "string", + "description": "Arbitrary id used for debug purpose" + } + }, + "required": ["placement"] +} diff --git a/static/bidder-params/bidmachine.json b/static/bidder-params/bidmachine.json new file mode 100644 index 00000000000..819dc9b7e2d --- /dev/null +++ b/static/bidder-params/bidmachine.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Bidmachine Adapter Params", + "description": "A schema which validates params accepted by the Kidoz adapter", + "type": "object", + "properties": { + "host": { + "type": "string", + "minLength": 1, + "description": "Host" + }, + "path": { + "type": "string", + "minLength": 1, + "description": "URL path" + }, + "seller_id": { + "type": "string", + "minLength": 1, + "description": "Seller Identifier" + } + }, + "required": [ + "host", + "path", + "seller_id" + ] +} diff --git a/static/bidder-params/connectad.json b/static/bidder-params/connectad.json index 961b3b71202..15f4ab66bf3 100644 --- a/static/bidder-params/connectad.json +++ b/static/bidder-params/connectad.json @@ -16,9 +16,9 @@ }, "bidfloor": { "type": "number", - "description": "Requestes Floorprice" + "description": "Requests Floorprice" } }, "required": ["networkId", "siteId"] } - \ No newline at end of file + diff --git a/static/bidder-params/criteo.json b/static/bidder-params/criteo.json new file mode 100644 index 00000000000..9d348a7eded --- /dev/null +++ b/static/bidder-params/criteo.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Criteo adapter params", + "description": "The schema to validate Criteo specific params accepted by Criteo adapter", + "type": "object", + "properties": { + "zoneid": { + "type": "number", + "description": "Impression's zone ID.", + "minimum": 0 + }, + "networkid": { + "type": "number", + "description": "Impression's network ID.", + "minimum": 0 + } + }, + "anyOf": [ + { + "required": [ + "zoneid" + ] + }, + { + "required": [ + "networkid" + ] + } + ] +} \ No newline at end of file diff --git a/static/bidder-params/dmx.json b/static/bidder-params/dmx.json index fa2d447b5d2..3c76e507b92 100644 --- a/static/bidder-params/dmx.json +++ b/static/bidder-params/dmx.json @@ -31,4 +31,4 @@ }, "required": ["memberid"] -} +} \ No newline at end of file diff --git a/static/bidder-params/epom.json b/static/bidder-params/epom.json new file mode 100644 index 00000000000..ee8c14e4f7e --- /dev/null +++ b/static/bidder-params/epom.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Epom Adapter Params", + "description": "A schema which validates params accepted by the Epom adapter", + "type": "object", + + "properties": {} +} diff --git a/static/bidder-params/gumgum.json b/static/bidder-params/gumgum.json index 5ec2b8e0cbf..8c8677d9407 100644 --- a/static/bidder-params/gumgum.json +++ b/static/bidder-params/gumgum.json @@ -8,7 +8,26 @@ "type": "string", "description": "A tracking id used to identify GumGum zone.", "minLength": 8 + }, + "pubId": { + "type": "integer", + "description": "A tracking id used to identify GumGum publisher" + }, + "irisid": { + "type": "string", + "description": "A hashed IRIS.TV Content ID" } }, - "required": ["zone"] + "anyOf": [ + { + "required": [ + "zone" + ] + }, + { + "required": [ + "pubId" + ] + } + ] } diff --git a/static/bidder-params/invibes.json b/static/bidder-params/invibes.json index 11d276f8d3e..5545b17409d 100644 --- a/static/bidder-params/invibes.json +++ b/static/bidder-params/invibes.json @@ -23,7 +23,7 @@ "type": "boolean" } }, - "description": "Parameters used for debugging porposes" + "description": "Parameters used for debugging purposes" } }, "required": ["placementId"] diff --git a/static/bidder-params/jixie.json b/static/bidder-params/jixie.json new file mode 100644 index 00000000000..d3d294fe481 --- /dev/null +++ b/static/bidder-params/jixie.json @@ -0,0 +1,27 @@ + { + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Jixie Adapter Params", + "description": "A schema which validates params accepted by the Jixie adapter", + "type": "object", + "properties": { + "unit" : { + "type": "string", + "description": "The unit code of an inventory target", + "minLength": 18 + }, + "accountid" : { + "type": "string", + "description": "The accountid of an inventory target" + }, + "jxprop1" : { + "type": "string", + "description": "jxprop1 of an inventory target" + }, + "jxprop2" : { + "type": "string", + "description": "jxprop2 of an inventory target" + } + }, + "required": ["unit"] + } + diff --git a/static/bidder-params/kidoz.json b/static/bidder-params/kidoz.json index 79e2edc2fd2..16511a15ca7 100644 --- a/static/bidder-params/kidoz.json +++ b/static/bidder-params/kidoz.json @@ -5,22 +5,18 @@ "type": "object", "properties": { "access_token": { - "$ref": "#/definitions/non-empty-string", + "type": "string", + "minLength": 1, "description": "Kidoz access_token" }, "publisher_id": { - "$ref": "#/definitions/non-empty-string", - "description": "Kidoz publisher_id" - } - }, - "definitions": { - "non-empty-string": { "type": "string", - "minLength": 1 + "minLength": 1, + "description": "Kidoz publisher_id" } }, "required": [ "access_token", "publisher_id" ] -} \ No newline at end of file +} diff --git a/static/bidder-params/mobfoxpb.json b/static/bidder-params/mobfoxpb.json index 0cc7a16c026..40ce83abc8e 100644 --- a/static/bidder-params/mobfoxpb.json +++ b/static/bidder-params/mobfoxpb.json @@ -1,14 +1,30 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Mobfox Adapter Params", - "description": "A schema which validates params accepted by the Mobfox adapter", - "type": "object", - "properties": { - "TagID": { - "type": "string", - "minLength": 1, - "description": "An ID which identifies the mobfox ad tag" - } - }, - "required" : [ "TagID" ] -} + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Mobfox Adapter Params", + "description": "A schema which validates params accepted by the Mobfox adapter", + "type": "object", + "properties": { + "TagID": { + "type": "string", + "minLength": 1, + "description": "An ID which identifies the mobfox ad tag" + }, + "key": { + "type": "string", + "minLength": 1, + "description": "An ID which identifies the mobfox adexchange partner" + } + }, + "oneOf": [ + { + "required": [ + "TagID" + ] + }, + { + "required": [ + "key" + ] + } + ] +} \ No newline at end of file diff --git a/static/bidder-params/nanointeractive.json b/static/bidder-params/nanointeractive.json index 707dff2fa50..aacd3154a92 100644 --- a/static/bidder-params/nanointeractive.json +++ b/static/bidder-params/nanointeractive.json @@ -6,7 +6,7 @@ "properties": { "pid": { "type": "string", - "description": "Placement idd" + "description": "Placement id" }, "nq": { "type": "array", @@ -29,4 +29,4 @@ } }, "required": ["pid"] -} \ No newline at end of file +} diff --git a/static/bidder-params/nobid.json b/static/bidder-params/nobid.json index 576dbfecb5c..6293c40c9fd 100644 --- a/static/bidder-params/nobid.json +++ b/static/bidder-params/nobid.json @@ -7,12 +7,12 @@ "properties": { "siteId": { "type": "integer", - "description": "A Required ID which identifies the NoBid site. The siteId paramerter is provided by your NoBid account manager." + "description": "A Required ID which identifies the NoBid site. The siteId parameter is provided by your NoBid account manager." }, "placementId": { "type": "integer", - "description": "An oprional ID which identifies an adunit in a site. The placementId paramerter is provided by your NoBid account manager." + "description": "An optional ID which identifies an adunit in a site. The placementId parameter is provided by your NoBid account manager." } }, "required": ["siteId"] } - \ No newline at end of file + diff --git a/static/bidder-params/onetag.json b/static/bidder-params/onetag.json new file mode 100644 index 00000000000..ca2911ba4d1 --- /dev/null +++ b/static/bidder-params/onetag.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Onetag Adapter Params", + "description": "A schema which validates params accepted by the Onetag adapter", + "type": "object", + + "properties": { + "pubId": { + "type": "string", + "minLength": 1, + "description": "The publisher’s ID provided by OneTag" + }, + "ext": { + "type": "object", + "description": "A set of custom key-value pairs" + } + }, + + "required": ["pubId"] +} \ No newline at end of file diff --git a/static/bidder-params/outbrain.json b/static/bidder-params/outbrain.json new file mode 100644 index 00000000000..8cfb8bbdf28 --- /dev/null +++ b/static/bidder-params/outbrain.json @@ -0,0 +1,40 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Outbrain Adapter Params", + "description": "A schema which validates params accepted by the Outbrain adapter", + + "type": "object", + "properties": { + "publisher": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "domain": { + "type": "string" + } + }, + "required": ["id"] + }, + "tagid": { + "type": "string" + }, + "bcat": { + "type": "array", + "items": { + "type": "string" + } + }, + "badv": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": ["publisher"] +} diff --git a/static/bidder-params/pangle.json b/static/bidder-params/pangle.json new file mode 100644 index 00000000000..74085cb5e65 --- /dev/null +++ b/static/bidder-params/pangle.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Pangle Adapter Params", + "description": "A schema which validates params accepted by the Pangle adapter", + "type": "object", + "properties": { + "token": { + "type": "string", + "description": "Access Token", + "pattern": ".+" + } + }, + "required": [ + "token" + ] +} diff --git a/static/bidder-params/rtbhouse.json b/static/bidder-params/rtbhouse.json index e8f6bd03cff..00732bedd2f 100644 --- a/static/bidder-params/rtbhouse.json +++ b/static/bidder-params/rtbhouse.json @@ -1,8 +1,13 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "RTB House Adapter Params", - "description": "A schema which validates params accepted by the RTB House adapter", - "type": "object", - "properties": {}, - "required": [] + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "RTB House Adapter Params", + "description": "A schema which validates params accepted by the RTB House adapter", + "type": "object", + "properties": { + "publisherId": { + "type": "string", + "description": "The publisher’s ID provided by RTB House" + } + }, + "required": ["publisherId"] } diff --git a/static/bidder-params/trustx.json b/static/bidder-params/trustx.json new file mode 100644 index 00000000000..efedf9de537 --- /dev/null +++ b/static/bidder-params/trustx.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "TrustX Adapter Params", + "description": "A schema which validates params accepted by TrustX adapter", + "type": "object", + "properties": { + "uid": { + "type": "integer", + "description": "An ID which identifies this placement of the impression" + } + }, + "required": [] +} diff --git a/static/bidder-params/unicorn.json b/static/bidder-params/unicorn.json new file mode 100644 index 00000000000..f9c4e1677b6 --- /dev/null +++ b/static/bidder-params/unicorn.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "UNICORN Adapter Params", + "description": "A schema which validates params accepted by the UNICORN adapter", + "type": "object", + "properties": { + "placementId": { + "type": "string", + "description": "In Application, if placementId is empty, prebid server configuration id will be used as placementId." + }, + "publisherId": { + "type": "integer", + "description": "Account specific publisher id" + }, + "mediaId": { + "type": "string", + "description": "Publisher specific media id" + }, + "accountId": { + "type": "integer", + "description": "Account ID for charge request" + } + }, + "required" : ["mediaId", "accountId"] +} \ No newline at end of file diff --git a/static/category-mapping/freewheel/freewheel.json b/static/category-mapping/freewheel/freewheel.json index 1b849b5392d..11529206087 100644 --- a/static/category-mapping/freewheel/freewheel.json +++ b/static/category-mapping/freewheel/freewheel.json @@ -1255,4 +1255,4 @@ "id": "403", "name": "Retail Stores/Chains" } -} +} \ No newline at end of file diff --git a/stored_requests/backends/db_fetcher/fetcher.go b/stored_requests/backends/db_fetcher/fetcher.go index c3b71a3be67..d8cf132d25b 100644 --- a/stored_requests/backends/db_fetcher/fetcher.go +++ b/stored_requests/backends/db_fetcher/fetcher.go @@ -7,8 +7,8 @@ import ( "github.com/lib/pq" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" "github.com/golang/glog" + "github.com/prebid/prebid-server/stored_requests" ) func NewFetcher(db *sql.DB, queryMaker func(int, int) string) stored_requests.AllFetcher { diff --git a/stored_requests/backends/empty_fetcher/fetcher.go b/stored_requests/backends/empty_fetcher/fetcher.go index 6edf3cc4d00..ee6b98b3b2e 100644 --- a/stored_requests/backends/empty_fetcher/fetcher.go +++ b/stored_requests/backends/empty_fetcher/fetcher.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" ) // EmptyFetcher is a nil-object which has no Stored Requests. diff --git a/stored_requests/backends/file_fetcher/fetcher.go b/stored_requests/backends/file_fetcher/fetcher.go index bff94b21e79..2d3b00657b9 100644 --- a/stored_requests/backends/file_fetcher/fetcher.go +++ b/stored_requests/backends/file_fetcher/fetcher.go @@ -7,7 +7,7 @@ import ( "io/ioutil" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" ) // NewFileFetcher _immediately_ loads stored request data from local files. diff --git a/stored_requests/backends/file_fetcher/fetcher_test.go b/stored_requests/backends/file_fetcher/fetcher_test.go index f0900002c8c..a145a3b43a2 100644 --- a/stored_requests/backends/file_fetcher/fetcher_test.go +++ b/stored_requests/backends/file_fetcher/fetcher_test.go @@ -6,7 +6,7 @@ import ( "fmt" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" "github.com/stretchr/testify/assert" ) diff --git a/stored_requests/backends/http_fetcher/fetcher.go b/stored_requests/backends/http_fetcher/fetcher.go index 5a7d8fa2878..bc12caecb98 100644 --- a/stored_requests/backends/http_fetcher/fetcher.go +++ b/stored_requests/backends/http_fetcher/fetcher.go @@ -10,7 +10,7 @@ import ( "net/url" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" "github.com/golang/glog" "golang.org/x/net/context/ctxhttp" diff --git a/stored_requests/caches/cachestest/reliable.go b/stored_requests/caches/cachestest/reliable.go index a0ab07df431..7fbaf7238af 100644 --- a/stored_requests/caches/cachestest/reliable.go +++ b/stored_requests/caches/cachestest/reliable.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" ) const ( diff --git a/stored_requests/caches/memory/cache.go b/stored_requests/caches/memory/cache.go index 288e6c26b71..5939c26ddec 100644 --- a/stored_requests/caches/memory/cache.go +++ b/stored_requests/caches/memory/cache.go @@ -5,9 +5,9 @@ import ( "encoding/json" "sync" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" "github.com/coocood/freecache" "github.com/golang/glog" + "github.com/prebid/prebid-server/stored_requests" ) // NewCache returns an in-memory Cache which evicts items if: diff --git a/stored_requests/caches/memory/cache_test.go b/stored_requests/caches/memory/cache_test.go index 20ec1239cd2..b89bd5af26f 100644 --- a/stored_requests/caches/memory/cache_test.go +++ b/stored_requests/caches/memory/cache_test.go @@ -7,8 +7,8 @@ import ( "strconv" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/cachestest" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/caches/cachestest" ) func TestLRURobustness(t *testing.T) { diff --git a/stored_requests/config/config.go b/stored_requests/config/config.go index ed51ed6f5de..7f92f2521cd 100644 --- a/stored_requests/config/config.go +++ b/stored_requests/config/config.go @@ -6,23 +6,23 @@ import ( "net/http" "time" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/db_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/file_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/http_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/memory" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/nil_cache" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" - apiEvents "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events/api" - httpEvents "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events/http" - postgresEvents "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events/postgres" - "github.com/PubMatic-OpenWrap/prebid-server/util/task" + "github.com/prebid/prebid-server/metrics" + "github.com/golang/glog" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/backends/db_fetcher" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/prebid/prebid-server/stored_requests/backends/file_fetcher" + "github.com/prebid/prebid-server/stored_requests/backends/http_fetcher" + "github.com/prebid/prebid-server/stored_requests/caches/memory" + "github.com/prebid/prebid-server/stored_requests/caches/nil_cache" + "github.com/prebid/prebid-server/stored_requests/events" + apiEvents "github.com/prebid/prebid-server/stored_requests/events/api" + httpEvents "github.com/prebid/prebid-server/stored_requests/events/http" + postgresEvents "github.com/prebid/prebid-server/stored_requests/events/postgres" + "github.com/prebid/prebid-server/util/task" ) // This gets set to the connection string used when a database connection is made. We only support a single diff --git a/stored_requests/config/config_test.go b/stored_requests/config/config_test.go index fa1bbfd8764..6c8cd612299 100644 --- a/stored_requests/config/config_test.go +++ b/stored_requests/config/config_test.go @@ -12,14 +12,14 @@ import ( "github.com/stretchr/testify/assert" sqlmock "github.com/DATA-DOG/go-sqlmock" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/empty_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/backends/http_fetcher" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" - httpEvents "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events/http" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/backends/empty_fetcher" + "github.com/prebid/prebid-server/stored_requests/backends/http_fetcher" + "github.com/prebid/prebid-server/stored_requests/events" + httpEvents "github.com/prebid/prebid-server/stored_requests/events/http" "github.com/stretchr/testify/mock" ) diff --git a/stored_requests/events/api/api.go b/stored_requests/events/api/api.go index 8fb6f6be9eb..6dce4ebaad6 100644 --- a/stored_requests/events/api/api.go +++ b/stored_requests/events/api/api.go @@ -5,8 +5,8 @@ import ( "io/ioutil" "net/http" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" "github.com/julienschmidt/httprouter" + "github.com/prebid/prebid-server/stored_requests/events" ) type eventsAPI struct { diff --git a/stored_requests/events/api/api_test.go b/stored_requests/events/api/api_test.go index 74e02e69e4d..cd3af77bd83 100644 --- a/stored_requests/events/api/api_test.go +++ b/stored_requests/events/api/api_test.go @@ -9,9 +9,9 @@ import ( "strings" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/memory" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/caches/memory" + "github.com/prebid/prebid-server/stored_requests/events" ) func TestGoodRequests(t *testing.T) { diff --git a/stored_requests/events/events.go b/stored_requests/events/events.go index 60909a0d426..5b89943572f 100644 --- a/stored_requests/events/events.go +++ b/stored_requests/events/events.go @@ -4,7 +4,7 @@ import ( "context" "encoding/json" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests" ) // Save represents a bulk save diff --git a/stored_requests/events/events_test.go b/stored_requests/events/events_test.go index 0a48b4cc365..f3483705e86 100644 --- a/stored_requests/events/events_test.go +++ b/stored_requests/events/events_test.go @@ -7,8 +7,8 @@ import ( "reflect" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/memory" + "github.com/prebid/prebid-server/stored_requests" + "github.com/prebid/prebid-server/stored_requests/caches/memory" ) func TestListen(t *testing.T) { diff --git a/stored_requests/events/http/http.go b/stored_requests/events/http/http.go index 790c247e368..4615183f693 100644 --- a/stored_requests/events/http/http.go +++ b/stored_requests/events/http/http.go @@ -11,8 +11,8 @@ import ( "golang.org/x/net/context/ctxhttp" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" "github.com/buger/jsonparser" + "github.com/prebid/prebid-server/stored_requests/events" "github.com/golang/glog" ) diff --git a/stored_requests/events/postgres/database.go b/stored_requests/events/postgres/database.go index 89fb30b88c8..e769a55585c 100644 --- a/stored_requests/events/postgres/database.go +++ b/stored_requests/events/postgres/database.go @@ -8,11 +8,11 @@ import ( "net" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" - "github.com/PubMatic-OpenWrap/prebid-server/util/timeutil" "github.com/golang/glog" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests/events" + "github.com/prebid/prebid-server/util/timeutil" ) func bytesNull() []byte { diff --git a/stored_requests/events/postgres/database_test.go b/stored_requests/events/postgres/database_test.go index 63625061dd3..15d0fbffbc3 100644 --- a/stored_requests/events/postgres/database_test.go +++ b/stored_requests/events/postgres/database_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/events" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/stored_requests/fetcher.go b/stored_requests/fetcher.go index 597b660cb61..865231ee757 100644 --- a/stored_requests/fetcher.go +++ b/stored_requests/fetcher.go @@ -5,7 +5,7 @@ import ( "encoding/json" "fmt" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" + "github.com/prebid/prebid-server/metrics" ) // Fetcher knows how to fetch Stored Request data by id. diff --git a/stored_requests/fetcher_test.go b/stored_requests/fetcher_test.go index 07631e79bbd..e77bc75c310 100644 --- a/stored_requests/fetcher_test.go +++ b/stored_requests/fetcher_test.go @@ -6,8 +6,8 @@ import ( "errors" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/metrics" - "github.com/PubMatic-OpenWrap/prebid-server/stored_requests/caches/nil_cache" + "github.com/prebid/prebid-server/metrics" + "github.com/prebid/prebid-server/stored_requests/caches/nil_cache" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" diff --git a/usersync/cookie.go b/usersync/cookie.go index c3a045aca77..f5083a83bbe 100644 --- a/usersync/cookie.go +++ b/usersync/cookie.go @@ -8,8 +8,8 @@ import ( "net/http" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) const ( @@ -177,9 +177,8 @@ func (cookie *PBSCookie) GetId(bidderName openrtb_ext.BidderName) (id string, ex // SetCookieOnResponse is a shortcut for "ToHTTPCookie(); cookie.setDomain(domain); setCookie(w, cookie)" func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, setSiteCookie bool, cfg *config.HostCookie, ttl time.Duration) { httpCookie := cookie.ToHTTPCookie(ttl) - httpCookie.Secure = true - var domain string = cfg.Domain + httpCookie.Secure = true if domain != "" { httpCookie.Domain = domain @@ -210,7 +209,6 @@ func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, setSiteCooki //httpCookie.Secure = true uidsCookieStr = httpCookie.String() uidsCookieStr += SameSiteAttribute - sameSiteCookie = &http.Cookie{ Name: SameSiteCookieName, Value: SameSiteCookieValue, @@ -218,7 +216,6 @@ func (cookie *PBSCookie) SetCookieOnResponse(w http.ResponseWriter, setSiteCooki Path: "/", Secure: true, } - sameSiteCookieStr := sameSiteCookie.String() sameSiteCookieStr += SameSiteAttribute w.Header().Add("Set-Cookie", sameSiteCookieStr) diff --git a/usersync/cookie_test.go b/usersync/cookie_test.go index c05eadd4a98..ef2e9911e46 100644 --- a/usersync/cookie_test.go +++ b/usersync/cookie_test.go @@ -9,8 +9,8 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" "github.com/stretchr/testify/assert" ) diff --git a/usersync/usersync.go b/usersync/usersync.go index 7730febcd90..dffc1832f01 100644 --- a/usersync/usersync.go +++ b/usersync/usersync.go @@ -1,6 +1,6 @@ package usersync -import "github.com/PubMatic-OpenWrap/prebid-server/privacy" +import "github.com/prebid/prebid-server/privacy" type Usersyncer interface { // GetUsersyncInfo returns basic info the browser needs in order to run a user sync. @@ -14,16 +14,6 @@ type Usersyncer interface { // TODO #362: when the appnexus usersyncer is consistent, delete this and use the key // of NewSyncerMap() here instead. FamilyName() string - - // GDPRVendorID returns the ID in the IAB Global Vendor List which refers to this Bidder. - // - // The Global Vendor list can be found here: https://vendor-list.consensu.org/vendorlist.json - // Bidders can register for the list here: https://register.consensu.org/ - // - // If you're not on the list, this should return 0. If cookie sync requests have GDPR consent info, - // or the Prebid Server host company configures its deploy to be "cautious" when no GDPR info exists - // in the request, it will _not_ sync user IDs with you. - GDPRVendorID() uint16 } type UsersyncInfo struct { diff --git a/usersync/usersyncers/syncer.go b/usersync/usersyncers/syncer.go old mode 100755 new mode 100644 index 04ec05430e5..50362ad04ec --- a/usersync/usersyncers/syncer.go +++ b/usersync/usersyncers/syncer.go @@ -4,87 +4,95 @@ import ( "strings" "text/template" - ttx "github.com/PubMatic-OpenWrap/prebid-server/adapters/33across" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/acuityads" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adform" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adkernel" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adkernelAdn" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adman" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/admixer" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adocean" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adpone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adtarget" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/adtelligent" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/advangelists" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/aja" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/amx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/appnexus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/audienceNetwork" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/avocet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/beachfront" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/beintoo" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/between" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/brightroll" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/colossus" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/connectad" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/consumable" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/conversant" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/cpmstar" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/datablocks" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/deepintent" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/dmx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/emx_digital" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/engagebdr" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/eplanning" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gamma" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gamoshi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/grid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/gumgum" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/improvedigital" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/invibes" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ix" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/krushmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lifestreet" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lockerdome" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/logicad" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/lunamedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/marsmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/mediafuse" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/mgid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/nanointeractive" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ninthdecimal" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/nobid" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/openx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pubmatic" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/pulsepoint" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rhythmone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rtbhouse" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/rubicon" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sharethrough" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartadserver" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartrtb" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/smartyads" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/somoaudience" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sonobi" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/sovrn" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/synacormedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/telaria" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/triplelift" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/triplelift_native" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/ucfunnel" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/unruly" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/valueimpression" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/verizonmedia" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/visx" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/vrtcal" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldlab" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldmo" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/yieldone" - "github.com/PubMatic-OpenWrap/prebid-server/adapters/zeroclickfraud" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" - "github.com/PubMatic-OpenWrap/prebid-server/usersync" "github.com/golang/glog" + ttx "github.com/prebid/prebid-server/adapters/33across" + "github.com/prebid/prebid-server/adapters/acuityads" + "github.com/prebid/prebid-server/adapters/adform" + "github.com/prebid/prebid-server/adapters/adkernel" + "github.com/prebid/prebid-server/adapters/adkernelAdn" + "github.com/prebid/prebid-server/adapters/adman" + "github.com/prebid/prebid-server/adapters/admixer" + "github.com/prebid/prebid-server/adapters/adocean" + "github.com/prebid/prebid-server/adapters/adpone" + "github.com/prebid/prebid-server/adapters/adtarget" + "github.com/prebid/prebid-server/adapters/adtelligent" + "github.com/prebid/prebid-server/adapters/advangelists" + "github.com/prebid/prebid-server/adapters/adxcg" + "github.com/prebid/prebid-server/adapters/adyoulike" + "github.com/prebid/prebid-server/adapters/aja" + "github.com/prebid/prebid-server/adapters/amx" + "github.com/prebid/prebid-server/adapters/appnexus" + "github.com/prebid/prebid-server/adapters/audienceNetwork" + "github.com/prebid/prebid-server/adapters/avocet" + "github.com/prebid/prebid-server/adapters/beachfront" + "github.com/prebid/prebid-server/adapters/beintoo" + "github.com/prebid/prebid-server/adapters/between" + "github.com/prebid/prebid-server/adapters/brightroll" + "github.com/prebid/prebid-server/adapters/colossus" + "github.com/prebid/prebid-server/adapters/connectad" + "github.com/prebid/prebid-server/adapters/consumable" + "github.com/prebid/prebid-server/adapters/conversant" + "github.com/prebid/prebid-server/adapters/cpmstar" + "github.com/prebid/prebid-server/adapters/criteo" + "github.com/prebid/prebid-server/adapters/datablocks" + "github.com/prebid/prebid-server/adapters/deepintent" + "github.com/prebid/prebid-server/adapters/dmx" + "github.com/prebid/prebid-server/adapters/emx_digital" + "github.com/prebid/prebid-server/adapters/engagebdr" + "github.com/prebid/prebid-server/adapters/eplanning" + "github.com/prebid/prebid-server/adapters/gamma" + "github.com/prebid/prebid-server/adapters/gamoshi" + "github.com/prebid/prebid-server/adapters/grid" + "github.com/prebid/prebid-server/adapters/gumgum" + "github.com/prebid/prebid-server/adapters/improvedigital" + "github.com/prebid/prebid-server/adapters/invibes" + "github.com/prebid/prebid-server/adapters/ix" + "github.com/prebid/prebid-server/adapters/jixie" + "github.com/prebid/prebid-server/adapters/krushmedia" + "github.com/prebid/prebid-server/adapters/lifestreet" + "github.com/prebid/prebid-server/adapters/lockerdome" + "github.com/prebid/prebid-server/adapters/logicad" + "github.com/prebid/prebid-server/adapters/lunamedia" + "github.com/prebid/prebid-server/adapters/marsmedia" + "github.com/prebid/prebid-server/adapters/mediafuse" + "github.com/prebid/prebid-server/adapters/mgid" + "github.com/prebid/prebid-server/adapters/nanointeractive" + "github.com/prebid/prebid-server/adapters/ninthdecimal" + "github.com/prebid/prebid-server/adapters/nobid" + "github.com/prebid/prebid-server/adapters/onetag" + "github.com/prebid/prebid-server/adapters/openx" + "github.com/prebid/prebid-server/adapters/outbrain" + "github.com/prebid/prebid-server/adapters/pubmatic" + "github.com/prebid/prebid-server/adapters/pulsepoint" + "github.com/prebid/prebid-server/adapters/rhythmone" + "github.com/prebid/prebid-server/adapters/rtbhouse" + "github.com/prebid/prebid-server/adapters/rubicon" + "github.com/prebid/prebid-server/adapters/sharethrough" + "github.com/prebid/prebid-server/adapters/smartadserver" + "github.com/prebid/prebid-server/adapters/smartrtb" + "github.com/prebid/prebid-server/adapters/smartyads" + "github.com/prebid/prebid-server/adapters/somoaudience" + "github.com/prebid/prebid-server/adapters/sonobi" + "github.com/prebid/prebid-server/adapters/sovrn" + "github.com/prebid/prebid-server/adapters/synacormedia" + "github.com/prebid/prebid-server/adapters/tappx" + "github.com/prebid/prebid-server/adapters/telaria" + "github.com/prebid/prebid-server/adapters/triplelift" + "github.com/prebid/prebid-server/adapters/triplelift_native" + "github.com/prebid/prebid-server/adapters/trustx" + "github.com/prebid/prebid-server/adapters/ucfunnel" + "github.com/prebid/prebid-server/adapters/unruly" + "github.com/prebid/prebid-server/adapters/valueimpression" + "github.com/prebid/prebid-server/adapters/verizonmedia" + "github.com/prebid/prebid-server/adapters/visx" + "github.com/prebid/prebid-server/adapters/vrtcal" + "github.com/prebid/prebid-server/adapters/yieldlab" + "github.com/prebid/prebid-server/adapters/yieldmo" + "github.com/prebid/prebid-server/adapters/yieldone" + "github.com/prebid/prebid-server/adapters/zeroclickfraud" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/usersync" ) // NewSyncerMap returns a map of all the usersyncer objects. @@ -105,6 +113,8 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderAdtarget, adtarget.NewAdtargetSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderAdtelligent, adtelligent.NewAdtelligentSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderAdvangelists, advangelists.NewAdvangelistsSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderAdxcg, adxcg.NewAdxcgSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderAdyoulike, adyoulike.NewAdyoulikeSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderAJA, aja.NewAJASyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderAMX, amx.NewAMXSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderAppnexus, appnexus.NewAppnexusSyncer) @@ -116,6 +126,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderConnectAd, connectad.NewConnectAdSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderConsumable, consumable.NewConsumableSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderConversant, conversant.NewConversantSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderCriteo, criteo.NewCriteoSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderCpmstar, cpmstar.NewCpmstarSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderDatablocks, datablocks.NewDatablocksSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderDeepintent, deepintent.NewDeepintentSyncer) @@ -131,6 +142,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderImprovedigital, improvedigital.NewImprovedigitalSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderInvibes, invibes.NewInvibesSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderIx, ix.NewIxSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderJixie, jixie.NewJixieSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderKrushmedia, krushmedia.NewKrushmediaSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderLifestreet, lifestreet.NewLifestreetSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderLockerDome, lockerdome.NewLockerDomeSyncer) @@ -142,6 +154,8 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderNanoInteractive, nanointeractive.NewNanoInteractiveSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderNinthDecimal, ninthdecimal.NewNinthDecimalSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderNoBid, nobid.NewNoBidSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderOneTag, onetag.NewSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderOutbrain, outbrain.NewOutbrainSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderOpenx, openx.NewOpenxSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderPubmatic, pubmatic.NewPubmaticSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderPulsepoint, pulsepoint.NewPulsepointSyncer) @@ -156,9 +170,11 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderSmartRTB, smartrtb.NewSmartRTBSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderSmartyAds, smartyads.NewSmartyAdsSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderSynacormedia, synacormedia.NewSynacorMediaSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderTappx, tappx.NewTappxSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderTelaria, telaria.NewTelariaSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderTriplelift, triplelift.NewTripleliftSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderTripleliftNative, triplelift_native.NewTripleliftSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderTrustX, trustx.NewTrustXSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderUcfunnel, ucfunnel.NewUcfunnelSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderUnruly, unruly.NewUnrulySyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderValueImpression, valueimpression.NewValueImpressionSyncer) diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index 08a31322553..7e10c41cd76 100755 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -4,8 +4,8 @@ import ( "strings" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/config" - "github.com/PubMatic-OpenWrap/prebid-server/openrtb_ext" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" ) func TestNewSyncerMap(t *testing.T) { @@ -26,6 +26,8 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderAdtarget): syncConfig, string(openrtb_ext.BidderAdtelligent): syncConfig, string(openrtb_ext.BidderAdvangelists): syncConfig, + string(openrtb_ext.BidderAdxcg): syncConfig, + string(openrtb_ext.BidderAdyoulike): syncConfig, string(openrtb_ext.BidderAJA): syncConfig, string(openrtb_ext.BidderAMX): syncConfig, string(openrtb_ext.BidderAppnexus): syncConfig, @@ -40,6 +42,7 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderConsumable): syncConfig, string(openrtb_ext.BidderConversant): syncConfig, string(openrtb_ext.BidderCpmstar): syncConfig, + string(openrtb_ext.BidderCriteo): syncConfig, string(openrtb_ext.BidderDatablocks): syncConfig, string(openrtb_ext.BidderDmx): syncConfig, string(openrtb_ext.BidderDeepintent): syncConfig, @@ -53,6 +56,7 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderImprovedigital): syncConfig, string(openrtb_ext.BidderInvibes): syncConfig, string(openrtb_ext.BidderIx): syncConfig, + string(openrtb_ext.BidderJixie): syncConfig, string(openrtb_ext.BidderKrushmedia): syncConfig, string(openrtb_ext.BidderLifestreet): syncConfig, string(openrtb_ext.BidderLockerDome): syncConfig, @@ -64,7 +68,9 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderNanoInteractive): syncConfig, string(openrtb_ext.BidderNinthDecimal): syncConfig, string(openrtb_ext.BidderNoBid): syncConfig, + string(openrtb_ext.BidderOneTag): syncConfig, string(openrtb_ext.BidderOpenx): syncConfig, + string(openrtb_ext.BidderOutbrain): syncConfig, string(openrtb_ext.BidderPubmatic): syncConfig, string(openrtb_ext.BidderPulsepoint): syncConfig, string(openrtb_ext.BidderRhythmone): syncConfig, @@ -78,9 +84,11 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderSonobi): syncConfig, string(openrtb_ext.BidderSovrn): syncConfig, string(openrtb_ext.BidderSynacormedia): syncConfig, + string(openrtb_ext.BidderTappx): syncConfig, string(openrtb_ext.BidderTelaria): syncConfig, string(openrtb_ext.BidderTriplelift): syncConfig, string(openrtb_ext.BidderTripleliftNative): syncConfig, + string(openrtb_ext.BidderTrustX): syncConfig, string(openrtb_ext.BidderUcfunnel): syncConfig, string(openrtb_ext.BidderUnruly): syncConfig, string(openrtb_ext.BidderValueImpression): syncConfig, @@ -101,6 +109,8 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderAdot: true, openrtb_ext.BidderAdprime: true, openrtb_ext.BidderApplogy: true, + openrtb_ext.BidderBidmachine: true, + openrtb_ext.BidderEpom: true, openrtb_ext.BidderDecenterAds: true, openrtb_ext.BidderInMobi: true, openrtb_ext.BidderKidoz: true, @@ -108,12 +118,13 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderMobfoxpb: true, openrtb_ext.BidderMobileFuse: true, openrtb_ext.BidderOrbidder: true, + openrtb_ext.BidderPangle: true, openrtb_ext.BidderPubnative: true, openrtb_ext.BidderRevcontent: true, openrtb_ext.BidderSilverMob: true, openrtb_ext.BidderSmaato: true, openrtb_ext.BidderSpotX: true, - openrtb_ext.BidderTappx: true, + openrtb_ext.BidderUnicorn: true, openrtb_ext.BidderYeahmobi: true, } @@ -130,31 +141,3 @@ func TestNewSyncerMap(t *testing.T) { } } } - -// Bidders may have an ID on the IAB-maintained global vendor list. -// This makes sure that we don't have conflicting IDs among Bidders in our project, -// since that's almost certainly a bug. -func TestVendorIDUniqueness(t *testing.T) { - cfg := &config.Configuration{} - syncers := NewSyncerMap(cfg) - - idMap := make(map[uint16]openrtb_ext.BidderName, len(syncers)) - for name, syncer := range syncers { - id := syncer.GDPRVendorID() - if id == 0 { - continue - } - - if oldName, ok := idMap[id]; ok { - t.Errorf("GDPR VendorList ID %d used by both %s and %s. These must be unique.", id, oldName, name) - } - idMap[id] = name - } -} - -func assertStringsMatch(t *testing.T, expected string, actual string) { - t.Helper() - if expected != actual { - t.Errorf("Expected %s, got %s", expected, actual) - } -} diff --git a/util/httputil/httputil.go b/util/httputil/httputil.go index 93bcca2a8c5..461512771b3 100644 --- a/util/httputil/httputil.go +++ b/util/httputil/httputil.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" + "github.com/prebid/prebid-server/util/iputil" ) var ( diff --git a/util/httputil/httputil_test.go b/util/httputil/httputil_test.go index 7b6a9a504f1..f7166740fe5 100644 --- a/util/httputil/httputil_test.go +++ b/util/httputil/httputil_test.go @@ -6,7 +6,7 @@ import ( "net/http" "testing" - "github.com/PubMatic-OpenWrap/prebid-server/util/iputil" + "github.com/prebid/prebid-server/util/iputil" "github.com/stretchr/testify/assert" ) diff --git a/util/iosutil/iosutil.go b/util/iosutil/iosutil.go new file mode 100644 index 00000000000..19d7c53d99a --- /dev/null +++ b/util/iosutil/iosutil.go @@ -0,0 +1,78 @@ +package iosutil + +import ( + "errors" + "strconv" + "strings" +) + +// Version specifies the version of an iOS device. +type Version struct { + Major int + Minor int +} + +// ParseVersion parses the major.minor version for an iOS device. +func ParseVersion(v string) (Version, error) { + parts := strings.Split(v, ".") + + if len(parts) != 2 { + return Version{}, errors.New("expected major.minor format") + } + + major, err := strconv.Atoi(parts[0]) + if err != nil { + return Version{}, errors.New("major version is not an integer") + } + + minor, err := strconv.Atoi(parts[1]) + if err != nil { + return Version{}, errors.New("minor version is not an integer") + } + + version := Version{ + Major: major, + Minor: minor, + } + return version, nil +} + +// EqualOrGreater returns true if the iOS device version is equal or greater to the desired version, using semantic versioning. +func (v Version) EqualOrGreater(major, minor int) bool { + if v.Major == major { + return v.Minor >= minor + } + + return v.Major > major +} + +// VersionClassification describes iOS version classifications which are important to Prebid Server. +type VersionClassification int + +// Values of VersionClassification. +const ( + VersionUnknown VersionClassification = iota + Version140 + Version141 + Version142OrGreater +) + +// DetectVersionClassification detects the iOS version classification. +func DetectVersionClassification(v string) VersionClassification { + // exact comparisons first. no parsing required. + if v == "14.0" { + return Version140 + } + if v == "14.1" { + return Version141 + } + + // semantic versioning comparison second. parsing required. + if iosVersion, err := ParseVersion(v); err == nil { + if iosVersion.EqualOrGreater(14, 2) { + return Version142OrGreater + } + } + + return VersionUnknown +} diff --git a/util/iosutil/iosutil_test.go b/util/iosutil/iosutil_test.go new file mode 100644 index 00000000000..2103760c1dc --- /dev/null +++ b/util/iosutil/iosutil_test.go @@ -0,0 +1,149 @@ +package iosutil + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestParseVersion(t *testing.T) { + tests := []struct { + description string + given string + expectedVersion Version + expectedError string + }{ + { + description: "Valid", + given: "14.2", + expectedVersion: Version{Major: 14, Minor: 2}, + }, + { + description: "Invalid Parts - Empty", + given: "", + expectedError: "expected major.minor format", + }, + { + description: "Invalid Parts - Too Few", + given: "14", + expectedError: "expected major.minor format", + }, + { + description: "Invalid Parts - Too Many", + given: "14.2.1", + expectedError: "expected major.minor format", + }, + { + description: "Invalid Major", + given: "xxx.2", + expectedError: "major version is not an integer", + }, + { + description: "Invalid Minor", + given: "14.xxx", + expectedError: "minor version is not an integer", + }, + } + + for _, test := range tests { + version, err := ParseVersion(test.given) + + if test.expectedError == "" { + assert.NoError(t, err, test.description+":err") + } else { + assert.EqualError(t, err, test.expectedError, test.description+":err") + } + + assert.Equal(t, test.expectedVersion, version, test.description+":version") + } +} + +func TestEqualOrGreater(t *testing.T) { + givenMajor := 14 + givenMinor := 2 + + tests := []struct { + description string + givenVersion Version + expected bool + }{ + { + description: "Less Than By Major + Minor", + givenVersion: Version{Major: 13, Minor: 1}, + expected: false, + }, + { + description: "Less Than By Major", + givenVersion: Version{Major: 13, Minor: 2}, + expected: false, + }, + { + description: "Less Than By Minor", + givenVersion: Version{Major: 14, Minor: 1}, + expected: false, + }, + { + description: "Equal", + givenVersion: Version{Major: 14, Minor: 2}, + expected: true, + }, + { + description: "Greater By Major + Minor", + givenVersion: Version{Major: 15, Minor: 3}, + expected: true, + }, + { + description: "Greater By Major", + givenVersion: Version{Major: 15, Minor: 2}, + expected: true, + }, + { + description: "Greater By Minor", + givenVersion: Version{Major: 14, Minor: 3}, + expected: true, + }, + } + + for _, test := range tests { + result := test.givenVersion.EqualOrGreater(givenMajor, givenMinor) + assert.Equal(t, test.expected, result, test.description) + } +} + +func TestDetectVersionClassification(t *testing.T) { + + tests := []struct { + given string + expected VersionClassification + }{ + { + given: "13.0", + expected: VersionUnknown, + }, + { + given: "14.0", + expected: Version140, + }, + { + given: "14.1", + expected: Version141, + }, + { + given: "14.2", + expected: Version142OrGreater, + }, + { + given: "14.3", + expected: Version142OrGreater, + }, + { + given: "15.0", + expected: Version142OrGreater, + }, + } + + for _, test := range tests { + result := DetectVersionClassification(test.given) + assert.Equal(t, test.expected, result, test.given) + } +} diff --git a/util/task/ticker_task_test.go b/util/task/ticker_task_test.go index 92cf6835ea6..27551c9a2c2 100644 --- a/util/task/ticker_task_test.go +++ b/util/task/ticker_task_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/PubMatic-OpenWrap/prebid-server/util/task" + "github.com/prebid/prebid-server/util/task" "github.com/stretchr/testify/assert" )