From 90adf689d1f2a7e7928929f042d19b39b7ea581b Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 13 Sep 2021 13:55:55 +0000 Subject: [PATCH 01/21] Making adnuntius bidder working. --- adapters/adnuntius/adnuntius.go | 142 +++++++++++++++ adapters/adnuntius/adnuntius_test.go | 20 +++ .../exemplary/simple-banner.json | 170 ++++++++++++++++++ .../supplemental/all-failed.json | 16 ++ .../supplemental/invalid-params.json | 133 ++++++++++++++ .../supplemental/status-204.json | 42 +++++ .../supplemental/status-400.json | 45 +++++ .../supplemental/status-502.json | 45 +++++ adapters/adnuntius/params_test.go | 60 +++++++ config/config.go | 1 + exchange/adapter_builders.go | 6 +- openrtb_ext/bidders.go | 2 + openrtb_ext/imp_adnuntius.go | 5 + static/bidder-info/adnuntius.yaml | 9 + static/bidder-params/adnuntius.json | 15 ++ 15 files changed, 709 insertions(+), 2 deletions(-) create mode 100644 adapters/adnuntius/adnuntius.go create mode 100644 adapters/adnuntius/adnuntius_test.go create mode 100644 adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/all-failed.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-204.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-502.json create mode 100644 adapters/adnuntius/params_test.go create mode 100644 openrtb_ext/imp_adnuntius.go create mode 100644 static/bidder-info/adnuntius.yaml create mode 100644 static/bidder-params/adnuntius.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go new file mode 100644 index 00000000000..ea99371e943 --- /dev/null +++ b/adapters/adnuntius/adnuntius.go @@ -0,0 +1,142 @@ +package adnuntius + +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 +} + +// Builder builds a new instance of the BrightMountainMedia 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, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var extRequests []*adapters.RequestData + var errs []error + + for _, imp := range request.Imp { + extRequest, err := a.makeRequest(*request, imp) + if err != nil { + errs = append(errs, err) + } else { + extRequests = append(extRequests, extRequest) + } + } + return extRequests, errs +} + +func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + + if ortbImp.Banner == nil && ortbImp.Video == nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("For Imp ID %s Banner or Video is undefined", ortbImp.ID), + } + } + + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + } + } + + var adnuntiusExt openrtb_ext.ImpExtAdnunitus + if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + } + } + + ortbImp.TagID = adnuntiusExt.Auid + ortbImp.Ext = nil + ortbRequest.Imp = []openrtb2.Imp{ortbImp} + + requestJSON, err := json.Marshal(ortbRequest) + if err != nil { + return nil, err + } + + requestData := &adapters.RequestData{ + Method: http.MethodPost, + Uri: a.endpoint, + Body: requestJSON, + Headers: headers, + } + return requestData, nil +} + +func (a *adapter) 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 { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + }} + } + + var bidResp openrtb2.BidResponse + + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{err} + } + + + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + + for _, sb := range bidResp.SeatBid { + for i := range sb.Bid { + sb.Bid[i].H = 600 + sb.Bid[i].W = 500 + sb.Bid[i].AdID = "123123123" + sb.Bid[i].CID = "123123" + sb.Bid[i].CrID = "asdasdasdas" + + + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: getMediaTypeForBid(sb.Bid[i].ImpID, internalRequest.Imp), + }) + } + } + return bidResponse, nil +} + + +func getMediaTypeForBid(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo + } + } + } + return openrtb_ext.BidTypeBanner +} diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go new file mode 100644 index 00000000000..e75b711c20e --- /dev/null +++ b/adapters/adnuntius/adnuntius_test.go @@ -0,0 +1,20 @@ +package adnuntius + +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.BidderAdnuntius, config.Adapter{ + Endpoint: "http://example.com/prebid"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder) +} diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json new file mode 100644 index 00000000000..a3926dea623 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -0,0 +1,170 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "format": [{ + "h": 250, + "w": 300 + }] + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }, { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }, { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-2" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "format": [{ + "h": 250, + "w": 300 + }], + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }] + }] + } + } + }, { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-2", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-2", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }] + }] + } + } + }, { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-2", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-3", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-2" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-3", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }] + }] + } + } + }], + "expectedBidResponses": [{ + "bids": [{ + "bid": { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }, + "type": "banner" + }] + }, { + "bids": [{ + "bid": { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }, + "type": "banner" + }] + }, { + "bids": [{ + "bid": { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }, + "type": "banner" + }] + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json new file mode 100644 index 00000000000..7f0244afcfb --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json @@ -0,0 +1,16 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + } + }] + }, + "expectedMakeRequestsErrors": [{ + "value": "impression extensions required", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json new file mode 100644 index 00000000000..e43e91addb0 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": {} + }, { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + } + }, { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": {} + }, { + "id": "test-impression-id-4" + }, { + "id": "test-impression-id-5", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": "invalid bidder" + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": {} + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": "invalid ext" + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-5", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-5", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, { + "id": "test-bid-id-6", + "impid": "test-impression-id-6", + "price": 6 + }] + }] + } + } + }], + "expectedBidResponses": [{ + "bids": [{ + "bid": { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + "type": "banner" + }] + }], + "expectedMakeRequestsErrors": [{ + "value": "banner size information missing", + "comparison": "literal" + }, { + "value": "impression extensions required", + "comparison": "literal" + }, { + "value": "bidder required", + "comparison": "literal" + }, { + "value": "Adnuntius only supports banner, video or native ads", + "comparison": "literal" + }, { + "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", + "comparison": "literal" + }, { + "value": "Adnuntius token required", + "comparison": "literal" + }, { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + }], + "expectedMakeBidsErrors": [{ + "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json new file mode 100644 index 00000000000..1c849b4fa3a --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json @@ -0,0 +1,42 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + }], + "expectedBidResponses": [] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json new file mode 100644 index 00000000000..95e271bae8e --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -0,0 +1,45 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + }], + "expectedMakeBidsErrors": [{ + "value": "unexpected status code: 400", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json new file mode 100644 index 00000000000..c0b1641653a --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json @@ -0,0 +1,45 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 502, + "body": {} + } + }], + "expectedMakeBidsErrors": [{ + "value": "unexpected status code: 502", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go new file mode 100644 index 00000000000..82e47d0e475 --- /dev/null +++ b/adapters/adnuntius/params_test.go @@ -0,0 +1,60 @@ +package adnuntius + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +// This file actually intends to test static/bidder-params/adtelligent.json +// These also validate the format of the external API: request.imp[i].ext.adtelligent +// TestValidParams makes sure that the adtelligent 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.BidderAdtelligent, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adtelligent params: %s", validParam) + } + } +} + +// TestInvalidParams makes sure that the adtelligent 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.BidderAdtelligent, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"aid":123}`, + `{"aid":123,"placementId":1234}`, + `{"aid":123,"siteId":4321}`, + `{"aid":123,"siteId":0,"bidFloor":0}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, + `{"aid":"123"}`, + `{"aid":"0"}`, + `{"aid":"123","placementId":"123"}`, + `{"aid":123, "placementId":"123", "siteId":"321"}`, +} diff --git a/config/config.go b/config/config.go index 0286744df4a..bb8eb546aa0 100644 --- a/config/config.go +++ b/config/config.go @@ -750,6 +750,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/rtb") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 630f18b6a3e..2ada8ca825d 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -14,6 +14,7 @@ import ( "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/adnuntius" "github.com/prebid/prebid-server/adapters/adocean" "github.com/prebid/prebid-server/adapters/adoppler" "github.com/prebid/prebid-server/adapters/adot" @@ -51,7 +52,7 @@ import ( "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/e_volution" + evolution "github.com/prebid/prebid-server/adapters/e_volution" "github.com/prebid/prebid-server/adapters/emx_digital" "github.com/prebid/prebid-server/adapters/engagebdr" "github.com/prebid/prebid-server/adapters/eplanning" @@ -97,7 +98,7 @@ import ( "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/sa_lunamedia" + salunamedia "github.com/prebid/prebid-server/adapters/sa_lunamedia" "github.com/prebid/prebid-server/adapters/sharethrough" "github.com/prebid/prebid-server/adapters/silvermob" "github.com/prebid/prebid-server/adapters/smaato" @@ -146,6 +147,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderAdkernelAdn: adkernelAdn.Builder, openrtb_ext.BidderAdman: adman.Builder, openrtb_ext.BidderAdmixer: admixer.Builder, + openrtb_ext.BidderAdnuntius: adnuntius.Builder, openrtb_ext.BidderAdOcean: adocean.Builder, openrtb_ext.BidderAdoppler: adoppler.Builder, openrtb_ext.BidderAdpone: adpone.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 88f816c293c..485b5ed7bae 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -85,6 +85,7 @@ const ( BidderAdkernelAdn BidderName = "adkernelAdn" BidderAdman BidderName = "adman" BidderAdmixer BidderName = "admixer" + BidderAdnuntius BidderName = "adnuntius" BidderAdOcean BidderName = "adocean" BidderAdoppler BidderName = "adoppler" BidderAdot BidderName = "adot" @@ -218,6 +219,7 @@ func CoreBidderNames() []BidderName { BidderAdkernelAdn, BidderAdman, BidderAdmixer, + BidderAdnuntius, BidderAdOcean, BidderAdoppler, BidderAdot, diff --git a/openrtb_ext/imp_adnuntius.go b/openrtb_ext/imp_adnuntius.go new file mode 100644 index 00000000000..152199c09df --- /dev/null +++ b/openrtb_ext/imp_adnuntius.go @@ -0,0 +1,5 @@ +package openrtb_ext + +type ImpExtAdnunitus struct { + Auid string `json:"auId"` +} diff --git a/static/bidder-info/adnuntius.yaml b/static/bidder-info/adnuntius.yaml new file mode 100644 index 00000000000..fe135164bd2 --- /dev/null +++ b/static/bidder-info/adnuntius.yaml @@ -0,0 +1,9 @@ +maintainer: + email: hello@adnuintius.com +capabilities: + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner \ No newline at end of file diff --git a/static/bidder-params/adnuntius.json b/static/bidder-params/adnuntius.json new file mode 100644 index 00000000000..f94c3378309 --- /dev/null +++ b/static/bidder-params/adnuntius.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adnuntius Adapter Params", + "description": "A schema which validates params accepted by the Adnuntius adapter", + "type": "object", + + "properties": { + "auId": { + "type": "string", + "description": "Placement ID" + } + }, + + "required": ["auId"] +} \ No newline at end of file From 8b5bb3036d2fff0c35d1de6772ddea5c4b4769f7 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 14 Sep 2021 15:30:34 +0000 Subject: [PATCH 02/21] Testing that container works. --- adapters/adnuntius/adnuntius.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index ea99371e943..d0b1484d786 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -104,10 +104,23 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } + + + type Bird struct { + Id string + Name string + Huhu string + } - + var bird Bird + + json.Unmarshal([]byte(response.Body), &bird) + fmt.Println("BID",bird.Id) + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + for _, sb := range bidResp.SeatBid { for i := range sb.Bid { From 2ef05d350ad9327ddbe9d06ce460cace7eb4529b Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Wed, 22 Sep 2021 12:54:29 +0200 Subject: [PATCH 03/21] Tests work but fail. --- adapters/adnuntius/adnuntius.go | 178 ++++++--- .../exemplary/simple-banner.json | 352 +++++++++--------- .../supplemental/invalid-params.json | 294 ++++++++------- .../supplemental/status-204.json | 86 +++-- .../supplemental/status-400.json | 94 ++--- .../supplemental/status-502.json | 94 ++--- adapters/adnuntius/params_test.go | 19 +- config/config.go | 2 +- 8 files changed, 633 insertions(+), 486 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index d0b1484d786..779aea8db1c 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -4,7 +4,10 @@ import ( "encoding/json" "fmt" "net/http" + "strconv" + "strings" + "github.com/gofrs/uuid" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -15,6 +18,40 @@ import ( type adapter struct { endpoint string } +type adnAdunit struct { + AuId string `json:"auId"` + TargetId string `json:"targetId"` +} + +type AdnResponse struct { + AdUnits []struct { + AuId string + TargetId string + Html string + ResponseId string + Ads []struct { + Bid struct { + Amount float64 + Currency string + } + AdId string + CreativeWidth string + CreativeHeight string + CreativeId string + LineItemId string + Html string + DestinationUrls map[string]string + } + } +} +type adnMetaData struct { + Usi string `json:"usi"` +} +type adnRequest struct { + AdUnits []adnAdunit `json:"adUnits"` + MetaData adnMetaData `json:"metaData,omitempty"` + Context string `json:"context,omitempty"` +} // Builder builds a new instance of the BrightMountainMedia adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { @@ -29,7 +66,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var errs []error for _, imp := range request.Imp { - extRequest, err := a.makeRequest(*request, imp) + extRequest, err := a.generateRequests(*request, imp) if err != nil { errs = append(errs, err) } else { @@ -39,16 +76,12 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E return extRequests, errs } -func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { + headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") - if ortbImp.Banner == nil && ortbImp.Video == nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("For Imp ID %s Banner or Video is undefined", ortbImp.ID), - } - } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { @@ -64,11 +97,12 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2. } } - ortbImp.TagID = adnuntiusExt.Auid - ortbImp.Ext = nil - ortbRequest.Imp = []openrtb2.Imp{ortbImp} + adnReq, reqErr := generateAdUnitRequest(adnuntiusExt, ortbRequest) + if reqErr != nil { + return nil, reqErr + } - requestJSON, err := json.Marshal(ortbRequest) + adnJson, err := json.Marshal(adnReq) if err != nil { return nil, err } @@ -76,13 +110,14 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2. requestData := &adapters.RequestData{ Method: http.MethodPost, Uri: a.endpoint, - Body: requestJSON, + Body: adnJson, Headers: headers, } + return requestData, nil } -func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -99,57 +134,102 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } - var bidResp openrtb2.BidResponse - - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + var adnResponse AdnResponse + if err := json.Unmarshal(response.Body, &adnResponse); err != nil { return nil, []error{err} } - - - type Bird struct { - Id string - Name string - Huhu string + + bidResponse, bidErr := generateBidResponse(&adnResponse, request) + if bidErr != nil { + return nil, bidErr } - var bird Bird + return bidResponse, nil +} - json.Unmarshal([]byte(response.Body), &bird) +func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) + currency := bidResponse.Currency - fmt.Println("BID",bird.Id) - - - bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) - + for i, adunit := range adnResponse.AdUnits { + var bid openrtb2.Bid + ad := adunit.Ads[0] - for _, sb := range bidResp.SeatBid { - for i := range sb.Bid { - sb.Bid[i].H = 600 - sb.Bid[i].W = 500 - sb.Bid[i].AdID = "123123123" - sb.Bid[i].CID = "123123" - sb.Bid[i].CrID = "asdasdasdas" + currency = ad.Bid.Currency + creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) + if Werr != nil { + return nil, []error{Werr} + } - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &sb.Bid[i], - BidType: getMediaTypeForBid(sb.Bid[i].ImpID, internalRequest.Imp), - }) + creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) + if Herr != nil { + return nil, []error{Herr} } + + adDomain := []string{} + for _, url := range ad.DestinationUrls { + domainArray := strings.Split(url, "/") + domain := strings.Replace(domainArray[2], "www.", "", -1) + adDomain = append(adDomain, domain) + } + + bid = openrtb2.Bid{ + ID: ad.AdId, + ImpID: request.Imp[i].ID, + W: creativeWidth, + H: creativeHeight, + AdID: ad.AdId, + CID: ad.LineItemId, + CrID: ad.CreativeId, + Price: ad.Bid.Amount * 1000, + AdM: adunit.Html, + ADomain: adDomain, + } + + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: "banner", + }) + } + bidResponse.Currency = currency return bidResponse, nil } +func generateAdUnitRequest(adnuntiusExt openrtb_ext.ImpExtAdnunitus, ortbRequest openrtb2.BidRequest) (*adnRequest, error) { + adunits := []adnAdunit{} + rawUuid, uidErr := uuid.NewV4() + if uidErr != nil { + return nil, uidErr + } + + adnuntiusAdunits := adnAdunit{ + AuId: adnuntiusExt.Auid, + TargetId: rawUuid.String(), + } + + adunits = append(adunits, adnuntiusAdunits) -func getMediaTypeForBid(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { - for _, imp := range imps { - if imp.ID == impID { - if imp.Banner != nil { - return openrtb_ext.BidTypeBanner - } else if imp.Video != nil { - return openrtb_ext.BidTypeVideo - } + var userId string + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + userId = ortbRequest.User.ID } } - return openrtb_ext.BidTypeBanner + + var site string + if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { + site = ortbRequest.Site.Page + } + + adnuntiusRequest := adnRequest{ + AdUnits: adunits, + MetaData: adnMetaData{Usi: userId}, + Context: site, + } + + return &adnuntiusRequest, nil } diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index a3926dea623..5ce2b5191f6 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -1,170 +1,186 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "format": [{ - "h": 250, - "w": 300 - }] - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }, { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }, { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-2" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "format": [{ - "h": 250, - "w": 300 - }], - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }] - }] - } - } - }, { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-2", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-2", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }] - }] - } - } - }, { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-2", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-3", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-2" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-3", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - }] - }] - } - } - }], - "expectedBidResponses": [{ - "bids": [{ - "bid": { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }, - "type": "banner" - }] - }, { - "bids": [{ - "bid": { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }, - "type": "banner" - }] - }, { - "bids": [{ - "bid": { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - }, - "type": "banner" - }] - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + }, + { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + }, + { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-2" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-1", + "targetId": "d7b3cb0f-6da6-4c17-8395-3b76c03f1d0f" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + } + ] + } + ] + } + } + }, + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-1", + "targetId": "12482e7c-6f24-495f-ac6c-446040231e1e" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-2", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + } + ] + } + ] + } + } + }, + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-2", + "targetId": "9c303223-26c7-4624-942d-aee848fd6545" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-3", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }, + "type": "banner" + } + ] + }, + { + "bids": [ + { + "bid": { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }, + "type": "banner" + } + ] + }, + { + "bids": [ + { + "bid": { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }, + "type": "banner" + } + ] + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json index e43e91addb0..fbe43f9e279 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json @@ -1,133 +1,165 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": {} - }, { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - } - }, { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": {} - }, { - "id": "test-impression-id-4" - }, { - "id": "test-impression-id-5", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": "invalid bidder" - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": {} - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": "invalid ext" - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-5", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-5", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, { - "id": "test-bid-id-6", - "impid": "test-impression-id-6", - "price": 6 - }] - }] - } - } - }], - "expectedBidResponses": [{ - "bids": [{ - "bid": { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - "type": "banner" - }] - }], - "expectedMakeRequestsErrors": [{ - "value": "banner size information missing", - "comparison": "literal" - }, { - "value": "impression extensions required", - "comparison": "literal" - }, { - "value": "bidder required", - "comparison": "literal" - }, { - "value": "Adnuntius only supports banner, video or native ads", - "comparison": "literal" - }, { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", - "comparison": "literal" - }, { - "value": "Adnuntius token required", - "comparison": "literal" - }, { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", - "comparison": "literal" - }], - "expectedMakeBidsErrors": [{ - "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": {} + }, + { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + } + }, + { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": {} + }, + { + "id": "test-impression-id-4" + }, + { + "id": "test-impression-id-5", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": "invalid bidder" + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": {} + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": "invalid ext" + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-5", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-5", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-5" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + { + "id": "test-bid-id-6", + "impid": "test-impression-id-6", + "price": 6 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + "type": "banner" + } + ] + } + ], + "expectedMakeRequestsErrors": [ + { + "value": "banner size information missing", + "comparison": "literal" + }, + { + "value": "impression extensions required", + "comparison": "literal" + }, + { + "value": "bidder required", + "comparison": "literal" + }, + { + "value": "Adnuntius only supports banner, video or native ads", + "comparison": "literal" + }, + { + "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", + "comparison": "literal" + }, + { + "value": "Adnuntius token required", + "comparison": "literal" + }, + { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + } + ], + "expectedMakeBidsErrors": [ + { + "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json index 1c849b4fa3a..2369ad64ca0 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json @@ -1,42 +1,48 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 204, - "body": {} - } - }], - "expectedBidResponses": [] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json index 95e271bae8e..41fb4c976f2 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -1,45 +1,53 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 400, - "body": {} - } - }], - "expectedMakeBidsErrors": [{ - "value": "unexpected status code: 400", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 400", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json index c0b1641653a..28616429080 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json @@ -1,45 +1,53 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 502, - "body": {} - } - }], - "expectedMakeBidsErrors": [{ - "value": "unexpected status code: 502", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 502, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 502", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index 82e47d0e475..33cf47ac409 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -7,9 +7,9 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -// This file actually intends to test static/bidder-params/adtelligent.json -// These also validate the format of the external API: request.imp[i].ext.adtelligent -// TestValidParams makes sure that the adtelligent schema accepts all imp.ext fields which we intend to support. +// This file actually intends to test static/bidder-params/adnuntius.json +// These also validate the format of the external API: request.imp[i].ext.adnuntius +// TestValidParams makes sure that the adnuntius schema accepts all imp.ext fields which we intend to support. func TestValidParams(t *testing.T) { validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") @@ -18,13 +18,13 @@ func TestValidParams(t *testing.T) { } for _, validParam := range validParams { - if err := validator.Validate(openrtb_ext.BidderAdtelligent, json.RawMessage(validParam)); err != nil { - t.Errorf("Schema rejected adtelligent params: %s", validParam) + if err := validator.Validate(openrtb_ext.BidderAdnuntius, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adnuntius params: %s", validParam) } } } -// TestInvalidParams makes sure that the adtelligent schema rejects all the imp.ext fields we don't support. +// TestInvalidParams makes sure that the adnuntius 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 { @@ -32,17 +32,14 @@ func TestInvalidParams(t *testing.T) { } for _, invalidParam := range invalidParams { - if err := validator.Validate(openrtb_ext.BidderAdtelligent, json.RawMessage(invalidParam)); err == nil { + if err := validator.Validate(openrtb_ext.BidderAdnuntius, json.RawMessage(invalidParam)); err == nil { t.Errorf("Schema allowed unexpected params: %s", invalidParam) } } } var validParams = []string{ - `{"aid":123}`, - `{"aid":123,"placementId":1234}`, - `{"aid":123,"siteId":4321}`, - `{"aid":123,"siteId":0,"bidFloor":0}`, + `{"auId":123}`, } var invalidParams = []string{ diff --git a/config/config.go b/config/config.go index bb8eb546aa0..fc267c8062d 100644 --- a/config/config.go +++ b/config/config.go @@ -750,7 +750,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/rtb") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?tzo=-60&format=json") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") From 57f824e20318f00fafd2f393039a6d39de3d308a Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 23 Sep 2021 15:25:15 +0200 Subject: [PATCH 04/21] Tzo added to the request. --- adapters/adnuntius/adnuntius.go | 209 +++++++++++++++------------- config/config.go | 2 +- openrtb_ext/imp_adnuntius.go | 3 +- static/bidder-params/adnuntius.json | 28 ++-- 4 files changed, 128 insertions(+), 114 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 779aea8db1c..7f67fc80fbb 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -6,8 +6,8 @@ import ( "net/http" "strconv" "strings" + "time" - "github.com/gofrs/uuid" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -53,7 +53,7 @@ type adnRequest struct { Context string `json:"context,omitempty"` } -// Builder builds a new instance of the BrightMountainMedia adapter for the given bidder with the given config. +// Builder builds a new instance of the Adnuntius 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, @@ -64,54 +64,97 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var extRequests []*adapters.RequestData var errs []error - - for _, imp := range request.Imp { - extRequest, err := a.generateRequests(*request, imp) - if err != nil { - errs = append(errs, err) - } else { - extRequests = append(extRequests, extRequest) - } + extRequests, err := a.generateRequests(*request) + if err != nil { + errs = append(errs, err) } return extRequests, errs } -func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { +/* + Generate the requests to Adnuntius to reduce the amount of requests going out. +*/ +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { + + var requestData []*adapters.RequestData + networkAdunitMap := make(map[string][]adnAdunit) headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") + for _, imp := range ortbRequest.Imp { - var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + } } - } - var adnuntiusExt openrtb_ext.ImpExtAdnunitus - if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + var adnuntiusExt openrtb_ext.ImpExtAdnunitus + if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + } } + + var network string + if adnuntiusExt.Network != "" { + network = adnuntiusExt.Network + } else { + network = "default" + } + + networkAdunitMap[network] = append( + networkAdunitMap[network], + adnAdunit{ + AuId: adnuntiusExt.Auid, + TargetId: fmt.Sprintf("%s-%s", adnuntiusExt.Auid, imp.ID), + }) } - adnReq, reqErr := generateAdUnitRequest(adnuntiusExt, ortbRequest) - if reqErr != nil { - return nil, reqErr + var userId string + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + userId = ortbRequest.User.ID + } } - adnJson, err := json.Marshal(adnReq) - if err != nil { - return nil, err + var site string + if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { + site = ortbRequest.Site.Page } - requestData := &adapters.RequestData{ - Method: http.MethodPost, - Uri: a.endpoint, - Body: adnJson, - Headers: headers, + /* + Divide requests that go to different networks. + */ + + for _, networkAdunits := range networkAdunitMap { + + adnuntiusRequest := adnRequest{ + AdUnits: networkAdunits, + MetaData: adnMetaData{Usi: userId}, + Context: site, + } + + adnJson, err := json.Marshal(adnuntiusRequest) + if err != nil { + return nil, err + } + + _, offset := time.Now().UTC().Local().Zone() + tzo := - offset / 3600 *60 + + requestData = append(requestData, &adapters.RequestData{ + Method: http.MethodPost, + Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), + Body: adnJson, + Headers: headers, + }) + } return requestData, nil @@ -152,84 +195,50 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) currency := bidResponse.Currency for i, adunit := range adnResponse.AdUnits { + var bid openrtb2.Bid - ad := adunit.Ads[0] + if len(adunit.Ads) > 0 { + ad := adunit.Ads[0] - currency = ad.Bid.Currency + currency = ad.Bid.Currency - creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) - if Werr != nil { - return nil, []error{Werr} - } + creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) + if Werr != nil { + return nil, []error{Werr} + } - creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) - if Herr != nil { - return nil, []error{Herr} - } + creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) + if Herr != nil { + return nil, []error{Herr} + } - adDomain := []string{} - for _, url := range ad.DestinationUrls { - domainArray := strings.Split(url, "/") - domain := strings.Replace(domainArray[2], "www.", "", -1) - adDomain = append(adDomain, domain) - } + adDomain := []string{} + for _, url := range ad.DestinationUrls { + domainArray := strings.Split(url, "/") + domain := strings.Replace(domainArray[2], "www.", "", -1) + adDomain = append(adDomain, domain) + } - bid = openrtb2.Bid{ - ID: ad.AdId, - ImpID: request.Imp[i].ID, - W: creativeWidth, - H: creativeHeight, - AdID: ad.AdId, - CID: ad.LineItemId, - CrID: ad.CreativeId, - Price: ad.Bid.Amount * 1000, - AdM: adunit.Html, - ADomain: adDomain, - } + bid = openrtb2.Bid{ + ID: ad.AdId, + ImpID: request.Imp[i].ID, + W: creativeWidth, + H: creativeHeight, + AdID: ad.AdId, + CID: ad.LineItemId, + CrID: ad.CreativeId, + Price: ad.Bid.Amount * 1000, + AdM: adunit.Html, + ADomain: adDomain, + } - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &bid, - BidType: "banner", - }) + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: "banner", + }) + } } bidResponse.Currency = currency return bidResponse, nil } - -func generateAdUnitRequest(adnuntiusExt openrtb_ext.ImpExtAdnunitus, ortbRequest openrtb2.BidRequest) (*adnRequest, error) { - adunits := []adnAdunit{} - rawUuid, uidErr := uuid.NewV4() - if uidErr != nil { - return nil, uidErr - } - - adnuntiusAdunits := adnAdunit{ - AuId: adnuntiusExt.Auid, - TargetId: rawUuid.String(), - } - - adunits = append(adunits, adnuntiusAdunits) - - var userId string - ortbUser := ortbRequest.User - if ortbUser != nil { - ortbUserId := ortbRequest.User.ID - if ortbUserId != "" { - userId = ortbRequest.User.ID - } - } - - var site string - if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { - site = ortbRequest.Site.Page - } - - adnuntiusRequest := adnRequest{ - AdUnits: adunits, - MetaData: adnMetaData{Usi: userId}, - Context: site, - } - - return &adnuntiusRequest, nil -} diff --git a/config/config.go b/config/config.go index fc267c8062d..9fb73608e79 100644 --- a/config/config.go +++ b/config/config.go @@ -750,7 +750,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?tzo=-60&format=json") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?format=json") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") diff --git a/openrtb_ext/imp_adnuntius.go b/openrtb_ext/imp_adnuntius.go index 152199c09df..bde30f0518f 100644 --- a/openrtb_ext/imp_adnuntius.go +++ b/openrtb_ext/imp_adnuntius.go @@ -1,5 +1,6 @@ package openrtb_ext type ImpExtAdnunitus struct { - Auid string `json:"auId"` + Auid string `json:"auId"` + Network string `json:"network"` } diff --git a/static/bidder-params/adnuntius.json b/static/bidder-params/adnuntius.json index f94c3378309..a8e65bea343 100644 --- a/static/bidder-params/adnuntius.json +++ b/static/bidder-params/adnuntius.json @@ -1,15 +1,19 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Adnuntius Adapter Params", - "description": "A schema which validates params accepted by the Adnuntius adapter", - "type": "object", + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adnuntius Adapter Params", + "description": "A schema which validates params accepted by the Adnuntius adapter", + "type": "object", - "properties": { - "auId": { - "type": "string", - "description": "Placement ID" - } - }, + "properties": { + "auId": { + "type": "string", + "description": "Placement ID" + }, + "network": { + "type": "string", + "description": "Network if required" + } + }, - "required": ["auId"] -} \ No newline at end of file + "required": ["auId"] +} From ef6d3b702a04bf6744d9cae97ca0db2c3ba570f9 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Fri, 24 Sep 2021 11:59:52 +0000 Subject: [PATCH 05/21] Tests for adnuntius adapter. --- adapters/adnuntius/adnuntius.go | 36 +-- adapters/adnuntius/adnuntius_test.go | 2 +- .../exemplary/simple-banner.json | 225 ++++++++---------- .../supplemental/all-failed.json | 16 -- .../supplemental/check-userId.json | 154 ++++++++++++ .../supplemental/invalid-params.json | 165 ------------- .../supplemental/native-error.json | 25 ++ .../supplemental/status-204.json | 48 ---- .../supplemental/status-400.json | 53 ----- .../supplemental/status-502.json | 53 ----- .../supplemental/video-error.json | 26 ++ adapters/adnuntius/params_test.go | 2 +- 12 files changed, 321 insertions(+), 484 deletions(-) delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/all-failed.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/check-userId.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/native-error.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-204.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-502.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/video-error.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 7f67fc80fbb..a6bc29c8ff0 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -45,7 +45,7 @@ type AdnResponse struct { } } type adnMetaData struct { - Usi string `json:"usi"` + Usi string `json:"usi,omitempty"` } type adnRequest struct { AdUnits []adnAdunit `json:"adUnits"` @@ -84,7 +84,11 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters headers.Add("Accept", "application/json") for _, imp := range ortbRequest.Imp { - + if imp.Banner == nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("ignoring imp id=%s, Adnuntius supports only Banner", imp.ID), + } + } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -114,18 +118,11 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }) } - var userId string - ortbUser := ortbRequest.User - if ortbUser != nil { - ortbUserId := ortbRequest.User.ID - if ortbUserId != "" { - userId = ortbRequest.User.ID - } - } - var site string if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { site = ortbRequest.Site.Page + } else { + site = "unknown" } /* @@ -135,9 +132,16 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters for _, networkAdunits := range networkAdunitMap { adnuntiusRequest := adnRequest{ - AdUnits: networkAdunits, - MetaData: adnMetaData{Usi: userId}, - Context: site, + AdUnits: networkAdunits, + Context: site, + } + + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + adnuntiusRequest.MetaData.Usi = ortbRequest.User.ID + } } adnJson, err := json.Marshal(adnuntiusRequest) @@ -146,8 +150,8 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters } _, offset := time.Now().UTC().Local().Zone() - tzo := - offset / 3600 *60 - + tzo := -offset / 3600 * 60 + requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go index e75b711c20e..0f575a7141a 100644 --- a/adapters/adnuntius/adnuntius_test.go +++ b/adapters/adnuntius/adnuntius_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAdnuntius, config.Adapter{ - Endpoint: "http://example.com/prebid"}) + Endpoint: "http://whatever.url"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index 5ce2b5191f6..2ca73e6f8c8 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -3,144 +3,124 @@ "id": "test-request-id", "imp": [ { - "id": "test-impression-id-1", + "id": "test-imp-id", "banner": { "format": [ { - "h": 250, - "w": 300 + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 } ] }, "ext": { "bidder": { - "auId": "test-token-1" - } - } - }, - { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - }, - { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-2" + "auId": "123" } } } ] }, + "httpCalls": [ { "expectedRequest": { - "uri": "http://example.com/prebid", + "uri": "http://whatever.url&tzo=0", "body": { "adUnits": [ { - "auId": "test-token-1", - "targetId": "d7b3cb0f-6da6-4c17-8395-3b76c03f1d0f" + "auId": "123", + "targetId": "123-test-imp-id" } ], - "metaData": { - "usi": "" - } + "context": "unknown", + "metaData": {} } }, "mockResponse": { "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - } - ] - } - ] - } - } - }, - { - "expectedRequest": { - "uri": "http://example.com/prebid", "body": { "adUnits": [ { - "auId": "test-token-1", - "targetId": "12482e7c-6f24-495f-ac6c-446040231e1e" - } - ], - "metaData": { - "usi": "" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-2", - "seatbid": [ - { - "bid": [ + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" } ] } - ] - } - } - }, - { - "expectedRequest": { - "uri": "http://example.com/prebid", - "body": { - "adUnits": [ - { - "auId": "test-token-2", - "targetId": "9c303223-26c7-4624-942d-aee848fd6545" - } ], "metaData": { - "usi": "" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-3", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - } - ] - } - ] + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] } } } @@ -150,33 +130,16 @@ "bids": [ { "bid": { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }, - "type": "banner" - } - ] - }, - { - "bids": [ - { - "bid": { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }, - "type": "banner" - } - ] - }, - { - "bids": [ - { - "bid": { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 }, "type": "banner" } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json deleted file mode 100644 index 7f0244afcfb..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - } - }] - }, - "expectedMakeRequestsErrors": [{ - "value": "impression extensions required", - "comparison": "literal" - }] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json new file mode 100644 index 00000000000..716b0d7e51d --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -0,0 +1,154 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "1kjh3429kjh295jkl" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "metaData": { + "usi": "1kjh3429kjh295jkl" + }, + "context": "unknown" + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" + } + ] + } + ], + "metaData": { + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json deleted file mode 100644 index fbe43f9e279..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": {} - }, - { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - } - }, - { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": {} - }, - { - "id": "test-impression-id-4" - }, - { - "id": "test-impression-id-5", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": "invalid bidder" - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": {} - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": "invalid ext" - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-5", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-5", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-5" - } - } - } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - { - "id": "test-bid-id-6", - "impid": "test-impression-id-6", - "price": 6 - } - ] - } - ] - } - } - } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid": { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - "type": "banner" - } - ] - } - ], - "expectedMakeRequestsErrors": [ - { - "value": "banner size information missing", - "comparison": "literal" - }, - { - "value": "impression extensions required", - "comparison": "literal" - }, - { - "value": "bidder required", - "comparison": "literal" - }, - { - "value": "Adnuntius only supports banner, video or native ads", - "comparison": "literal" - }, - { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", - "comparison": "literal" - }, - { - "value": "Adnuntius token required", - "comparison": "literal" - }, - { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", - "comparison": "literal" - } - ], - "expectedMakeBidsErrors": [ - { - "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/native-error.json b/adapters/adnuntius/adnuntiustest/supplemental/native-error.json new file mode 100644 index 00000000000..a8203e581ef --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/native-error.json @@ -0,0 +1,25 @@ +{ + "mockBidRequest": { + "id": "unsupported-native-request", + "imp": [ + { + "id": "unsupported-native-imp", + "native": { + "ver": "1.1" + }, + "ext": { + "bidder": { + "auId": "1" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "ignoring imp id=unsupported-native-imp, Adnuntius supports only Banner", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json deleted file mode 100644 index 2369ad64ca0..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 204, - "body": {} - } - } - ], - "expectedBidResponses": [] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json deleted file mode 100644 index 41fb4c976f2..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 400, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "unexpected status code: 400", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json deleted file mode 100644 index 28616429080..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 502, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "unexpected status code: 502", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/video-error.json b/adapters/adnuntius/adnuntiustest/supplemental/video-error.json new file mode 100644 index 00000000000..357cb165f36 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/video-error.json @@ -0,0 +1,26 @@ +{ + "mockBidRequest": { + "id": "unsupported-native-request", + "imp": [ + { + "id": "unsupported-native-imp", + "video": { + "w": 728, + "h": 90 + }, + "ext": { + "bidder": { + "auId": "1" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "ignoring imp id=unsupported-native-imp, Adnuntius supports only Banner", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index 33cf47ac409..d096376c881 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -39,7 +39,7 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"auId":123}`, + `{"auId":"123"}`, } var invalidParams = []string{ From c21586a7fddff44c74e6acf4580bc6e1fd1f74a6 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Fri, 24 Sep 2021 13:22:35 +0000 Subject: [PATCH 06/21] Gdpr Added to adapter. --- adapters/adnuntius/adnuntius.go | 78 +++++++-- .../exemplary/simple-banner.json | 2 +- .../supplemental/check-gdpr.json | 162 ++++++++++++++++++ .../supplemental/check-userId.json | 2 +- config/config.go | 2 +- 5 files changed, 230 insertions(+), 16 deletions(-) create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index a6bc29c8ff0..4a6fa39f7f3 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" "strconv" "strings" "time" @@ -15,6 +16,7 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) +type QueryString map[string]string type adapter struct { endpoint string } @@ -71,17 +73,50 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E return extRequests, errs } +func setHeaders() http.Header { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + return headers +} + +func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, []error) { + uri, err := url.Parse(endpoint) + if err != nil { + return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + } + + _, offset := time.Now().UTC().Local().Zone() + tzo := -offset / 3600 * 60 + + gdpr, consent, err := getGDPR(&ortbRequest) + if err != nil { + return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + } + + q := uri.Query() + if gdpr != "" && consent != "" { + q.Set("gdpr", gdpr) + q.Set("consentString", consent) + } + q.Set("tzo", fmt.Sprint(tzo)) + q.Set("format", "json") + + url := endpoint + "?" + q.Encode() + return url, nil +} + /* Generate the requests to Adnuntius to reduce the amount of requests going out. */ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { - var requestData []*adapters.RequestData networkAdunitMap := make(map[string][]adnAdunit) - - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") + headers := setHeaders() + endpoint, err := makeEndpointUrl(ortbRequest, a.endpoint) + if err != nil { + return nil, fmt.Errorf("failed to parse URL: %v", err) + } for _, imp := range ortbRequest.Imp { if imp.Banner == nil { @@ -125,10 +160,6 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters site = "unknown" } - /* - Divide requests that go to different networks. - */ - for _, networkAdunits := range networkAdunitMap { adnuntiusRequest := adnRequest{ @@ -149,12 +180,9 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters return nil, err } - _, offset := time.Now().UTC().Local().Zone() - tzo := -offset / 3600 * 60 - requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, - Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), + Uri: endpoint, Body: adnJson, Headers: headers, }) @@ -194,6 +222,30 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte return bidResponse, nil } +func getGDPR(request *openrtb2.BidRequest) (string, string, error) { + gdpr := "" + var extRegs openrtb_ext.ExtRegs + if request.Regs != nil { + if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { + return "", "", fmt.Errorf("failed to parse ExtRegs in Yieldlab GDPR check: %v", err) + } + if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { + gdpr = strconv.Itoa(int(*extRegs.GDPR)) + } + } + + consent := "" + if request.User != nil && request.User.Ext != nil { + var extUser openrtb_ext.ExtUser + if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { + return "", "", fmt.Errorf("failed to parse ExtUser in Yieldlab GDPR check: %v", err) + } + consent = extUser.Consent + } + + return gdpr, consent, nil +} + func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) currency := bidResponse.Currency diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index 2ca73e6f8c8..f98028cf79f 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -28,7 +28,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://whatever.url&tzo=0", + "uri": "http://whatever.url?format=json&tzo=0", "body": { "adUnits": [ { diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json new file mode 100644 index 00000000000..807b115d3d1 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json @@ -0,0 +1,162 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "1kjh3429kjh295jkl", + "ext": { + "consent": "CONSENT_STRING" + } + }, + "regs": { + "ext": { + "gdpr": 1 + } + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?consentString=CONSENT_STRING&format=json&gdpr=1&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "metaData": { + "usi": "1kjh3429kjh295jkl" + }, + "context": "unknown" + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" + } + ] + } + ], + "metaData": { + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json index 716b0d7e51d..fead83afe86 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -31,7 +31,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://whatever.url&tzo=0", + "uri": "http://whatever.url?format=json&tzo=0", "body": { "adUnits": [ { diff --git a/config/config.go b/config/config.go index 9fb73608e79..ff0021610f7 100644 --- a/config/config.go +++ b/config/config.go @@ -750,7 +750,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?format=json") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") From 2825270fa31f5c035f91faa0cb88e5afd5d8eeb8 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 5 Oct 2021 19:40:52 +0000 Subject: [PATCH 07/21] Fixing commented issues in pull request. --- adapters/adnuntius/adnuntius.go | 82 ++++++++-------- adapters/adnuntius/adnuntius_test.go | 15 +++ .../exemplary/simple-banner.json | 70 ++----------- .../supplemental/check-gdpr.json | 65 ++----------- .../supplemental/check-userId.json | 65 ++----------- .../supplemental/height-error.json | 84 ++++++++++++++++ .../supplemental/status-400.json | 54 +++++++++++ .../supplemental/test-networks.json | 97 +++++++++++++++++++ .../supplemental/width-error.json | 84 ++++++++++++++++ adapters/adnuntius/params_test.go | 11 ++- adapters/adnuntius/timezone.go | 23 +++++ static/bidder-info/adnuntius.yaml | 15 +-- 12 files changed, 435 insertions(+), 230 deletions(-) create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/height-error.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/test-networks.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/width-error.json create mode 100644 adapters/adnuntius/timezone.go diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 4a6fa39f7f3..47bab06f622 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -7,7 +7,6 @@ import ( "net/url" "strconv" "strings" - "time" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" @@ -18,6 +17,7 @@ import ( type QueryString map[string]string type adapter struct { + tzo timezone endpoint string } type adnAdunit struct { @@ -58,17 +58,20 @@ type adnRequest struct { // Builder builds a new instance of the Adnuntius adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &adapter{ + tzo: realTzo{}, endpoint: config.Endpoint, } + return bidder, nil } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var extRequests []*adapters.RequestData var errs []error + extRequests, err := a.generateRequests(*request) if err != nil { - errs = append(errs, err) + errs = append(errs, err...) } return extRequests, errs } @@ -80,20 +83,20 @@ func setHeaders() http.Header { return headers } -func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, []error) { - uri, err := url.Parse(endpoint) +func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []error) { + uri, err := url.Parse(a.endpoint) if err != nil { - return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } - _, offset := time.Now().UTC().Local().Zone() - tzo := -offset / 3600 * 60 - gdpr, consent, err := getGDPR(&ortbRequest) if err != nil { - return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } + _, offset := a.tzo.Now().UTC().Local().Zone() + tzo := -offset / 3600 * 60 + q := uri.Query() if gdpr != "" && consent != "" { q.Set("gdpr", gdpr) @@ -102,47 +105,47 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, q.Set("tzo", fmt.Sprint(tzo)) q.Set("format", "json") - url := endpoint + "?" + q.Encode() + url := a.endpoint + "?" + q.Encode() return url, nil } /* Generate the requests to Adnuntius to reduce the amount of requests going out. */ -func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, []error) { var requestData []*adapters.RequestData + var errors []error networkAdunitMap := make(map[string][]adnAdunit) headers := setHeaders() - endpoint, err := makeEndpointUrl(ortbRequest, a.endpoint) + + endpoint, err := makeEndpointUrl(ortbRequest, a) if err != nil { - return nil, fmt.Errorf("failed to parse URL: %v", err) + errors = append(errors, fmt.Errorf("failed to parse URL: %v", err)) } for _, imp := range ortbRequest.Imp { if imp.Banner == nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, Adnuntius supports only Banner", imp.ID), - } + }) } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), - } + }) } var adnuntiusExt openrtb_ext.ImpExtAdnunitus if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), - } + }) } - var network string + network := "default" if adnuntiusExt.Network != "" { network = adnuntiusExt.Network - } else { - network = "default" } networkAdunitMap[network] = append( @@ -153,11 +156,9 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }) } - var site string + site := "unknown" if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { site = ortbRequest.Site.Page - } else { - site = "unknown" } for _, networkAdunits := range networkAdunitMap { @@ -177,9 +178,12 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters adnJson, err := json.Marshal(adnuntiusRequest) if err != nil { - return nil, err + errors = append(errors, err) } + if len(errors) > 0 { + return nil, errors + } requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, Uri: endpoint, @@ -193,19 +197,10 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters } func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode == http.StatusNoContent { - return nil, nil - } if response.StatusCode == http.StatusBadRequest { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), - }} - } - - if response.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + Message: fmt.Sprintf("Status code: %d, Request malformed", response.StatusCode), }} } @@ -227,7 +222,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { var extRegs openrtb_ext.ExtRegs if request.Regs != nil { if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { - return "", "", fmt.Errorf("failed to parse ExtRegs in Yieldlab GDPR check: %v", err) + return "", "", fmt.Errorf("failed to parse ExtRegs in Adnuntius GDPR check: %v", err) } if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { gdpr = strconv.Itoa(int(*extRegs.GDPR)) @@ -238,7 +233,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { if request.User != nil && request.User.Ext != nil { var extUser openrtb_ext.ExtUser if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { - return "", "", fmt.Errorf("failed to parse ExtUser in Yieldlab GDPR check: %v", err) + return "", "", fmt.Errorf("failed to parse ExtUser in Adnuntius GDPR check: %v", err) } consent = extUser.Consent } @@ -248,24 +243,25 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) - currency := bidResponse.Currency + var currency string for i, adunit := range adnResponse.AdUnits { var bid openrtb2.Bid if len(adunit.Ads) > 0 { + var adsErr []error ad := adunit.Ads[0] currency = ad.Bid.Currency creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) if Werr != nil { - return nil, []error{Werr} + adsErr = append(adsErr, Werr) } creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) if Herr != nil { - return nil, []error{Herr} + adsErr = append(adsErr, Herr) } adDomain := []string{} @@ -275,6 +271,10 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) adDomain = append(adDomain, domain) } + if len(adsErr) > 0 { + return nil, adsErr + } + bid = openrtb2.Bid{ ID: ad.AdId, ImpID: request.Imp[i].ID, diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go index 0f575a7141a..2734bc0cf27 100644 --- a/adapters/adnuntius/adnuntius_test.go +++ b/adapters/adnuntius/adnuntius_test.go @@ -2,10 +2,13 @@ package adnuntius import ( "testing" + "time" + "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" ) func TestJsonSamples(t *testing.T) { @@ -15,6 +18,18 @@ func TestJsonSamples(t *testing.T) { if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) } + assertTzo(t, bidder) + replaceTzoWithKnownTime(bidder) adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder) } + +func assertTzo(t *testing.T, bidder adapters.Bidder) { + bidderAdnuntius, _ := bidder.(*adapter) + assert.NotNil(t, bidderAdnuntius.tzo) +} + +func replaceTzoWithKnownTime(bidder adapters.Bidder) { + bidderAdnuntius, _ := bidder.(*adapter) + bidderAdnuntius.tzo = knownTzo(time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC)) +} diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index f98028cf79f..6e943810aa9 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -1,6 +1,9 @@ { "mockBidRequest": { "id": "test-request-id", + "site": { + "page": "prebid.org" + }, "imp": [ { "id": "test-imp-id", @@ -36,7 +39,7 @@ "targetId": "123-test-imp-id" } ], - "context": "unknown", + "context": "prebid.org", "metaData": {} } }, @@ -45,82 +48,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -143,7 +92,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json index 807b115d3d1..e195429cef9 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json @@ -58,82 +58,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -156,7 +102,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json index fead83afe86..8305bcdb59a 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -50,82 +50,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -148,7 +94,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json new file mode 100644 index 00000000000..64ff199af2e --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "context": "prebid.org", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": "980", + "creativeHeight": 240, + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field .AdUnits.Ads.CreativeHeight of type string", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json new file mode 100644 index 00000000000..c6da39dadd5 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -0,0 +1,54 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auI": "1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "", + "targetId": "-test-imp-id" + } + ], + "context": "unknown", + "metaData": {} + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Status code: 400, Request malformed", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json b/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json new file mode 100644 index 00000000000..727cf19498f --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json @@ -0,0 +1,97 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-network", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123", + "network": "test" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-network" + } + ], + "context": "unknown", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-network", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ], + "currency": "NOK" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json new file mode 100644 index 00000000000..4a90ab2fb48 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "context": "prebid.org", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": 980, + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field .AdUnits.Ads.CreativeWidth of type string", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index d096376c881..dd8fafc79a9 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -40,6 +40,7 @@ func TestInvalidParams(t *testing.T) { var validParams = []string{ `{"auId":"123"}`, + `{"auId":"123", "network":"test"}`, } var invalidParams = []string{ @@ -50,8 +51,10 @@ var invalidParams = []string{ `4.2`, `[]`, `{}`, - `{"aid":"123"}`, - `{"aid":"0"}`, - `{"aid":"123","placementId":"123"}`, - `{"aid":123, "placementId":"123", "siteId":"321"}`, + `{"auId":123}`, + `{"auID":"123"}`, + `{"network":123}`, + `{"network":123, "auID":123}`, + `{"network":"test", "auID":123}`, + `{"network":test, "auID":"123"}`, } diff --git a/adapters/adnuntius/timezone.go b/adapters/adnuntius/timezone.go new file mode 100644 index 00000000000..5e469b37079 --- /dev/null +++ b/adapters/adnuntius/timezone.go @@ -0,0 +1,23 @@ +package adnuntius + +import ( + "time" +) + +type timezone interface { + Now() time.Time +} + +// Send a real instance when you construct it in adapter_map.go +type realTzo struct{} + +func (_ realTzo) Now() time.Time { + return time.Now() +} + +// Use this for tests e.g. knownTzo(time.Date(y, m, ..., time.UTC)) +type knownTzo time.Time + +func (i knownTzo) Now() time.Time { + return time.Time(i) +} diff --git a/static/bidder-info/adnuntius.yaml b/static/bidder-info/adnuntius.yaml index fe135164bd2..2fc52490716 100644 --- a/static/bidder-info/adnuntius.yaml +++ b/static/bidder-info/adnuntius.yaml @@ -1,9 +1,10 @@ maintainer: - email: hello@adnuintius.com + email: hello@adnuntius.com +gvlVendorID: 855 capabilities: - app: - mediaTypes: - - banner - site: - mediaTypes: - - banner \ No newline at end of file + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner From 9444bffaa6d6a67d43fd1908417d40a84322bfe9 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Mon, 13 Sep 2021 13:55:55 +0000 Subject: [PATCH 08/21] Making adnuntius bidder working. --- adapters/adnuntius/adnuntius.go | 142 +++++++++++++++ adapters/adnuntius/adnuntius_test.go | 20 +++ .../exemplary/simple-banner.json | 170 ++++++++++++++++++ .../supplemental/all-failed.json | 16 ++ .../supplemental/invalid-params.json | 133 ++++++++++++++ .../supplemental/status-204.json | 42 +++++ .../supplemental/status-400.json | 45 +++++ .../supplemental/status-502.json | 45 +++++ adapters/adnuntius/params_test.go | 60 +++++++ config/config.go | 1 + exchange/adapter_builders.go | 2 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_adnuntius.go | 5 + static/bidder-info/adnuntius.yaml | 9 + static/bidder-params/adnuntius.json | 15 ++ 15 files changed, 707 insertions(+) create mode 100644 adapters/adnuntius/adnuntius.go create mode 100644 adapters/adnuntius/adnuntius_test.go create mode 100644 adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/all-failed.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-204.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-502.json create mode 100644 adapters/adnuntius/params_test.go create mode 100644 openrtb_ext/imp_adnuntius.go create mode 100644 static/bidder-info/adnuntius.yaml create mode 100644 static/bidder-params/adnuntius.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go new file mode 100644 index 00000000000..ea99371e943 --- /dev/null +++ b/adapters/adnuntius/adnuntius.go @@ -0,0 +1,142 @@ +package adnuntius + +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 +} + +// Builder builds a new instance of the BrightMountainMedia 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, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var extRequests []*adapters.RequestData + var errs []error + + for _, imp := range request.Imp { + extRequest, err := a.makeRequest(*request, imp) + if err != nil { + errs = append(errs, err) + } else { + extRequests = append(extRequests, extRequest) + } + } + return extRequests, errs +} + +func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + + if ortbImp.Banner == nil && ortbImp.Video == nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("For Imp ID %s Banner or Video is undefined", ortbImp.ID), + } + } + + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + } + } + + var adnuntiusExt openrtb_ext.ImpExtAdnunitus + if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + } + } + + ortbImp.TagID = adnuntiusExt.Auid + ortbImp.Ext = nil + ortbRequest.Imp = []openrtb2.Imp{ortbImp} + + requestJSON, err := json.Marshal(ortbRequest) + if err != nil { + return nil, err + } + + requestData := &adapters.RequestData{ + Method: http.MethodPost, + Uri: a.endpoint, + Body: requestJSON, + Headers: headers, + } + return requestData, nil +} + +func (a *adapter) 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 { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + }} + } + + var bidResp openrtb2.BidResponse + + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{err} + } + + + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + + for _, sb := range bidResp.SeatBid { + for i := range sb.Bid { + sb.Bid[i].H = 600 + sb.Bid[i].W = 500 + sb.Bid[i].AdID = "123123123" + sb.Bid[i].CID = "123123" + sb.Bid[i].CrID = "asdasdasdas" + + + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &sb.Bid[i], + BidType: getMediaTypeForBid(sb.Bid[i].ImpID, internalRequest.Imp), + }) + } + } + return bidResponse, nil +} + + +func getMediaTypeForBid(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo + } + } + } + return openrtb_ext.BidTypeBanner +} diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go new file mode 100644 index 00000000000..e75b711c20e --- /dev/null +++ b/adapters/adnuntius/adnuntius_test.go @@ -0,0 +1,20 @@ +package adnuntius + +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.BidderAdnuntius, config.Adapter{ + Endpoint: "http://example.com/prebid"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder) +} diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json new file mode 100644 index 00000000000..a3926dea623 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -0,0 +1,170 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "format": [{ + "h": 250, + "w": 300 + }] + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }, { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }, { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-2" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "format": [{ + "h": 250, + "w": 300 + }], + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }] + }] + } + } + }, { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-2", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-2", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }] + }] + } + } + }, { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-2", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-3", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-2" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-3", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }] + }] + } + } + }], + "expectedBidResponses": [{ + "bids": [{ + "bid": { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }, + "type": "banner" + }] + }, { + "bids": [{ + "bid": { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }, + "type": "banner" + }] + }, { + "bids": [{ + "bid": { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }, + "type": "banner" + }] + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json new file mode 100644 index 00000000000..7f0244afcfb --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json @@ -0,0 +1,16 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + } + }] + }, + "expectedMakeRequestsErrors": [{ + "value": "impression extensions required", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json new file mode 100644 index 00000000000..e43e91addb0 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json @@ -0,0 +1,133 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": {} + }, { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + } + }, { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": {} + }, { + "id": "test-impression-id-4" + }, { + "id": "test-impression-id-5", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": "invalid bidder" + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": {} + } + }, { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": "invalid ext" + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-5", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-5", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [{ + "bid": [{ + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, { + "id": "test-bid-id-6", + "impid": "test-impression-id-6", + "price": 6 + }] + }] + } + } + }], + "expectedBidResponses": [{ + "bids": [{ + "bid": { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + "type": "banner" + }] + }], + "expectedMakeRequestsErrors": [{ + "value": "banner size information missing", + "comparison": "literal" + }, { + "value": "impression extensions required", + "comparison": "literal" + }, { + "value": "bidder required", + "comparison": "literal" + }, { + "value": "Adnuntius only supports banner, video or native ads", + "comparison": "literal" + }, { + "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", + "comparison": "literal" + }, { + "value": "Adnuntius token required", + "comparison": "literal" + }, { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + }], + "expectedMakeBidsErrors": [{ + "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json new file mode 100644 index 00000000000..1c849b4fa3a --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json @@ -0,0 +1,42 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + }], + "expectedBidResponses": [] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json new file mode 100644 index 00000000000..95e271bae8e --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -0,0 +1,45 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + }], + "expectedMakeBidsErrors": [{ + "value": "unexpected status code: 400", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json new file mode 100644 index 00000000000..c0b1641653a --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json @@ -0,0 +1,45 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [{ + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "token": "test-token-1" + } + } + }] + } + }, + "mockResponse": { + "status": 502, + "body": {} + } + }], + "expectedMakeBidsErrors": [{ + "value": "unexpected status code: 502", + "comparison": "literal" + }] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go new file mode 100644 index 00000000000..82e47d0e475 --- /dev/null +++ b/adapters/adnuntius/params_test.go @@ -0,0 +1,60 @@ +package adnuntius + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/openrtb_ext" +) + +// This file actually intends to test static/bidder-params/adtelligent.json +// These also validate the format of the external API: request.imp[i].ext.adtelligent +// TestValidParams makes sure that the adtelligent 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.BidderAdtelligent, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adtelligent params: %s", validParam) + } + } +} + +// TestInvalidParams makes sure that the adtelligent 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.BidderAdtelligent, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"aid":123}`, + `{"aid":123,"placementId":1234}`, + `{"aid":123,"siteId":4321}`, + `{"aid":123,"siteId":0,"bidFloor":0}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, + `{"aid":"123"}`, + `{"aid":"0"}`, + `{"aid":"123","placementId":"123"}`, + `{"aid":123, "placementId":"123", "siteId":"321"}`, +} diff --git a/config/config.go b/config/config.go index 597ac1b41a7..0a3984cc125 100644 --- a/config/config.go +++ b/config/config.go @@ -756,6 +756,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/rtb") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index f34e74ea41b..a44d1f579c8 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -14,6 +14,7 @@ import ( "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/adnuntius" "github.com/prebid/prebid-server/adapters/adocean" "github.com/prebid/prebid-server/adapters/adoppler" "github.com/prebid/prebid-server/adapters/adot" @@ -148,6 +149,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderAdkernelAdn: adkernelAdn.Builder, openrtb_ext.BidderAdman: adman.Builder, openrtb_ext.BidderAdmixer: admixer.Builder, + openrtb_ext.BidderAdnuntius: adnuntius.Builder, openrtb_ext.BidderAdOcean: adocean.Builder, openrtb_ext.BidderAdoppler: adoppler.Builder, openrtb_ext.BidderAdpone: adpone.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 7976451877c..1c738a49d38 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -85,6 +85,7 @@ const ( BidderAdkernelAdn BidderName = "adkernelAdn" BidderAdman BidderName = "adman" BidderAdmixer BidderName = "admixer" + BidderAdnuntius BidderName = "adnuntius" BidderAdOcean BidderName = "adocean" BidderAdoppler BidderName = "adoppler" BidderAdot BidderName = "adot" @@ -221,6 +222,7 @@ func CoreBidderNames() []BidderName { BidderAdkernelAdn, BidderAdman, BidderAdmixer, + BidderAdnuntius, BidderAdOcean, BidderAdoppler, BidderAdot, diff --git a/openrtb_ext/imp_adnuntius.go b/openrtb_ext/imp_adnuntius.go new file mode 100644 index 00000000000..152199c09df --- /dev/null +++ b/openrtb_ext/imp_adnuntius.go @@ -0,0 +1,5 @@ +package openrtb_ext + +type ImpExtAdnunitus struct { + Auid string `json:"auId"` +} diff --git a/static/bidder-info/adnuntius.yaml b/static/bidder-info/adnuntius.yaml new file mode 100644 index 00000000000..fe135164bd2 --- /dev/null +++ b/static/bidder-info/adnuntius.yaml @@ -0,0 +1,9 @@ +maintainer: + email: hello@adnuintius.com +capabilities: + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner \ No newline at end of file diff --git a/static/bidder-params/adnuntius.json b/static/bidder-params/adnuntius.json new file mode 100644 index 00000000000..f94c3378309 --- /dev/null +++ b/static/bidder-params/adnuntius.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adnuntius Adapter Params", + "description": "A schema which validates params accepted by the Adnuntius adapter", + "type": "object", + + "properties": { + "auId": { + "type": "string", + "description": "Placement ID" + } + }, + + "required": ["auId"] +} \ No newline at end of file From 82ddf794ee38d2b7c06d67051287153d1a473dbb Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 14 Sep 2021 15:30:34 +0000 Subject: [PATCH 09/21] Testing that container works. --- adapters/adnuntius/adnuntius.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index ea99371e943..d0b1484d786 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -104,10 +104,23 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest if err := json.Unmarshal(response.Body, &bidResp); err != nil { return nil, []error{err} } + + + type Bird struct { + Id string + Name string + Huhu string + } - + var bird Bird + + json.Unmarshal([]byte(response.Body), &bird) + fmt.Println("BID",bird.Id) + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) + for _, sb := range bidResp.SeatBid { for i := range sb.Bid { From 524d0b32de6ac2e83858fd424ba0c32403067f23 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Wed, 22 Sep 2021 12:54:29 +0200 Subject: [PATCH 10/21] Tests work but fail. --- adapters/adnuntius/adnuntius.go | 178 ++++++--- .../exemplary/simple-banner.json | 352 +++++++++--------- .../supplemental/invalid-params.json | 294 ++++++++------- .../supplemental/status-204.json | 86 +++-- .../supplemental/status-400.json | 94 ++--- .../supplemental/status-502.json | 94 ++--- adapters/adnuntius/params_test.go | 19 +- config/config.go | 2 +- 8 files changed, 633 insertions(+), 486 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index d0b1484d786..779aea8db1c 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -4,7 +4,10 @@ import ( "encoding/json" "fmt" "net/http" + "strconv" + "strings" + "github.com/gofrs/uuid" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -15,6 +18,40 @@ import ( type adapter struct { endpoint string } +type adnAdunit struct { + AuId string `json:"auId"` + TargetId string `json:"targetId"` +} + +type AdnResponse struct { + AdUnits []struct { + AuId string + TargetId string + Html string + ResponseId string + Ads []struct { + Bid struct { + Amount float64 + Currency string + } + AdId string + CreativeWidth string + CreativeHeight string + CreativeId string + LineItemId string + Html string + DestinationUrls map[string]string + } + } +} +type adnMetaData struct { + Usi string `json:"usi"` +} +type adnRequest struct { + AdUnits []adnAdunit `json:"adUnits"` + MetaData adnMetaData `json:"metaData,omitempty"` + Context string `json:"context,omitempty"` +} // Builder builds a new instance of the BrightMountainMedia adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { @@ -29,7 +66,7 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E var errs []error for _, imp := range request.Imp { - extRequest, err := a.makeRequest(*request, imp) + extRequest, err := a.generateRequests(*request, imp) if err != nil { errs = append(errs, err) } else { @@ -39,16 +76,12 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E return extRequests, errs } -func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { + headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") - if ortbImp.Banner == nil && ortbImp.Video == nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("For Imp ID %s Banner or Video is undefined", ortbImp.ID), - } - } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { @@ -64,11 +97,12 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2. } } - ortbImp.TagID = adnuntiusExt.Auid - ortbImp.Ext = nil - ortbRequest.Imp = []openrtb2.Imp{ortbImp} + adnReq, reqErr := generateAdUnitRequest(adnuntiusExt, ortbRequest) + if reqErr != nil { + return nil, reqErr + } - requestJSON, err := json.Marshal(ortbRequest) + adnJson, err := json.Marshal(adnReq) if err != nil { return nil, err } @@ -76,13 +110,14 @@ func (a *adapter) makeRequest(ortbRequest openrtb2.BidRequest, ortbImp openrtb2. requestData := &adapters.RequestData{ Method: http.MethodPost, Uri: a.endpoint, - Body: requestJSON, + Body: adnJson, Headers: headers, } + return requestData, nil } -func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } @@ -99,57 +134,102 @@ func (a *adapter) MakeBids(internalRequest *openrtb2.BidRequest, externalRequest }} } - var bidResp openrtb2.BidResponse - - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + var adnResponse AdnResponse + if err := json.Unmarshal(response.Body, &adnResponse); err != nil { return nil, []error{err} } - - - type Bird struct { - Id string - Name string - Huhu string + + bidResponse, bidErr := generateBidResponse(&adnResponse, request) + if bidErr != nil { + return nil, bidErr } - var bird Bird + return bidResponse, nil +} - json.Unmarshal([]byte(response.Body), &bird) +func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) + currency := bidResponse.Currency - fmt.Println("BID",bird.Id) - - - bidResponse := adapters.NewBidderResponseWithBidsCapacity(1) - + for i, adunit := range adnResponse.AdUnits { + var bid openrtb2.Bid + ad := adunit.Ads[0] - for _, sb := range bidResp.SeatBid { - for i := range sb.Bid { - sb.Bid[i].H = 600 - sb.Bid[i].W = 500 - sb.Bid[i].AdID = "123123123" - sb.Bid[i].CID = "123123" - sb.Bid[i].CrID = "asdasdasdas" + currency = ad.Bid.Currency + creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) + if Werr != nil { + return nil, []error{Werr} + } - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &sb.Bid[i], - BidType: getMediaTypeForBid(sb.Bid[i].ImpID, internalRequest.Imp), - }) + creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) + if Herr != nil { + return nil, []error{Herr} } + + adDomain := []string{} + for _, url := range ad.DestinationUrls { + domainArray := strings.Split(url, "/") + domain := strings.Replace(domainArray[2], "www.", "", -1) + adDomain = append(adDomain, domain) + } + + bid = openrtb2.Bid{ + ID: ad.AdId, + ImpID: request.Imp[i].ID, + W: creativeWidth, + H: creativeHeight, + AdID: ad.AdId, + CID: ad.LineItemId, + CrID: ad.CreativeId, + Price: ad.Bid.Amount * 1000, + AdM: adunit.Html, + ADomain: adDomain, + } + + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: "banner", + }) + } + bidResponse.Currency = currency return bidResponse, nil } +func generateAdUnitRequest(adnuntiusExt openrtb_ext.ImpExtAdnunitus, ortbRequest openrtb2.BidRequest) (*adnRequest, error) { + adunits := []adnAdunit{} + rawUuid, uidErr := uuid.NewV4() + if uidErr != nil { + return nil, uidErr + } + + adnuntiusAdunits := adnAdunit{ + AuId: adnuntiusExt.Auid, + TargetId: rawUuid.String(), + } + + adunits = append(adunits, adnuntiusAdunits) -func getMediaTypeForBid(impID string, imps []openrtb2.Imp) openrtb_ext.BidType { - for _, imp := range imps { - if imp.ID == impID { - if imp.Banner != nil { - return openrtb_ext.BidTypeBanner - } else if imp.Video != nil { - return openrtb_ext.BidTypeVideo - } + var userId string + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + userId = ortbRequest.User.ID } } - return openrtb_ext.BidTypeBanner + + var site string + if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { + site = ortbRequest.Site.Page + } + + adnuntiusRequest := adnRequest{ + AdUnits: adunits, + MetaData: adnMetaData{Usi: userId}, + Context: site, + } + + return &adnuntiusRequest, nil } diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index a3926dea623..5ce2b5191f6 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -1,170 +1,186 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "format": [{ - "h": 250, - "w": 300 - }] - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }, { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }, { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-2" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "format": [{ - "h": 250, - "w": 300 - }], - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }] - }] - } - } - }, { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-2", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-2", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }] - }] - } - } - }, { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-2", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-3", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-2" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-3", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - }] - }] - } - } - }], - "expectedBidResponses": [{ - "bids": [{ - "bid": { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }, - "type": "banner" - }] - }, { - "bids": [{ - "bid": { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }, - "type": "banner" - }] - }, { - "bids": [{ - "bid": { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - }, - "type": "banner" - }] - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + }, + { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + }, + { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-2" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-1", + "targetId": "d7b3cb0f-6da6-4c17-8395-3b76c03f1d0f" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + } + ] + } + ] + } + } + }, + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-1", + "targetId": "12482e7c-6f24-495f-ac6c-446040231e1e" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-2", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + } + ] + } + ] + } + } + }, + { + "expectedRequest": { + "uri": "http://example.com/prebid", + "body": { + "adUnits": [ + { + "auId": "test-token-2", + "targetId": "9c303223-26c7-4624-942d-aee848fd6545" + } + ], + "metaData": { + "usi": "" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id-3", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id-1", + "impid": "test-impression-id-1", + "price": 1 + }, + "type": "banner" + } + ] + }, + { + "bids": [ + { + "bid": { + "id": "test-bid-id-2", + "impid": "test-impression-id-2", + "price": 2 + }, + "type": "banner" + } + ] + }, + { + "bids": [ + { + "bid": { + "id": "test-bid-id-3", + "impid": "test-impression-id-3", + "price": 3 + }, + "type": "banner" + } + ] + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json index e43e91addb0..fbe43f9e279 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json @@ -1,133 +1,165 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": {} - }, { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - } - }, { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": {} - }, { - "id": "test-impression-id-4" - }, { - "id": "test-impression-id-5", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": "invalid bidder" - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": {} - } - }, { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": "invalid ext" - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-5", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-5", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [{ - "bid": [{ - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, { - "id": "test-bid-id-6", - "impid": "test-impression-id-6", - "price": 6 - }] - }] - } - } - }], - "expectedBidResponses": [{ - "bids": [{ - "bid": { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - "type": "banner" - }] - }], - "expectedMakeRequestsErrors": [{ - "value": "banner size information missing", - "comparison": "literal" - }, { - "value": "impression extensions required", - "comparison": "literal" - }, { - "value": "bidder required", - "comparison": "literal" - }, { - "value": "Adnuntius only supports banner, video or native ads", - "comparison": "literal" - }, { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", - "comparison": "literal" - }, { - "value": "Adnuntius token required", - "comparison": "literal" - }, { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", - "comparison": "literal" - }], - "expectedMakeBidsErrors": [{ - "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": {} + }, + { + "id": "test-impression-id-2", + "banner": { + "w": 300, + "h": 250 + } + }, + { + "id": "test-impression-id-3", + "banner": { + "w": 300, + "h": 250 + }, + "ext": {} + }, + { + "id": "test-impression-id-4" + }, + { + "id": "test-impression-id-5", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "token": "test-token-5" + } + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": "invalid bidder" + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": {} + } + }, + { + "id": "test-impression-id-0", + "banner": { + "w": 300, + "h": 250 + }, + "ext": "invalid ext" + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-5", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-5", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-5" + } + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-response-id", + "seatbid": [ + { + "bid": [ + { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + { + "id": "test-bid-id-6", + "impid": "test-impression-id-6", + "price": 6 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "test-bid-id-5", + "impid": "test-impression-id-5", + "price": 5 + }, + "type": "banner" + } + ] + } + ], + "expectedMakeRequestsErrors": [ + { + "value": "banner size information missing", + "comparison": "literal" + }, + { + "value": "impression extensions required", + "comparison": "literal" + }, + { + "value": "bidder required", + "comparison": "literal" + }, + { + "value": "Adnuntius only supports banner, video or native ads", + "comparison": "literal" + }, + { + "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", + "comparison": "literal" + }, + { + "value": "Adnuntius token required", + "comparison": "literal" + }, + { + "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", + "comparison": "literal" + } + ], + "expectedMakeBidsErrors": [ + { + "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json index 1c849b4fa3a..2369ad64ca0 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json @@ -1,42 +1,48 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 204, - "body": {} - } - }], - "expectedBidResponses": [] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json index 95e271bae8e..41fb4c976f2 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -1,45 +1,53 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 400, - "body": {} - } - }], - "expectedMakeBidsErrors": [{ - "value": "unexpected status code: 400", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 400", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json index c0b1641653a..28616429080 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json @@ -1,45 +1,53 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "token": "test-token-1" - } - } - }] - } - }, - "mockResponse": { - "status": 502, - "body": {} - } - }], - "expectedMakeBidsErrors": [{ - "value": "unexpected status code: 502", - "comparison": "literal" - }] + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "w": 300, + "h": 250 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://example.com/prebid/test-token-1", + "body": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-id-1", + "banner": { + "h": 250, + "w": 300 + }, + "ext": { + "bidder": { + "auId": "test-token-1" + } + } + } + ] + } + }, + "mockResponse": { + "status": 502, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 502", + "comparison": "literal" + } + ] } diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index 82e47d0e475..33cf47ac409 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -7,9 +7,9 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -// This file actually intends to test static/bidder-params/adtelligent.json -// These also validate the format of the external API: request.imp[i].ext.adtelligent -// TestValidParams makes sure that the adtelligent schema accepts all imp.ext fields which we intend to support. +// This file actually intends to test static/bidder-params/adnuntius.json +// These also validate the format of the external API: request.imp[i].ext.adnuntius +// TestValidParams makes sure that the adnuntius schema accepts all imp.ext fields which we intend to support. func TestValidParams(t *testing.T) { validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params") @@ -18,13 +18,13 @@ func TestValidParams(t *testing.T) { } for _, validParam := range validParams { - if err := validator.Validate(openrtb_ext.BidderAdtelligent, json.RawMessage(validParam)); err != nil { - t.Errorf("Schema rejected adtelligent params: %s", validParam) + if err := validator.Validate(openrtb_ext.BidderAdnuntius, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected adnuntius params: %s", validParam) } } } -// TestInvalidParams makes sure that the adtelligent schema rejects all the imp.ext fields we don't support. +// TestInvalidParams makes sure that the adnuntius 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 { @@ -32,17 +32,14 @@ func TestInvalidParams(t *testing.T) { } for _, invalidParam := range invalidParams { - if err := validator.Validate(openrtb_ext.BidderAdtelligent, json.RawMessage(invalidParam)); err == nil { + if err := validator.Validate(openrtb_ext.BidderAdnuntius, json.RawMessage(invalidParam)); err == nil { t.Errorf("Schema allowed unexpected params: %s", invalidParam) } } } var validParams = []string{ - `{"aid":123}`, - `{"aid":123,"placementId":1234}`, - `{"aid":123,"siteId":4321}`, - `{"aid":123,"siteId":0,"bidFloor":0}`, + `{"auId":123}`, } var invalidParams = []string{ diff --git a/config/config.go b/config/config.go index 0a3984cc125..45a790c73f0 100644 --- a/config/config.go +++ b/config/config.go @@ -756,7 +756,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/rtb") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?tzo=-60&format=json") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") From 41bf3ff88af92a554eff699117854e895e2037f8 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 23 Sep 2021 15:25:15 +0200 Subject: [PATCH 11/21] Tzo added to the request. --- adapters/adnuntius/adnuntius.go | 209 +++++++++++++++------------- config/config.go | 2 +- openrtb_ext/imp_adnuntius.go | 3 +- static/bidder-params/adnuntius.json | 28 ++-- 4 files changed, 128 insertions(+), 114 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 779aea8db1c..7f67fc80fbb 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -6,8 +6,8 @@ import ( "net/http" "strconv" "strings" + "time" - "github.com/gofrs/uuid" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" @@ -53,7 +53,7 @@ type adnRequest struct { Context string `json:"context,omitempty"` } -// Builder builds a new instance of the BrightMountainMedia adapter for the given bidder with the given config. +// Builder builds a new instance of the Adnuntius 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, @@ -64,54 +64,97 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var extRequests []*adapters.RequestData var errs []error - - for _, imp := range request.Imp { - extRequest, err := a.generateRequests(*request, imp) - if err != nil { - errs = append(errs, err) - } else { - extRequests = append(extRequests, extRequest) - } + extRequests, err := a.generateRequests(*request) + if err != nil { + errs = append(errs, err) } return extRequests, errs } -func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest, ortbImp openrtb2.Imp) (*adapters.RequestData, error) { +/* + Generate the requests to Adnuntius to reduce the amount of requests going out. +*/ +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { + + var requestData []*adapters.RequestData + networkAdunitMap := make(map[string][]adnAdunit) headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") + for _, imp := range ortbRequest.Imp { - var bidderExt adapters.ExtImpBidder - if err := json.Unmarshal(ortbImp.Ext, &bidderExt); err != nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + var bidderExt adapters.ExtImpBidder + if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), + } } - } - var adnuntiusExt openrtb_ext.ImpExtAdnunitus - if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { - return nil, &errortypes.BadInput{ - Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + var adnuntiusExt openrtb_ext.ImpExtAdnunitus + if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), + } } + + var network string + if adnuntiusExt.Network != "" { + network = adnuntiusExt.Network + } else { + network = "default" + } + + networkAdunitMap[network] = append( + networkAdunitMap[network], + adnAdunit{ + AuId: adnuntiusExt.Auid, + TargetId: fmt.Sprintf("%s-%s", adnuntiusExt.Auid, imp.ID), + }) } - adnReq, reqErr := generateAdUnitRequest(adnuntiusExt, ortbRequest) - if reqErr != nil { - return nil, reqErr + var userId string + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + userId = ortbRequest.User.ID + } } - adnJson, err := json.Marshal(adnReq) - if err != nil { - return nil, err + var site string + if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { + site = ortbRequest.Site.Page } - requestData := &adapters.RequestData{ - Method: http.MethodPost, - Uri: a.endpoint, - Body: adnJson, - Headers: headers, + /* + Divide requests that go to different networks. + */ + + for _, networkAdunits := range networkAdunitMap { + + adnuntiusRequest := adnRequest{ + AdUnits: networkAdunits, + MetaData: adnMetaData{Usi: userId}, + Context: site, + } + + adnJson, err := json.Marshal(adnuntiusRequest) + if err != nil { + return nil, err + } + + _, offset := time.Now().UTC().Local().Zone() + tzo := - offset / 3600 *60 + + requestData = append(requestData, &adapters.RequestData{ + Method: http.MethodPost, + Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), + Body: adnJson, + Headers: headers, + }) + } return requestData, nil @@ -152,84 +195,50 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) currency := bidResponse.Currency for i, adunit := range adnResponse.AdUnits { + var bid openrtb2.Bid - ad := adunit.Ads[0] + if len(adunit.Ads) > 0 { + ad := adunit.Ads[0] - currency = ad.Bid.Currency + currency = ad.Bid.Currency - creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) - if Werr != nil { - return nil, []error{Werr} - } + creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) + if Werr != nil { + return nil, []error{Werr} + } - creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) - if Herr != nil { - return nil, []error{Herr} - } + creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) + if Herr != nil { + return nil, []error{Herr} + } - adDomain := []string{} - for _, url := range ad.DestinationUrls { - domainArray := strings.Split(url, "/") - domain := strings.Replace(domainArray[2], "www.", "", -1) - adDomain = append(adDomain, domain) - } + adDomain := []string{} + for _, url := range ad.DestinationUrls { + domainArray := strings.Split(url, "/") + domain := strings.Replace(domainArray[2], "www.", "", -1) + adDomain = append(adDomain, domain) + } - bid = openrtb2.Bid{ - ID: ad.AdId, - ImpID: request.Imp[i].ID, - W: creativeWidth, - H: creativeHeight, - AdID: ad.AdId, - CID: ad.LineItemId, - CrID: ad.CreativeId, - Price: ad.Bid.Amount * 1000, - AdM: adunit.Html, - ADomain: adDomain, - } + bid = openrtb2.Bid{ + ID: ad.AdId, + ImpID: request.Imp[i].ID, + W: creativeWidth, + H: creativeHeight, + AdID: ad.AdId, + CID: ad.LineItemId, + CrID: ad.CreativeId, + Price: ad.Bid.Amount * 1000, + AdM: adunit.Html, + ADomain: adDomain, + } - bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ - Bid: &bid, - BidType: "banner", - }) + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: "banner", + }) + } } bidResponse.Currency = currency return bidResponse, nil } - -func generateAdUnitRequest(adnuntiusExt openrtb_ext.ImpExtAdnunitus, ortbRequest openrtb2.BidRequest) (*adnRequest, error) { - adunits := []adnAdunit{} - rawUuid, uidErr := uuid.NewV4() - if uidErr != nil { - return nil, uidErr - } - - adnuntiusAdunits := adnAdunit{ - AuId: adnuntiusExt.Auid, - TargetId: rawUuid.String(), - } - - adunits = append(adunits, adnuntiusAdunits) - - var userId string - ortbUser := ortbRequest.User - if ortbUser != nil { - ortbUserId := ortbRequest.User.ID - if ortbUserId != "" { - userId = ortbRequest.User.ID - } - } - - var site string - if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { - site = ortbRequest.Site.Page - } - - adnuntiusRequest := adnRequest{ - AdUnits: adunits, - MetaData: adnMetaData{Usi: userId}, - Context: site, - } - - return &adnuntiusRequest, nil -} diff --git a/config/config.go b/config/config.go index 45a790c73f0..1366468e422 100644 --- a/config/config.go +++ b/config/config.go @@ -756,7 +756,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?tzo=-60&format=json") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?format=json") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") diff --git a/openrtb_ext/imp_adnuntius.go b/openrtb_ext/imp_adnuntius.go index 152199c09df..bde30f0518f 100644 --- a/openrtb_ext/imp_adnuntius.go +++ b/openrtb_ext/imp_adnuntius.go @@ -1,5 +1,6 @@ package openrtb_ext type ImpExtAdnunitus struct { - Auid string `json:"auId"` + Auid string `json:"auId"` + Network string `json:"network"` } diff --git a/static/bidder-params/adnuntius.json b/static/bidder-params/adnuntius.json index f94c3378309..a8e65bea343 100644 --- a/static/bidder-params/adnuntius.json +++ b/static/bidder-params/adnuntius.json @@ -1,15 +1,19 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Adnuntius Adapter Params", - "description": "A schema which validates params accepted by the Adnuntius adapter", - "type": "object", + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Adnuntius Adapter Params", + "description": "A schema which validates params accepted by the Adnuntius adapter", + "type": "object", - "properties": { - "auId": { - "type": "string", - "description": "Placement ID" - } - }, + "properties": { + "auId": { + "type": "string", + "description": "Placement ID" + }, + "network": { + "type": "string", + "description": "Network if required" + } + }, - "required": ["auId"] -} \ No newline at end of file + "required": ["auId"] +} From cbddd6945afccdb2ee1cd2f25a16198f44193a36 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Fri, 24 Sep 2021 11:59:52 +0000 Subject: [PATCH 12/21] Tests for adnuntius adapter. --- adapters/adnuntius/adnuntius.go | 36 +-- adapters/adnuntius/adnuntius_test.go | 2 +- .../exemplary/simple-banner.json | 225 ++++++++---------- .../supplemental/all-failed.json | 16 -- .../supplemental/check-userId.json | 154 ++++++++++++ .../supplemental/invalid-params.json | 165 ------------- .../supplemental/native-error.json | 25 ++ .../supplemental/status-204.json | 48 ---- .../supplemental/status-400.json | 53 ----- .../supplemental/status-502.json | 53 ----- .../supplemental/video-error.json | 26 ++ adapters/adnuntius/params_test.go | 2 +- 12 files changed, 321 insertions(+), 484 deletions(-) delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/all-failed.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/check-userId.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/native-error.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-204.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json delete mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-502.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/video-error.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 7f67fc80fbb..a6bc29c8ff0 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -45,7 +45,7 @@ type AdnResponse struct { } } type adnMetaData struct { - Usi string `json:"usi"` + Usi string `json:"usi,omitempty"` } type adnRequest struct { AdUnits []adnAdunit `json:"adUnits"` @@ -84,7 +84,11 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters headers.Add("Accept", "application/json") for _, imp := range ortbRequest.Imp { - + if imp.Banner == nil { + return nil, &errortypes.BadInput{ + Message: fmt.Sprintf("ignoring imp id=%s, Adnuntius supports only Banner", imp.ID), + } + } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { return nil, &errortypes.BadInput{ @@ -114,18 +118,11 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }) } - var userId string - ortbUser := ortbRequest.User - if ortbUser != nil { - ortbUserId := ortbRequest.User.ID - if ortbUserId != "" { - userId = ortbRequest.User.ID - } - } - var site string if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { site = ortbRequest.Site.Page + } else { + site = "unknown" } /* @@ -135,9 +132,16 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters for _, networkAdunits := range networkAdunitMap { adnuntiusRequest := adnRequest{ - AdUnits: networkAdunits, - MetaData: adnMetaData{Usi: userId}, - Context: site, + AdUnits: networkAdunits, + Context: site, + } + + ortbUser := ortbRequest.User + if ortbUser != nil { + ortbUserId := ortbRequest.User.ID + if ortbUserId != "" { + adnuntiusRequest.MetaData.Usi = ortbRequest.User.ID + } } adnJson, err := json.Marshal(adnuntiusRequest) @@ -146,8 +150,8 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters } _, offset := time.Now().UTC().Local().Zone() - tzo := - offset / 3600 *60 - + tzo := -offset / 3600 * 60 + requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go index e75b711c20e..0f575a7141a 100644 --- a/adapters/adnuntius/adnuntius_test.go +++ b/adapters/adnuntius/adnuntius_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderAdnuntius, config.Adapter{ - Endpoint: "http://example.com/prebid"}) + Endpoint: "http://whatever.url"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index 5ce2b5191f6..2ca73e6f8c8 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -3,144 +3,124 @@ "id": "test-request-id", "imp": [ { - "id": "test-impression-id-1", + "id": "test-imp-id", "banner": { "format": [ { - "h": 250, - "w": 300 + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 } ] }, "ext": { "bidder": { - "auId": "test-token-1" - } - } - }, - { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - }, - { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-2" + "auId": "123" } } } ] }, + "httpCalls": [ { "expectedRequest": { - "uri": "http://example.com/prebid", + "uri": "http://whatever.url&tzo=0", "body": { "adUnits": [ { - "auId": "test-token-1", - "targetId": "d7b3cb0f-6da6-4c17-8395-3b76c03f1d0f" + "auId": "123", + "targetId": "123-test-imp-id" } ], - "metaData": { - "usi": "" - } + "context": "unknown", + "metaData": {} } }, "mockResponse": { "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - } - ] - } - ] - } - } - }, - { - "expectedRequest": { - "uri": "http://example.com/prebid", "body": { "adUnits": [ { - "auId": "test-token-1", - "targetId": "12482e7c-6f24-495f-ac6c-446040231e1e" - } - ], - "metaData": { - "usi": "" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-2", - "seatbid": [ - { - "bid": [ + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" } ] } - ] - } - } - }, - { - "expectedRequest": { - "uri": "http://example.com/prebid", - "body": { - "adUnits": [ - { - "auId": "test-token-2", - "targetId": "9c303223-26c7-4624-942d-aee848fd6545" - } ], "metaData": { - "usi": "" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id-3", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 - } - ] - } - ] + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] } } } @@ -150,33 +130,16 @@ "bids": [ { "bid": { - "id": "test-bid-id-1", - "impid": "test-impression-id-1", - "price": 1 - }, - "type": "banner" - } - ] - }, - { - "bids": [ - { - "bid": { - "id": "test-bid-id-2", - "impid": "test-impression-id-2", - "price": 2 - }, - "type": "banner" - } - ] - }, - { - "bids": [ - { - "bid": { - "id": "test-bid-id-3", - "impid": "test-impression-id-3", - "price": 3 + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 }, "type": "banner" } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json b/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json deleted file mode 100644 index 7f0244afcfb..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/all-failed.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [{ - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - } - }] - }, - "expectedMakeRequestsErrors": [{ - "value": "impression extensions required", - "comparison": "literal" - }] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json new file mode 100644 index 00000000000..716b0d7e51d --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -0,0 +1,154 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "1kjh3429kjh295jkl" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "metaData": { + "usi": "1kjh3429kjh295jkl" + }, + "context": "unknown" + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" + } + ] + } + ], + "metaData": { + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json b/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json deleted file mode 100644 index fbe43f9e279..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/invalid-params.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": {} - }, - { - "id": "test-impression-id-2", - "banner": { - "w": 300, - "h": 250 - } - }, - { - "id": "test-impression-id-3", - "banner": { - "w": 300, - "h": 250 - }, - "ext": {} - }, - { - "id": "test-impression-id-4" - }, - { - "id": "test-impression-id-5", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "token": "test-token-5" - } - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": "invalid bidder" - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": {} - } - }, - { - "id": "test-impression-id-0", - "banner": { - "w": 300, - "h": 250 - }, - "ext": "invalid ext" - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-5", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-5", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-5" - } - } - } - ] - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-response-id", - "seatbid": [ - { - "bid": [ - { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - { - "id": "test-bid-id-6", - "impid": "test-impression-id-6", - "price": 6 - } - ] - } - ] - } - } - } - ], - "expectedBidResponses": [ - { - "bids": [ - { - "bid": { - "id": "test-bid-id-5", - "impid": "test-impression-id-5", - "price": 5 - }, - "type": "banner" - } - ] - } - ], - "expectedMakeRequestsErrors": [ - { - "value": "banner size information missing", - "comparison": "literal" - }, - { - "value": "impression extensions required", - "comparison": "literal" - }, - { - "value": "bidder required", - "comparison": "literal" - }, - { - "value": "Adnuntius only supports banner, video or native ads", - "comparison": "literal" - }, - { - "value": "json: cannot unmarshal string into Go value of type openrtb_ext.ExtImpAdnuntius", - "comparison": "literal" - }, - { - "value": "Adnuntius token required", - "comparison": "literal" - }, - { - "value": "json: cannot unmarshal string into Go value of type adapters.ExtImpBidder", - "comparison": "literal" - } - ], - "expectedMakeBidsErrors": [ - { - "value": "ignoring bid id=test-bid-id-6, request doesn't contain any valid impression with id=test-impression-id-6", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/native-error.json b/adapters/adnuntius/adnuntiustest/supplemental/native-error.json new file mode 100644 index 00000000000..a8203e581ef --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/native-error.json @@ -0,0 +1,25 @@ +{ + "mockBidRequest": { + "id": "unsupported-native-request", + "imp": [ + { + "id": "unsupported-native-imp", + "native": { + "ver": "1.1" + }, + "ext": { + "bidder": { + "auId": "1" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "ignoring imp id=unsupported-native-imp, Adnuntius supports only Banner", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json b/adapters/adnuntius/adnuntiustest/supplemental/status-204.json deleted file mode 100644 index 2369ad64ca0..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-204.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 204, - "body": {} - } - } - ], - "expectedBidResponses": [] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json deleted file mode 100644 index 41fb4c976f2..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 400, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "unexpected status code: 400", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json b/adapters/adnuntius/adnuntiustest/supplemental/status-502.json deleted file mode 100644 index 28616429080..00000000000 --- a/adapters/adnuntius/adnuntiustest/supplemental/status-502.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "w": 300, - "h": 250 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - }, - "httpCalls": [ - { - "expectedRequest": { - "uri": "http://example.com/prebid/test-token-1", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-impression-id-1", - "banner": { - "h": 250, - "w": 300 - }, - "ext": { - "bidder": { - "auId": "test-token-1" - } - } - } - ] - } - }, - "mockResponse": { - "status": 502, - "body": {} - } - } - ], - "expectedMakeBidsErrors": [ - { - "value": "unexpected status code: 502", - "comparison": "literal" - } - ] -} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/video-error.json b/adapters/adnuntius/adnuntiustest/supplemental/video-error.json new file mode 100644 index 00000000000..357cb165f36 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/video-error.json @@ -0,0 +1,26 @@ +{ + "mockBidRequest": { + "id": "unsupported-native-request", + "imp": [ + { + "id": "unsupported-native-imp", + "video": { + "w": 728, + "h": 90 + }, + "ext": { + "bidder": { + "auId": "1" + } + } + } + ] + }, + + "expectedMakeRequestsErrors": [ + { + "value": "ignoring imp id=unsupported-native-imp, Adnuntius supports only Banner", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index 33cf47ac409..d096376c881 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -39,7 +39,7 @@ func TestInvalidParams(t *testing.T) { } var validParams = []string{ - `{"auId":123}`, + `{"auId":"123"}`, } var invalidParams = []string{ From 25fefefa5bbf05959ab37176b41af4fcd744fb06 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Fri, 24 Sep 2021 13:22:35 +0000 Subject: [PATCH 13/21] Gdpr Added to adapter. --- adapters/adnuntius/adnuntius.go | 78 +++++++-- .../exemplary/simple-banner.json | 2 +- .../supplemental/check-gdpr.json | 162 ++++++++++++++++++ .../supplemental/check-userId.json | 2 +- config/config.go | 2 +- 5 files changed, 230 insertions(+), 16 deletions(-) create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index a6bc29c8ff0..4a6fa39f7f3 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "net/url" "strconv" "strings" "time" @@ -15,6 +16,7 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) +type QueryString map[string]string type adapter struct { endpoint string } @@ -71,17 +73,50 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.E return extRequests, errs } +func setHeaders() http.Header { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + return headers +} + +func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, []error) { + uri, err := url.Parse(endpoint) + if err != nil { + return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + } + + _, offset := time.Now().UTC().Local().Zone() + tzo := -offset / 3600 * 60 + + gdpr, consent, err := getGDPR(&ortbRequest) + if err != nil { + return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + } + + q := uri.Query() + if gdpr != "" && consent != "" { + q.Set("gdpr", gdpr) + q.Set("consentString", consent) + } + q.Set("tzo", fmt.Sprint(tzo)) + q.Set("format", "json") + + url := endpoint + "?" + q.Encode() + return url, nil +} + /* Generate the requests to Adnuntius to reduce the amount of requests going out. */ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { - var requestData []*adapters.RequestData networkAdunitMap := make(map[string][]adnAdunit) - - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") + headers := setHeaders() + endpoint, err := makeEndpointUrl(ortbRequest, a.endpoint) + if err != nil { + return nil, fmt.Errorf("failed to parse URL: %v", err) + } for _, imp := range ortbRequest.Imp { if imp.Banner == nil { @@ -125,10 +160,6 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters site = "unknown" } - /* - Divide requests that go to different networks. - */ - for _, networkAdunits := range networkAdunitMap { adnuntiusRequest := adnRequest{ @@ -149,12 +180,9 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters return nil, err } - _, offset := time.Now().UTC().Local().Zone() - tzo := -offset / 3600 * 60 - requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, - Uri: a.endpoint + fmt.Sprintf("&tzo=%s", fmt.Sprint(tzo)), + Uri: endpoint, Body: adnJson, Headers: headers, }) @@ -194,6 +222,30 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte return bidResponse, nil } +func getGDPR(request *openrtb2.BidRequest) (string, string, error) { + gdpr := "" + var extRegs openrtb_ext.ExtRegs + if request.Regs != nil { + if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { + return "", "", fmt.Errorf("failed to parse ExtRegs in Yieldlab GDPR check: %v", err) + } + if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { + gdpr = strconv.Itoa(int(*extRegs.GDPR)) + } + } + + consent := "" + if request.User != nil && request.User.Ext != nil { + var extUser openrtb_ext.ExtUser + if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { + return "", "", fmt.Errorf("failed to parse ExtUser in Yieldlab GDPR check: %v", err) + } + consent = extUser.Consent + } + + return gdpr, consent, nil +} + func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) currency := bidResponse.Currency diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index 2ca73e6f8c8..f98028cf79f 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -28,7 +28,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://whatever.url&tzo=0", + "uri": "http://whatever.url?format=json&tzo=0", "body": { "adUnits": [ { diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json new file mode 100644 index 00000000000..807b115d3d1 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json @@ -0,0 +1,162 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "user": { + "id": "1kjh3429kjh295jkl", + "ext": { + "consent": "CONSENT_STRING" + } + }, + "regs": { + "ext": { + "gdpr": 1 + } + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?consentString=CONSENT_STRING&format=json&gdpr=1&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "metaData": { + "usi": "1kjh3429kjh295jkl" + }, + "context": "unknown" + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "000000000001789f", + "targetId": "1789f-some1111", + "html": "", + "matchedAdCount": 1, + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrlEsc": "", + "assets": { + "Image": { + "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", + "width": "660", + "height": "200" + } + }, + "text": {}, + "choices": {}, + "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "urls": { + "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" + }, + "urlsEsc": { + "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" + }, + "destinationUrls": { + "url": "http://www.google.com" + }, + "cpm": { + "amount": 20000.0, + "currency": "NOK" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "cost": { + "amount": 20.0, + "currency": "NOK" + }, + "impressionTrackingUrls": [], + "impressionTrackingUrlsEsc": [], + "adId": "adn-id-1559784094", + "selectedColumn": "0", + "selectedColumnPosition": "0", + "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", + "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv", + "layoutId": "adnuntius_image_layout_1", + "layoutName": "Image", + "layoutExternalReference": "", + "renderTemplate": "", + "html": "" + } + ] + } + ], + "metaData": { + "r": "0AAAAAQAA", + "s": "0AAAAAQAA", + "c": "0AAAAAQAA", + "v": "0AAAAAQAA", + "i": "0AAAAAQAA", + "usi": "1kjh3429kjh295jkl", + "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" + }, + "duplicateFilter": "AAAAAAAAAAA=", + "segments": [], + "keywords": [] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-imp-id", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json index 716b0d7e51d..fead83afe86 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -31,7 +31,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://whatever.url&tzo=0", + "uri": "http://whatever.url?format=json&tzo=0", "body": { "adUnits": [ { diff --git a/config/config.go b/config/config.go index 1366468e422..7fd7c562532 100644 --- a/config/config.go +++ b/config/config.go @@ -756,7 +756,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.adman.endpoint", "http://pub.admanmedia.com/?c=o&m=ortb") v.SetDefault("adapters.admixer.endpoint", "http://inv-nets.admixer.net/pbs.aspx") v.SetDefault("adapters.adocean.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i?format=json") + v.SetDefault("adapters.adnuntius.endpoint", "https://ads.adnuntius.delivery/i") v.SetDefault("adapters.adoppler.endpoint", "http://{{.AccountID}}.trustedmarketplace.io/ads/processHeaderBid/{{.AdUnit}}") v.SetDefault("adapters.adot.endpoint", "https://dsp.adotmob.com/headerbidding/bidrequest") v.SetDefault("adapters.adpone.endpoint", "http://rtb.adpone.com/bid-request?src=prebid_server") From a651cce6c4612564af237e78143766d315946cf7 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 5 Oct 2021 19:40:52 +0000 Subject: [PATCH 14/21] Fixing commented issues in pull request. --- adapters/adnuntius/adnuntius.go | 82 ++++++++-------- adapters/adnuntius/adnuntius_test.go | 15 +++ .../exemplary/simple-banner.json | 70 ++----------- .../supplemental/check-gdpr.json | 65 ++----------- .../supplemental/check-userId.json | 65 ++----------- .../supplemental/height-error.json | 84 ++++++++++++++++ .../supplemental/status-400.json | 54 +++++++++++ .../supplemental/test-networks.json | 97 +++++++++++++++++++ .../supplemental/width-error.json | 84 ++++++++++++++++ adapters/adnuntius/params_test.go | 11 ++- adapters/adnuntius/timezone.go | 23 +++++ static/bidder-info/adnuntius.yaml | 15 +-- 12 files changed, 435 insertions(+), 230 deletions(-) create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/height-error.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/status-400.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/test-networks.json create mode 100644 adapters/adnuntius/adnuntiustest/supplemental/width-error.json create mode 100644 adapters/adnuntius/timezone.go diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 4a6fa39f7f3..47bab06f622 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -7,7 +7,6 @@ import ( "net/url" "strconv" "strings" - "time" "github.com/mxmCherry/openrtb/v15/openrtb2" "github.com/prebid/prebid-server/adapters" @@ -18,6 +17,7 @@ import ( type QueryString map[string]string type adapter struct { + tzo timezone endpoint string } type adnAdunit struct { @@ -58,17 +58,20 @@ type adnRequest struct { // Builder builds a new instance of the Adnuntius adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &adapter{ + tzo: realTzo{}, endpoint: config.Endpoint, } + return bidder, nil } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { var extRequests []*adapters.RequestData var errs []error + extRequests, err := a.generateRequests(*request) if err != nil { - errs = append(errs, err) + errs = append(errs, err...) } return extRequests, errs } @@ -80,20 +83,20 @@ func setHeaders() http.Header { return headers } -func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, []error) { - uri, err := url.Parse(endpoint) +func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []error) { + uri, err := url.Parse(a.endpoint) if err != nil { - return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } - _, offset := time.Now().UTC().Local().Zone() - tzo := -offset / 3600 * 60 - gdpr, consent, err := getGDPR(&ortbRequest) if err != nil { - return "", []error{fmt.Errorf("failed to parse yieldlab endpoint: %v", err)} + return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } + _, offset := a.tzo.Now().UTC().Local().Zone() + tzo := -offset / 3600 * 60 + q := uri.Query() if gdpr != "" && consent != "" { q.Set("gdpr", gdpr) @@ -102,47 +105,47 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, endpoint string) (string, q.Set("tzo", fmt.Sprint(tzo)) q.Set("format", "json") - url := endpoint + "?" + q.Encode() + url := a.endpoint + "?" + q.Encode() return url, nil } /* Generate the requests to Adnuntius to reduce the amount of requests going out. */ -func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, error) { +func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, []error) { var requestData []*adapters.RequestData + var errors []error networkAdunitMap := make(map[string][]adnAdunit) headers := setHeaders() - endpoint, err := makeEndpointUrl(ortbRequest, a.endpoint) + + endpoint, err := makeEndpointUrl(ortbRequest, a) if err != nil { - return nil, fmt.Errorf("failed to parse URL: %v", err) + errors = append(errors, fmt.Errorf("failed to parse URL: %v", err)) } for _, imp := range ortbRequest.Imp { if imp.Banner == nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, Adnuntius supports only Banner", imp.ID), - } + }) } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), - } + }) } var adnuntiusExt openrtb_ext.ImpExtAdnunitus if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { - return nil, &errortypes.BadInput{ + errors = append(errors, &errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), - } + }) } - var network string + network := "default" if adnuntiusExt.Network != "" { network = adnuntiusExt.Network - } else { - network = "default" } networkAdunitMap[network] = append( @@ -153,11 +156,9 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }) } - var site string + site := "unknown" if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { site = ortbRequest.Site.Page - } else { - site = "unknown" } for _, networkAdunits := range networkAdunitMap { @@ -177,9 +178,12 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters adnJson, err := json.Marshal(adnuntiusRequest) if err != nil { - return nil, err + errors = append(errors, err) } + if len(errors) > 0 { + return nil, errors + } requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, Uri: endpoint, @@ -193,19 +197,10 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters } func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode == http.StatusNoContent { - return nil, nil - } if response.StatusCode == http.StatusBadRequest { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), - }} - } - - if response.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unknown status code: %d.", response.StatusCode), + Message: fmt.Sprintf("Status code: %d, Request malformed", response.StatusCode), }} } @@ -227,7 +222,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { var extRegs openrtb_ext.ExtRegs if request.Regs != nil { if err := json.Unmarshal(request.Regs.Ext, &extRegs); err != nil { - return "", "", fmt.Errorf("failed to parse ExtRegs in Yieldlab GDPR check: %v", err) + return "", "", fmt.Errorf("failed to parse ExtRegs in Adnuntius GDPR check: %v", err) } if extRegs.GDPR != nil && (*extRegs.GDPR == 0 || *extRegs.GDPR == 1) { gdpr = strconv.Itoa(int(*extRegs.GDPR)) @@ -238,7 +233,7 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { if request.User != nil && request.User.Ext != nil { var extUser openrtb_ext.ExtUser if err := json.Unmarshal(request.User.Ext, &extUser); err != nil { - return "", "", fmt.Errorf("failed to parse ExtUser in Yieldlab GDPR check: %v", err) + return "", "", fmt.Errorf("failed to parse ExtUser in Adnuntius GDPR check: %v", err) } consent = extUser.Consent } @@ -248,24 +243,25 @@ func getGDPR(request *openrtb2.BidRequest) (string, string, error) { func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) (*adapters.BidderResponse, []error) { bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(adnResponse.AdUnits)) - currency := bidResponse.Currency + var currency string for i, adunit := range adnResponse.AdUnits { var bid openrtb2.Bid if len(adunit.Ads) > 0 { + var adsErr []error ad := adunit.Ads[0] currency = ad.Bid.Currency creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) if Werr != nil { - return nil, []error{Werr} + adsErr = append(adsErr, Werr) } creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) if Herr != nil { - return nil, []error{Herr} + adsErr = append(adsErr, Herr) } adDomain := []string{} @@ -275,6 +271,10 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) adDomain = append(adDomain, domain) } + if len(adsErr) > 0 { + return nil, adsErr + } + bid = openrtb2.Bid{ ID: ad.AdId, ImpID: request.Imp[i].ID, diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go index 0f575a7141a..2734bc0cf27 100644 --- a/adapters/adnuntius/adnuntius_test.go +++ b/adapters/adnuntius/adnuntius_test.go @@ -2,10 +2,13 @@ package adnuntius import ( "testing" + "time" + "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" ) func TestJsonSamples(t *testing.T) { @@ -15,6 +18,18 @@ func TestJsonSamples(t *testing.T) { if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) } + assertTzo(t, bidder) + replaceTzoWithKnownTime(bidder) adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder) } + +func assertTzo(t *testing.T, bidder adapters.Bidder) { + bidderAdnuntius, _ := bidder.(*adapter) + assert.NotNil(t, bidderAdnuntius.tzo) +} + +func replaceTzoWithKnownTime(bidder adapters.Bidder) { + bidderAdnuntius, _ := bidder.(*adapter) + bidderAdnuntius.tzo = knownTzo(time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC)) +} diff --git a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json index f98028cf79f..6e943810aa9 100644 --- a/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json +++ b/adapters/adnuntius/adnuntiustest/exemplary/simple-banner.json @@ -1,6 +1,9 @@ { "mockBidRequest": { "id": "test-request-id", + "site": { + "page": "prebid.org" + }, "imp": [ { "id": "test-imp-id", @@ -36,7 +39,7 @@ "targetId": "123-test-imp-id" } ], - "context": "unknown", + "context": "prebid.org", "metaData": {} } }, @@ -45,82 +48,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -143,7 +92,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json index 807b115d3d1..e195429cef9 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-gdpr.json @@ -58,82 +58,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -156,7 +102,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json index fead83afe86..8305bcdb59a 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/check-userId.json @@ -50,82 +50,28 @@ "body": { "adUnits": [ { - "auId": "000000000001789f", - "targetId": "1789f-some1111", + "auId": "0000000000000123", + "targetId": "123-test-imp-id", "html": "", - "matchedAdCount": 1, "responseId": "adn-rsp-900646517", "ads": [ { - "destinationUrlEsc": "", - "assets": { - "Image": { - "cdnId": "https://assets.adnuntius.com/PwdmnbBpj7Hgd4wdbxDpvLFRyxFgojt5DIDFAfK9rrc.jpg", - "width": "660", - "height": "200" - } - }, - "text": {}, - "choices": {}, - "clickUrl": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "urls": { - "url": "https://ads.adnuntius.delivery/c/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G?ct=2587&r=http%3A%2F%2Fwww.google.com" - }, - "urlsEsc": { - "url": "https%3A%2F%2Fads.adnuntius.delivery%2Fc%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G%3Fct%3D2587%26r%3Dhttp%253A%252F%252Fwww.google.com" - }, "destinationUrls": { "url": "http://www.google.com" }, - "cpm": { - "amount": 20000.0, - "currency": "NOK" - }, "bid": { "amount": 20.0, "currency": "NOK" }, - "cost": { - "amount": 20.0, - "currency": "NOK" - }, - "impressionTrackingUrls": [], - "impressionTrackingUrlsEsc": [], "adId": "adn-id-1559784094", - "selectedColumn": "0", - "selectedColumnPosition": "0", - "renderedPixel": "https://ads.adnuntius.delivery/b/n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "renderedPixelEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fb%2Fn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G.html", - "visibleUrl": "https://ads.adnuntius.delivery/s?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "visibleUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fs%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrl": "https://ads.adnuntius.delivery/v?rt=n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "viewUrlEsc": "https%3A%2F%2Fads.adnuntius.delivery%2Fv%3Frt%3Dn6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", - "rt": "n6xZq-VhchUD8PbfezltPoCESuAfspN-w0wjkkwzHXsAAAAQCtjQz9kbGWD4nuZy3q6HaHGLVNv__f6bBEfVP76Mfd6iokhXOQf7XpiOka60HChCnQjfT3AAqAO1swCIxQR73xnw2Okk_huqOKANzHxOy9gOZB8wEKOW8bs-Po5kTzB8U8UaB4BF9d48j6zHV7ST6-6cRBhpWFyKZUaUDEgmwKXM8xlQC-OJY7F9UJ0rN8OZQis1rnmeXrbik9VvxuV8Owsd_I9ZMS4G", "creativeWidth": "980", "creativeHeight": "240", "creativeId": "jn9hpzvlsf8cpdmm", - "lineItemId": "q7y9qm5b0xt9htrv", - "layoutId": "adnuntius_image_layout_1", - "layoutName": "Image", - "layoutExternalReference": "", - "renderTemplate": "", - "html": "" + "lineItemId": "q7y9qm5b0xt9htrv" } ] } - ], - "metaData": { - "r": "0AAAAAQAA", - "s": "0AAAAAQAA", - "c": "0AAAAAQAA", - "v": "0AAAAAQAA", - "i": "0AAAAAQAA", - "usi": "1kjh3429kjh295jkl", - "sessionId": "328ebda9ca77c2e0d29317be1ef4336c" - }, - "duplicateFilter": "AAAAAAAAAAA=", - "segments": [], - "keywords": [] + ] } } } @@ -148,7 +94,8 @@ }, "type": "banner" } - ] + ], + "currency": "NOK" } ] } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json new file mode 100644 index 00000000000..64ff199af2e --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "context": "prebid.org", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": "980", + "creativeHeight": 240, + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field .AdUnits.Ads.CreativeHeight of type string", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/status-400.json b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json new file mode 100644 index 00000000000..c6da39dadd5 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/status-400.json @@ -0,0 +1,54 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auI": "1" + } + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "", + "targetId": "-test-imp-id" + } + ], + "context": "unknown", + "metaData": {} + } + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Status code: 400, Request malformed", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json b/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json new file mode 100644 index 00000000000..727cf19498f --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/test-networks.json @@ -0,0 +1,97 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-network", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123", + "network": "test" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-network" + } + ], + "context": "unknown", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": "980", + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "adn-id-1559784094", + "impid": "test-network", + "price": 20000, + "adm": "", + "adid": "adn-id-1559784094", + "adomain": ["google.com"], + "cid": "q7y9qm5b0xt9htrv", + "crid": "jn9hpzvlsf8cpdmm", + "w": 980, + "h": 240 + }, + "type": "banner" + } + ], + "currency": "NOK" + } + ] +} diff --git a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json new file mode 100644 index 00000000000..4a90ab2fb48 --- /dev/null +++ b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json @@ -0,0 +1,84 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "auId": "123" + } + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://whatever.url?format=json&tzo=0", + "body": { + "adUnits": [ + { + "auId": "123", + "targetId": "123-test-imp-id" + } + ], + "context": "prebid.org", + "metaData": {} + } + }, + "mockResponse": { + "status": 200, + "body": { + "adUnits": [ + { + "auId": "0000000000000123", + "targetId": "123-test-imp-id", + "html": "", + "responseId": "adn-rsp-900646517", + "ads": [ + { + "destinationUrls": { + "url": "http://www.google.com" + }, + "bid": { + "amount": 20.0, + "currency": "NOK" + }, + "adId": "adn-id-1559784094", + "creativeWidth": 980, + "creativeHeight": "240", + "creativeId": "jn9hpzvlsf8cpdmm", + "lineItemId": "q7y9qm5b0xt9htrv" + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal number into Go struct field .AdUnits.Ads.CreativeWidth of type string", + "comparison": "literal" + } + ] +} diff --git a/adapters/adnuntius/params_test.go b/adapters/adnuntius/params_test.go index d096376c881..dd8fafc79a9 100644 --- a/adapters/adnuntius/params_test.go +++ b/adapters/adnuntius/params_test.go @@ -40,6 +40,7 @@ func TestInvalidParams(t *testing.T) { var validParams = []string{ `{"auId":"123"}`, + `{"auId":"123", "network":"test"}`, } var invalidParams = []string{ @@ -50,8 +51,10 @@ var invalidParams = []string{ `4.2`, `[]`, `{}`, - `{"aid":"123"}`, - `{"aid":"0"}`, - `{"aid":"123","placementId":"123"}`, - `{"aid":123, "placementId":"123", "siteId":"321"}`, + `{"auId":123}`, + `{"auID":"123"}`, + `{"network":123}`, + `{"network":123, "auID":123}`, + `{"network":"test", "auID":123}`, + `{"network":test, "auID":"123"}`, } diff --git a/adapters/adnuntius/timezone.go b/adapters/adnuntius/timezone.go new file mode 100644 index 00000000000..5e469b37079 --- /dev/null +++ b/adapters/adnuntius/timezone.go @@ -0,0 +1,23 @@ +package adnuntius + +import ( + "time" +) + +type timezone interface { + Now() time.Time +} + +// Send a real instance when you construct it in adapter_map.go +type realTzo struct{} + +func (_ realTzo) Now() time.Time { + return time.Now() +} + +// Use this for tests e.g. knownTzo(time.Date(y, m, ..., time.UTC)) +type knownTzo time.Time + +func (i knownTzo) Now() time.Time { + return time.Time(i) +} diff --git a/static/bidder-info/adnuntius.yaml b/static/bidder-info/adnuntius.yaml index fe135164bd2..2fc52490716 100644 --- a/static/bidder-info/adnuntius.yaml +++ b/static/bidder-info/adnuntius.yaml @@ -1,9 +1,10 @@ maintainer: - email: hello@adnuintius.com + email: hello@adnuntius.com +gvlVendorID: 855 capabilities: - app: - mediaTypes: - - banner - site: - mediaTypes: - - banner \ No newline at end of file + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner From 6c5fe815d3c099bfdbe0b100118e1395483adfef Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 14 Oct 2021 13:39:58 +0000 Subject: [PATCH 15/21] Changes made in response to comments in pull request. --- adapters/adnuntius/adnuntius.go | 36 ++++++++++--------- adapters/adnuntius/adnuntius_test.go | 19 +++++++--- .../supplemental/height-error.json | 2 +- .../supplemental/width-error.json | 2 +- adapters/adnuntius/timezone.go | 23 ------------ static/bidder-info/adnuntius.yaml | 14 ++++---- 6 files changed, 43 insertions(+), 53 deletions(-) delete mode 100644 adapters/adnuntius/timezone.go diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 47bab06f622..6851edeb0c4 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -13,11 +13,12 @@ import ( "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/timeutil" ) type QueryString map[string]string type adapter struct { - tzo timezone + time timeutil.Time endpoint string } type adnAdunit struct { @@ -58,7 +59,7 @@ type adnRequest struct { // Builder builds a new instance of the Adnuntius adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &adapter{ - tzo: realTzo{}, + time: &timeutil.RealTime{}, endpoint: config.Endpoint, } @@ -94,8 +95,9 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []err return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } - _, offset := a.tzo.Now().UTC().Local().Zone() - tzo := -offset / 3600 * 60 + const minutesInHour = 60 + _, offset := a.time.Now().Zone() + tzo := -offset / minutesInHour q := uri.Query() if gdpr != "" && consent != "" { @@ -125,22 +127,22 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters for _, imp := range ortbRequest.Imp { if imp.Banner == nil { - errors = append(errors, &errortypes.BadInput{ + return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("ignoring imp id=%s, Adnuntius supports only Banner", imp.ID), - }) + }} } var bidderExt adapters.ExtImpBidder if err := json.Unmarshal(imp.Ext, &bidderExt); err != nil { - errors = append(errors, &errortypes.BadInput{ + return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBidder: %s", err.Error()), - }) + }} } var adnuntiusExt openrtb_ext.ImpExtAdnunitus if err := json.Unmarshal(bidderExt.Bidder, &adnuntiusExt); err != nil { - errors = append(errors, &errortypes.BadInput{ + return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Error unmarshalling ExtImpBmtm: %s", err.Error()), - }) + }} } network := "default" @@ -198,7 +200,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode == http.StatusBadRequest { + if response.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Status code: %d, Request malformed", response.StatusCode), }} @@ -254,14 +256,14 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) currency = ad.Bid.Currency - creativeWidth, Werr := strconv.ParseInt(ad.CreativeWidth, 10, 64) - if Werr != nil { - adsErr = append(adsErr, Werr) + creativeWidth, widthErr := strconv.ParseInt(ad.CreativeWidth, 10, 64) + if widthErr != nil { + adsErr = append(adsErr, widthErr) } - creativeHeight, Herr := strconv.ParseInt(ad.CreativeHeight, 10, 64) - if Herr != nil { - adsErr = append(adsErr, Herr) + creativeHeight, heightErr := strconv.ParseInt(ad.CreativeHeight, 10, 64) + if heightErr != nil { + adsErr = append(adsErr, heightErr) } adDomain := []string{} diff --git a/adapters/adnuntius/adnuntius_test.go b/adapters/adnuntius/adnuntius_test.go index 2734bc0cf27..270f27a9366 100644 --- a/adapters/adnuntius/adnuntius_test.go +++ b/adapters/adnuntius/adnuntius_test.go @@ -19,17 +19,28 @@ func TestJsonSamples(t *testing.T) { t.Fatalf("Builder returned unexpected error %v", buildErr) } assertTzo(t, bidder) - replaceTzoWithKnownTime(bidder) + replaceRealTimeWithKnownTime(bidder) adapterstest.RunJSONBidderTest(t, "adnuntiustest", bidder) } func assertTzo(t *testing.T, bidder adapters.Bidder) { bidderAdnuntius, _ := bidder.(*adapter) - assert.NotNil(t, bidderAdnuntius.tzo) + assert.NotNil(t, bidderAdnuntius.time) } -func replaceTzoWithKnownTime(bidder adapters.Bidder) { +// FakeTime implements the Time interface +type FakeTime struct { + time time.Time +} + +func (ft *FakeTime) Now() time.Time { + return ft.time +} + +func replaceRealTimeWithKnownTime(bidder adapters.Bidder) { bidderAdnuntius, _ := bidder.(*adapter) - bidderAdnuntius.tzo = knownTzo(time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC)) + bidderAdnuntius.time = &FakeTime{ + time: time.Date(2016, 1, 1, 12, 30, 15, 0, time.UTC), + } } diff --git a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json index 64ff199af2e..ba388f1deea 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/height-error.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/height-error.json @@ -62,7 +62,7 @@ "currency": "NOK" }, "adId": "adn-id-1559784094", - "creativeWidth": "980", + "creativeWidth": "abc", "creativeHeight": 240, "creativeId": "jn9hpzvlsf8cpdmm", "lineItemId": "q7y9qm5b0xt9htrv" diff --git a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json index 4a90ab2fb48..2659841197f 100644 --- a/adapters/adnuntius/adnuntiustest/supplemental/width-error.json +++ b/adapters/adnuntius/adnuntiustest/supplemental/width-error.json @@ -63,7 +63,7 @@ }, "adId": "adn-id-1559784094", "creativeWidth": 980, - "creativeHeight": "240", + "creativeHeight": "abc", "creativeId": "jn9hpzvlsf8cpdmm", "lineItemId": "q7y9qm5b0xt9htrv" } diff --git a/adapters/adnuntius/timezone.go b/adapters/adnuntius/timezone.go deleted file mode 100644 index 5e469b37079..00000000000 --- a/adapters/adnuntius/timezone.go +++ /dev/null @@ -1,23 +0,0 @@ -package adnuntius - -import ( - "time" -) - -type timezone interface { - Now() time.Time -} - -// Send a real instance when you construct it in adapter_map.go -type realTzo struct{} - -func (_ realTzo) Now() time.Time { - return time.Now() -} - -// Use this for tests e.g. knownTzo(time.Date(y, m, ..., time.UTC)) -type knownTzo time.Time - -func (i knownTzo) Now() time.Time { - return time.Time(i) -} diff --git a/static/bidder-info/adnuntius.yaml b/static/bidder-info/adnuntius.yaml index 2fc52490716..86a0192cd62 100644 --- a/static/bidder-info/adnuntius.yaml +++ b/static/bidder-info/adnuntius.yaml @@ -1,10 +1,10 @@ maintainer: - email: hello@adnuntius.com + email: hello@adnuntius.com gvlVendorID: 855 capabilities: - app: - mediaTypes: - - banner - site: - mediaTypes: - - banner + app: + mediaTypes: + - banner + site: + mediaTypes: + - banner From e4a5700f63c0dd871c5f5ecdd371f3c7333a81a1 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 14 Oct 2021 14:35:48 +0000 Subject: [PATCH 16/21] Adding constants. --- adapters/adnuntius/adnuntius.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 6851edeb0c4..5e6b5711af4 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -56,6 +56,12 @@ type adnRequest struct { Context string `json:"context,omitempty"` } + +const defaultNetwork = "default" +const defaultSite = "unknown" +const minutesInHour = 60 + + // Builder builds a new instance of the Adnuntius adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &adapter{ @@ -95,7 +101,7 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []err return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } - const minutesInHour = 60 + _, offset := a.time.Now().Zone() tzo := -offset / minutesInHour @@ -145,7 +151,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }} } - network := "default" + network := defaultNetwork if adnuntiusExt.Network != "" { network = adnuntiusExt.Network } @@ -158,7 +164,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters }) } - site := "unknown" + site := defaultSite if ortbRequest.Site != nil && ortbRequest.Site.Page != "" { site = ortbRequest.Site.Page } From 6f8ee162ded5a764b2f7b2b674f6d14fba4b98d1 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 14 Oct 2021 15:00:36 +0000 Subject: [PATCH 17/21] Validation issue fixed. --- adapters/adnuntius/adnuntius.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 5e6b5711af4..1e5e273f48c 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -56,12 +56,10 @@ type adnRequest struct { Context string `json:"context,omitempty"` } - const defaultNetwork = "default" const defaultSite = "unknown" const minutesInHour = 60 - // Builder builds a new instance of the Adnuntius adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { bidder := &adapter{ @@ -101,7 +99,6 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []err return "", []error{fmt.Errorf("failed to parse Adnuntius endpoint: %v", err)} } - _, offset := a.time.Now().Zone() tzo := -offset / minutesInHour From 2f3b0b75ec03b007b6d8fd560cc432325980f0fc Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 14 Oct 2021 16:47:03 +0000 Subject: [PATCH 18/21] Adding handling of 400 error, removing timezone file. --- adapters/adnuntius/adnuntius.go | 8 +++++++- adapters/adnuntius/timezone.go | 23 ----------------------- 2 files changed, 7 insertions(+), 24 deletions(-) delete mode 100644 adapters/adnuntius/timezone.go diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 1e5e273f48c..9dd5c6ab820 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -203,12 +203,18 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if response.StatusCode != http.StatusOK { + if response.StatusCode == http.StatusBadRequest { return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("Status code: %d, Request malformed", response.StatusCode), }} } + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Status code: %d, Something went wrong with your request", response.StatusCode), + }} + } + var adnResponse AdnResponse if err := json.Unmarshal(response.Body, &adnResponse); err != nil { return nil, []error{err} diff --git a/adapters/adnuntius/timezone.go b/adapters/adnuntius/timezone.go deleted file mode 100644 index 5e469b37079..00000000000 --- a/adapters/adnuntius/timezone.go +++ /dev/null @@ -1,23 +0,0 @@ -package adnuntius - -import ( - "time" -) - -type timezone interface { - Now() time.Time -} - -// Send a real instance when you construct it in adapter_map.go -type realTzo struct{} - -func (_ realTzo) Now() time.Time { - return time.Now() -} - -// Use this for tests e.g. knownTzo(time.Date(y, m, ..., time.UTC)) -type knownTzo time.Time - -func (i knownTzo) Now() time.Time { - return time.Time(i) -} From f1682e1d00dce4c19d225cdf499670842646e858 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Tue, 19 Oct 2021 16:01:24 +0200 Subject: [PATCH 19/21] Changed from errortypes.BadInput to errortypes.BadServerResponse. --- adapters/adnuntius/adnuntius.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 9dd5c6ab820..0224529e81f 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -210,7 +210,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, externalRequest *adapte } if response.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadInput{ + return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("Status code: %d, Something went wrong with your request", response.StatusCode), }} } From 1aedd364740ee69c96cef265abd134180fc7ece4 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Thu, 28 Oct 2021 10:55:06 +0000 Subject: [PATCH 20/21] Made changes based on comments --- adapters/adnuntius/adnuntius.go | 38 +++++++++++++-------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 0224529e81f..5257b9604c8 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -71,14 +71,7 @@ func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters } func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - var extRequests []*adapters.RequestData - var errs []error - - extRequests, err := a.generateRequests(*request) - if err != nil { - errs = append(errs, err...) - } - return extRequests, errs + return a.generateRequests(*request) } func setHeaders() http.Header { @@ -119,13 +112,14 @@ func makeEndpointUrl(ortbRequest openrtb2.BidRequest, a *adapter) (string, []err */ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters.RequestData, []error) { var requestData []*adapters.RequestData - var errors []error networkAdunitMap := make(map[string][]adnAdunit) headers := setHeaders() endpoint, err := makeEndpointUrl(ortbRequest, a) if err != nil { - errors = append(errors, fmt.Errorf("failed to parse URL: %v", err)) + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("failed to parse URL: %s", err), + }} } for _, imp := range ortbRequest.Imp { @@ -183,12 +177,11 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters adnJson, err := json.Marshal(adnuntiusRequest) if err != nil { - errors = append(errors, err) + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Error unmarshalling adnuntius request: %s", err.Error()), + }} } - if len(errors) > 0 { - return nil, errors - } requestData = append(requestData, &adapters.RequestData{ Method: http.MethodPost, Uri: endpoint, @@ -258,21 +251,24 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) for i, adunit := range adnResponse.AdUnits { - var bid openrtb2.Bid if len(adunit.Ads) > 0 { - var adsErr []error + ad := adunit.Ads[0] currency = ad.Bid.Currency creativeWidth, widthErr := strconv.ParseInt(ad.CreativeWidth, 10, 64) if widthErr != nil { - adsErr = append(adsErr, widthErr) + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Value of width: %s is not a string", ad.CreativeWidth), + }} } creativeHeight, heightErr := strconv.ParseInt(ad.CreativeHeight, 10, 64) if heightErr != nil { - adsErr = append(adsErr, heightErr) + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Value of height: %s is not a string", ad.CreativeHeight), + }} } adDomain := []string{} @@ -282,11 +278,7 @@ func generateBidResponse(adnResponse *AdnResponse, request *openrtb2.BidRequest) adDomain = append(adDomain, domain) } - if len(adsErr) > 0 { - return nil, adsErr - } - - bid = openrtb2.Bid{ + bid := openrtb2.Bid{ ID: ad.AdId, ImpID: request.Imp[i].ID, W: creativeWidth, From 5838ca34c712c09d78d56c00dd40a43796c9b086 Mon Sep 17 00:00:00 2001 From: Mikael Lundin Date: Fri, 29 Oct 2021 10:48:04 +0200 Subject: [PATCH 21/21] Changed error type to Bad input for url-parsing. --- adapters/adnuntius/adnuntius.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adapters/adnuntius/adnuntius.go b/adapters/adnuntius/adnuntius.go index 5257b9604c8..f556081ae70 100644 --- a/adapters/adnuntius/adnuntius.go +++ b/adapters/adnuntius/adnuntius.go @@ -117,7 +117,7 @@ func (a *adapter) generateRequests(ortbRequest openrtb2.BidRequest) ([]*adapters endpoint, err := makeEndpointUrl(ortbRequest, a) if err != nil { - return nil, []error{&errortypes.BadServerResponse{ + return nil, []error{&errortypes.BadInput{ Message: fmt.Sprintf("failed to parse URL: %s", err), }} }