From 98e1c1cbae32c984e0c3b790ee668f319fbd4d14 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 21 Feb 2020 09:59:43 -0800 Subject: [PATCH 01/26] TELARIA adapter. First Pass --- adapters/telaria/telaria.go | 186 ++++++++++++++++++ adapters/telaria/telaria_test.go | 31 +++ .../telariatest/params/race/video.json | 0 .../supplemental/simple-video.json | 0 adapters/telaria/usersync.go | 12 ++ adapters/telaria/usersync_test.go | 1 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_telaria.go | 1 + 8 files changed, 233 insertions(+) create mode 100644 adapters/telaria/telaria.go create mode 100644 adapters/telaria/telaria_test.go create mode 100644 adapters/telaria/telariatest/params/race/video.json create mode 100644 adapters/telaria/telariatest/supplemental/simple-video.json create mode 100644 adapters/telaria/usersync.go create mode 100644 adapters/telaria/usersync_test.go create mode 100644 openrtb_ext/imp_telaria.go diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go new file mode 100644 index 00000000000..be4e3d2a837 --- /dev/null +++ b/adapters/telaria/telaria.go @@ -0,0 +1,186 @@ +package telaria + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strconv" + "strings" + + "github.com/golang/glog" + "github.com/prebid/prebid-server/pbs" + + "golang.org/x/net/context/ctxhttp" + + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" +) + +const Endpoint = "fubarTodoChange" + +type TelariaAdapter struct { + URI string +} + +// used for cookies and such +func (a *TelariaAdapter) Name() string { + return "telaria" +} + +func (a *TelariaAdapter) SkipNoCookies() bool { + return false +} + +func (a *TelariaAdapter) fetchEndpoint(adCode string) (string, error) { + if adCode == "" { + return "", &errortypes.BadInput{Message: "Invalid ad Code" } + } + + return a.URI + "?adCode=" + adCode, nil +} + +func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + request := *requestIn + errs := make([]error, 0, len(request.Imp)) + if len(request.Imp) == 0 { + err := &errortypes.BadInput{ + Message: "No imp object in the bid request", + } + errs = append(errs, err) + return nil, errs + } + + errors := make([]error, 0, 1) + + var bidderExt adapters.ExtImpBidder + err := json.Unmarshal(request.Imp[0].Ext, &bidderExt) + + if err != nil { + err = &errortypes.BadInput{ + Message: "ext.bidder not provided", + } + errors = append(errors, err) + return nil, errors + } + + var telariaExt openrtb_ext.ExtImpTelaria + err = json.Unmarshal(bidderExt.Bidder, &telariaExt) + if err != nil { + err = &errortypes.BadInput{ + Message: "ext.bidder.adCode not provided", + } + errors = append(errors, err) + return nil, errors + } + if telariaExt.AdCode == "" { + err = &errortypes.BadInput{ + Message: "adCode is empty", + } + errors = append(errors, err) + return nil, errors + } + validImpExists := false + for i := 0; i < len(request.Imp); i++ { + validImpExists = request.Imp[i].Video != nil + } + if !validImpExists { + err := &errortypes.BadInput{ + Message: fmt.Sprintf("No valid impression in the bid request"), + } + errs = append(errs, err) + return nil, errs + } + + reqJSON, err := json.Marshal(request) + if err != nil { + errs = append(errs, err) + return nil, errs + } + + thisURI, err := a.fetchEndpoint(telariaExt.AdCode) + if err != nil { + errs = append(errs, err) + return nil, errs + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + headers.Add("x-openrtb-version", "2.5") + + if request.Device != nil { + if len(request.Device.UA) > 0 { + headers.Add("User-Agent", request.Device.UA) + } + + if len(request.Device.IP) > 0 { + headers.Add("x-Forwarded-For", request.Device.IP) + } + + if len(request.Device.Language) > 0 { + headers.Add("Accept-Language", request.Device.Language) + } + + if request.Device.DNT != nil { + headers.Add("DNT", strconv.Itoa(int(*request.Device.DNT))) + } + } + + return []*adapters.RequestData{{ + Method: "POST", + Uri: thisURI, + Body: reqJSON, + Headers: headers, + }}, errors +} + +func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.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("Unexpected status code: %d. ", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), + }} + } + + var bidResp openrtb.BidResponse + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("bad server response: %d. ", err), + }} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.SeatBid[0].Bid)) + sb := bidResp.SeatBid[0] + + for i := 0; i < len(sb.Bid); i++ { + bid := sb.Bid[i] + + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &bid, + BidType: openrtb_ext.BidTypeVideo, + }) + } + + return bidResponse, nil +} + +func NewTelariaBidder() *TelariaAdapter { + return &TelariaAdapter{ + URI: Endpoint, + } +} diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go new file mode 100644 index 00000000000..7923eafe919 --- /dev/null +++ b/adapters/telaria/telaria_test.go @@ -0,0 +1,31 @@ +package telaria + +import ( + "github.com/prebid/prebid-server/adapters/adapterstest" + "testing" +) + +/** + * Verify adapter names are setup correctly. + */ +func TestTelariaAdapterNames(t *testing.T) { + adapter := NewTelariaBidder() + adapterstest.VerifyStringValue(adapter.Name(), "telaria", t) +} + +/** + * Verify adapter SkipNoCookie is correct. + */ +func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { + adapter := NewTelariaBidder() + adapterstest.VerifyBoolValue(adapter.SkipNoCookies(), false, t) +} + +/** + * Verify bidder has the proper URL + */ +func TestTelariaAdapterEndpoint(t *testing.T) { + adapter := NewTelariaBidder() + adapterstest.VerifyStringValue(adapter.URI, "fubarTodoChange", t) +} + diff --git a/adapters/telaria/telariatest/params/race/video.json b/adapters/telaria/telariatest/params/race/video.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/adapters/telaria/telariatest/supplemental/simple-video.json b/adapters/telaria/telariatest/supplemental/simple-video.json new file mode 100644 index 00000000000..e69de29bb2d diff --git a/adapters/telaria/usersync.go b/adapters/telaria/usersync.go new file mode 100644 index 00000000000..e3f76f6e9b4 --- /dev/null +++ b/adapters/telaria/usersync.go @@ -0,0 +1,12 @@ +package telaria + +import ( + "text/template" + + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/usersync" +) + +func NewTelariaSyncer(temp *template.Template) usersync.Usersyncer { + return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeRedirect) +} diff --git a/adapters/telaria/usersync_test.go b/adapters/telaria/usersync_test.go new file mode 100644 index 00000000000..e4689ebb42c --- /dev/null +++ b/adapters/telaria/usersync_test.go @@ -0,0 +1 @@ +package telaria diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 7a3f24eb07f..0ed88e90a31 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -64,6 +64,7 @@ const ( BidderSovrn BidderName = "sovrn" BidderSynacormedia BidderName = "synacormedia" BidderTappx BidderName = "tappx" + BidderTelaria BidderName = "telaria" BidderTriplelift BidderName = "triplelift" BidderTripleliftNative BidderName = "triplelift_native" BidderUnruly BidderName = "unruly" @@ -119,6 +120,7 @@ var BidderMap = map[string]BidderName{ "sovrn": BidderSovrn, "synacormedia": BidderSynacormedia, "tappx": BidderTappx, + "telaria": BidderTelaria, "triplelift": BidderTriplelift, "triplelift_native": BidderTripleliftNative, "unruly": BidderUnruly, diff --git a/openrtb_ext/imp_telaria.go b/openrtb_ext/imp_telaria.go new file mode 100644 index 00000000000..113e73b3820 --- /dev/null +++ b/openrtb_ext/imp_telaria.go @@ -0,0 +1 @@ +package openrtb_ext From eced74d169ca213dd33fecf8d71bc43ab933f680 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 21 Feb 2020 15:58:37 -0800 Subject: [PATCH 02/26] Some refactoring --- adapters/telaria/telaria.go | 87 +++++++++++++++---------------- adapters/telaria/telaria_test.go | 3 ++ adapters/telaria/usersync_test.go | 6 +++ openrtb_ext/imp_telaria.go | 4 ++ 4 files changed, 54 insertions(+), 46 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index be4e3d2a837..b80a02209f0 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -1,25 +1,14 @@ package telaria import ( - "bytes" - "context" "encoding/json" "fmt" - "io/ioutil" - "net/http" - "net/url" - "strconv" - "strings" - - "github.com/golang/glog" - "github.com/prebid/prebid-server/pbs" - - "golang.org/x/net/context/ctxhttp" - "github.com/mxmCherry/openrtb" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" + "net/http" + "strconv" ) const Endpoint = "fubarTodoChange" @@ -37,7 +26,7 @@ func (a *TelariaAdapter) SkipNoCookies() bool { return false } -func (a *TelariaAdapter) fetchEndpoint(adCode string) (string, error) { +func (a *TelariaAdapter) FetchEndpoint(adCode string) (string, error) { if adCode == "" { return "", &errortypes.BadInput{Message: "Invalid ad Code" } } @@ -45,6 +34,33 @@ func (a *TelariaAdapter) fetchEndpoint(adCode string) (string, error) { return a.URI + "?adCode=" + adCode, nil } +func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + headers.Add("Accept", "application/json") + headers.Add("x-openrtb-version", "2.5") + + if request.Device != nil { + if len(request.Device.UA) > 0 { + headers.Add("User-Agent", request.Device.UA) + } + + if len(request.Device.IP) > 0 { + headers.Add("x-Forwarded-For", request.Device.IP) + } + + if len(request.Device.Language) > 0 { + headers.Add("Accept-Language", request.Device.Language) + } + + if request.Device.DNT != nil { + headers.Add("DNT", strconv.Itoa(int(*request.Device.DNT))) + } + } + + return headers +} + func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { request := *requestIn errs := make([]error, 0, len(request.Imp)) @@ -78,6 +94,7 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad errors = append(errors, err) return nil, errors } + if telariaExt.AdCode == "" { err = &errortypes.BadInput{ Message: "adCode is empty", @@ -87,56 +104,34 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad } validImpExists := false for i := 0; i < len(request.Imp); i++ { - validImpExists = request.Imp[i].Video != nil + validImpExists = validImpExists || request.Imp[i].Video != nil } + if !validImpExists { err := &errortypes.BadInput{ Message: fmt.Sprintf("No valid impression in the bid request"), } - errs = append(errs, err) - return nil, errs + errors = append(errors, err) + return nil, errors } reqJSON, err := json.Marshal(request) if err != nil { - errs = append(errs, err) - return nil, errs + errors = append(errors, err) + return nil, errors } - thisURI, err := a.fetchEndpoint(telariaExt.AdCode) + thisURI, err := a.FetchEndpoint(telariaExt.AdCode) if err != nil { - errs = append(errs, err) - return nil, errs - } - - headers := http.Header{} - headers.Add("Content-Type", "application/json;charset=utf-8") - headers.Add("Accept", "application/json") - headers.Add("x-openrtb-version", "2.5") - - if request.Device != nil { - if len(request.Device.UA) > 0 { - headers.Add("User-Agent", request.Device.UA) - } - - if len(request.Device.IP) > 0 { - headers.Add("x-Forwarded-For", request.Device.IP) - } - - if len(request.Device.Language) > 0 { - headers.Add("Accept-Language", request.Device.Language) - } - - if request.Device.DNT != nil { - headers.Add("DNT", strconv.Itoa(int(*request.Device.DNT))) - } + errors = append(errors, err) + return nil, errors } return []*adapters.RequestData{{ Method: "POST", Uri: thisURI, Body: reqJSON, - Headers: headers, + Headers: a.GetHeaders(request), }}, errors } diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index 7923eafe919..7edeeedafbe 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -29,3 +29,6 @@ func TestTelariaAdapterEndpoint(t *testing.T) { adapterstest.VerifyStringValue(adapter.URI, "fubarTodoChange", t) } +func testJsonSamples(t *testing.T) { + adapterstest.RunJSONBidderTest(t, "telariatest", new(TelariaAdapter)) +} diff --git a/adapters/telaria/usersync_test.go b/adapters/telaria/usersync_test.go index e4689ebb42c..16fa3cf201c 100644 --- a/adapters/telaria/usersync_test.go +++ b/adapters/telaria/usersync_test.go @@ -1 +1,7 @@ package telaria + +import "testing" + +func TestTelariaSyncer(t *testing.T) { + +} diff --git a/openrtb_ext/imp_telaria.go b/openrtb_ext/imp_telaria.go index 113e73b3820..071283b651d 100644 --- a/openrtb_ext/imp_telaria.go +++ b/openrtb_ext/imp_telaria.go @@ -1 +1,5 @@ package openrtb_ext + +type ExtImpTelaria struct { + AdCode string `json:"adCode"` +} From bd482afa395c94691c1d8de60a573c90c4002204 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 24 Feb 2020 15:26:21 -0800 Subject: [PATCH 03/26] added the json files --- adapters/telaria/telaria.go | 39 +++++++++---------- .../telaria/telariatest/exemplary/video.json | 29 ++++++++++++++ .../telariatest/params/race/video.json | 3 ++ .../supplemental/required-ad-code.json | 29 ++++++++++++++ .../supplemental/simple-video.json | 0 static/bidder-params/telaria.json | 15 +++++++ 6 files changed, 95 insertions(+), 20 deletions(-) create mode 100644 adapters/telaria/telariatest/exemplary/video.json create mode 100644 adapters/telaria/telariatest/supplemental/required-ad-code.json delete mode 100644 adapters/telaria/telariatest/supplemental/simple-video.json create mode 100644 static/bidder-params/telaria.json diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index b80a02209f0..da0c3257801 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -17,6 +17,10 @@ type TelariaAdapter struct { URI string } +type TagIDExt struct { + OriginalTagID string `json:"originalTagid"` +} + // used for cookies and such func (a *TelariaAdapter) Name() string { return "telaria" @@ -26,12 +30,8 @@ func (a *TelariaAdapter) SkipNoCookies() bool { return false } -func (a *TelariaAdapter) FetchEndpoint(adCode string) (string, error) { - if adCode == "" { - return "", &errortypes.BadInput{Message: "Invalid ad Code" } - } - - return a.URI + "?adCode=" + adCode, nil +func (a *TelariaAdapter) FetchEndpoint() string { + return a.URI } func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { @@ -39,6 +39,7 @@ func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") headers.Add("x-openrtb-version", "2.5") + headers.Add("Accept-Encoding", "gzip") if request.Device != nil { if len(request.Device.UA) > 0 { @@ -103,8 +104,15 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad return nil, errors } validImpExists := false - for i := 0; i < len(request.Imp); i++ { - validImpExists = validImpExists || request.Imp[i].Video != nil + + for i, imp := range request.Imp { + validImpExists = validImpExists || imp.Video != nil + var impExt = &TagIDExt{request.Imp[i].TagID} + request.Imp[i].TagID = telariaExt.AdCode + if impExt.OriginalTagID != "" { + request.Imp[i].Ext, _ = json.Marshal(impExt) + } + } if !validImpExists { @@ -121,17 +129,11 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad return nil, errors } - thisURI, err := a.FetchEndpoint(telariaExt.AdCode) - if err != nil { - errors = append(errors, err) - return nil, errors - } - return []*adapters.RequestData{{ Method: "POST", - Uri: thisURI, + Uri: a.FetchEndpoint(), Body: reqJSON, - Headers: a.GetHeaders(request), + Headers: a.GetHeaders(&request), }}, errors } @@ -162,15 +164,12 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.SeatBid[0].Bid)) sb := bidResp.SeatBid[0] - for i := 0; i < len(sb.Bid); i++ { - bid := sb.Bid[i] - + for _, bid := range sb.Bid { bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bid, BidType: openrtb_ext.BidTypeVideo, }) } - return bidResponse, nil } diff --git a/adapters/telaria/telariatest/exemplary/video.json b/adapters/telaria/telariatest/exemplary/video.json new file mode 100644 index 00000000000..c36a353f3e3 --- /dev/null +++ b/adapters/telaria/telariatest/exemplary/video.json @@ -0,0 +1,29 @@ + +{ + "description": "This uses Telaria to fetch the sample ad", + + "requestPayload": { + "id": "some-request-id", + "site": { + "page": "test.com" + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + ] + } +} diff --git a/adapters/telaria/telariatest/params/race/video.json b/adapters/telaria/telariatest/params/race/video.json index e69de29bb2d..87a4fef3c95 100644 --- a/adapters/telaria/telariatest/params/race/video.json +++ b/adapters/telaria/telariatest/params/race/video.json @@ -0,0 +1,3 @@ +{ + "adCode": "ssp-!demo!-lufip" +} diff --git a/adapters/telaria/telariatest/supplemental/required-ad-code.json b/adapters/telaria/telariatest/supplemental/required-ad-code.json new file mode 100644 index 00000000000..78ce7868ea2 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/required-ad-code.json @@ -0,0 +1,29 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-1", + "video": { + "w": 640, + "h": 480, + "linearity": 1 + }, + "ext": { + "bidder": { + + } + } + } + ], + "site": { + "page": "test.com" + } + }, + "expectedMakeRequestsErrors": [ + { + "value": "imp[0].ext.bidder.telaria.adCode required", + "comparison": "literal" + } + ] +} diff --git a/adapters/telaria/telariatest/supplemental/simple-video.json b/adapters/telaria/telariatest/supplemental/simple-video.json deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/static/bidder-params/telaria.json b/static/bidder-params/telaria.json new file mode 100644 index 00000000000..f72fbdc458e --- /dev/null +++ b/static/bidder-params/telaria.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Telaria Adapter Params", + "description": "A schema which validates params accepted by the Telaria adapter", + + "type": "object", + "properties": { + "adCode": { + "type": "string", + "description": "The Ad Unit Code." + } + }, + + "required": ["adCode"] +} From 44d6bdc89943fec65354b24bed698f302796aa8c Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 24 Feb 2020 15:45:07 -0800 Subject: [PATCH 04/26] fixed some tests and added the bidder info --- adapters/telaria/telaria.go | 2 +- adapters/telaria/telaria_test.go | 6 +++--- config/config.go | 1 + exchange/adapter_map.go | 2 ++ openrtb_ext/bidders.go | 4 ++-- static/bidder-info/telaria.yaml | 9 +++++++++ 6 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 static/bidder-info/telaria.yaml diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index da0c3257801..f66a2c1f272 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -173,7 +173,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR return bidResponse, nil } -func NewTelariaBidder() *TelariaAdapter { +func NewTelariaBidder(endpoint string) *TelariaAdapter { return &TelariaAdapter{ URI: Endpoint, } diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index 7edeeedafbe..0a123e38549 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -9,7 +9,7 @@ import ( * Verify adapter names are setup correctly. */ func TestTelariaAdapterNames(t *testing.T) { - adapter := NewTelariaBidder() + adapter := NewTelariaBidder("https://{{.Host}}") adapterstest.VerifyStringValue(adapter.Name(), "telaria", t) } @@ -17,7 +17,7 @@ func TestTelariaAdapterNames(t *testing.T) { * Verify adapter SkipNoCookie is correct. */ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { - adapter := NewTelariaBidder() + adapter := NewTelariaBidder("https://{{.Host}}") adapterstest.VerifyBoolValue(adapter.SkipNoCookies(), false, t) } @@ -25,7 +25,7 @@ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { * Verify bidder has the proper URL */ func TestTelariaAdapterEndpoint(t *testing.T) { - adapter := NewTelariaBidder() + adapter := NewTelariaBidder("https://{{.Host}}") adapterstest.VerifyStringValue(adapter.URI, "fubarTodoChange", t) } diff --git a/config/config.go b/config/config.go index 943d18a95de..3cb18dddbfa 100644 --- a/config/config.go +++ b/config/config.go @@ -713,6 +713,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.sovrn.endpoint", "http://ap.lijit.com/rtb/bid?src=prebid_server") v.SetDefault("adapters.synacormedia.endpoint", "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}") v.SetDefault("adapters.tappx.endpoint", "https://{{.Host}}") + v.SetDefault("adapters.telaria.endpoint", "https://{{.Host}}") v.SetDefault("adapters.triplelift_native.disabled", true) v.SetDefault("adapters.triplelift_native.extra_info", "{\"publisher_whitelist\":[]}") v.SetDefault("adapters.triplelift.endpoint", "https://tlx.3lift.com/s2s/auction?supplier_id=20") diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 95f5b7f5882..72e5bba9e7a 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -2,6 +2,7 @@ package exchange import ( "fmt" + "github.com/prebid/prebid-server/adapters/telaria" "net/http" "strings" @@ -117,6 +118,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderSovrn: sovrn.NewSovrnBidder(client, cfg.Adapters[string(openrtb_ext.BidderSovrn)].Endpoint), openrtb_ext.BidderSynacormedia: synacormedia.NewSynacorMediaBidder(cfg.Adapters[string(openrtb_ext.BidderSynacormedia)].Endpoint), openrtb_ext.BidderTappx: tappx.NewTappxBidder(client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTappx))].Endpoint), + openrtb_ext.BidderTelaria: telaria.NewTelariaBidder(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderTelaria))].Endpoint), openrtb_ext.BidderTriplelift: triplelift.NewTripleliftBidder(client, cfg.Adapters[string(openrtb_ext.BidderTriplelift)].Endpoint), openrtb_ext.BidderTripleliftNative: triplelift_native.NewTripleliftNativeBidder(client, cfg.Adapters[string(openrtb_ext.BidderTripleliftNative)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderTripleliftNative)].ExtraAdapterInfo), openrtb_ext.BidderUnruly: unruly.NewUnrulyBidder(client, cfg.Adapters[string(openrtb_ext.BidderUnruly)].Endpoint), diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index 0ed88e90a31..2a49f152ad1 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -64,7 +64,7 @@ const ( BidderSovrn BidderName = "sovrn" BidderSynacormedia BidderName = "synacormedia" BidderTappx BidderName = "tappx" - BidderTelaria BidderName = "telaria" + BidderTelaria BidderName = "telaria" BidderTriplelift BidderName = "triplelift" BidderTripleliftNative BidderName = "triplelift_native" BidderUnruly BidderName = "unruly" @@ -120,7 +120,7 @@ var BidderMap = map[string]BidderName{ "sovrn": BidderSovrn, "synacormedia": BidderSynacormedia, "tappx": BidderTappx, - "telaria": BidderTelaria, + "telaria": BidderTelaria, "triplelift": BidderTriplelift, "triplelift_native": BidderTripleliftNative, "unruly": BidderUnruly, diff --git a/static/bidder-info/telaria.yaml b/static/bidder-info/telaria.yaml new file mode 100644 index 00000000000..43e8707a17b --- /dev/null +++ b/static/bidder-info/telaria.yaml @@ -0,0 +1,9 @@ +maintainer: + email: "github@telaria.com" +capabilities: + app: + mediaTypes: + - video + site: + mediaTypes: + - video From 854269c7e4a17da1fc1add535ecf01c85fa2e469 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Tue, 25 Feb 2020 16:18:18 -0800 Subject: [PATCH 05/26] fixed some tests and added the bidder info --- adapters/telaria/telaria.go | 4 ++-- adapters/telaria/telaria_test.go | 2 +- adapters/telaria/usersync.go | 2 +- usersync/usersyncers/syncer.go | 2 ++ usersync/usersyncers/syncer_test.go | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index f66a2c1f272..2a36c5a5c91 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -11,7 +11,7 @@ import ( "strconv" ) -const Endpoint = "fubarTodoChange" +const Endpoint = "https://ads.vhfp.net/ad/rtb/prebid" type TelariaAdapter struct { URI string @@ -39,7 +39,7 @@ func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") headers.Add("x-openrtb-version", "2.5") - headers.Add("Accept-Encoding", "gzip") + //headers.Add("Accept-Encoding", "gzip, deflate") if request.Device != nil { if len(request.Device.UA) > 0 { diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index 0a123e38549..17cd2b87705 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -26,7 +26,7 @@ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { */ func TestTelariaAdapterEndpoint(t *testing.T) { adapter := NewTelariaBidder("https://{{.Host}}") - adapterstest.VerifyStringValue(adapter.URI, "fubarTodoChange", t) + adapterstest.VerifyStringValue(adapter.URI, "https://ads.vhfp.net/ad/rtb/prebid", t) } func testJsonSamples(t *testing.T) { diff --git a/adapters/telaria/usersync.go b/adapters/telaria/usersync.go index e3f76f6e9b4..ebf35704f0a 100644 --- a/adapters/telaria/usersync.go +++ b/adapters/telaria/usersync.go @@ -8,5 +8,5 @@ import ( ) func NewTelariaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeRedirect) + return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeIframe) } diff --git a/usersync/usersyncers/syncer.go b/usersync/usersyncers/syncer.go index 5447cd28800..f14361ced58 100644 --- a/usersync/usersyncers/syncer.go +++ b/usersync/usersyncers/syncer.go @@ -1,6 +1,7 @@ package usersyncers import ( + "github.com/prebid/prebid-server/adapters/telaria" "strings" "text/template" @@ -104,6 +105,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync insertIntoMap(cfg, syncers, openrtb_ext.BidderSovrn, sovrn.NewSovrnSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderSmartRTB, smartrtb.NewSmartRTBSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderSynacormedia, synacormedia.NewSynacorMediaSyncer) + insertIntoMap(cfg, syncers, openrtb_ext.BidderTelaria, telaria.NewTelariaSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderTriplelift, triplelift.NewTripleliftSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderTripleliftNative, triplelift_native.NewTripleliftSyncer) insertIntoMap(cfg, syncers, openrtb_ext.BidderUnruly, unruly.NewUnrulySyncer) diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index ded8fd2bd78..ba138c25be5 100644 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -54,6 +54,7 @@ func TestNewSyncerMap(t *testing.T) { string(openrtb_ext.BidderSovrn): syncConfig, string(openrtb_ext.BidderSmartRTB): syncConfig, string(openrtb_ext.BidderSynacormedia): syncConfig, + string(openrtb_ext.BidderTelaria): syncConfig, string(openrtb_ext.BidderTriplelift): syncConfig, string(openrtb_ext.BidderTripleliftNative): syncConfig, string(openrtb_ext.BidderUnruly): syncConfig, From e76bbdec639cb1a6bc46d74ab4085be6ab0c401d Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 26 Feb 2020 10:44:27 -0800 Subject: [PATCH 06/26] added default user sync ur; --- adapters/telaria/usersync.go | 2 +- adapters/telaria/usersync_test.go | 28 +++++++++++++++++++++++++++- config/config.go | 1 + 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/adapters/telaria/usersync.go b/adapters/telaria/usersync.go index ebf35704f0a..e3f76f6e9b4 100644 --- a/adapters/telaria/usersync.go +++ b/adapters/telaria/usersync.go @@ -8,5 +8,5 @@ import ( ) func NewTelariaSyncer(temp *template.Template) usersync.Usersyncer { - return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeIframe) + return adapters.NewSyncer("telaria", 202, temp, adapters.SyncTypeRedirect) } diff --git a/adapters/telaria/usersync_test.go b/adapters/telaria/usersync_test.go index 16fa3cf201c..27c2ee6bc42 100644 --- a/adapters/telaria/usersync_test.go +++ b/adapters/telaria/usersync_test.go @@ -1,7 +1,33 @@ package telaria -import "testing" +import ( + "testing" + "text/template" + + "github.com/prebid/prebid-server/privacy" + "github.com/prebid/prebid-server/privacy/gdpr" + "github.com/stretchr/testify/assert" +) func TestTelariaSyncer(t *testing.T) { + syncURL := "http://partners.tremorhub.com/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURLTemplate := template.Must( + template.New("sync-template").Parse(syncURL), + ) + + syncer := NewTelariaSyncer(syncURLTemplate) + syncInfo, err := syncer.GetUsersyncInfo(privacy.Policies{ + GDPR: gdpr.Policy{ + Signal: "0", + }, + }) + + assert.NoError(t, err) + assert.Equal(t, "http://partners.tremorhub.com/unwrap?gdpr=0&gdpr_consent=", syncInfo.URL) + assert.Equal(t, "redirect", syncInfo.Type) + assert.EqualValues(t, 202, syncer.GDPRVendorID()) + assert.Equal(t, false, syncInfo.SupportCORS) + assert.Equal(t, "telaria", syncer.FamilyName()) + } diff --git a/config/config.go b/config/config.go index 3cb18dddbfa..722b36cd905 100644 --- a/config/config.go +++ b/config/config.go @@ -526,6 +526,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.vhfp.net/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUnruly, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") From e56007cbb5b81e990e1545f76ec16eae746660d7 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 26 Feb 2020 14:13:23 -0800 Subject: [PATCH 07/26] - Handling gzipped responses from our server --- adapters/telaria/telaria.go | 50 +++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 2a36c5a5c91..407f4677dc8 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -1,6 +1,8 @@ package telaria import ( + "bytes" + "compress/gzip" "encoding/json" "fmt" "github.com/mxmCherry/openrtb" @@ -34,12 +36,12 @@ func (a *TelariaAdapter) FetchEndpoint() string { return a.URI } -func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { +func GetHeaders(request *openrtb.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") headers.Add("x-openrtb-version", "2.5") - //headers.Add("Accept-Encoding", "gzip, deflate") + headers.Add("Accept-Encoding", "gzip") if request.Device != nil { if len(request.Device.UA) > 0 { @@ -59,7 +61,7 @@ func (a *TelariaAdapter) GetHeaders(request *openrtb.BidRequest) http.Header { } } - return headers + return &headers } func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { @@ -133,10 +135,36 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad Method: "POST", Uri: a.FetchEndpoint(), Body: reqJSON, - Headers: a.GetHeaders(&request), + Headers: *GetHeaders(&request), }}, errors } +// response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip +func GetResponseBody(response *adapters.ResponseData) (*[]byte, error) { + responseBody := response.Body + + if "gzip" == response.Headers.Get("Content-Encoding") { + body := bytes.NewBuffer(response.Body) + r, readerErr := gzip.NewReader(body) + if readerErr != nil { + return nil, &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode), + } + } + var resB bytes.Buffer + var err error + _, err = resB.ReadFrom(r) + if err != nil { + return nil, &errortypes.BadServerResponse{ + Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode), + } + } + responseBody = resB.Bytes() + } + + return &responseBody, nil +} + func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil @@ -144,20 +172,26 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR if response.StatusCode == http.StatusBadRequest { return nil, []error{&errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: %d. ", response.StatusCode), + Message: fmt.Sprintf("Unexpected status code: [ %d ] . ", response.StatusCode), }} } if response.StatusCode != http.StatusOK { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info", response.StatusCode), + Message: fmt.Sprintf("unexpected status code:[ %d ]. Run with request.debug = 1 for more info", response.StatusCode), }} } + responseBody, err := GetResponseBody(response) + + if err != nil { + return nil, []error{err} + } + var bidResp openrtb.BidResponse - if err := json.Unmarshal(response.Body, &bidResp); err != nil { + if err := json.Unmarshal(*responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("bad server response: %d. ", err), + Message: fmt.Sprintf("bad server response: [ %d ]. ", err), }} } From b4e3db4b061492d403485f80664445e0dad27f7b Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 26 Feb 2020 15:25:40 -0800 Subject: [PATCH 08/26] - more refactoring. --- adapters/telaria/telaria.go | 88 +++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 29 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 407f4677dc8..bc8e287ec7c 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -64,19 +64,17 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { return &headers } -func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { - request := *requestIn - errs := make([]error, 0, len(request.Imp)) +func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { if len(request.Imp) == 0 { err := &errortypes.BadInput{ Message: "No imp object in the bid request", } - errs = append(errs, err) - return nil, errs + return err } + return nil +} - errors := make([]error, 0, 1) - +func (a *TelariaAdapter) FetchBidderExt(request *openrtb.BidRequest) (*adapters.ExtImpBidder, error) { var bidderExt adapters.ExtImpBidder err := json.Unmarshal(request.Imp[0].Ext, &bidderExt) @@ -84,8 +82,17 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad err = &errortypes.BadInput{ Message: "ext.bidder not provided", } - errors = append(errors, err) - return nil, errors + + return nil, err + } + + return &bidderExt, nil +} + +func (a *TelariaAdapter) FetchTelariaParams(request *openrtb.BidRequest) (*openrtb_ext.ExtImpTelaria, error) { + bidderExt, err := a.FetchBidderExt(request) + if err != nil { + return nil, err } var telariaExt openrtb_ext.ExtImpTelaria @@ -94,49 +101,72 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad err = &errortypes.BadInput{ Message: "ext.bidder.adCode not provided", } - errors = append(errors, err) - return nil, errors + + return nil, err } if telariaExt.AdCode == "" { err = &errortypes.BadInput{ Message: "adCode is empty", } - errors = append(errors, err) - return nil, errors + + return nil, err } - validImpExists := false - for i, imp := range request.Imp { - validImpExists = validImpExists || imp.Video != nil - var impExt = &TagIDExt{request.Imp[i].TagID} - request.Imp[i].TagID = telariaExt.AdCode - if impExt.OriginalTagID != "" { - request.Imp[i].Ext, _ = json.Marshal(impExt) + return &telariaExt, nil +} + +func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error { + hasVideoObject := false + + for _, imp := range request.Imp { + hasVideoObject = hasVideoObject || imp.Video != nil + } + + if !hasVideoObject { + return &errortypes.BadInput{ + Message: "Telaria only supports Video", } + } + + return nil +} + +func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + if noImps := a.CheckHasImps(request); noImps != nil { + return nil, []error{noImps} } - if !validImpExists { - err := &errortypes.BadInput{ - Message: fmt.Sprintf("No valid impression in the bid request"), + if noVideoObject := a.CheckHasVideoObject(request); noVideoObject != nil { + return nil, []error{noVideoObject} + } + + telariaExt, err := a.FetchTelariaParams(request) + if err != nil { + return nil, []error{err} + } + + for i, _ := range request.Imp { + impExt := &TagIDExt{request.Imp[i].TagID} + request.Imp[i].TagID = telariaExt.AdCode + + if impExt.OriginalTagID != "" { + request.Imp[i].Ext, _ = json.Marshal(impExt) } - errors = append(errors, err) - return nil, errors } reqJSON, err := json.Marshal(request) if err != nil { - errors = append(errors, err) - return nil, errors + return nil, []error{err} } return []*adapters.RequestData{{ Method: "POST", Uri: a.FetchEndpoint(), Body: reqJSON, - Headers: *GetHeaders(&request), - }}, errors + Headers: *GetHeaders(request), + }}, nil } // response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip From 0427507ad11c1923b3ed4c63e321a304b77d28df Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 26 Feb 2020 18:26:36 -0800 Subject: [PATCH 09/26] added the proper user sync default URL --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 7442e2a8766..5ded88f1392 100644 --- a/config/config.go +++ b/config/config.go @@ -526,7 +526,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.vhfp.net/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.vhfp.net/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3DTVUSER_ID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUnruly, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") From 3d8ae591541cd0998ad0f0018de9d9ebbf4e44f6 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Thu, 27 Feb 2020 15:12:03 -0800 Subject: [PATCH 10/26] changed the urls from dev to prod --- adapters/telaria/telaria.go | 2 +- adapters/telaria/telaria_test.go | 2 +- config/config.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index bc8e287ec7c..efec930fffb 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -13,7 +13,7 @@ import ( "strconv" ) -const Endpoint = "https://ads.vhfp.net/ad/rtb/prebid" +const Endpoint = "https://ads.tremorhub.com/ad/rtb/prebid" type TelariaAdapter struct { URI string diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index 17cd2b87705..ba81a0a7351 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -26,7 +26,7 @@ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { */ func TestTelariaAdapterEndpoint(t *testing.T) { adapter := NewTelariaBidder("https://{{.Host}}") - adapterstest.VerifyStringValue(adapter.URI, "https://ads.vhfp.net/ad/rtb/prebid", t) + adapterstest.VerifyStringValue(adapter.URI, "https://ads.tremorhub.com/ad/rtb/prebid", t) } func testJsonSamples(t *testing.T) { diff --git a/config/config.go b/config/config.go index 5ded88f1392..d403cc01be4 100644 --- a/config/config.go +++ b/config/config.go @@ -526,7 +526,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.vhfp.net/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3DTVUSER_ID") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.tremorhub.com/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3DTVUSER_ID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUnruly, "https://usermatch.targeting.unrulymedia.com/pbsync?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dunruly%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") From 9320f4a5999116d93eb9e944409cb8346beea1d0 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 2 Mar 2020 16:27:55 -0800 Subject: [PATCH 11/26] changed up the required fields. Now AdCode in the Imp.Ext isn't required but Bid.SeatCode is required --- adapters/telaria/telaria.go | 201 +++++++++++++----- .../telaria/telariatest/exemplary/video.json | 8 +- .../telariatest/params/race/video.json | 3 +- ...d-ad-code.json => required-seat-code.json} | 2 +- openrtb_ext/imp_telaria.go | 2 +- 5 files changed, 158 insertions(+), 58 deletions(-) rename adapters/telaria/telariatest/supplemental/{required-ad-code.json => required-seat-code.json} (86%) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index efec930fffb..fb5293f115a 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -19,10 +19,28 @@ type TelariaAdapter struct { URI string } -type TagIDExt struct { +// This will be part of Imp[i].Ext when this adapter calls out the Telaria Ad Server +type ImpressionExtOut struct { OriginalTagID string `json:"originalTagid"` } +// This will be part of Request.Ext when this adapter calls out the Telaria Ad Server +type BidExtOut struct { + openrtb_ext.ExtRequest + OriginalPublisherID string `json:"originalPublisherId"` +} + +// Publishers must send this information as part of the Request under the Ext object +type ReqExtTelariaIn struct { + SeatCode string `json:"seatCode,omitempty"` +} + +// Full request extension including Telaria extension object +type ReqExtIn struct { + openrtb_ext.ExtRequest + Telaria *ReqExtTelariaIn `json:"telaria,omitempty"` +} + // used for cookies and such func (a *TelariaAdapter) Name() string { return "telaria" @@ -32,10 +50,46 @@ func (a *TelariaAdapter) SkipNoCookies() bool { return false } +// Endpoint for Telaria Ad server func (a *TelariaAdapter) FetchEndpoint() string { return a.URI } +// Checker method to ensure len(request.Imp) > 0 +func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { + if len(request.Imp) == 0 { + err := &errortypes.BadInput{ + Message: "No imp object in the bid request", + } + return err + } + return nil +} + +// Checking if Imp[i].Video exists and Imp[i].Banner doesn't exist +func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error { + hasVideoObject := false + + for _, imp := range request.Imp { + if imp.Banner != nil { + return &errortypes.BadInput{ + Message: "Telaria doesn't support banner", + } + } + + hasVideoObject = hasVideoObject || imp.Video != nil + } + + if !hasVideoObject { + return &errortypes.BadInput{ + Message: "No Video object present in Imp object", + } + } + + return nil +} + +// Fetches the populated header object func GetHeaders(request *openrtb.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") @@ -64,19 +118,10 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { return &headers } -func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { - if len(request.Imp) == 0 { - err := &errortypes.BadInput{ - Message: "No imp object in the bid request", - } - return err - } - return nil -} - -func (a *TelariaAdapter) FetchBidderExt(request *openrtb.BidRequest) (*adapters.ExtImpBidder, error) { +// Checks the imp[i].ext object and returns a imp.ext object as per ExtImpTelaria format +func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ext.ExtImpTelaria, error) { var bidderExt adapters.ExtImpBidder - err := json.Unmarshal(request.Imp[0].Ext, &bidderExt) + err := json.Unmarshal(imp.Ext, &bidderExt) if err != nil { err = &errortypes.BadInput{ @@ -86,46 +131,74 @@ func (a *TelariaAdapter) FetchBidderExt(request *openrtb.BidRequest) (*adapters. return nil, err } - return &bidderExt, nil -} - -func (a *TelariaAdapter) FetchTelariaParams(request *openrtb.BidRequest) (*openrtb_ext.ExtImpTelaria, error) { - bidderExt, err := a.FetchBidderExt(request) - if err != nil { - return nil, err - } - var telariaExt openrtb_ext.ExtImpTelaria err = json.Unmarshal(bidderExt.Bidder, &telariaExt) if err != nil { err = &errortypes.BadInput{ - Message: "ext.bidder.adCode not provided", + Message: "error while unwrapping the JSON", } return nil, err } - if telariaExt.AdCode == "" { - err = &errortypes.BadInput{ - Message: "adCode is empty", + return &telariaExt, nil +} + +// Fetch the id from the appropriate publisher object +func (a *TelariaAdapter) FetchPublisherId(request *openrtb.BidRequest) string { + + if request.Site != nil { + if request.Site.Publisher != nil { + if request.Site.Publisher.ID != "" { + return request.Site.Publisher.ID + } } + } - return nil, err + if request.App != nil { + if request.App.Publisher != nil { + if request.App.Publisher.ID != "" { + return request.App.Publisher.ID + } + } } - return &telariaExt, nil + return "" } -func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error { - hasVideoObject := false +// This method changes .publisher.id to request.ext.telaria.seatCode +// And moves the publisher.id to request.ext.originalPublisherId +func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) error { + var requestExtIncoming ReqExtIn + if err := json.Unmarshal(request.Ext, &requestExtIncoming); err != nil { + return err + } - for _, imp := range request.Imp { - hasVideoObject = hasVideoObject || imp.Video != nil + if requestExtIncoming.Telaria == nil { + requestExtIncoming.Telaria = &ReqExtTelariaIn{} } - if !hasVideoObject { - return &errortypes.BadInput{ - Message: "Telaria only supports Video", + if requestExtIncoming.Telaria.SeatCode == "" { + return &errortypes.BadInput{Message: "Seat Code is required"} + } + + request.Ext, _ = json.Marshal(&BidExtOut{requestExtIncoming.ExtRequest, a.FetchPublisherId(request)}) + + publisherObject := &openrtb.Publisher{ID: requestExtIncoming.Telaria.SeatCode} + + if request.Site != nil { + if request.Site.Publisher != nil { + request.Site.Publisher.ID = requestExtIncoming.Telaria.SeatCode + } else { + request.Site.Publisher = publisherObject + } + } + + if request.App != nil { + if request.App.Publisher != nil { + request.App.Publisher.ID = requestExtIncoming.Telaria.SeatCode + } else { + request.App.Publisher = publisherObject } } @@ -138,22 +211,28 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return nil, []error{noImps} } - if noVideoObject := a.CheckHasVideoObject(request); noVideoObject != nil { - return nil, []error{noVideoObject} + if noVideoObjectError := a.CheckHasVideoObject(request); noVideoObjectError != nil { + return nil, []error{noVideoObjectError} } - telariaExt, err := a.FetchTelariaParams(request) - if err != nil { - return nil, []error{err} + if noSeatCodeError := a.PopulateRequestExtAndPubId(request); noSeatCodeError != nil { + return nil, []error{noSeatCodeError} } - for i, _ := range request.Imp { - impExt := &TagIDExt{request.Imp[i].TagID} - request.Imp[i].TagID = telariaExt.AdCode + var errors []error + for i, imp := range request.Imp { + telariaExt, err := a.FetchTelariaExtImpParams(&imp) - if impExt.OriginalTagID != "" { - request.Imp[i].Ext, _ = json.Marshal(impExt) + if err != nil { + errors = append(errors, err) } + + request.Imp[i].TagID = telariaExt.AdCode + request.Imp[i].Ext, _ = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) + } + + if len(errors) > 0 { + return nil, errors } reqJSON, err := json.Marshal(request) @@ -195,21 +274,37 @@ func GetResponseBody(response *adapters.ResponseData) (*[]byte, error) { return &responseBody, nil } -func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error { if response.StatusCode == http.StatusNoContent { - return nil, nil + return &errortypes.BadInput{Message: "Invalid Bid Request received by the server"} } if response.StatusCode == http.StatusBadRequest { - return nil, []error{&errortypes.BadInput{ + return &errortypes.BadInput{ Message: fmt.Sprintf("Unexpected status code: [ %d ] . ", response.StatusCode), - }} + } } - if response.StatusCode != http.StatusOK { - return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("unexpected status code:[ %d ]. Run with request.debug = 1 for more info", response.StatusCode), - }} + if response.StatusCode == http.StatusServiceUnavailable { + return &errortypes.BadInput{ + Message: fmt.Sprintf("Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), + } + } + + if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices { + return &errortypes.BadInput{ + Message: fmt.Sprintf("Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), + } + } + + return nil +} + +func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + + httpStatusError := a.CheckResponseStatusCodes(response) + if httpStatusError != nil { + return nil, []error{httpStatusError} } responseBody, err := GetResponseBody(response) diff --git a/adapters/telaria/telariatest/exemplary/video.json b/adapters/telaria/telariatest/exemplary/video.json index c36a353f3e3..0d0c4aad7d0 100644 --- a/adapters/telaria/telariatest/exemplary/video.json +++ b/adapters/telaria/telariatest/exemplary/video.json @@ -5,7 +5,10 @@ "requestPayload": { "id": "some-request-id", "site": { - "page": "test.com" + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } }, "imp": [ { @@ -20,7 +23,8 @@ }, "ext": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } diff --git a/adapters/telaria/telariatest/params/race/video.json b/adapters/telaria/telariatest/params/race/video.json index 87a4fef3c95..6c9db79850a 100644 --- a/adapters/telaria/telariatest/params/race/video.json +++ b/adapters/telaria/telariatest/params/race/video.json @@ -1,3 +1,4 @@ { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } diff --git a/adapters/telaria/telariatest/supplemental/required-ad-code.json b/adapters/telaria/telariatest/supplemental/required-seat-code.json similarity index 86% rename from adapters/telaria/telariatest/supplemental/required-ad-code.json rename to adapters/telaria/telariatest/supplemental/required-seat-code.json index 78ce7868ea2..82d5f550558 100644 --- a/adapters/telaria/telariatest/supplemental/required-ad-code.json +++ b/adapters/telaria/telariatest/supplemental/required-seat-code.json @@ -22,7 +22,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "imp[0].ext.bidder.telaria.adCode required", + "value": "imp[0].ext.bidder.telaria.seatCode required", "comparison": "literal" } ] diff --git a/openrtb_ext/imp_telaria.go b/openrtb_ext/imp_telaria.go index 071283b651d..fb20107c8e0 100644 --- a/openrtb_ext/imp_telaria.go +++ b/openrtb_ext/imp_telaria.go @@ -1,5 +1,5 @@ package openrtb_ext type ExtImpTelaria struct { - AdCode string `json:"adCode"` + AdCode string `json:"adCode,omitempty"` } From 59e78585cccc0c222437f184600c6989e9f5bda7 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 6 Mar 2020 16:10:14 -0800 Subject: [PATCH 12/26] change in the return type after decompressing --- adapters/telaria/telaria.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index fb5293f115a..1858d4723f4 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -249,7 +249,7 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap } // response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip -func GetResponseBody(response *adapters.ResponseData) (*[]byte, error) { +func GetResponseBody(response *adapters.ResponseData) ([]byte, error) { responseBody := response.Body if "gzip" == response.Headers.Get("Content-Encoding") { @@ -271,7 +271,7 @@ func GetResponseBody(response *adapters.ResponseData) (*[]byte, error) { responseBody = resB.Bytes() } - return &responseBody, nil + return responseBody, nil } func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error { @@ -314,7 +314,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR } var bidResp openrtb.BidResponse - if err := json.Unmarshal(*responseBody, &bidResp); err != nil { + if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ Message: fmt.Sprintf("bad server response: [ %d ]. ", err), }} From b4bfc8da9e798eb58c946162e6eccbc90c165adb Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 9 Mar 2020 18:57:18 -0700 Subject: [PATCH 13/26] some refactoring --- adapters/telaria/telaria.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 1858d4723f4..4aadd342719 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -250,7 +250,6 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap // response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip func GetResponseBody(response *adapters.ResponseData) ([]byte, error) { - responseBody := response.Body if "gzip" == response.Headers.Get("Content-Encoding") { body := bytes.NewBuffer(response.Body) @@ -268,10 +267,13 @@ func GetResponseBody(response *adapters.ResponseData) ([]byte, error) { Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode), } } - responseBody = resB.Bytes() - } - return responseBody, nil + response.Headers.Del("Content-Encoding") + + return resB.Bytes(), nil + } else { + return response.Body, nil + } } func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error { From ec251d7d565a7c4323d244adb465bd4de53e99c2 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 18 Mar 2020 12:06:55 -0700 Subject: [PATCH 14/26] change in our config url --- config/config.go | 2 +- static/bidder-params/telaria.json | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index cbc79c9c64f..4096c7f4bbe 100644 --- a/config/config.go +++ b/config/config.go @@ -527,7 +527,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://partners.tremorhub.com/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3DTVUSER_ID") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.vhfp.net/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUcfunnel, "https://sync.aralego.com/idsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&usprivacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ducfunnel%26uid%3DSspCookieUserId") diff --git a/static/bidder-params/telaria.json b/static/bidder-params/telaria.json index f72fbdc458e..fde6bafb379 100644 --- a/static/bidder-params/telaria.json +++ b/static/bidder-params/telaria.json @@ -8,8 +8,12 @@ "adCode": { "type": "string", "description": "The Ad Unit Code." + }, + "seatCode": { + "type": "string", + "description": "Your Seat Code." } }, - "required": ["adCode"] + "required": ["seatCode"] } From f7b3cce8592509edf7f4e35806eac33f28a96dd2 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 20 Mar 2020 09:46:01 -0700 Subject: [PATCH 15/26] using pbs.yml to switch between our production and test URLs --- adapters/telaria/telaria.go | 6 +++++- adapters/telaria/telaria_test.go | 6 +++--- adapters/telaria/usersync_test.go | 4 ++-- config/config.go | 2 +- static/bidder-params/telaria.json | 4 +--- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 4aadd342719..c139b8d3a3a 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -335,7 +335,11 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR } func NewTelariaBidder(endpoint string) *TelariaAdapter { + if endpoint == "" { + endpoint = Endpoint + } + return &TelariaAdapter{ - URI: Endpoint, + URI: endpoint, } } diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index ba81a0a7351..c19bfd9ee29 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -9,7 +9,7 @@ import ( * Verify adapter names are setup correctly. */ func TestTelariaAdapterNames(t *testing.T) { - adapter := NewTelariaBidder("https://{{.Host}}") + adapter := NewTelariaBidder("") adapterstest.VerifyStringValue(adapter.Name(), "telaria", t) } @@ -17,7 +17,7 @@ func TestTelariaAdapterNames(t *testing.T) { * Verify adapter SkipNoCookie is correct. */ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { - adapter := NewTelariaBidder("https://{{.Host}}") + adapter := NewTelariaBidder("") adapterstest.VerifyBoolValue(adapter.SkipNoCookies(), false, t) } @@ -25,7 +25,7 @@ func TestTelariaAdapterSkipNoCookiesFlag(t *testing.T) { * Verify bidder has the proper URL */ func TestTelariaAdapterEndpoint(t *testing.T) { - adapter := NewTelariaBidder("https://{{.Host}}") + adapter := NewTelariaBidder("") adapterstest.VerifyStringValue(adapter.URI, "https://ads.tremorhub.com/ad/rtb/prebid", t) } diff --git a/adapters/telaria/usersync_test.go b/adapters/telaria/usersync_test.go index 27c2ee6bc42..4896b253d2f 100644 --- a/adapters/telaria/usersync_test.go +++ b/adapters/telaria/usersync_test.go @@ -11,7 +11,7 @@ import ( func TestTelariaSyncer(t *testing.T) { - syncURL := "http://partners.tremorhub.com/unwrap?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" + syncURL := "https://pbs.publishers.tremorhub.com/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}" syncURLTemplate := template.Must( template.New("sync-template").Parse(syncURL), ) @@ -24,7 +24,7 @@ func TestTelariaSyncer(t *testing.T) { }) assert.NoError(t, err) - assert.Equal(t, "http://partners.tremorhub.com/unwrap?gdpr=0&gdpr_consent=", syncInfo.URL) + assert.Equal(t, "https://pbs.publishers.tremorhub.com/pubsync?gdpr=0&gdpr_consent=", syncInfo.URL) assert.Equal(t, "redirect", syncInfo.Type) assert.EqualValues(t, 202, syncer.GDPRVendorID()) assert.Equal(t, false, syncInfo.SupportCORS) diff --git a/config/config.go b/config/config.go index 05ef682bfd8..6bff3b969c2 100644 --- a/config/config.go +++ b/config/config.go @@ -534,7 +534,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSovrn, "https://ap.lijit.com/pixel?redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsovrn%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderSynacormedia, "https://sync.technoratimedia.com/services?srv=cs&pid=70&cb="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dsynacormedia%26uid%3D%5BUSER_ID%5D") // openrtb_ext.BidderTappx doesn't have a good default. - setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.vhfp.net/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D") + setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTelaria, "https://pbs.publishers.tremorhub.com/pubsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtelaria%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Btvid%5D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTriplelift, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderTripleliftNative, "https://eb2.3lift.com/getuid?gdpr={{.GDPR}}&cmp_cs={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dtriplelift_native%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderUcfunnel, "https://sync.aralego.com/idsync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&usprivacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Ducfunnel%26uid%3DSspCookieUserId") diff --git a/static/bidder-params/telaria.json b/static/bidder-params/telaria.json index fde6bafb379..36e88d4c0a1 100644 --- a/static/bidder-params/telaria.json +++ b/static/bidder-params/telaria.json @@ -13,7 +13,5 @@ "type": "string", "description": "Your Seat Code." } - }, - - "required": ["seatCode"] + } } From 31a69b401fca71bb8da30d26360037aadcaee4e2 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 20 Mar 2020 17:42:56 -0700 Subject: [PATCH 16/26] setting default endpoint --- config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index 6bff3b969c2..4cc0f53f66b 100644 --- a/config/config.go +++ b/config/config.go @@ -728,7 +728,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.sovrn.endpoint", "http://ap.lijit.com/rtb/bid?src=prebid_server") v.SetDefault("adapters.synacormedia.endpoint", "http://{{.Host}}.technoratimedia.com/openrtb/bids/{{.Host}}") v.SetDefault("adapters.tappx.endpoint", "https://{{.Host}}") - v.SetDefault("adapters.telaria.endpoint", "https://{{.Host}}") + v.SetDefault("adapters.telaria.endpoint", "https://ads.tremorhub.com/ad/rtb/prebid") v.SetDefault("adapters.triplelift_native.disabled", true) v.SetDefault("adapters.triplelift_native.extra_info", "{\"publisher_whitelist\":[]}") v.SetDefault("adapters.triplelift.endpoint", "https://tlx.3lift.com/s2s/auction?supplier_id=20") From a22719df75d3fbcf0a653c991b484b7623fe3c16 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 25 Mar 2020 12:48:54 -0700 Subject: [PATCH 17/26] - fixed the issue that was preventing telaria test cases to run. - added more test cases --- adapters/telaria/telaria.go | 34 ++-- adapters/telaria/telaria_test.go | 4 +- .../telariatest/exemplary/video-app.json | 165 ++++++++++++++++++ .../telariatest/exemplary/video-web.json | 153 ++++++++++++++++ .../telaria/telariatest/exemplary/video.json | 33 ---- .../supplemental/banner-unsupported.json | 48 +++++ .../supplemental/invalid-ext-object.json | 40 +++++ .../supplemental/invalid-response.json | 113 ++++++++++++ .../invalid-telaria-ext-object.json | 34 ++++ .../supplemental/requires-imp-object.json | 21 +++ ...seat-code.json => requires-seat-code.json} | 22 ++- .../supplemental/requires-video-object.json | 32 ++++ .../supplemental/status-code-bad-request.json | 88 ++++++++++ .../supplemental/status-code-no-content.json | 91 ++++++++++ .../supplemental/status-code-other-error.json | 91 ++++++++++ .../status-code-service-unavailable.json | 91 ++++++++++ 16 files changed, 994 insertions(+), 66 deletions(-) create mode 100644 adapters/telaria/telariatest/exemplary/video-app.json create mode 100644 adapters/telaria/telariatest/exemplary/video-web.json delete mode 100644 adapters/telaria/telariatest/exemplary/video.json create mode 100644 adapters/telaria/telariatest/supplemental/banner-unsupported.json create mode 100644 adapters/telaria/telariatest/supplemental/invalid-ext-object.json create mode 100644 adapters/telaria/telariatest/supplemental/invalid-response.json create mode 100644 adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json create mode 100644 adapters/telaria/telariatest/supplemental/requires-imp-object.json rename adapters/telaria/telariatest/supplemental/{required-seat-code.json => requires-seat-code.json} (68%) create mode 100644 adapters/telaria/telariatest/supplemental/requires-video-object.json create mode 100644 adapters/telaria/telariatest/supplemental/status-code-bad-request.json create mode 100644 adapters/telaria/telariatest/supplemental/status-code-no-content.json create mode 100644 adapters/telaria/telariatest/supplemental/status-code-other-error.json create mode 100644 adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index c139b8d3a3a..ff2dca8d591 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -94,7 +94,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { headers := http.Header{} headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") - headers.Add("x-openrtb-version", "2.5") + headers.Add("X-Openrtb-Version", "2.5") headers.Add("Accept-Encoding", "gzip") if request.Device != nil { @@ -103,7 +103,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { } if len(request.Device.IP) > 0 { - headers.Add("x-Forwarded-For", request.Device.IP) + headers.Add("X-Forwarded-For", request.Device.IP) } if len(request.Device.Language) > 0 { @@ -111,7 +111,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { } if request.Device.DNT != nil { - headers.Add("DNT", strconv.Itoa(int(*request.Device.DNT))) + headers.Add("Dnt", strconv.Itoa(int(*request.Device.DNT))) } } @@ -132,14 +132,7 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex } var telariaExt openrtb_ext.ExtImpTelaria - err = json.Unmarshal(bidderExt.Bidder, &telariaExt) - if err != nil { - err = &errortypes.BadInput{ - Message: "error while unwrapping the JSON", - } - - return nil, err - } + _ = json.Unmarshal(bidderExt.Bidder, &telariaExt) return &telariaExt, nil } @@ -174,10 +167,6 @@ func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) return err } - if requestExtIncoming.Telaria == nil { - requestExtIncoming.Telaria = &ReqExtTelariaIn{} - } - if requestExtIncoming.Telaria.SeatCode == "" { return &errortypes.BadInput{Message: "Seat Code is required"} } @@ -225,20 +214,17 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap if err != nil { errors = append(errors, err) + } else { + request.Imp[i].TagID = telariaExt.AdCode + request.Imp[i].Ext, _ = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) } - - request.Imp[i].TagID = telariaExt.AdCode - request.Imp[i].Ext, _ = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) } if len(errors) > 0 { return nil, errors } - reqJSON, err := json.Marshal(request) - if err != nil { - return nil, []error{err} - } + reqJSON, _ := json.Marshal(request) return []*adapters.RequestData{{ Method: "POST", @@ -283,7 +269,7 @@ func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseDat if response.StatusCode == http.StatusBadRequest { return &errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: [ %d ] . ", response.StatusCode), + Message: fmt.Sprintf("Unexpected status code: [ %d ] ", response.StatusCode), } } @@ -318,7 +304,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR var bidResp openrtb.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ - Message: fmt.Sprintf("bad server response: [ %d ]. ", err), + Message: "bad server response", }} } diff --git a/adapters/telaria/telaria_test.go b/adapters/telaria/telaria_test.go index c19bfd9ee29..7ad96b9307b 100644 --- a/adapters/telaria/telaria_test.go +++ b/adapters/telaria/telaria_test.go @@ -29,6 +29,6 @@ func TestTelariaAdapterEndpoint(t *testing.T) { adapterstest.VerifyStringValue(adapter.URI, "https://ads.tremorhub.com/ad/rtb/prebid", t) } -func testJsonSamples(t *testing.T) { - adapterstest.RunJSONBidderTest(t, "telariatest", new(TelariaAdapter)) +func TestJsonSamples(t *testing.T) { + adapterstest.RunJSONBidderTest(t, "telariatest", NewTelariaBidder("")) } diff --git a/adapters/telaria/telariatest/exemplary/video-app.json b/adapters/telaria/telariatest/exemplary/video-app.json new file mode 100644 index 00000000000..23ccd9c5bb3 --- /dev/null +++ b/adapters/telaria/telariatest/exemplary/video-app.json @@ -0,0 +1,165 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "app": { + "publisher": { + "id": "123456789" + }, + "cat": [ + "IAB22-1" + ], + "bundle": "com.app.awesome", + "name": "Awesome App", + "domain": "awesomeapp.com", + "id": "123456789" + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": [ + "video/mp4" + ], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + "httpCalls": [{ + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"], + "X-Openrtb-Version": ["2.5"], + "Accept-Encoding": ["gzip"], + "User-Agent": ["test-user-agent"], + "X-Forwarded-For": ["123.123.123.123"], + "Accept-Language": ["en"], + "Dnt": ["0"] + }, + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "app": { + "id": "123456789", + "name": "Awesome App", + "bundle": "com.app.awesome", + "domain": "awesomeapp.com", + "cat": [ + "IAB22-1" + ], + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "123456789" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "awesome-resp-id", + "seatbid": [{ + "bid": [{ + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "1", + "price": 3.5, + "adm": "asesome-markup", + "adomain": [ + "awesome.com" + ], + "crid": "20", + "w": 1280, + "h": 720, + "ext": { + "prebid": { + "type": "video" + } + } + }], + "seat": "telaria" + }], + "cur": "USD", + "ext": { + "responsetimemillis": { + "telaria": 154 + }, + "tmaxrequest": 1000 + } + } + } + }], + "expectedBids": [{ + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "1", + "price": 3.5, + "adm": "asesome-markup", + "adomain": [ + "awesome.com" + ], + "crid": "20", + "w": 1280, + "h": 720, + "ext": { + "prebid": { + "type": "video" + } + } + }] +} diff --git a/adapters/telaria/telariatest/exemplary/video-web.json b/adapters/telaria/telariatest/exemplary/video-web.json new file mode 100644 index 00000000000..afc0b389f25 --- /dev/null +++ b/adapters/telaria/telariatest/exemplary/video-web.json @@ -0,0 +1,153 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"], + "X-Openrtb-Version": ["2.5"], + "Accept-Encoding": ["gzip"], + "User-Agent": ["test-user-agent"], + "X-Forwarded-For": ["123.123.123.123"], + "Accept-Language": ["en"], + "Dnt": ["0"] + }, + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "someother-publisher-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "awesome-resp-id", + "seatbid": [{ + "bid": [{ + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "1", + "price": 3.5, + "adm": "asesome-markup", + "adomain": [ + "awesome.com" + ], + "crid": "20", + "w": 1280, + "h": 720, + "ext": { + "prebid": { + "type": "video" + } + } + }], + "seat": "telaria" + }], + "cur": "USD", + "ext": { + "responsetimemillis": { + "telaria": 154 + }, + "tmaxrequest": 1000 + } + } + } + }], + "expectedBids": [{ + "id": "a3ae1b4e2fc24a4fb45540082e98e161", + "impid": "1", + "price": 3.5, + "adm": "asesome-markup", + "adomain": [ + "awesome.com" + ], + "crid": "20", + "w": 1280, + "h": 720, + "ext": { + "prebid": { + "type": "video" + } + } + }] +} diff --git a/adapters/telaria/telariatest/exemplary/video.json b/adapters/telaria/telariatest/exemplary/video.json deleted file mode 100644 index 0d0c4aad7d0..00000000000 --- a/adapters/telaria/telariatest/exemplary/video.json +++ /dev/null @@ -1,33 +0,0 @@ - -{ - "description": "This uses Telaria to fetch the sample ad", - - "requestPayload": { - "id": "some-request-id", - "site": { - "page": "test.com", - "publisher": { - "id": "someother-publisher-id" - } - }, - "imp": [ - { - "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", - "video": { - "mimes": ["video/mp4"], - "w": 640, - "h": 480, - "minduration": 120, - "maxduration": 150 - }, - "ext": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } - } - } - ] - } -} diff --git a/adapters/telaria/telariatest/supplemental/banner-unsupported.json b/adapters/telaria/telariatest/supplemental/banner-unsupported.json new file mode 100644 index 00000000000..5e42056adfd --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/banner-unsupported.json @@ -0,0 +1,48 @@ + +{ + "expectedMakeRequestsErrors": [ + { + "value": "Telaria doesn't support banner", + "comparison": "literal" + } + ], + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "awesome-seat" + } + } + } +} diff --git a/adapters/telaria/telariatest/supplemental/invalid-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-ext-object.json new file mode 100644 index 00000000000..a92e6b19a31 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/invalid-ext-object.json @@ -0,0 +1,40 @@ +{ + "expectedMakeRequestsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type telaria.ReqExtIn", + "comparison": "literal" + } + ], + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": [] + } + } + } + ], + "app": { + "cat": [ + "IAB22-1" + ], + "bundle": "com.app.awesome", + "name": "Awesome App", + "domain": "awesomeapp.com", + "id": "123456789" + }, + "ext": "Invalid" + }, + "httpCalls": [] +} diff --git a/adapters/telaria/telariatest/supplemental/invalid-response.json b/adapters/telaria/telariatest/supplemental/invalid-response.json new file mode 100644 index 00000000000..6c975daab7d --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/invalid-response.json @@ -0,0 +1,113 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "headers": { + "Content-Type": ["application/json;charset=utf-8"], + "Accept": ["application/json"], + "X-Openrtb-Version": ["2.5"], + "Accept-Encoding": ["gzip"], + "User-Agent": ["test-user-agent"], + "X-Forwarded-For": ["123.123.123.123"], + "Accept-Language": ["en"], + "Dnt": ["0"] + }, + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "device": { + "ua": "test-user-agent", + "ip": "123.123.123.123", + "language": "en", + "dnt": 0 + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "someother-publisher-id" + } + } + }, + "mockResponse": { + "status": 200, + "body": "invalid response" + } + }], + "expectedMakeBidsErrors": [ + { + "value": "bad server response", + "comparison": "literal" + } + ] +} diff --git a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json new file mode 100644 index 00000000000..7ea0d18f075 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json @@ -0,0 +1,34 @@ +{ + "expectedMakeRequestsErrors": [ + { + "value": "ext.bidder not provided", + "comparison": "literal" + } + ], + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": "Awesome" + } + ], + "site": { + "page": "test.com" + }, + "ext": { + "telaria": { + "seatCode": "awesome-seat" + } + } + }, + "httpCalls": [] +} diff --git a/adapters/telaria/telariatest/supplemental/requires-imp-object.json b/adapters/telaria/telariatest/supplemental/requires-imp-object.json new file mode 100644 index 00000000000..3113ad4cbf4 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/requires-imp-object.json @@ -0,0 +1,21 @@ +{ + "expectedMakeRequestsErrors": [ + { + "value": "No imp object in the bid request", + "comparison": "literal" + } + ], + "mockBidRequest": { + "id": "test-request-id", + "imp": [], + "site": { + "page": "test.com" + }, + "ext": { + "telaria": { + "seatCode": "awesome-seat" + } + } + }, + "httpCalls": [] +} diff --git a/adapters/telaria/telariatest/supplemental/required-seat-code.json b/adapters/telaria/telariatest/supplemental/requires-seat-code.json similarity index 68% rename from adapters/telaria/telariatest/supplemental/required-seat-code.json rename to adapters/telaria/telariatest/supplemental/requires-seat-code.json index 82d5f550558..ab369031c43 100644 --- a/adapters/telaria/telariatest/supplemental/required-seat-code.json +++ b/adapters/telaria/telariatest/supplemental/requires-seat-code.json @@ -1,4 +1,10 @@ { + "expectedMakeRequestsErrors": [ + { + "value": "Seat Code is required", + "comparison": "literal" + } + ], "mockBidRequest": { "id": "test-request-id", "imp": [ @@ -11,19 +17,21 @@ }, "ext": { "bidder": { - + "telaria": { + "adCode": "ssp-!demo!-lufip" + } } } } ], "site": { "page": "test.com" + }, + "ext": { + "telaria": { + + } } }, - "expectedMakeRequestsErrors": [ - { - "value": "imp[0].ext.bidder.telaria.seatCode required", - "comparison": "literal" - } - ] + "httpCalls": [] } diff --git a/adapters/telaria/telariatest/supplemental/requires-video-object.json b/adapters/telaria/telariatest/supplemental/requires-video-object.json new file mode 100644 index 00000000000..9ca22146c8d --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/requires-video-object.json @@ -0,0 +1,32 @@ +{ + "expectedMakeRequestsErrors": [ + { + "value": "No Video object present in Imp object", + "comparison": "literal" + } + ], + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-impression-1", + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "site": { + "page": "test.com" + }, + "ext": { + "telaria": { + "seatCode": "awesome-seat" + } + } + }, + "httpCalls": [] +} diff --git a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json new file mode 100644 index 00000000000..885b2b03c38 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json @@ -0,0 +1,88 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "app": { + "id": "123456789" + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "app": { + "id": "123456789", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "" + } + } + }, + "mockResponse": { + "status": 400 + } + }], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: [ 400 ] ", + "comparison": "literal" + } + ] +} diff --git a/adapters/telaria/telariatest/supplemental/status-code-no-content.json b/adapters/telaria/telariatest/supplemental/status-code-no-content.json new file mode 100644 index 00000000000..d245240c0c5 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/status-code-no-content.json @@ -0,0 +1,91 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "someother-publisher-id" + } + } + }, + "mockResponse": { + "status": 204 + } + }], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Invalid Bid Request received by the server", + "comparison": "literal" + } + ] +} diff --git a/adapters/telaria/telariatest/supplemental/status-code-other-error.json b/adapters/telaria/telariatest/supplemental/status-code-other-error.json new file mode 100644 index 00000000000..5a6bc17d8d9 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/status-code-other-error.json @@ -0,0 +1,91 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "someother-publisher-id" + } + } + }, + "mockResponse": { + "status": 306 + } + }], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Something went wrong, please contact your Account Manager. Status Code: [ 306 ] ", + "comparison": "literal" + } + ] +} diff --git a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json new file mode 100644 index 00000000000..4799a7cbe43 --- /dev/null +++ b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json @@ -0,0 +1,91 @@ + +{ + "mockBidRequest": { + "id": "some-request-id", + "tmax": 1000, + "user": { + "buyeruid": "awesome-user" + }, + "site": { + "page": "test.com", + "publisher": { + "id": "someother-publisher-id" + } + }, + "imp": [ + { + "id": "some-impression-id", + "tagid": "ssp-!demo!-lufip", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480, + "minduration": 120, + "maxduration": 150 + }, + "ext": { + "bidder": { + "telaria": { + "adCode": "ssp-!demo!-lufip" + } + } + } + } + ], + "ext": { + "telaria": { + "seatCode": "test-code" + } + } + }, + + "httpCalls": [{ + "expectedRequest": { + "uri": "https://ads.tremorhub.com/ad/rtb/prebid", + "body": { + "id": "some-request-id", + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 120, + "maxduration": 150, + "w": 640, + "h": 480 + }, + "ext": { + "originalTagid": "" + } + } + ], + "site": { + "page": "test.com", + "publisher": { + "id": "test-code" + } + }, + "user": { + "buyeruid": "awesome-user" + }, + "tmax": 1000, + "ext": { + "prebid": {}, + "originalPublisherId": "someother-publisher-id" + } + } + }, + "mockResponse": { + "status": 503 + } + }], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Something went wrong, please contact your Account Manager. Status Code: [ 503 ] ", + "comparison": "literal" + } + ] +} From 965715f37dc8d1f2889f2a9fde7d5eb912edeae8 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 27 Mar 2020 12:32:35 -0700 Subject: [PATCH 18/26] - Modifications as per the changes requested by the maintainers. --- adapters/telaria/telaria.go | 61 ++++++++++++++++++------------------- exchange/adapter_map.go | 2 +- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index ff2dca8d591..98d9c2ed5f0 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -137,28 +137,6 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex return &telariaExt, nil } -// Fetch the id from the appropriate publisher object -func (a *TelariaAdapter) FetchPublisherId(request *openrtb.BidRequest) string { - - if request.Site != nil { - if request.Site.Publisher != nil { - if request.Site.Publisher.ID != "" { - return request.Site.Publisher.ID - } - } - } - - if request.App != nil { - if request.App.Publisher != nil { - if request.App.Publisher.ID != "" { - return request.App.Publisher.ID - } - } - } - - return "" -} - // This method changes .publisher.id to request.ext.telaria.seatCode // And moves the publisher.id to request.ext.originalPublisherId func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) error { @@ -167,17 +145,19 @@ func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) return err } - if requestExtIncoming.Telaria.SeatCode == "" { + if requestExtIncoming.Telaria == nil || requestExtIncoming.Telaria.SeatCode == "" { return &errortypes.BadInput{Message: "Seat Code is required"} } - request.Ext, _ = json.Marshal(&BidExtOut{requestExtIncoming.ExtRequest, a.FetchPublisherId(request)}) - publisherObject := &openrtb.Publisher{ID: requestExtIncoming.Telaria.SeatCode} + originalPubId := "" if request.Site != nil { if request.Site.Publisher != nil { - request.Site.Publisher.ID = requestExtIncoming.Telaria.SeatCode + if request.Site.Publisher.ID != "" { + originalPubId = request.Site.Publisher.ID + request.Site.Publisher.ID = requestExtIncoming.Telaria.SeatCode + } } else { request.Site.Publisher = publisherObject } @@ -185,12 +165,22 @@ func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) if request.App != nil { if request.App.Publisher != nil { - request.App.Publisher.ID = requestExtIncoming.Telaria.SeatCode + if request.App.Publisher.ID != "" { + originalPubId = request.App.Publisher.ID + request.App.Publisher.ID = requestExtIncoming.Telaria.SeatCode + } } else { request.App.Publisher = publisherObject } } + var err error + request.Ext, err = json.Marshal(&BidExtOut{requestExtIncoming.ExtRequest, originalPubId}) + + if err != nil { + return &errortypes.BadInput{Message: "Error while adding the request.Ext object"} + } + return nil } @@ -214,9 +204,14 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap if err != nil { errors = append(errors, err) - } else { - request.Imp[i].TagID = telariaExt.AdCode - request.Imp[i].Ext, _ = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) + break + } + + request.Imp[i].TagID = telariaExt.AdCode + request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) + if err != nil { + errors = append(errors, err) + break } } @@ -224,7 +219,11 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return nil, errors } - reqJSON, _ := json.Marshal(request) + reqJSON, err := json.Marshal(request) + + if err != nil { + return nil, []error{err} + } return []*adapters.RequestData{{ Method: "POST", diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index f864be4c6ea..f2c36504dd1 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -2,7 +2,6 @@ package exchange import ( "fmt" - "github.com/prebid/prebid-server/adapters/telaria" "net/http" "strings" @@ -54,6 +53,7 @@ import ( "github.com/prebid/prebid-server/adapters/sovrn" "github.com/prebid/prebid-server/adapters/synacormedia" "github.com/prebid/prebid-server/adapters/tappx" + "github.com/prebid/prebid-server/adapters/telaria" "github.com/prebid/prebid-server/adapters/triplelift" "github.com/prebid/prebid-server/adapters/triplelift_native" "github.com/prebid/prebid-server/adapters/ucfunnel" From 6df25ccb33b556e3762bd00d1249bc95c62baae2 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 6 Apr 2020 13:25:46 -0700 Subject: [PATCH 19/26] Moved the seat code to imp.ext --- adapters/telaria/telaria.go | 64 ++++++++----------- .../telariatest/exemplary/video-app.json | 10 +-- .../telariatest/exemplary/video-web.json | 10 +-- .../supplemental/banner-unsupported.json | 10 +-- .../supplemental/invalid-ext-object.json | 40 ------------ .../supplemental/invalid-response.json | 10 +-- .../invalid-telaria-ext-object.json | 5 -- .../supplemental/requires-imp-object.json | 5 -- .../supplemental/requires-seat-code.json | 5 -- .../supplemental/requires-video-object.json | 8 +-- .../supplemental/status-code-bad-request.json | 10 +-- .../supplemental/status-code-no-content.json | 10 +-- .../supplemental/status-code-other-error.json | 10 +-- .../status-code-service-unavailable.json | 10 +-- analytics/config/testFiles/test-20200303 | 0 openrtb_ext/imp_telaria.go | 3 +- static/bidder-params/telaria.json | 7 +- 17 files changed, 60 insertions(+), 157 deletions(-) delete mode 100644 adapters/telaria/telariatest/supplemental/invalid-ext-object.json delete mode 100644 analytics/config/testFiles/test-20200303 diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 98d9c2ed5f0..ef2e22200f6 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -21,25 +21,16 @@ type TelariaAdapter struct { // This will be part of Imp[i].Ext when this adapter calls out the Telaria Ad Server type ImpressionExtOut struct { - OriginalTagID string `json:"originalTagid"` -} - -// This will be part of Request.Ext when this adapter calls out the Telaria Ad Server -type BidExtOut struct { - openrtb_ext.ExtRequest + OriginalTagID string `json:"originalTagid"` OriginalPublisherID string `json:"originalPublisherId"` } -// Publishers must send this information as part of the Request under the Ext object -type ReqExtTelariaIn struct { - SeatCode string `json:"seatCode,omitempty"` -} - +/* // Full request extension including Telaria extension object type ReqExtIn struct { openrtb_ext.ExtRequest Telaria *ReqExtTelariaIn `json:"telaria,omitempty"` -} +}*/ // used for cookies and such func (a *TelariaAdapter) Name() string { @@ -132,31 +123,31 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex } var telariaExt openrtb_ext.ExtImpTelaria - _ = json.Unmarshal(bidderExt.Bidder, &telariaExt) + err = json.Unmarshal(bidderExt.Bidder, &telariaExt) + + if err != nil { + return nil, err + } + + if telariaExt.SeatCode == "" { + return nil, &errortypes.BadInput{Message: "Seat Code required"} + } return &telariaExt, nil } // This method changes .publisher.id to request.ext.telaria.seatCode // And moves the publisher.id to request.ext.originalPublisherId -func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) error { - var requestExtIncoming ReqExtIn - if err := json.Unmarshal(request.Ext, &requestExtIncoming); err != nil { - return err - } +func (a *TelariaAdapter) PopulatePublisherId(request *openrtb.BidRequest, impExt *openrtb_ext.ExtImpTelaria) (string, error) { - if requestExtIncoming.Telaria == nil || requestExtIncoming.Telaria.SeatCode == "" { - return &errortypes.BadInput{Message: "Seat Code is required"} - } - - publisherObject := &openrtb.Publisher{ID: requestExtIncoming.Telaria.SeatCode} + publisherObject := &openrtb.Publisher{ID: impExt.SeatCode} originalPubId := "" if request.Site != nil { if request.Site.Publisher != nil { if request.Site.Publisher.ID != "" { originalPubId = request.Site.Publisher.ID - request.Site.Publisher.ID = requestExtIncoming.Telaria.SeatCode + request.Site.Publisher.ID = impExt.SeatCode } } else { request.Site.Publisher = publisherObject @@ -167,21 +158,14 @@ func (a *TelariaAdapter) PopulateRequestExtAndPubId(request *openrtb.BidRequest) if request.App.Publisher != nil { if request.App.Publisher.ID != "" { originalPubId = request.App.Publisher.ID - request.App.Publisher.ID = requestExtIncoming.Telaria.SeatCode + request.App.Publisher.ID = impExt.SeatCode } } else { request.App.Publisher = publisherObject } } - var err error - request.Ext, err = json.Marshal(&BidExtOut{requestExtIncoming.ExtRequest, originalPubId}) - - if err != nil { - return &errortypes.BadInput{Message: "Error while adding the request.Ext object"} - } - - return nil + return originalPubId, nil } func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { @@ -194,10 +178,6 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap return nil, []error{noVideoObjectError} } - if noSeatCodeError := a.PopulateRequestExtAndPubId(request); noSeatCodeError != nil { - return nil, []error{noSeatCodeError} - } - var errors []error for i, imp := range request.Imp { telariaExt, err := a.FetchTelariaExtImpParams(&imp) @@ -207,8 +187,16 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap break } + var originalPublisherID string + + originalPublisherID, err = a.PopulatePublisherId(request, telariaExt) + if err != nil { + errors = append(errors, err) + break + } + request.Imp[i].TagID = telariaExt.AdCode - request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID}) + request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID, originalPublisherID}) if err != nil { errors = append(errors, err) break diff --git a/adapters/telaria/telariatest/exemplary/video-app.json b/adapters/telaria/telariatest/exemplary/video-app.json index 23ccd9c5bb3..b09c0cba532 100644 --- a/adapters/telaria/telariatest/exemplary/video-app.json +++ b/adapters/telaria/telariatest/exemplary/video-app.json @@ -39,17 +39,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ "expectedRequest": { diff --git a/adapters/telaria/telariatest/exemplary/video-web.json b/adapters/telaria/telariatest/exemplary/video-web.json index afc0b389f25..729883b604e 100644 --- a/adapters/telaria/telariatest/exemplary/video-web.json +++ b/adapters/telaria/telariatest/exemplary/video-web.json @@ -32,17 +32,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/adapters/telaria/telariatest/supplemental/banner-unsupported.json b/adapters/telaria/telariatest/supplemental/banner-unsupported.json index 5e42056adfd..2ee4c2227d5 100644 --- a/adapters/telaria/telariatest/supplemental/banner-unsupported.json +++ b/adapters/telaria/telariatest/supplemental/banner-unsupported.json @@ -33,16 +33,12 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "awesome-seat" - } - } + ] } } diff --git a/adapters/telaria/telariatest/supplemental/invalid-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-ext-object.json deleted file mode 100644 index a92e6b19a31..00000000000 --- a/adapters/telaria/telariatest/supplemental/invalid-ext-object.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "expectedMakeRequestsErrors": [ - { - "value": "json: cannot unmarshal string into Go value of type telaria.ReqExtIn", - "comparison": "literal" - } - ], - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", - "video": { - "mimes": ["video/mp4"], - "w": 640, - "h": 480, - "minduration": 120, - "maxduration": 150 - }, - "ext": { - "bidder": { - "telaria": [] - } - } - } - ], - "app": { - "cat": [ - "IAB22-1" - ], - "bundle": "com.app.awesome", - "name": "Awesome App", - "domain": "awesomeapp.com", - "id": "123456789" - }, - "ext": "Invalid" - }, - "httpCalls": [] -} diff --git a/adapters/telaria/telariatest/supplemental/invalid-response.json b/adapters/telaria/telariatest/supplemental/invalid-response.json index 6c975daab7d..35399a572b7 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-response.json +++ b/adapters/telaria/telariatest/supplemental/invalid-response.json @@ -32,17 +32,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json index 7ea0d18f075..781c98beb4f 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json +++ b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json @@ -23,11 +23,6 @@ ], "site": { "page": "test.com" - }, - "ext": { - "telaria": { - "seatCode": "awesome-seat" - } } }, "httpCalls": [] diff --git a/adapters/telaria/telariatest/supplemental/requires-imp-object.json b/adapters/telaria/telariatest/supplemental/requires-imp-object.json index 3113ad4cbf4..79e0cb1c286 100644 --- a/adapters/telaria/telariatest/supplemental/requires-imp-object.json +++ b/adapters/telaria/telariatest/supplemental/requires-imp-object.json @@ -10,11 +10,6 @@ "imp": [], "site": { "page": "test.com" - }, - "ext": { - "telaria": { - "seatCode": "awesome-seat" - } } }, "httpCalls": [] diff --git a/adapters/telaria/telariatest/supplemental/requires-seat-code.json b/adapters/telaria/telariatest/supplemental/requires-seat-code.json index ab369031c43..eb5c35d25bb 100644 --- a/adapters/telaria/telariatest/supplemental/requires-seat-code.json +++ b/adapters/telaria/telariatest/supplemental/requires-seat-code.json @@ -26,11 +26,6 @@ ], "site": { "page": "test.com" - }, - "ext": { - "telaria": { - - } } }, "httpCalls": [] diff --git a/adapters/telaria/telariatest/supplemental/requires-video-object.json b/adapters/telaria/telariatest/supplemental/requires-video-object.json index 9ca22146c8d..874f1cbfdf2 100644 --- a/adapters/telaria/telariatest/supplemental/requires-video-object.json +++ b/adapters/telaria/telariatest/supplemental/requires-video-object.json @@ -13,7 +13,8 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "awesome-seat" } } } @@ -21,11 +22,6 @@ ], "site": { "page": "test.com" - }, - "ext": { - "telaria": { - "seatCode": "awesome-seat" - } } }, "httpCalls": [] diff --git a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json index 885b2b03c38..24da93abe56 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json +++ b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json @@ -23,17 +23,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/adapters/telaria/telariatest/supplemental/status-code-no-content.json b/adapters/telaria/telariatest/supplemental/status-code-no-content.json index d245240c0c5..49c4110bdd3 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-no-content.json +++ b/adapters/telaria/telariatest/supplemental/status-code-no-content.json @@ -26,17 +26,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/adapters/telaria/telariatest/supplemental/status-code-other-error.json b/adapters/telaria/telariatest/supplemental/status-code-other-error.json index 5a6bc17d8d9..23f050a0fb7 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-other-error.json +++ b/adapters/telaria/telariatest/supplemental/status-code-other-error.json @@ -26,17 +26,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json index 4799a7cbe43..6a4b3d781a5 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json +++ b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json @@ -26,17 +26,13 @@ "ext": { "bidder": { "telaria": { - "adCode": "ssp-!demo!-lufip" + "adCode": "ssp-!demo!-lufip", + "seatCode": "test-code" } } } } - ], - "ext": { - "telaria": { - "seatCode": "test-code" - } - } + ] }, "httpCalls": [{ diff --git a/analytics/config/testFiles/test-20200303 b/analytics/config/testFiles/test-20200303 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/openrtb_ext/imp_telaria.go b/openrtb_ext/imp_telaria.go index fb20107c8e0..8ea371a8ad0 100644 --- a/openrtb_ext/imp_telaria.go +++ b/openrtb_ext/imp_telaria.go @@ -1,5 +1,6 @@ package openrtb_ext type ExtImpTelaria struct { - AdCode string `json:"adCode,omitempty"` + AdCode string `json:"adCode,omitempty"` + SeatCode string `json:"seatCode"` } diff --git a/static/bidder-params/telaria.json b/static/bidder-params/telaria.json index 36e88d4c0a1..f2c8c0da910 100644 --- a/static/bidder-params/telaria.json +++ b/static/bidder-params/telaria.json @@ -12,6 +12,11 @@ "seatCode": { "type": "string", "description": "Your Seat Code." + }, + "originalPublisherId": { + "type": "string", + "description": "publisher ID from the original request" } - } + }, + "required": ["seatCode"] } From 8e77271a0c7b31b67092e1a0b8a4e9cdb835505f Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 6 Apr 2020 15:58:23 -0700 Subject: [PATCH 20/26] Moved the seat code to imp.ext --- adapters/telaria/telaria.go | 5 +++-- .../telariatest/exemplary/video-app.json | 22 ++++++++----------- .../telariatest/exemplary/video-web.json | 22 ++++++++----------- .../telariatest/params/race/video.json | 4 ++-- .../supplemental/banner-unsupported.json | 8 +++---- .../supplemental/invalid-response.json | 22 ++++++++----------- .../invalid-telaria-ext-object.json | 2 +- .../supplemental/requires-seat-code.json | 6 ++--- .../supplemental/requires-video-object.json | 6 ++--- .../supplemental/status-code-bad-request.json | 20 +++++++---------- .../supplemental/status-code-no-content.json | 22 ++++++++----------- .../supplemental/status-code-other-error.json | 22 ++++++++----------- .../status-code-service-unavailable.json | 22 ++++++++----------- static/bidder-params/telaria.json | 2 +- 14 files changed, 76 insertions(+), 109 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index ef2e22200f6..400383843e6 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -22,7 +22,7 @@ type TelariaAdapter struct { // This will be part of Imp[i].Ext when this adapter calls out the Telaria Ad Server type ImpressionExtOut struct { OriginalTagID string `json:"originalTagid"` - OriginalPublisherID string `json:"originalPublisherId"` + OriginalPublisherID string `json:"originalPublisherid"` } /* @@ -195,8 +195,9 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap break } + originalTagId := request.Imp[i].TagID request.Imp[i].TagID = telariaExt.AdCode - request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID, originalPublisherID}) + request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{originalTagId, originalPublisherID}) if err != nil { errors = append(errors, err) break diff --git a/adapters/telaria/telariatest/exemplary/video-app.json b/adapters/telaria/telariatest/exemplary/video-app.json index b09c0cba532..09bcf998454 100644 --- a/adapters/telaria/telariatest/exemplary/video-app.json +++ b/adapters/telaria/telariatest/exemplary/video-app.json @@ -26,7 +26,7 @@ "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": [ "video/mp4" @@ -38,10 +38,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -80,8 +78,10 @@ "w": 640, "h": 480 }, + "tagid": "my-adcode", "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], @@ -94,17 +94,13 @@ "IAB22-1" ], "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "123456789" - } + "tmax": 1000 } }, "mockResponse": { @@ -145,7 +141,7 @@ "id": "a3ae1b4e2fc24a4fb45540082e98e161", "impid": "1", "price": 3.5, - "adm": "asesome-markup", + "adm": "awesome-markup", "adomain": [ "awesome.com" ], diff --git a/adapters/telaria/telariatest/exemplary/video-web.json b/adapters/telaria/telariatest/exemplary/video-web.json index 729883b604e..5dc26b0f018 100644 --- a/adapters/telaria/telariatest/exemplary/video-web.json +++ b/adapters/telaria/telariatest/exemplary/video-web.json @@ -15,13 +15,13 @@ "site": { "page": "test.com", "publisher": { - "id": "someother-publisher-id" + "id": "123456789" } }, "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -31,10 +31,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -65,6 +63,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -75,24 +74,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], "site": { "page": "test.com", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "someother-publisher-id" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/adapters/telaria/telariatest/params/race/video.json b/adapters/telaria/telariatest/params/race/video.json index 6c9db79850a..e3b67ec8c20 100644 --- a/adapters/telaria/telariatest/params/race/video.json +++ b/adapters/telaria/telariatest/params/race/video.json @@ -1,4 +1,4 @@ { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" + "adCode": "my-adcode", + "seatCode": "my-seatcode" } diff --git a/adapters/telaria/telariatest/supplemental/banner-unsupported.json b/adapters/telaria/telariatest/supplemental/banner-unsupported.json index 2ee4c2227d5..1cc9572f37c 100644 --- a/adapters/telaria/telariatest/supplemental/banner-unsupported.json +++ b/adapters/telaria/telariatest/supplemental/banner-unsupported.json @@ -17,7 +17,7 @@ "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "my-adcode", "banner": { "format": [ { @@ -32,10 +32,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } diff --git a/adapters/telaria/telariatest/supplemental/invalid-response.json b/adapters/telaria/telariatest/supplemental/invalid-response.json index 35399a572b7..2de4c6ae081 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-response.json +++ b/adapters/telaria/telariatest/supplemental/invalid-response.json @@ -15,13 +15,13 @@ "site": { "page": "test.com", "publisher": { - "id": "someother-publisher-id" + "id": "123456789" } }, "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -31,10 +31,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -65,6 +63,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -75,24 +74,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], "site": { "page": "test.com", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "someother-publisher-id" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json index 781c98beb4f..77752d01edf 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json +++ b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json @@ -10,7 +10,7 @@ "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "my-adcode", "video": { "mimes": ["video/mp4"], "w": 640, diff --git a/adapters/telaria/telariatest/supplemental/requires-seat-code.json b/adapters/telaria/telariatest/supplemental/requires-seat-code.json index eb5c35d25bb..bae912a7767 100644 --- a/adapters/telaria/telariatest/supplemental/requires-seat-code.json +++ b/adapters/telaria/telariatest/supplemental/requires-seat-code.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Seat Code is required", + "value": "Seat Code required", "comparison": "literal" } ], @@ -17,9 +17,7 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip" - } + "adCode": "my-adcode" } } } diff --git a/adapters/telaria/telariatest/supplemental/requires-video-object.json b/adapters/telaria/telariatest/supplemental/requires-video-object.json index 874f1cbfdf2..fa2d2cac017 100644 --- a/adapters/telaria/telariatest/supplemental/requires-video-object.json +++ b/adapters/telaria/telariatest/supplemental/requires-video-object.json @@ -12,10 +12,8 @@ "id": "test-impression-1", "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "awesome-seat" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } diff --git a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json index 24da93abe56..f0e7cb30e2e 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json +++ b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json @@ -12,7 +12,7 @@ "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -22,10 +22,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -40,6 +38,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -50,24 +49,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "" } } ], "app": { "id": "123456789", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/adapters/telaria/telariatest/supplemental/status-code-no-content.json b/adapters/telaria/telariatest/supplemental/status-code-no-content.json index 49c4110bdd3..b702e47c593 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-no-content.json +++ b/adapters/telaria/telariatest/supplemental/status-code-no-content.json @@ -9,13 +9,13 @@ "site": { "page": "test.com", "publisher": { - "id": "someother-publisher-id" + "id": "123456789" } }, "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -25,10 +25,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -43,6 +41,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -53,24 +52,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], "site": { "page": "test.com", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "someother-publisher-id" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/adapters/telaria/telariatest/supplemental/status-code-other-error.json b/adapters/telaria/telariatest/supplemental/status-code-other-error.json index 23f050a0fb7..077c8b271d2 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-other-error.json +++ b/adapters/telaria/telariatest/supplemental/status-code-other-error.json @@ -9,13 +9,13 @@ "site": { "page": "test.com", "publisher": { - "id": "someother-publisher-id" + "id": "123456789" } }, "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -25,10 +25,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -43,6 +41,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -53,24 +52,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], "site": { "page": "test.com", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "someother-publisher-id" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json index 6a4b3d781a5..94db8e66a53 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json +++ b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json @@ -9,13 +9,13 @@ "site": { "page": "test.com", "publisher": { - "id": "someother-publisher-id" + "id": "123456789" } }, "imp": [ { "id": "some-impression-id", - "tagid": "ssp-!demo!-lufip", + "tagid": "ogTAGID", "video": { "mimes": ["video/mp4"], "w": 640, @@ -25,10 +25,8 @@ }, "ext": { "bidder": { - "telaria": { - "adCode": "ssp-!demo!-lufip", - "seatCode": "test-code" - } + "adCode": "my-adcode", + "seatCode": "my-seatcode" } } } @@ -43,6 +41,7 @@ "imp": [ { "id": "some-impression-id", + "tagid": "my-adcode", "video": { "mimes": [ "video/mp4" @@ -53,24 +52,21 @@ "h": 480 }, "ext": { - "originalTagid": "" + "originalTagid": "ogTAGID", + "originalPublisherid": "123456789" } } ], "site": { "page": "test.com", "publisher": { - "id": "test-code" + "id": "my-seatcode" } }, "user": { "buyeruid": "awesome-user" }, - "tmax": 1000, - "ext": { - "prebid": {}, - "originalPublisherId": "someother-publisher-id" - } + "tmax": 1000 } }, "mockResponse": { diff --git a/static/bidder-params/telaria.json b/static/bidder-params/telaria.json index f2c8c0da910..b4121967351 100644 --- a/static/bidder-params/telaria.json +++ b/static/bidder-params/telaria.json @@ -13,7 +13,7 @@ "type": "string", "description": "Your Seat Code." }, - "originalPublisherId": { + "originalPublisherid": { "type": "string", "description": "publisher ID from the original request" } From 22b8a2d4e327d0b81dcb77b75cb63edc64dda311 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Mon, 6 Apr 2020 16:06:42 -0700 Subject: [PATCH 21/26] Added 'Telaria: ' prefix for error messages --- adapters/telaria/telaria.go | 20 +++++++++---------- .../supplemental/banner-unsupported.json | 2 +- .../supplemental/invalid-response.json | 2 +- .../invalid-telaria-ext-object.json | 2 +- .../supplemental/requires-imp-object.json | 2 +- .../supplemental/requires-seat-code.json | 2 +- .../supplemental/requires-video-object.json | 2 +- .../supplemental/status-code-bad-request.json | 2 +- .../supplemental/status-code-no-content.json | 2 +- .../supplemental/status-code-other-error.json | 2 +- .../status-code-service-unavailable.json | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 400383843e6..be99d4d958b 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -50,7 +50,7 @@ func (a *TelariaAdapter) FetchEndpoint() string { func (a *TelariaAdapter) CheckHasImps(request *openrtb.BidRequest) error { if len(request.Imp) == 0 { err := &errortypes.BadInput{ - Message: "No imp object in the bid request", + Message: "Telaria: Missing Imp Object", } return err } @@ -64,7 +64,7 @@ func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error for _, imp := range request.Imp { if imp.Banner != nil { return &errortypes.BadInput{ - Message: "Telaria doesn't support banner", + Message: "Telaria: Banner not supported", } } @@ -73,7 +73,7 @@ func (a *TelariaAdapter) CheckHasVideoObject(request *openrtb.BidRequest) error if !hasVideoObject { return &errortypes.BadInput{ - Message: "No Video object present in Imp object", + Message: "Telaria: Only Supports Video", } } @@ -116,7 +116,7 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex if err != nil { err = &errortypes.BadInput{ - Message: "ext.bidder not provided", + Message: "Telaria: ext.bidder not provided", } return nil, err @@ -130,7 +130,7 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex } if telariaExt.SeatCode == "" { - return nil, &errortypes.BadInput{Message: "Seat Code required"} + return nil, &errortypes.BadInput{Message: "Telaria: Seat Code required"} } return &telariaExt, nil @@ -252,24 +252,24 @@ func GetResponseBody(response *adapters.ResponseData) ([]byte, error) { func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error { if response.StatusCode == http.StatusNoContent { - return &errortypes.BadInput{Message: "Invalid Bid Request received by the server"} + return &errortypes.BadInput{Message: "Telaria: Invalid Bid Request received by the server"} } if response.StatusCode == http.StatusBadRequest { return &errortypes.BadInput{ - Message: fmt.Sprintf("Unexpected status code: [ %d ] ", response.StatusCode), + Message: fmt.Sprintf("Telaria: Unexpected status code: [ %d ] ", response.StatusCode), } } if response.StatusCode == http.StatusServiceUnavailable { return &errortypes.BadInput{ - Message: fmt.Sprintf("Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), + Message: fmt.Sprintf("Telaria: Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), } } if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices { return &errortypes.BadInput{ - Message: fmt.Sprintf("Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), + Message: fmt.Sprintf("Telaria: Something went wrong, please contact your Account Manager. Status Code: [ %d ] ", response.StatusCode), } } @@ -292,7 +292,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR var bidResp openrtb.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { return nil, []error{&errortypes.BadServerResponse{ - Message: "bad server response", + Message: "Telaria: Bad Server Response", }} } diff --git a/adapters/telaria/telariatest/supplemental/banner-unsupported.json b/adapters/telaria/telariatest/supplemental/banner-unsupported.json index 1cc9572f37c..1e75371dd22 100644 --- a/adapters/telaria/telariatest/supplemental/banner-unsupported.json +++ b/adapters/telaria/telariatest/supplemental/banner-unsupported.json @@ -2,7 +2,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Telaria doesn't support banner", + "value": "Telaria: Banner not supported", "comparison": "literal" } ], diff --git a/adapters/telaria/telariatest/supplemental/invalid-response.json b/adapters/telaria/telariatest/supplemental/invalid-response.json index 2de4c6ae081..8e4f1ee8cb5 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-response.json +++ b/adapters/telaria/telariatest/supplemental/invalid-response.json @@ -98,7 +98,7 @@ }], "expectedMakeBidsErrors": [ { - "value": "bad server response", + "value": "Telaria: Bad Server Response", "comparison": "literal" } ] diff --git a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json index 77752d01edf..efdec8ad61b 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json +++ b/adapters/telaria/telariatest/supplemental/invalid-telaria-ext-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "ext.bidder not provided", + "value": "Telaria: ext.bidder not provided", "comparison": "literal" } ], diff --git a/adapters/telaria/telariatest/supplemental/requires-imp-object.json b/adapters/telaria/telariatest/supplemental/requires-imp-object.json index 79e0cb1c286..5933dc4ee08 100644 --- a/adapters/telaria/telariatest/supplemental/requires-imp-object.json +++ b/adapters/telaria/telariatest/supplemental/requires-imp-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "No imp object in the bid request", + "value": "Telaria: Missing Imp Object", "comparison": "literal" } ], diff --git a/adapters/telaria/telariatest/supplemental/requires-seat-code.json b/adapters/telaria/telariatest/supplemental/requires-seat-code.json index bae912a7767..5c05e529772 100644 --- a/adapters/telaria/telariatest/supplemental/requires-seat-code.json +++ b/adapters/telaria/telariatest/supplemental/requires-seat-code.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "Seat Code required", + "value": "Telaria: Seat Code required", "comparison": "literal" } ], diff --git a/adapters/telaria/telariatest/supplemental/requires-video-object.json b/adapters/telaria/telariatest/supplemental/requires-video-object.json index fa2d2cac017..3f797c9e1de 100644 --- a/adapters/telaria/telariatest/supplemental/requires-video-object.json +++ b/adapters/telaria/telariatest/supplemental/requires-video-object.json @@ -1,7 +1,7 @@ { "expectedMakeRequestsErrors": [ { - "value": "No Video object present in Imp object", + "value": "Telaria: Only Supports Video", "comparison": "literal" } ], diff --git a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json index f0e7cb30e2e..0b5d8a85982 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-bad-request.json +++ b/adapters/telaria/telariatest/supplemental/status-code-bad-request.json @@ -73,7 +73,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Unexpected status code: [ 400 ] ", + "value": "Telaria: Unexpected status code: [ 400 ] ", "comparison": "literal" } ] diff --git a/adapters/telaria/telariatest/supplemental/status-code-no-content.json b/adapters/telaria/telariatest/supplemental/status-code-no-content.json index b702e47c593..ffb183f4121 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-no-content.json +++ b/adapters/telaria/telariatest/supplemental/status-code-no-content.json @@ -76,7 +76,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Invalid Bid Request received by the server", + "value": "Telaria: Invalid Bid Request received by the server", "comparison": "literal" } ] diff --git a/adapters/telaria/telariatest/supplemental/status-code-other-error.json b/adapters/telaria/telariatest/supplemental/status-code-other-error.json index 077c8b271d2..15e4b7f87d8 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-other-error.json +++ b/adapters/telaria/telariatest/supplemental/status-code-other-error.json @@ -76,7 +76,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Something went wrong, please contact your Account Manager. Status Code: [ 306 ] ", + "value": "Telaria: Something went wrong, please contact your Account Manager. Status Code: [ 306 ] ", "comparison": "literal" } ] diff --git a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json index 94db8e66a53..b92d4ea8ba1 100644 --- a/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json +++ b/adapters/telaria/telariatest/supplemental/status-code-service-unavailable.json @@ -76,7 +76,7 @@ "expectedBidResponses": [], "expectedMakeBidsErrors": [ { - "value": "Something went wrong, please contact your Account Manager. Status Code: [ 503 ] ", + "value": "Telaria: Something went wrong, please contact your Account Manager. Status Code: [ 503 ] ", "comparison": "literal" } ] From 53a1833238c0ba5ef1322665a7d105d6477b67e5 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Tue, 7 Apr 2020 16:35:56 -0700 Subject: [PATCH 22/26] - Fixes for race conditions. Was modifying the original request object instead of a copy --- adapters/telaria/telaria.go | 96 ++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 39 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index be99d4d958b..7dd50a4d66e 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -136,80 +136,98 @@ func (a *TelariaAdapter) FetchTelariaExtImpParams(imp *openrtb.Imp) (*openrtb_ex return &telariaExt, nil } -// This method changes .publisher.id to request.ext.telaria.seatCode -// And moves the publisher.id to request.ext.originalPublisherId -func (a *TelariaAdapter) PopulatePublisherId(request *openrtb.BidRequest, impExt *openrtb_ext.ExtImpTelaria) (string, error) { +// Method to fetch the original publisher ID. Note that this method must be called +// before we replace publisher.ID with seatCode +func (a *TelariaAdapter) FetchOriginalPublisherID(request *openrtb.BidRequest) string { + + if request.Site != nil && request.Site.Publisher != nil { + return request.Site.Publisher.ID + } else if request.App != nil && request.App.Publisher != nil { + return request.App.Publisher.ID + } - publisherObject := &openrtb.Publisher{ID: impExt.SeatCode} - originalPubId := "" + return "" +} - if request.Site != nil { - if request.Site.Publisher != nil { - if request.Site.Publisher.ID != "" { - originalPubId = request.Site.Publisher.ID - request.Site.Publisher.ID = impExt.SeatCode - } - } else { - request.Site.Publisher = publisherObject - } - } +// Method to do a deep copy of the publisher object. It also adds the seatCode as publisher.ID +func (a *TelariaAdapter) MakePublisherObject(seatCode string, publisher *openrtb.Publisher) *openrtb.Publisher { + var pub = &openrtb.Publisher{ID: seatCode} - if request.App != nil { - if request.App.Publisher != nil { - if request.App.Publisher.ID != "" { - originalPubId = request.App.Publisher.ID - request.App.Publisher.ID = impExt.SeatCode - } - } else { - request.App.Publisher = publisherObject - } + if publisher != nil { + pub.Domain = publisher.Domain + pub.Name = publisher.Name + pub.Cat = publisher.Cat + pub.Ext = publisher.Ext } - return originalPubId, nil + return pub +} + +// This method changes .publisher.id to the seatCode +func (a *TelariaAdapter) PopulatePublisherId(request *openrtb.BidRequest, seatCode string) (*openrtb.Site, *openrtb.App) { + if request.Site != nil { + siteCopy := *request.Site + siteCopy.Publisher = a.MakePublisherObject(seatCode, request.Site.Publisher) + return &siteCopy, nil + } else if request.App != nil { + appCopy := *request.App + appCopy.Publisher = a.MakePublisherObject(seatCode, request.App.Publisher) + return nil, &appCopy + } + return nil, nil } -func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { +func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + + // make a copy of the incoming request + request := *requestIn - if noImps := a.CheckHasImps(request); noImps != nil { + // ensure that the request has Impressions + if noImps := a.CheckHasImps(&request); noImps != nil { return nil, []error{noImps} } - if noVideoObjectError := a.CheckHasVideoObject(request); noVideoObjectError != nil { + // ensure that the request has a Video object + if noVideoObjectError := a.CheckHasVideoObject(&request); noVideoObjectError != nil { return nil, []error{noVideoObjectError} } + var seatCode string + originalPublisherID := a.FetchOriginalPublisherID(&request) + var errors []error for i, imp := range request.Imp { + // fetch adCode & seatCode from Imp[i].Ext telariaExt, err := a.FetchTelariaExtImpParams(&imp) - if err != nil { errors = append(errors, err) break } - var originalPublisherID string + seatCode = telariaExt.SeatCode - originalPublisherID, err = a.PopulatePublisherId(request, telariaExt) + // move the original tagId and the original publisher.id into the Imp[i].Ext object + request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{request.Imp[i].TagID, originalPublisherID}) if err != nil { errors = append(errors, err) break } - originalTagId := request.Imp[i].TagID + // Swap the tagID with adCode request.Imp[i].TagID = telariaExt.AdCode - request.Imp[i].Ext, err = json.Marshal(&ImpressionExtOut{originalTagId, originalPublisherID}) - if err != nil { - errors = append(errors, err) - break - } } if len(errors) > 0 { return nil, errors } - reqJSON, err := json.Marshal(request) + // Add seatCode to .Publisher.ID + siteObject, appObject := a.PopulatePublisherId(&request, seatCode) + request.Site = siteObject + request.App = appObject + + reqJSON, err := json.Marshal(request) if err != nil { return nil, []error{err} } @@ -218,7 +236,7 @@ func (a *TelariaAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adap Method: "POST", Uri: a.FetchEndpoint(), Body: reqJSON, - Headers: *GetHeaders(request), + Headers: *GetHeaders(&request), }}, nil } From 6f7cb771444e052d35faf8026f888a28924d71f5 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 8 Apr 2020 20:05:52 -0700 Subject: [PATCH 23/26] cosmetic changes. --- adapters/telaria/telaria.go | 7 ------- usersync/usersyncers/syncer.go | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 7dd50a4d66e..9edafa86a32 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -25,13 +25,6 @@ type ImpressionExtOut struct { OriginalPublisherID string `json:"originalPublisherid"` } -/* -// Full request extension including Telaria extension object -type ReqExtIn struct { - openrtb_ext.ExtRequest - Telaria *ReqExtTelariaIn `json:"telaria,omitempty"` -}*/ - // used for cookies and such func (a *TelariaAdapter) Name() string { return "telaria" diff --git a/usersync/usersyncers/syncer.go b/usersync/usersyncers/syncer.go index 362fcf2c972..da235402bf0 100644 --- a/usersync/usersyncers/syncer.go +++ b/usersync/usersyncers/syncer.go @@ -1,7 +1,6 @@ package usersyncers import ( - "github.com/prebid/prebid-server/adapters/telaria" "strings" "text/template" @@ -48,6 +47,7 @@ import ( "github.com/prebid/prebid-server/adapters/sonobi" "github.com/prebid/prebid-server/adapters/sovrn" "github.com/prebid/prebid-server/adapters/synacormedia" + "github.com/prebid/prebid-server/adapters/telaria" "github.com/prebid/prebid-server/adapters/triplelift" "github.com/prebid/prebid-server/adapters/triplelift_native" "github.com/prebid/prebid-server/adapters/ucfunnel" From 63eeb39917d1f18188db4226cb6429c72e05a272 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Wed, 8 Apr 2020 20:24:35 -0700 Subject: [PATCH 24/26] added params_test.go --- adapters/telaria/params_test.go | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 adapters/telaria/params_test.go diff --git a/adapters/telaria/params_test.go b/adapters/telaria/params_test.go new file mode 100644 index 00000000000..efa3fba1be9 --- /dev/null +++ b/adapters/telaria/params_test.go @@ -0,0 +1,50 @@ +package telaria + +import ( + "encoding/json" + "github.com/prebid/prebid-server/openrtb_ext" + "testing" +) + +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.BidderTelaria, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected Telaria params: %s", validParam) + } + } +} + +// TestInvalidParams makes sure that the Telaria 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.BidderTelaria, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"adCode": "string", "seatCode": "string", "originalPublisherid": "string"}`, +} + +var invalidParams = []string{ + ``, + `null`, + `true`, + `5`, + `4.2`, + `[]`, + `{}`, + `{"adCode": "string", "originalPublisherid": "string"}`, + `{"adCode": "string", "seatCode": 5, "originalPublisherid": "string"}`, +} From 08db57bfbc9e5af440048e908a88736d50e48a84 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Thu, 28 May 2020 15:26:35 -0700 Subject: [PATCH 25/26] Removed some redundant methods. --- adapters/telaria/telaria.go | 38 +------------------ .../telariatest/exemplary/video-app.json | 1 - .../telariatest/exemplary/video-web.json | 1 - .../supplemental/invalid-response.json | 1 - 4 files changed, 2 insertions(+), 39 deletions(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 9edafa86a32..28698b3086c 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -1,8 +1,6 @@ package telaria import ( - "bytes" - "compress/gzip" "encoding/json" "fmt" "github.com/mxmCherry/openrtb" @@ -79,7 +77,7 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") headers.Add("X-Openrtb-Version", "2.5") - headers.Add("Accept-Encoding", "gzip") + /*headers.Add("Accept-Encoding", "gzip")*/ if request.Device != nil { if len(request.Device.UA) > 0 { @@ -233,34 +231,6 @@ func (a *TelariaAdapter) MakeRequests(requestIn *openrtb.BidRequest, reqInfo *ad }}, nil } -// response isn't automatically decompressed. This method unzips the response if Content-Encoding is gzip -func GetResponseBody(response *adapters.ResponseData) ([]byte, error) { - - if "gzip" == response.Headers.Get("Content-Encoding") { - body := bytes.NewBuffer(response.Body) - r, readerErr := gzip.NewReader(body) - if readerErr != nil { - return nil, &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode), - } - } - var resB bytes.Buffer - var err error - _, err = resB.ReadFrom(r) - if err != nil { - return nil, &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Error while trying to unzip data [ %d ]", response.StatusCode), - } - } - - response.Headers.Del("Content-Encoding") - - return resB.Bytes(), nil - } else { - return response.Body, nil - } -} - func (a *TelariaAdapter) CheckResponseStatusCodes(response *adapters.ResponseData) error { if response.StatusCode == http.StatusNoContent { return &errortypes.BadInput{Message: "Telaria: Invalid Bid Request received by the server"} @@ -294,11 +264,7 @@ func (a *TelariaAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalR return nil, []error{httpStatusError} } - responseBody, err := GetResponseBody(response) - - if err != nil { - return nil, []error{err} - } + responseBody := response.Body var bidResp openrtb.BidResponse if err := json.Unmarshal(responseBody, &bidResp); err != nil { diff --git a/adapters/telaria/telariatest/exemplary/video-app.json b/adapters/telaria/telariatest/exemplary/video-app.json index 09bcf998454..fa755cc93d3 100644 --- a/adapters/telaria/telariatest/exemplary/video-app.json +++ b/adapters/telaria/telariatest/exemplary/video-app.json @@ -51,7 +51,6 @@ "Content-Type": ["application/json;charset=utf-8"], "Accept": ["application/json"], "X-Openrtb-Version": ["2.5"], - "Accept-Encoding": ["gzip"], "User-Agent": ["test-user-agent"], "X-Forwarded-For": ["123.123.123.123"], "Accept-Language": ["en"], diff --git a/adapters/telaria/telariatest/exemplary/video-web.json b/adapters/telaria/telariatest/exemplary/video-web.json index 5dc26b0f018..c671d2f5f30 100644 --- a/adapters/telaria/telariatest/exemplary/video-web.json +++ b/adapters/telaria/telariatest/exemplary/video-web.json @@ -45,7 +45,6 @@ "Content-Type": ["application/json;charset=utf-8"], "Accept": ["application/json"], "X-Openrtb-Version": ["2.5"], - "Accept-Encoding": ["gzip"], "User-Agent": ["test-user-agent"], "X-Forwarded-For": ["123.123.123.123"], "Accept-Language": ["en"], diff --git a/adapters/telaria/telariatest/supplemental/invalid-response.json b/adapters/telaria/telariatest/supplemental/invalid-response.json index 8e4f1ee8cb5..3f614a0724c 100644 --- a/adapters/telaria/telariatest/supplemental/invalid-response.json +++ b/adapters/telaria/telariatest/supplemental/invalid-response.json @@ -45,7 +45,6 @@ "Content-Type": ["application/json;charset=utf-8"], "Accept": ["application/json"], "X-Openrtb-Version": ["2.5"], - "Accept-Encoding": ["gzip"], "User-Agent": ["test-user-agent"], "X-Forwarded-For": ["123.123.123.123"], "Accept-Language": ["en"], From 57172967e921d9c93eef5c3c486af6e2629a2fa1 Mon Sep 17 00:00:00 2001 From: Vinay Prasad Date: Fri, 29 May 2020 09:03:02 -0700 Subject: [PATCH 26/26] Removed a comment --- adapters/telaria/telaria.go | 1 - 1 file changed, 1 deletion(-) diff --git a/adapters/telaria/telaria.go b/adapters/telaria/telaria.go index 28698b3086c..294d0d100a9 100644 --- a/adapters/telaria/telaria.go +++ b/adapters/telaria/telaria.go @@ -77,7 +77,6 @@ func GetHeaders(request *openrtb.BidRequest) *http.Header { headers.Add("Content-Type", "application/json;charset=utf-8") headers.Add("Accept", "application/json") headers.Add("X-Openrtb-Version", "2.5") - /*headers.Add("Accept-Encoding", "gzip")*/ if request.Device != nil { if len(request.Device.UA) > 0 {