From d4d25d1e58df46a87cdf1ae36a6365879f96379e Mon Sep 17 00:00:00 2001
From: CompassSSP <95415988+CompassSSP@users.noreply.github.com>
Date: Mon, 20 Dec 2021 20:31:01 +0200
Subject: [PATCH] New Adapter: Compass (#2102)
---
adapters/compass/compass.go | 154 ++++++++++++++++++
adapters/compass/compass_test.go | 20 +++
.../compasstest/exemplary/endpointId.json | 133 +++++++++++++++
.../compasstest/exemplary/simple-banner.json | 133 +++++++++++++++
.../compasstest/exemplary/simple-native.json | 117 +++++++++++++
.../compasstest/exemplary/simple-video.json | 128 +++++++++++++++
.../exemplary/simple-web-banner.json | 133 +++++++++++++++
.../supplemental/bad_media_type.json | 86 ++++++++++
.../supplemental/bad_response.json | 84 ++++++++++
.../compasstest/supplemental/status-204.json | 79 +++++++++
.../supplemental/status-not-200.json | 84 ++++++++++
adapters/compass/params_test.go | 47 ++++++
config/config.go | 1 +
exchange/adapter_builders.go | 2 +
openrtb_ext/bidders.go | 2 +
openrtb_ext/imp_compass.go | 6 +
static/bidder-info/compass.yaml | 19 +++
static/bidder-params/compass.json | 23 +++
18 files changed, 1251 insertions(+)
create mode 100644 adapters/compass/compass.go
create mode 100644 adapters/compass/compass_test.go
create mode 100644 adapters/compass/compasstest/exemplary/endpointId.json
create mode 100644 adapters/compass/compasstest/exemplary/simple-banner.json
create mode 100644 adapters/compass/compasstest/exemplary/simple-native.json
create mode 100644 adapters/compass/compasstest/exemplary/simple-video.json
create mode 100644 adapters/compass/compasstest/exemplary/simple-web-banner.json
create mode 100644 adapters/compass/compasstest/supplemental/bad_media_type.json
create mode 100644 adapters/compass/compasstest/supplemental/bad_response.json
create mode 100644 adapters/compass/compasstest/supplemental/status-204.json
create mode 100644 adapters/compass/compasstest/supplemental/status-not-200.json
create mode 100644 adapters/compass/params_test.go
create mode 100644 openrtb_ext/imp_compass.go
create mode 100644 static/bidder-info/compass.yaml
create mode 100644 static/bidder-params/compass.json
diff --git a/adapters/compass/compass.go b/adapters/compass/compass.go
new file mode 100644
index 00000000000..eed846576bb
--- /dev/null
+++ b/adapters/compass/compass.go
@@ -0,0 +1,154 @@
+package compass
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+
+ "github.com/mxmCherry/openrtb/v15/openrtb2"
+ "github.com/prebid/prebid-server/adapters"
+ "github.com/prebid/prebid-server/config"
+ "github.com/prebid/prebid-server/errortypes"
+ "github.com/prebid/prebid-server/openrtb_ext"
+)
+
+type adapter struct {
+ endpoint string
+}
+
+type reqBodyExt struct {
+ CompassBidderExt reqBodyExtBidder `json:"bidder"`
+}
+
+type reqBodyExtBidder struct {
+ Type string `json:"type"`
+ PlacementID string `json:"placementId,omitempty"`
+ EndpointID string `json:"endpointId,omitempty"`
+}
+
+func Builder(bidderName openrtb_ext.BidderName, config config.Adapter) (adapters.Bidder, error) {
+ bidder := &adapter{
+ endpoint: config.Endpoint,
+ }
+ return bidder, nil
+}
+
+func (a *adapter) MakeRequests(request *openrtb2.BidRequest, reqInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) {
+ var err error
+ var adapterRequests []*adapters.RequestData
+
+ reqCopy := *request
+ for _, imp := range request.Imp {
+ reqCopy.Imp = []openrtb2.Imp{imp}
+
+ var bidderExt adapters.ExtImpBidder
+ var compassExt openrtb_ext.ImpExtCompass
+
+ if err = json.Unmarshal(reqCopy.Imp[0].Ext, &bidderExt); err != nil {
+ return nil, []error{err}
+ }
+ if err = json.Unmarshal(bidderExt.Bidder, &compassExt); err != nil {
+ return nil, []error{err}
+ }
+
+ temp := reqBodyExt{CompassBidderExt: reqBodyExtBidder{}}
+
+ if compassExt.PlacementID != "" {
+ temp.CompassBidderExt.PlacementID = compassExt.PlacementID
+ temp.CompassBidderExt.Type = "publisher"
+ } else if compassExt.EndpointID != "" {
+ temp.CompassBidderExt.EndpointID = compassExt.EndpointID
+ temp.CompassBidderExt.Type = "network"
+ }
+
+ finalyImpExt, err := json.Marshal(temp)
+ if err != nil {
+ return nil, []error{err}
+ }
+
+ reqCopy.Imp[0].Ext = finalyImpExt
+
+ adapterReq, err := a.makeRequest(&reqCopy)
+ if err != nil {
+ return nil, []error{err}
+ }
+
+ if adapterReq != nil {
+ adapterRequests = append(adapterRequests, adapterReq)
+ }
+ }
+ return adapterRequests, nil
+}
+
+func (a *adapter) makeRequest(request *openrtb2.BidRequest) (*adapters.RequestData, error) {
+ reqJSON, err := json.Marshal(request)
+ if err != nil {
+ return nil, err
+ }
+
+ 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,
+ }, err
+}
+
+func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) {
+ if responseData.StatusCode == http.StatusNoContent {
+ return nil, nil
+ }
+
+ if responseData.StatusCode != http.StatusOK {
+ err := &errortypes.BadServerResponse{
+ Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info.", responseData.StatusCode),
+ }
+ return nil, []error{err}
+ }
+
+ var response openrtb2.BidResponse
+ if err := json.Unmarshal(responseData.Body, &response); err != nil {
+ return nil, []error{err}
+ }
+
+ bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp))
+ bidResponse.Currency = response.Cur
+ for _, seatBid := range response.SeatBid {
+ for i := range seatBid.Bid {
+ bidType, err := getMediaTypeForImp(seatBid.Bid[i].ImpID, request.Imp)
+ if err != nil {
+ return nil, []error{err}
+ }
+
+ b := &adapters.TypedBid{
+ Bid: &seatBid.Bid[i],
+ BidType: bidType,
+ }
+ bidResponse.Bids = append(bidResponse.Bids, b)
+ }
+ }
+ 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),
+ }
+}
diff --git a/adapters/compass/compass_test.go b/adapters/compass/compass_test.go
new file mode 100644
index 00000000000..fce791e5997
--- /dev/null
+++ b/adapters/compass/compass_test.go
@@ -0,0 +1,20 @@
+package compass
+
+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.BidderCompass, config.Adapter{
+ Endpoint: "http://sa-lb.deliverimp.com/pserver"})
+
+ if buildErr != nil {
+ t.Fatalf("Builder returned unexpected error %v", buildErr)
+ }
+
+ adapterstest.RunJSONBidderTest(t, "compasstest", bidder)
+}
diff --git a/adapters/compass/compasstest/exemplary/endpointId.json b/adapters/compass/compasstest/exemplary/endpointId.json
new file mode 100644
index 00000000000..f02481b32a3
--- /dev/null
+++ b/adapters/compass/compasstest/exemplary/endpointId.json
@@ -0,0 +1,133 @@
+{
+ "mockBidRequest": {
+ "id": "test-request-id",
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ },
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "banner": {
+ "format": [
+ {
+ "w": 300,
+ "h": 250
+ },
+ {
+ "w": 300,
+ "h": 600
+ }
+ ]
+ },
+ "ext": {
+ "bidder": {
+ "endpointId": "test"
+ }
+ }
+ }
+ ]
+ },
+ "httpCalls": [
+ {
+ "expectedRequest": {
+ "uri": "http://sa-lb.deliverimp.com/pserver",
+ "body": {
+ "id": "test-request-id",
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "banner": {
+ "format": [
+ {
+ "w": 300,
+ "h": 250
+ },
+ {
+ "w": 300,
+ "h": 600
+ }
+ ]
+ },
+ "ext": {
+ "bidder": {
+ "endpointId": "test",
+ "type": "network"
+ }
+ }
+ }
+ ],
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ }
+ }
+ },
+ "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": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }
+ ],
+ "expectedBidResponses": [
+ {
+ "bids": [
+ {
+ "bid": {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "w": 300,
+ "h": 250,
+ "ext": {
+ "prebid": {
+ "type": "banner"
+ }
+ }
+ },
+ "type": "banner"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/adapters/compass/compasstest/exemplary/simple-banner.json b/adapters/compass/compasstest/exemplary/simple-banner.json
new file mode 100644
index 00000000000..592570cda6b
--- /dev/null
+++ b/adapters/compass/compasstest/exemplary/simple-banner.json
@@ -0,0 +1,133 @@
+{
+ "mockBidRequest": {
+ "id": "test-request-id",
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ },
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "banner": {
+ "format": [
+ {
+ "w": 300,
+ "h": 250
+ },
+ {
+ "w": 300,
+ "h": 600
+ }
+ ]
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test"
+ }
+ }
+ }
+ ]
+ },
+ "httpCalls": [
+ {
+ "expectedRequest": {
+ "uri": "http://sa-lb.deliverimp.com/pserver",
+ "body": {
+ "id": "test-request-id",
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "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",
+ "ua": "iPad"
+ }
+ }
+ },
+ "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": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }
+ ],
+ "expectedBidResponses": [
+ {
+ "bids": [
+ {
+ "bid": {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "w": 300,
+ "h": 250,
+ "ext": {
+ "prebid": {
+ "type": "banner"
+ }
+ }
+ },
+ "type": "banner"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/adapters/compass/compasstest/exemplary/simple-native.json b/adapters/compass/compasstest/exemplary/simple-native.json
new file mode 100644
index 00000000000..0ec8b43ce9c
--- /dev/null
+++ b/adapters/compass/compasstest/exemplary/simple-native.json
@@ -0,0 +1,117 @@
+{
+ "mockBidRequest": {
+ "id": "test-request-id",
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ },
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "native": {
+ "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}",
+ "ver": "1.1"
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test"
+ }
+ }
+ }
+ ]
+ },
+ "httpCalls": [
+ {
+ "expectedRequest": {
+ "uri": "http://sa-lb.deliverimp.com/pserver",
+ "body": {
+ "id": "test-request-id",
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "native": {
+ "request": "{\"ver\":\"1.1\",\"layout\":1,\"adunit\":2,\"plcmtcnt\":6,\"plcmttype\":4,\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"len\":75}},{\"id\":2,\"required\":1,\"img\":{\"wmin\":492,\"hmin\":328,\"type\":3,\"mimes\":[\"image/jpeg\",\"image/jpg\",\"image/png\"]}},{\"id\":4,\"required\":0,\"data\":{\"type\":6}},{\"id\":5,\"required\":0,\"data\":{\"type\":7}},{\"id\":6,\"required\":0,\"data\":{\"type\":1,\"len\":20}}]}",
+ "ver": "1.1"
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test",
+ "type": "publisher"
+ }
+ }
+ }
+ ],
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ }
+ }
+ },
+ "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": "native"
+ }
+ }
+ }
+ ],
+ "seat": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }
+ ],
+ "expectedBidResponses": [
+ {
+ "bids": [
+ {
+ "bid": {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "w": 300,
+ "h": 250,
+ "ext": {
+ "prebid": {
+ "type": "native"
+ }
+ }
+ },
+ "type": "native"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/adapters/compass/compasstest/exemplary/simple-video.json b/adapters/compass/compasstest/exemplary/simple-video.json
new file mode 100644
index 00000000000..0f279496f36
--- /dev/null
+++ b/adapters/compass/compasstest/exemplary/simple-video.json
@@ -0,0 +1,128 @@
+{
+ "mockBidRequest": {
+ "id": "test-request-id",
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ },
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "video": {
+ "mimes": [
+ "video/mp4"
+ ],
+ "protocols": [
+ 2,
+ 5
+ ],
+ "w": 1024,
+ "h": 576
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test"
+ }
+ }
+ }
+ ]
+ },
+ "httpCalls": [
+ {
+ "expectedRequest": {
+ "uri": "http://sa-lb.deliverimp.com/pserver",
+ "body": {
+ "id": "test-request-id",
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "iPad"
+ },
+ "app": {
+ "id": "1",
+ "bundle": "com.wls.testwlsapplication"
+ },
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "video": {
+ "mimes": [
+ "video/mp4"
+ ],
+ "protocols": [
+ 2,
+ 5
+ ],
+ "w": 1024,
+ "h": 576
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test",
+ "type": "publisher"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "mockResponse": {
+ "status": 200,
+ "body": {
+ "id": "test-request-id",
+ "seatbid": [
+ {
+ "bid": [
+ {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "00:01:00",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "ext": {
+ "prebid": {
+ "type": "video"
+ }
+ }
+ }
+ ],
+ "seat": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }
+ ],
+ "expectedBidResponses": [
+ {
+ "currency": "USD",
+ "bids": [
+ {
+ "bid": {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "00:01:00",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "ext": {
+ "prebid": {
+ "type": "video"
+ }
+ }
+ },
+ "type": "video"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/adapters/compass/compasstest/exemplary/simple-web-banner.json b/adapters/compass/compasstest/exemplary/simple-web-banner.json
new file mode 100644
index 00000000000..1896101ac68
--- /dev/null
+++ b/adapters/compass/compasstest/exemplary/simple-web-banner.json
@@ -0,0 +1,133 @@
+{
+ "mockBidRequest": {
+ "id": "test-request-id",
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "banner": {
+ "format": [
+ {
+ "w": 300,
+ "h": 250
+ },
+ {
+ "w": 300,
+ "h": 600
+ }
+ ]
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test"
+ }
+ }
+ }
+ ],
+ "site": {
+ "id": "1",
+ "domain": "test.com"
+ },
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "Ubuntu"
+ }
+ },
+ "httpCalls": [
+ {
+ "expectedRequest": {
+ "uri": "http://sa-lb.deliverimp.com/pserver",
+ "body": {
+ "id": "test-request-id",
+ "imp": [
+ {
+ "id": "test-imp-id",
+ "tagid": "test",
+ "banner": {
+ "format": [
+ {
+ "w": 300,
+ "h": 250
+ },
+ {
+ "w": 300,
+ "h": 600
+ }
+ ]
+ },
+ "ext": {
+ "bidder": {
+ "placementId": "test",
+ "type": "publisher"
+ }
+ }
+ }
+ ],
+ "site": {
+ "id": "1",
+ "domain": "test.com"
+ },
+ "device": {
+ "ip": "123.123.123.123",
+ "ua": "Ubuntu"
+ }
+ }
+ },
+ "mockResponse": {
+ "status": 200,
+ "body": {
+ "id": "test-request-id",
+ "seatbid": [
+ {
+ "bid": [
+ {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "w": 468,
+ "h": 60,
+ "ext": {
+ "prebid": {
+ "type": "banner"
+ }
+ }
+ }
+ ],
+ "seat": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }
+ ],
+ "expectedBidResponses": [
+ {
+ "bids": [
+ {
+ "bid": {
+ "id": "test_bid_id",
+ "impid": "test-imp-id",
+ "price": 0.27543,
+ "adm": "",
+ "cid": "test_cid",
+ "crid": "test_crid",
+ "dealid": "test_dealid",
+ "w": 468,
+ "h": 60,
+ "ext": {
+ "prebid": {
+ "type": "banner"
+ }
+ }
+ },
+ "type": "banner"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/adapters/compass/compasstest/supplemental/bad_media_type.json b/adapters/compass/compasstest/supplemental/bad_media_type.json
new file mode 100644
index 00000000000..0bfaec4f23d
--- /dev/null
+++ b/adapters/compass/compasstest/supplemental/bad_media_type.json
@@ -0,0 +1,86 @@
+{
+ "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://sa-lb.deliverimp.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": "compass"
+ }
+ ],
+ "cur": "USD"
+ }
+ }
+ }],
+ "expectedMakeBidsErrors": [
+ {
+ "value": "Failed to find impression \"test-imp-id\"",
+ "comparison": "literal"
+ }
+ ]
+}
diff --git a/adapters/compass/compasstest/supplemental/bad_response.json b/adapters/compass/compasstest/supplemental/bad_response.json
new file mode 100644
index 00000000000..3c660338c63
--- /dev/null
+++ b/adapters/compass/compasstest/supplemental/bad_response.json
@@ -0,0 +1,84 @@
+{
+ "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://sa-lb.deliverimp.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"
+ }
+ ]
+}
diff --git a/adapters/compass/compasstest/supplemental/status-204.json b/adapters/compass/compasstest/supplemental/status-204.json
new file mode 100644
index 00000000000..1ff5c55abeb
--- /dev/null
+++ b/adapters/compass/compasstest/supplemental/status-204.json
@@ -0,0 +1,79 @@
+{
+ "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://sa-lb.deliverimp.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": []
+}
diff --git a/adapters/compass/compasstest/supplemental/status-not-200.json b/adapters/compass/compasstest/supplemental/status-not-200.json
new file mode 100644
index 00000000000..51f648de360
--- /dev/null
+++ b/adapters/compass/compasstest/supplemental/status-not-200.json
@@ -0,0 +1,84 @@
+{
+ "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://sa-lb.deliverimp.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"
+ }
+ ]
+}
diff --git a/adapters/compass/params_test.go b/adapters/compass/params_test.go
new file mode 100644
index 00000000000..fca398b06fb
--- /dev/null
+++ b/adapters/compass/params_test.go
@@ -0,0 +1,47 @@
+package compass
+
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/prebid/prebid-server/openrtb_ext"
+)
+
+func TestValidParams(t *testing.T) {
+ validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
+ if err != nil {
+ t.Fatalf("Failed to fetch the json schema. %v", err)
+ }
+
+ for _, p := range validParams {
+ if err := validator.Validate(openrtb_ext.BidderCompass, json.RawMessage(p)); err != nil {
+ t.Errorf("Schema rejected valid params: %s", p)
+ }
+ }
+}
+
+func TestInvalidParams(t *testing.T) {
+ validator, err := openrtb_ext.NewBidderParamsValidator("../../static/bidder-params")
+ if err != nil {
+ t.Fatalf("Failed to fetch the json schema. %v", err)
+ }
+
+ for _, p := range invalidParams {
+ if err := validator.Validate(openrtb_ext.BidderCompass, json.RawMessage(p)); err == nil {
+ t.Errorf("Schema allowed invalid params: %s", p)
+ }
+ }
+}
+
+var validParams = []string{
+ `{"placementId": "test"}`,
+ `{"placementId": "1"}`,
+ `{"endpointId": "test"}`,
+ `{"endpointId": "1"}`,
+}
+
+var invalidParams = []string{
+ `{"placementId": 42}`,
+ `{"endpointId": 42}`,
+ `{"placementId": "1", "endpointId": "1"}`,
+}
diff --git a/config/config.go b/config/config.go
index f9dbc274ec1..dd842be72b9 100644
--- a/config/config.go
+++ b/config/config.go
@@ -809,6 +809,7 @@ func SetupViper(v *viper.Viper, filename string) {
v.SetDefault("adapters.brightroll.endpoint", "http://east-bid.ybp.yahoo.com/bid/appnexuspbs")
v.SetDefault("adapters.coinzilla.endpoint", "http://request-global.czilladx.com/serve/prebid-server.php")
v.SetDefault("adapters.colossus.endpoint", "http://colossusssp.com/?c=o&m=rtb")
+ v.SetDefault("adapters.compass.endpoint", "http://sa-lb.deliverimp.com/pserver")
v.SetDefault("adapters.connectad.endpoint", "http://bidder.connectad.io/API?src=pbs")
v.SetDefault("adapters.consumable.endpoint", "https://e.serverbid.com/api/v2")
v.SetDefault("adapters.conversant.endpoint", "http://api.hb.ad.cpe.dotomi.com/cvx/server/hb/ortb/25")
diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go
index 0f14b75c27f..59c892ab9e4 100755
--- a/exchange/adapter_builders.go
+++ b/exchange/adapter_builders.go
@@ -44,6 +44,7 @@ import (
"github.com/prebid/prebid-server/adapters/brightroll"
"github.com/prebid/prebid-server/adapters/coinzilla"
"github.com/prebid/prebid-server/adapters/colossus"
+ "github.com/prebid/prebid-server/adapters/compass"
"github.com/prebid/prebid-server/adapters/connectad"
"github.com/prebid/prebid-server/adapters/consumable"
"github.com/prebid/prebid-server/adapters/conversant"
@@ -183,6 +184,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder {
openrtb_ext.BidderBrightroll: brightroll.Builder,
openrtb_ext.BidderCoinzilla: coinzilla.Builder,
openrtb_ext.BidderColossus: colossus.Builder,
+ openrtb_ext.BidderCompass: compass.Builder,
openrtb_ext.BidderConnectAd: connectad.Builder,
openrtb_ext.BidderConsumable: consumable.Builder,
openrtb_ext.BidderConversant: conversant.Builder,
diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go
index 7ebfe631bdb..d02a7a48320 100644
--- a/openrtb_ext/bidders.go
+++ b/openrtb_ext/bidders.go
@@ -119,6 +119,7 @@ const (
BidderBrightroll BidderName = "brightroll"
BidderCoinzilla BidderName = "coinzilla"
BidderColossus BidderName = "colossus"
+ BidderCompass BidderName = "compass"
BidderConnectAd BidderName = "connectad"
BidderConsumable BidderName = "consumable"
BidderConversant BidderName = "conversant"
@@ -262,6 +263,7 @@ func CoreBidderNames() []BidderName {
BidderBrightroll,
BidderCoinzilla,
BidderColossus,
+ BidderCompass,
BidderConnectAd,
BidderConsumable,
BidderConversant,
diff --git a/openrtb_ext/imp_compass.go b/openrtb_ext/imp_compass.go
new file mode 100644
index 00000000000..3a150b9daaf
--- /dev/null
+++ b/openrtb_ext/imp_compass.go
@@ -0,0 +1,6 @@
+package openrtb_ext
+
+type ImpExtCompass struct {
+ PlacementID string `json:"placementId"`
+ EndpointID string `json:"endpointId"`
+}
diff --git a/static/bidder-info/compass.yaml b/static/bidder-info/compass.yaml
new file mode 100644
index 00000000000..5944b27eb5a
--- /dev/null
+++ b/static/bidder-info/compass.yaml
@@ -0,0 +1,19 @@
+maintainer:
+ email: "sa-support@brightcom.com"
+gvlVendorID: 883
+capabilities:
+ site:
+ mediaTypes:
+ - banner
+ - video
+ - native
+
+ app:
+ mediaTypes:
+ - banner
+ - video
+ - native
+userSync:
+ redirect:
+ url: "https://sa-cs.deliverimp.com/pserver?gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redir={{.RedirectURL}}"
+ userMacro: "[UID]"
diff --git a/static/bidder-params/compass.json b/static/bidder-params/compass.json
new file mode 100644
index 00000000000..11fcbf31ea4
--- /dev/null
+++ b/static/bidder-params/compass.json
@@ -0,0 +1,23 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "title": "Compass Adapter Params",
+ "description": "A schema which validates params accepted by the Compass adapter",
+ "type": "object",
+
+ "properties": {
+ "placementId": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Placement ID"
+ },
+ "endpointId": {
+ "type": "string",
+ "minLength": 1,
+ "description": "Endpoint ID"
+ }
+ },
+ "oneOf": [
+ { "required": ["placementId"] },
+ { "required": ["endpointId"] }
+ ]
+ }
\ No newline at end of file