From 64b80feed00b3976421ceb6527683463692179d3 Mon Sep 17 00:00:00 2001 From: Vasyl Zarva Date: Tue, 26 Jan 2021 14:58:19 +0200 Subject: [PATCH 1/4] epom adapter implementation --- adapters/epom/epom.go | 172 ++++++++++++++++++ adapters/epom/epom_test.go | 20 ++ .../epomtest/exemplary/simple-app-banner.json | 105 +++++++++++ .../epomtest/exemplary/simple-app-native.json | 91 +++++++++ .../epomtest/exemplary/simple-app-video.json | 115 ++++++++++++ .../exemplary/simple-site-banner.json | 105 +++++++++++ .../exemplary/simple-site-native.json | 92 ++++++++++ .../epomtest/exemplary/simple-site-video.json | 115 ++++++++++++ .../epom/epomtest/params/race/banner.json | 2 + .../epom/epomtest/params/race/native.json | 2 + adapters/epom/epomtest/params/race/video.json | 2 + .../supplemental/bad-request-no-device.json | 27 +++ .../supplemental/bad-request-no-imp-id.json | 29 +++ .../bad-request-no-impressions.json | 19 ++ .../supplemental/bad-request-no-ip.json | 29 +++ .../bad-request-no-site-or-app.json | 27 +++ ...d-request-site-and-app-simultaneously.json | 33 ++++ .../bad-response-bad-request-error.json | 72 ++++++++ .../bad-response-server-internal-error.json | 72 ++++++++ .../bad-response-unexpected-error.json | 72 ++++++++ config/config.go | 3 + exchange/adapter_builders.go | 2 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_epom.go | 4 + static/bidder-info/epom.yaml | 14 ++ static/bidder-params/epom.json | 8 + usersync/usersyncers/syncer_test.go | 1 + 27 files changed, 1235 insertions(+) create mode 100644 adapters/epom/epom.go create mode 100644 adapters/epom/epom_test.go create mode 100644 adapters/epom/epomtest/exemplary/simple-app-banner.json create mode 100644 adapters/epom/epomtest/exemplary/simple-app-native.json create mode 100644 adapters/epom/epomtest/exemplary/simple-app-video.json create mode 100644 adapters/epom/epomtest/exemplary/simple-site-banner.json create mode 100644 adapters/epom/epomtest/exemplary/simple-site-native.json create mode 100644 adapters/epom/epomtest/exemplary/simple-site-video.json create mode 100644 adapters/epom/epomtest/params/race/banner.json create mode 100644 adapters/epom/epomtest/params/race/native.json create mode 100644 adapters/epom/epomtest/params/race/video.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-device.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-impressions.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-ip.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json create mode 100644 adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json create mode 100644 adapters/epom/epomtest/supplemental/bad-response-bad-request-error.json create mode 100644 adapters/epom/epomtest/supplemental/bad-response-server-internal-error.json create mode 100644 adapters/epom/epomtest/supplemental/bad-response-unexpected-error.json create mode 100644 openrtb_ext/imp_epom.go create mode 100644 static/bidder-info/epom.yaml create mode 100644 static/bidder-params/epom.json diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go new file mode 100644 index 00000000000..e12de7fdbb8 --- /dev/null +++ b/adapters/epom/epom.go @@ -0,0 +1,172 @@ +package epom + +import ( + "encoding/json" + "fmt" + "net/http" + + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" +) + +type EpomAdapter struct { + endpoint string +} + +// Builder builds a new instance of the Epom adapter for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { + bidder := &EpomAdapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (a *EpomAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { + rq, errs := a.makeRequest(request) + + if len(errs) > 0 { + errors = append(errors, errs...) + return nil, errors + } + + if rq != nil { + requests = append(requests, rq) + } + + return requests, errors +} + +func (a *EpomAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { + var errs []error + var validImps []openrtb.Imp + + if len(request.Imp) == 0 { + return nil, []error{&errortypes.BadInput{ + Message: "No impressions in request", + }} + } + + if request.Device == nil || request.Device.IP == "" { + return nil, []error{&errortypes.BadInput{ + Message: "No ip address in request", + }} + } + + if request.Site == nil && request.App == nil { + return nil, []error{&errortypes.BadInput{ + Message: "Site or app field shouldn't be empty", + }} + } + + if request.Site != nil && request.App != nil { + return nil, []error{&errortypes.BadInput{ + Message: "Site and app can't be filled simultaneously", + }} + } + + for _, imp := range request.Imp { + if err := preprocess(&imp); err != nil { + errs = append(errs, err) + continue + } + validImps = append(validImps, imp) + } + + if len(validImps) == 0 { + return nil, errs + } + + request.Imp = validImps + + reqJSON, err := json.Marshal(request) + 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") + return &adapters.RequestData{ + Method: "POST", + Uri: a.endpoint, + Body: reqJSON, + Headers: headers, + }, errs +} + +func preprocess(imp *openrtb.Imp) error { + if imp.ID == "" { + return &errortypes.BadInput{ + Message: "Impression id is empty", + } + } + + return nil +} + +func (a *EpomAdapter) 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.StatusInternalServerError { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d. Dsp server internal error", response.StatusCode), + }} + } + + if response.StatusCode >= http.StatusBadRequest { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unexpected status code: %d. Bad request to dsp", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("Unexpected status code: %d", response.StatusCode), + }} + } + + var bidResp openrtb.BidResponse + if err := json.Unmarshal(response.Body, &bidResp); err != nil { + return nil, []error{err} + } + + //additional no content check + if len(bidResp.SeatBid) == 0 || len(bidResp.SeatBid[0].Bid) == 0 { + return nil, nil + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.SeatBid[0].Bid)) + + var errs []error + for _, seatBid := range bidResp.SeatBid { + for _, bid := range seatBid.Bid { + b := &adapters.TypedBid{ + Bid: &bid, + BidType: getMediaTypeForImp(bid.ImpID, internalRequest.Imp), + } + bidResponse.Bids = append(bidResponse.Bids, b) + } + } + return bidResponse, errs +} + +func getMediaTypeForImp(impID string, imps []openrtb.Imp) openrtb_ext.BidType { + for _, imp := range imps { + if imp.ID == impID { + if imp.Banner != nil { + return openrtb_ext.BidTypeBanner + } else if imp.Video != nil { + return openrtb_ext.BidTypeVideo + } else if imp.Native != nil { + return openrtb_ext.BidTypeNative + } + } + } + return openrtb_ext.BidTypeBanner +} diff --git a/adapters/epom/epom_test.go b/adapters/epom/epom_test.go new file mode 100644 index 00000000000..7991f4eabc7 --- /dev/null +++ b/adapters/epom/epom_test.go @@ -0,0 +1,20 @@ +package epom + +import ( + "testing" + + "github.com/prebid/prebid-server/adapters/adapterstest" + "github.com/prebid/prebid-server/config" + "github.com/prebid/prebid-server/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderEpom, config.Adapter{ + Endpoint: "https://an.epom.com/ortb"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "epomtest", bidder) +} diff --git a/adapters/epom/epomtest/exemplary/simple-app-banner.json b/adapters/epom/epomtest/exemplary/simple-app-banner.json new file mode 100644 index 00000000000..f24b5b6e25f --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-app-banner.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "epom", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "test-adm", + "crid": "test-crid", + "h": 50, + "w": 300 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "test-adm", + "crid": "test-crid", + "w": 300, + "h": 50 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/exemplary/simple-app-native.json b/adapters/epom/epomtest/exemplary/simple-app-native.json new file mode 100644 index 00000000000..1504870b3a2 --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-app-native.json @@ -0,0 +1,91 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "ver": "1.1", + "request": "{\"ver\":\"1.0\",\"layout\":1,\"adunit\":1,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":60,\"hmin\":60,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":3,\"required\":0,\"data\":{\"type\":2,\"len\":75}},{\"id\":4,\"required\":0,\"data\":{\"type\":6,\"len\":1000}},{\"id\":5,\"required\":0,\"data\":{\"type\":7,\"len\":1000}},{\"id\":6,\"required\":0,\"data\":{\"type\":11,\"len\":1000}}]}" + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "ver": "1.1", + "request": "{\"ver\":\"1.0\",\"layout\":1,\"adunit\":1,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":60,\"hmin\":60,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":3,\"required\":0,\"data\":{\"type\":2,\"len\":75}},{\"id\":4,\"required\":0,\"data\":{\"type\":6,\"len\":1000}},{\"id\":5,\"required\":0,\"data\":{\"type\":7,\"len\":1000}},{\"id\":6,\"required\":0,\"data\":{\"type\":11,\"len\":1000}}]}" + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "epom", + "bid": [{ + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-adm", + "crid": "test-crid" + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-adm", + "crid": "test-crid" + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/exemplary/simple-app-video.json b/adapters/epom/epomtest/exemplary/simple-app-video.json new file mode 100644 index 00000000000..af210467f78 --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-app-video.json @@ -0,0 +1,115 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "epom", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-adm", + "crid": "test-crid", + "w": 1024, + "h": 576 + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-adm", + "crid": "test-crid", + "w": 1024, + "h": 576 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/exemplary/simple-site-banner.json b/adapters/epom/epomtest/exemplary/simple-site-banner.json new file mode 100644 index 00000000000..65d05977424 --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-site-banner.json @@ -0,0 +1,105 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "epom", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-adm", + "crid": "test-crid", + "h": 50, + "w": 300 + } + ] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-adm", + "crid": "test-crid", + "w": 300, + "h": 50 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/exemplary/simple-site-native.json b/adapters/epom/epomtest/exemplary/simple-site-native.json new file mode 100644 index 00000000000..0ae393f5704 --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-site-native.json @@ -0,0 +1,92 @@ + +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "ver": "1.1", + "request": "{\"ver\":\"1.0\",\"layout\":1,\"adunit\":1,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":60,\"hmin\":60,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":3,\"required\":0,\"data\":{\"type\":2,\"len\":75}},{\"id\":4,\"required\":0,\"data\":{\"type\":6,\"len\":1000}},{\"id\":5,\"required\":0,\"data\":{\"type\":7,\"len\":1000}},{\"id\":6,\"required\":0,\"data\":{\"type\":11,\"len\":1000}}]}" + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "native": { + "ver": "1.1", + "request": "{\"ver\":\"1.0\",\"layout\":1,\"adunit\":1,\"plcmttype\":1,\"plcmtcnt\":1,\"seq\":0,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"type\":3,\"wmin\":60,\"hmin\":60,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":3,\"required\":0,\"data\":{\"type\":2,\"len\":75}},{\"id\":4,\"required\":0,\"data\":{\"type\":6,\"len\":1000}},{\"id\":5,\"required\":0,\"data\":{\"type\":7,\"len\":1000}},{\"id\":6,\"required\":0,\"data\":{\"type\":11,\"len\":1000}}]}" + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "epom", + "bid": [{ + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-adm", + "crid": "test-crid" + }] + } + ], + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-adm", + "crid": "test-crid" + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/exemplary/simple-site-video.json b/adapters/epom/epomtest/exemplary/simple-site-video.json new file mode 100644 index 00000000000..fdf89011dd5 --- /dev/null +++ b/adapters/epom/epomtest/exemplary/simple-site-video.json @@ -0,0 +1,115 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + } + } + ] + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "video": { + "mimes": [ + "video/mp4" + ], + "protocols": [ + 2, + 3, + 5, + 6 + ], + "w": 1024, + "h": 576 + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "epom", + "bid": [ + { + "id": "1", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-adm", + "crid": "test-crid", + "w": 1024, + "h": 576 + } + ] + } + ] + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "1", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-adm", + "crid": "test-crid", + "w": 1024, + "h": 576 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/epom/epomtest/params/race/banner.json b/adapters/epom/epomtest/params/race/banner.json new file mode 100644 index 00000000000..2c63c085104 --- /dev/null +++ b/adapters/epom/epomtest/params/race/banner.json @@ -0,0 +1,2 @@ +{ +} diff --git a/adapters/epom/epomtest/params/race/native.json b/adapters/epom/epomtest/params/race/native.json new file mode 100644 index 00000000000..7a73a41bfdf --- /dev/null +++ b/adapters/epom/epomtest/params/race/native.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/adapters/epom/epomtest/params/race/video.json b/adapters/epom/epomtest/params/race/video.json new file mode 100644 index 00000000000..2c63c085104 --- /dev/null +++ b/adapters/epom/epomtest/params/race/video.json @@ -0,0 +1,2 @@ +{ +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-device.json b/adapters/epom/epomtest/supplemental/bad-request-no-device.json new file mode 100644 index 00000000000..4a01639fd0b --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-no-device.json @@ -0,0 +1,27 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "No ip address in request", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json b/adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json new file mode 100644 index 00000000000..4271b96e07f --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json @@ -0,0 +1,29 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Impression id is empty", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json b/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json new file mode 100644 index 00000000000..3a6c1db418d --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json @@ -0,0 +1,19 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "No impressions in request", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-ip.json b/adapters/epom/epomtest/supplemental/bad-request-no-ip.json new file mode 100644 index 00000000000..e9245357696 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-no-ip.json @@ -0,0 +1,29 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "No ip address in request", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json b/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json new file mode 100644 index 00000000000..9f32235b6fd --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json @@ -0,0 +1,27 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Site or app field shouldn't be empty", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json b/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json new file mode 100644 index 00000000000..de30c75b3a8 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json @@ -0,0 +1,33 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "expectedMakeRequestsErrors": [ + { + "value": "Site and app can't be filled simultaneously", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-response-bad-request-error.json b/adapters/epom/epomtest/supplemental/bad-response-bad-request-error.json new file mode 100644 index 00000000000..b278bc9ce17 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-response-bad-request-error.json @@ -0,0 +1,72 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 400, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Bad request to dsp", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-response-server-internal-error.json b/adapters/epom/epomtest/supplemental/bad-response-server-internal-error.json new file mode 100644 index 00000000000..402990ebb84 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-response-server-internal-error.json @@ -0,0 +1,72 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "app": { + "bundle": "com.prebid" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 500, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 500. Dsp server internal error", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-response-unexpected-error.json b/adapters/epom/epomtest/supplemental/bad-response-unexpected-error.json new file mode 100644 index 00000000000..23e5e974033 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-response-unexpected-error.json @@ -0,0 +1,72 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 301, + "body": { + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 301", + "comparison": "literal" + } + ] +} diff --git a/config/config.go b/config/config.go index 6577c1fbb5e..bcfe6107f93 100755 --- a/config/config.go +++ b/config/config.go @@ -595,6 +595,7 @@ func (cfg *Configuration) setDerivedDefaults() { setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEmxDigital, "https://cs.emxdgt.com/um?ssp=pbs&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Demx_digital%26uid%3D%24UID") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEngageBDR, "https://match.bnmla.com/usersync/s2s_sync?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&r="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dengagebdr%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24%7BUUID%7D") setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderEPlanning, "https://ads.us.e-planning.net/uspd/1/?du="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Deplanning%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%24UID") + // openrtb_ext.BidderEpom doesn't have a good default. // openrtb_ext.BidderFacebook doesn't have a good default. // openrtb_ext.BidderGamma doesn't have a good default. setDefaultUsersync(cfg.Adapters, openrtb_ext.BidderGamoshi, "https://rtb.gamoshi.io/user_sync_prebid?gdpr={{.GDPR}}&consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&rurl="+url.QueryEscape(externalURL)+"%2Fsetuid%3Fbidder%3Dgamoshi%26gdpr%3D{{.GDPR}}%26gdpr_consent%3D{{.GDPRConsent}}%26uid%3D%5Bgusr%5D") @@ -833,6 +834,8 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.emx_digital.endpoint", "https://hb.emxdgt.com") v.SetDefault("adapters.engagebdr.endpoint", "http://dsp.bnmla.com/hb") v.SetDefault("adapters.eplanning.endpoint", "http://rtb.e-planning.net/pbs/1") + v.SetDefault("adapters.epom.endpoint", "https://an.epom.com/ortb") + v.SetDefault("adapters.epom.disabled", true) v.SetDefault("adapters.gamma.endpoint", "https://hb.gammaplatform.com/adx/request/") v.SetDefault("adapters.gamoshi.endpoint", "https://rtb.gamoshi.io") v.SetDefault("adapters.grid.endpoint", "https://grid.bidswitch.net/sp_bid?sp=prebid") diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 31342a4c5ff..a970d6b3409 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -40,6 +40,7 @@ import ( "github.com/prebid/prebid-server/adapters/emx_digital" "github.com/prebid/prebid-server/adapters/engagebdr" "github.com/prebid/prebid-server/adapters/eplanning" + "github.com/prebid/prebid-server/adapters/epom" "github.com/prebid/prebid-server/adapters/gamma" "github.com/prebid/prebid-server/adapters/gamoshi" "github.com/prebid/prebid-server/adapters/grid" @@ -140,6 +141,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderEmxDigital: emx_digital.Builder, openrtb_ext.BidderEngageBDR: engagebdr.Builder, openrtb_ext.BidderEPlanning: eplanning.Builder, + openrtb_ext.BidderEpom: epom.Builder, openrtb_ext.BidderGamma: gamma.Builder, openrtb_ext.BidderGamoshi: gamoshi.Builder, openrtb_ext.BidderGrid: grid.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index c0839632c7e..769f953eea8 100755 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -78,6 +78,7 @@ const ( BidderEmxDigital BidderName = "emx_digital" BidderEngageBDR BidderName = "engagebdr" BidderEPlanning BidderName = "eplanning" + BidderEpom BidderName = "epom" BidderGamma BidderName = "gamma" BidderGamoshi BidderName = "gamoshi" BidderGrid BidderName = "grid" @@ -178,6 +179,7 @@ func CoreBidderNames() []BidderName { BidderEmxDigital, BidderEngageBDR, BidderEPlanning, + BidderEpom, BidderGamma, BidderGamoshi, BidderGrid, diff --git a/openrtb_ext/imp_epom.go b/openrtb_ext/imp_epom.go new file mode 100644 index 00000000000..a99f60ef368 --- /dev/null +++ b/openrtb_ext/imp_epom.go @@ -0,0 +1,4 @@ +package openrtb_ext + +type ImpExtEpom struct { +} diff --git a/static/bidder-info/epom.yaml b/static/bidder-info/epom.yaml new file mode 100644 index 00000000000..32afa346c9e --- /dev/null +++ b/static/bidder-info/epom.yaml @@ -0,0 +1,14 @@ +maintainer: + email: "support@epom.com" +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - native + site: + mediaTypes: + - banner + - video + - native diff --git a/static/bidder-params/epom.json b/static/bidder-params/epom.json new file mode 100644 index 00000000000..ee8c14e4f7e --- /dev/null +++ b/static/bidder-params/epom.json @@ -0,0 +1,8 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Epom Adapter Params", + "description": "A schema which validates params accepted by the Epom adapter", + "type": "object", + + "properties": {} +} diff --git a/usersync/usersyncers/syncer_test.go b/usersync/usersyncers/syncer_test.go index bca8623d98b..458eca2d3ca 100755 --- a/usersync/usersyncers/syncer_test.go +++ b/usersync/usersyncers/syncer_test.go @@ -101,6 +101,7 @@ func TestNewSyncerMap(t *testing.T) { openrtb_ext.BidderAdot: true, openrtb_ext.BidderAdprime: true, openrtb_ext.BidderApplogy: true, + openrtb_ext.BidderEpom: true, openrtb_ext.BidderInMobi: true, openrtb_ext.BidderKidoz: true, openrtb_ext.BidderKubient: true, From 89c104f5c3c7bd822664c4dc1c387ab953ec627e Mon Sep 17 00:00:00 2001 From: Vasyl Zarva Date: Thu, 28 Jan 2021 15:31:36 +0200 Subject: [PATCH 2/4] Epom Adapter impl: pull request fixes --- adapters/epom/epom.go | 27 ++++----------- .../bad-request-no-impressions.json | 19 ----------- ...d-request-site-and-app-simultaneously.json | 33 ------------------- 3 files changed, 7 insertions(+), 72 deletions(-) delete mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-impressions.json delete mode 100644 adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go index e12de7fdbb8..50c695ec002 100644 --- a/adapters/epom/epom.go +++ b/adapters/epom/epom.go @@ -12,43 +12,36 @@ import ( "github.com/prebid/prebid-server/openrtb_ext" ) -type EpomAdapter struct { +type adapter struct { endpoint string } // Builder builds a new instance of the Epom adapter for the given bidder with the given config. func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) { - bidder := &EpomAdapter{ + bidder := &adapter{ endpoint: config.Endpoint, } return bidder, nil } -func (a *EpomAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { +func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.ExtraRequestInfo) (requests []*adapters.RequestData, errors []error) { rq, errs := a.makeRequest(request) if len(errs) > 0 { - errors = append(errors, errs...) - return nil, errors + return nil, errs } if rq != nil { requests = append(requests, rq) } - return requests, errors + return requests, nil } -func (a *EpomAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { +func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { var errs []error var validImps []openrtb.Imp - if len(request.Imp) == 0 { - return nil, []error{&errortypes.BadInput{ - Message: "No impressions in request", - }} - } - if request.Device == nil || request.Device.IP == "" { return nil, []error{&errortypes.BadInput{ Message: "No ip address in request", @@ -61,12 +54,6 @@ func (a *EpomAdapter) makeRequest(request *openrtb.BidRequest) (*adapters.Reques }} } - if request.Site != nil && request.App != nil { - return nil, []error{&errortypes.BadInput{ - Message: "Site and app can't be filled simultaneously", - }} - } - for _, imp := range request.Imp { if err := preprocess(&imp); err != nil { errs = append(errs, err) @@ -108,7 +95,7 @@ func preprocess(imp *openrtb.Imp) error { return nil } -func (a *EpomAdapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { +func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { if response.StatusCode == http.StatusNoContent { return nil, nil } diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json b/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json deleted file mode 100644 index 3a6c1db418d..00000000000 --- a/adapters/epom/epomtest/supplemental/bad-request-no-impressions.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "site": { - "page": "prebid.org" - }, - "device": { - "ip":"238.89.104.156" - }, - "imp": [ - ] - }, - "expectedMakeRequestsErrors": [ - { - "value": "No impressions in request", - "comparison": "literal" - } - ] -} diff --git a/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json b/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json deleted file mode 100644 index de30c75b3a8..00000000000 --- a/adapters/epom/epomtest/supplemental/bad-request-site-and-app-simultaneously.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "site": { - "page": "prebid.org" - }, - "app": { - "bundle": "com.prebid" - }, - "device": { - "ip":"238.89.104.156" - }, - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 50 - } - ] - } - } - ] - }, - "expectedMakeRequestsErrors": [ - { - "value": "Site and app can't be filled simultaneously", - "comparison": "literal" - } - ] -} From ff556f89d4f58f396ecd2ce8e138229915db78bd Mon Sep 17 00:00:00 2001 From: Vasyl Zarva Date: Mon, 15 Feb 2021 13:16:12 +0200 Subject: [PATCH 3/4] Epom Adapter impl: pull request fixes --- adapters/epom/epom.go | 12 +++------ ...> bad-request-audio-is-not-supported.json} | 11 +++----- .../supplemental/bad-request-no-device.json | 2 +- .../supplemental/bad-request-no-ip.json | 2 +- .../bad-request-no-site-or-app.json | 27 ------------------- 5 files changed, 9 insertions(+), 45 deletions(-) rename adapters/epom/epomtest/supplemental/{bad-request-no-imp-id.json => bad-request-audio-is-not-supported.json} (65%) delete mode 100644 adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go index 50c695ec002..786830945e0 100644 --- a/adapters/epom/epom.go +++ b/adapters/epom/epom.go @@ -44,13 +44,7 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat if request.Device == nil || request.Device.IP == "" { return nil, []error{&errortypes.BadInput{ - Message: "No ip address in request", - }} - } - - if request.Site == nil && request.App == nil { - return nil, []error{&errortypes.BadInput{ - Message: "Site or app field shouldn't be empty", + Message: "ipv4 address is required field", }} } @@ -86,9 +80,9 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat } func preprocess(imp *openrtb.Imp) error { - if imp.ID == "" { + if imp.Audio != nil { return &errortypes.BadInput{ - Message: "Impression id is empty", + Message: "Audio is not supported", } } diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json b/adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json similarity index 65% rename from adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json rename to adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json index 4271b96e07f..422e7ec20cf 100644 --- a/adapters/epom/epomtest/supplemental/bad-request-no-imp-id.json +++ b/adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json @@ -9,12 +9,9 @@ }, "imp": [ { - "banner": { - "format": [ - { - "w": 300, - "h": 50 - } + "audio": { + "mimes": [ + "audio/mp4" ] } } @@ -22,7 +19,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "Impression id is empty", + "value": "Audio is not supported", "comparison": "literal" } ] diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-device.json b/adapters/epom/epomtest/supplemental/bad-request-no-device.json index 4a01639fd0b..87267fca88b 100644 --- a/adapters/epom/epomtest/supplemental/bad-request-no-device.json +++ b/adapters/epom/epomtest/supplemental/bad-request-no-device.json @@ -20,7 +20,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "No ip address in request", + "value": "ipv4 address is required field", "comparison": "literal" } ] diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-ip.json b/adapters/epom/epomtest/supplemental/bad-request-no-ip.json index e9245357696..42db8fc489b 100644 --- a/adapters/epom/epomtest/supplemental/bad-request-no-ip.json +++ b/adapters/epom/epomtest/supplemental/bad-request-no-ip.json @@ -22,7 +22,7 @@ }, "expectedMakeRequestsErrors": [ { - "value": "No ip address in request", + "value": "ipv4 address is required field", "comparison": "literal" } ] diff --git a/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json b/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json deleted file mode 100644 index 9f32235b6fd..00000000000 --- a/adapters/epom/epomtest/supplemental/bad-request-no-site-or-app.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "device": { - "ip":"238.89.104.156" - }, - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 50 - } - ] - } - } - ] - }, - "expectedMakeRequestsErrors": [ - { - "value": "Site or app field shouldn't be empty", - "comparison": "literal" - } - ] -} From cbf13c7acec7208715ef3632a9ea7b20534ed6c0 Mon Sep 17 00:00:00 2001 From: Vasyl Zarva Date: Thu, 18 Feb 2021 19:19:12 +0200 Subject: [PATCH 4/4] Epom Adapter impl: pull request fixes and improvements --- adapters/epom/epom.go | 36 ++------- .../bad-request-audio-is-not-supported.json | 26 ------- .../bad-response-no-bid-obj-error.json | 75 +++++++++++++++++++ .../bad-response-no-seatbid-error.json | 74 ++++++++++++++++++ 4 files changed, 154 insertions(+), 57 deletions(-) delete mode 100644 adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json create mode 100644 adapters/epom/epomtest/supplemental/bad-response-no-bid-obj-error.json create mode 100644 adapters/epom/epomtest/supplemental/bad-response-no-seatbid-error.json diff --git a/adapters/epom/epom.go b/adapters/epom/epom.go index 786830945e0..4cb9a364cbd 100644 --- a/adapters/epom/epom.go +++ b/adapters/epom/epom.go @@ -39,33 +39,15 @@ func (a *adapter) MakeRequests(request *openrtb.BidRequest, reqInfo *adapters.Ex } func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestData, []error) { - var errs []error - var validImps []openrtb.Imp - if request.Device == nil || request.Device.IP == "" { return nil, []error{&errortypes.BadInput{ Message: "ipv4 address is required field", }} } - for _, imp := range request.Imp { - if err := preprocess(&imp); err != nil { - errs = append(errs, err) - continue - } - validImps = append(validImps, imp) - } - - if len(validImps) == 0 { - return nil, errs - } - - request.Imp = validImps - reqJSON, err := json.Marshal(request) if err != nil { - errs = append(errs, err) - return nil, errs + return nil, []error{err} } headers := http.Header{} @@ -76,17 +58,7 @@ func (a *adapter) makeRequest(request *openrtb.BidRequest) (*adapters.RequestDat Uri: a.endpoint, Body: reqJSON, Headers: headers, - }, errs -} - -func preprocess(imp *openrtb.Imp) error { - if imp.Audio != nil { - return &errortypes.BadInput{ - Message: "Audio is not supported", - } - } - - return nil + }, nil } func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { @@ -119,7 +91,9 @@ func (a *adapter) MakeBids(internalRequest *openrtb.BidRequest, externalRequest //additional no content check if len(bidResp.SeatBid) == 0 || len(bidResp.SeatBid[0].Bid) == 0 { - return nil, nil + return nil, []error{&errortypes.Warning{ + Message: "No bids in response", + }} } bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(bidResp.SeatBid[0].Bid)) diff --git a/adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json b/adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json deleted file mode 100644 index 422e7ec20cf..00000000000 --- a/adapters/epom/epomtest/supplemental/bad-request-audio-is-not-supported.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "mockBidRequest": { - "id": "test-request-id", - "site": { - "page": "prebid.org" - }, - "device": { - "ip":"238.89.104.156" - }, - "imp": [ - { - "audio": { - "mimes": [ - "audio/mp4" - ] - } - } - ] - }, - "expectedMakeRequestsErrors": [ - { - "value": "Audio is not supported", - "comparison": "literal" - } - ] -} diff --git a/adapters/epom/epomtest/supplemental/bad-response-no-bid-obj-error.json b/adapters/epom/epomtest/supplemental/bad-response-no-bid-obj-error.json new file mode 100644 index 00000000000..47eea3a44c2 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-response-no-bid-obj-error.json @@ -0,0 +1,75 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [] + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "No bids in response", + "comparison": "literal" + } + ] +} diff --git a/adapters/epom/epomtest/supplemental/bad-response-no-seatbid-error.json b/adapters/epom/epomtest/supplemental/bad-response-no-seatbid-error.json new file mode 100644 index 00000000000..ef8c7698f32 --- /dev/null +++ b/adapters/epom/epomtest/supplemental/bad-response-no-seatbid-error.json @@ -0,0 +1,74 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://an.epom.com/ortb", + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json;charset=utf-8" + ] + }, + "body": { + "id": "test-request-id", + "site": { + "page": "prebid.org" + }, + "device": { + "ip":"238.89.104.156" + }, + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 50 + } + ] + } + } + ] + } + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD" + } + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "No bids in response", + "comparison": "literal" + } + ] +}