diff --git a/adapters/edge226/edge226.go b/adapters/edge226/edge226.go index 7959f987d43..a124cb47eca 100644 --- a/adapters/edge226/edge226.go +++ b/adapters/edge226/edge226.go @@ -8,7 +8,6 @@ import ( "github.com/prebid/openrtb/v19/openrtb2" "github.com/prebid/prebid-server/adapters" "github.com/prebid/prebid-server/config" - "github.com/prebid/prebid-server/errortypes" "github.com/prebid/prebid-server/openrtb_ext" ) @@ -98,14 +97,11 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestDa } func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { - if responseData.StatusCode == http.StatusNoContent { + if adapters.IsResponseStatusCodeNoContent(responseData) { return nil, nil } - if responseData.StatusCode != http.StatusOK { - err := &errortypes.BadServerResponse{ - Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode), - } + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { return nil, []error{err} } @@ -118,7 +114,7 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R bidResponse.Currency = response.Cur for _, seatBid := range response.SeatBid { for i := range seatBid.Bid { - bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp) + bidType, err := getBidMediaType(&seatBid.Bid[i]) if err != nil { return nil, []error{err} } @@ -133,22 +129,17 @@ func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.R return bidResponse, nil } -func getMediaTypeForImp(impID string, imps []openrtb2.Imp) (openrtb_ext.BidType, error) { - for _, imp := range imps { - if imp.ID == impID { - if imp.Banner != nil { - return openrtb_ext.BidTypeBanner, nil - } - if imp.Video != nil { - return openrtb_ext.BidTypeVideo, nil - } - if imp.Native != nil { - return openrtb_ext.BidTypeNative, nil - } - } - } - - return "", &errortypes.BadInput{ - Message: fmt.Sprintf("Failed to find impression \"%s\"", impID), +func getBidMediaType(bid *openrtb2.Bid) (openrtb_ext.BidType, error) { + switch bid.MType { + case openrtb2.MarkupBanner: + return openrtb_ext.BidTypeBanner, nil + case openrtb2.MarkupVideo: + return openrtb_ext.BidTypeVideo, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + case openrtb2.MarkupNative: + return openrtb_ext.BidTypeNative, nil + default: + return "", fmt.Errorf("Unable to fetch mediaType in multi-format: %s", bid.ImpID) } } diff --git a/adapters/edge226/edge226_test.go b/adapters/edge226/edge226_test.go index a688c719843..c5e40ce726d 100644 --- a/adapters/edge226/edge226_test.go +++ b/adapters/edge226/edge226_test.go @@ -10,7 +10,7 @@ import ( func TestJsonSamples(t *testing.T) { bidder, buildErr := Builder(openrtb_ext.BidderEdge226, config.Adapter{ - Endpoint: "http://ssp.dauup.com/pserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + Endpoint: "http://test.com/pserver"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) if buildErr != nil { t.Fatalf("Builder returned unexpected error %v", buildErr) diff --git a/adapters/edge226/edge226test/exemplary/endpointId.json b/adapters/edge226/edge226test/exemplary/endpointId.json index 5ea2bd376e6..741c1f8cb9b 100644 --- a/adapters/edge226/edge226test/exemplary/endpointId.json +++ b/adapters/edge226/edge226test/exemplary/endpointId.json @@ -36,7 +36,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", + "uri": "http://test.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -84,17 +84,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "edge226" @@ -113,17 +109,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/edge226/edge226test/exemplary/simple-banner.json b/adapters/edge226/edge226test/exemplary/simple-banner.json index 45862fd8501..741c1f8cb9b 100644 --- a/adapters/edge226/edge226test/exemplary/simple-banner.json +++ b/adapters/edge226/edge226test/exemplary/simple-banner.json @@ -27,7 +27,7 @@ }, "ext": { "bidder": { - "placementId": "test" + "endpointId": "test" } } } @@ -36,7 +36,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", + "uri": "http://test.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -57,8 +57,8 @@ }, "ext": { "bidder": { - "placementId": "test", - "type": "publisher" + "endpointId": "test", + "type": "network" } } } @@ -84,17 +84,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "edge226" @@ -113,17 +109,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/edge226/edge226test/exemplary/simple-native.json b/adapters/edge226/edge226test/exemplary/simple-native.json index 5d9e823bb24..581864cdb41 100644 --- a/adapters/edge226/edge226test/exemplary/simple-native.json +++ b/adapters/edge226/edge226test/exemplary/simple-native.json @@ -28,7 +28,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", + "uri": "http://test.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -68,17 +68,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "native" - } - } + "mtype": 4 } ], "seat": "edge226" @@ -97,17 +93,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 300, "h": 250, - "ext": { - "prebid": { - "type": "native" - } - } + "mtype": 4 }, "type": "native" } diff --git a/adapters/edge226/edge226test/exemplary/simple-video.json b/adapters/edge226/edge226test/exemplary/simple-video.json index f3588a6fa08..c14a1bd988e 100644 --- a/adapters/edge226/edge226test/exemplary/simple-video.json +++ b/adapters/edge226/edge226test/exemplary/simple-video.json @@ -35,7 +35,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", + "uri": "http://test.com/pserver", "body": { "id": "test-request-id", "device": { @@ -86,11 +86,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } + "mtype": 2 } ], "seat": "edge226" @@ -114,11 +110,7 @@ "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", - "ext": { - "prebid": { - "type": "video" - } - } + "mtype": 2 }, "type": "video" } diff --git a/adapters/edge226/edge226test/exemplary/simple-web-banner.json b/adapters/edge226/edge226test/exemplary/simple-web-banner.json index cd9d75cbca7..6cc7295003c 100644 --- a/adapters/edge226/edge226test/exemplary/simple-web-banner.json +++ b/adapters/edge226/edge226test/exemplary/simple-web-banner.json @@ -36,7 +36,7 @@ "httpCalls": [ { "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", + "uri": "http://test.com/pserver", "body": { "id": "test-request-id", "imp": [ @@ -84,17 +84,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 468, "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 } ], "seat": "edge226" @@ -113,17 +109,13 @@ "id": "test_bid_id", "impid": "test-imp-id", "price": 0.27543, - "adm": "", + "adm": "", "cid": "test_cid", "crid": "test_crid", "dealid": "test_dealid", "w": 468, "h": 60, - "ext": { - "prebid": { - "type": "banner" - } - } + "mtype": 1 }, "type": "banner" } diff --git a/adapters/edge226/edge226test/supplemental/bad_media_type.json b/adapters/edge226/edge226test/supplemental/bad_media_type.json index 94eb3436cfc..75b13412ad6 100644 --- a/adapters/edge226/edge226test/supplemental/bad_media_type.json +++ b/adapters/edge226/edge226test/supplemental/bad_media_type.json @@ -1,86 +1,82 @@ { - "mockBidRequest": { + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { "id": "test-request-id", "imp": [ - { - "id": "test-imp-id", - "ext": { - "bidder": { - "placementId": "test" - } - } + { + "id": "test-imp-id", + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } } + } ], "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "id": "1", + "bundle": "com.wls.testwlsapplication" }, "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" } + } }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "ext": { - "bidder": { - "placementId": "test", - "type": "publisher" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - } - }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "bid": [ - { - "id": "test_bid_id", - "impid": "test-imp-id", - "price": 0.27543, - "adm": "", - "cid": "test_cid", - "crid": "test_crid", - "dealid": "test_dealid", - "w": 300, - "h": 250, - "ext": { - "prebid": { - "type": "banner" - } - } - } - ], - "seat": "edge226" - } - ], - "cur": "USD" - } - } - }], - "expectedMakeBidsErrors": [ - { - "value": "Failed to find impression \"test-imp-id\"", - "comparison": "literal" - } - ] + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "bid": [ + { + "id": "test_bid_id", + "impid": "test-imp-id", + "price": 0.27543, + "adm": "", + "cid": "test_cid", + "crid": "test_crid", + "dealid": "test_dealid", + "w": 300, + "h": 250, + "ext": {} + } + ], + "seat": "edge226" + } + ], + "cur": "USD" + } + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unable to fetch mediaType in multi-format: test-imp-id", + "comparison": "literal" + } + ] } diff --git a/adapters/edge226/edge226test/supplemental/bad_response.json b/adapters/edge226/edge226test/supplemental/bad_response.json index 40a1d1a5cd5..1e5664bafec 100644 --- a/adapters/edge226/edge226test/supplemental/bad_response.json +++ b/adapters/edge226/edge226test/supplemental/bad_response.json @@ -1,84 +1,84 @@ { - "mockBidRequest": { + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { "id": "test-request-id", "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 }, - "ext": { - "bidder": { - "placementId": "test" - } + { + "w": 300, + "h": 600 } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } } + } ], "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "id": "1", + "bundle": "com.wls.testwlsapplication" }, "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" } + } }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "bidder": { - "placementId": "test", - "type": "publisher" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - } - }, - "mockResponse": { - "status": 200, - "body": "" - } - }], - "expectedMakeBidsErrors": [ - { - "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", - "comparison": "literal" - } - ] + "mockResponse": { + "status": 200, + "body": "" + } + }], + "expectedMakeBidsErrors": [ + { + "value": "json: cannot unmarshal string into Go value of type openrtb2.BidResponse", + "comparison": "literal" + } + ] } diff --git a/adapters/edge226/edge226test/supplemental/status-204.json b/adapters/edge226/edge226test/supplemental/status-204.json index 4a9abe3ee2a..da929ce61cb 100644 --- a/adapters/edge226/edge226test/supplemental/status-204.json +++ b/adapters/edge226/edge226test/supplemental/status-204.json @@ -1,79 +1,79 @@ { - "mockBidRequest": { + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { "id": "test-request-id", "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 }, - "ext": { - "bidder": { - "placementId": "test" - } + { + "w": 300, + "h": 600 } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } } + } ], "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "id": "1", + "bundle": "com.wls.testwlsapplication" }, "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" } + } }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "bidder": { - "placementId": "test", - "type": "publisher" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - } - }, - "mockResponse": { - "status": 204, - "body": {} - } - }], - "expectedBidResponses": [] + "mockResponse": { + "status": 204, + "body": {} + } + }], + "expectedBidResponses": [] } diff --git a/adapters/edge226/edge226test/supplemental/status-not-200.json b/adapters/edge226/edge226test/supplemental/status-not-200.json index c7c0210732f..cf1847c2cac 100644 --- a/adapters/edge226/edge226test/supplemental/status-not-200.json +++ b/adapters/edge226/edge226test/supplemental/status-not-200.json @@ -1,84 +1,84 @@ { - "mockBidRequest": { + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 + }, + { + "w": 300, + "h": 600 + } + ] + }, + "ext": { + "bidder": { + "placementId": "test" + } + } + } + ], + "app": { + "id": "1", + "bundle": "com.wls.testwlsapplication" + }, + "device": { + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + } + }, + "httpCalls": [{ + "expectedRequest": { + "uri": "http://test.com/pserver", + "body": { "id": "test-request-id", "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] + { + "id": "test-imp-id", + "banner": { + "format": [ + { + "w": 300, + "h": 250 }, - "ext": { - "bidder": { - "placementId": "test" - } + { + "w": 300, + "h": 600 } + ] + }, + "ext": { + "bidder": { + "placementId": "test", + "type": "publisher" + } } + } ], "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" + "id": "1", + "bundle": "com.wls.testwlsapplication" }, "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" + "ip": "123.123.123.123", + "ifa": "sdjfksdf-dfsds-dsdg-dsgg" } + } }, - "httpCalls": [{ - "expectedRequest": { - "uri": "http://ssp.dauup.com/pserver", - "body": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "banner": { - "format": [ - { - "w": 300, - "h": 250 - }, - { - "w": 300, - "h": 600 - } - ] - }, - "ext": { - "bidder": { - "placementId": "test", - "type": "publisher" - } - } - } - ], - "app": { - "id": "1", - "bundle": "com.wls.testwlsapplication" - }, - "device": { - "ip": "123.123.123.123", - "ifa": "sdjfksdf-dfsds-dsdg-dsgg" - } - } - }, - "mockResponse": { - "status": 404, - "body": {} - } - }], - "expectedMakeBidsErrors": [ - { - "value": "Unexpected status code: 404. Run with request.debug = 1 for more info.", - "comparison": "literal" - } - ] + "mockResponse": { + "status": 404, + "body": {} + } + }], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 404. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] }