From bf7ab4288afb0332963eb9adf081517775cdf040 Mon Sep 17 00:00:00 2001 From: saar120 Date: Mon, 4 Nov 2024 19:21:36 +0200 Subject: [PATCH 1/4] kueezrtb adapter --- adapters/kueezrtb/kueezrtb.go | 134 +++++++++ adapters/kueezrtb/kueezrtb_test.go | 24 ++ .../kueezrtbtest/exemplary/banner.json | 127 +++++++++ .../kueezrtbtest/exemplary/multi-imp.json | 265 ++++++++++++++++++ .../kueezrtbtest/exemplary/video.json | 154 ++++++++++ .../supplemental/bad-request.json | 65 +++++ .../supplemental/internal-error.json | 65 +++++ .../kueezrtbtest/supplemental/no-content.json | 60 ++++ .../supplemental/unknown-bid-type.json | 109 +++++++ adapters/kueezrtb/params_test.go | 42 +++ exchange/adapter_builders.go | 2 + openrtb_ext/bidders.go | 2 + openrtb_ext/imp_kueezrtb.go | 6 + static/bidder-info/kueezrtb.yaml | 20 ++ static/bidder-params/kueezrtb.json | 16 ++ 15 files changed, 1091 insertions(+) create mode 100644 adapters/kueezrtb/kueezrtb.go create mode 100644 adapters/kueezrtb/kueezrtb_test.go create mode 100644 adapters/kueezrtb/kueezrtbtest/exemplary/banner.json create mode 100644 adapters/kueezrtb/kueezrtbtest/exemplary/multi-imp.json create mode 100644 adapters/kueezrtb/kueezrtbtest/exemplary/video.json create mode 100644 adapters/kueezrtb/kueezrtbtest/supplemental/bad-request.json create mode 100644 adapters/kueezrtb/kueezrtbtest/supplemental/internal-error.json create mode 100644 adapters/kueezrtb/kueezrtbtest/supplemental/no-content.json create mode 100644 adapters/kueezrtb/kueezrtbtest/supplemental/unknown-bid-type.json create mode 100644 adapters/kueezrtb/params_test.go create mode 100644 openrtb_ext/imp_kueezrtb.go create mode 100644 static/bidder-info/kueezrtb.yaml create mode 100644 static/bidder-params/kueezrtb.json diff --git a/adapters/kueezrtb/kueezrtb.go b/adapters/kueezrtb/kueezrtb.go new file mode 100644 index 00000000000..0257c95fae6 --- /dev/null +++ b/adapters/kueezrtb/kueezrtb.go @@ -0,0 +1,134 @@ +package kueezrtb + +import ( + "encoding/json" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v3/adapters" + "github.com/prebid/prebid-server/v3/config" + "github.com/prebid/prebid-server/v3/errortypes" + "github.com/prebid/prebid-server/v3/openrtb_ext" + "github.com/prebid/prebid-server/v3/util/jsonutil" +) + +type adapter struct { + endpoint string +} + +// Builder builds a new instance of the kueezrtb for the given bidder with the given config. +func Builder(bidderName openrtb_ext.BidderName, config config.Adapter, server config.Server) (adapters.Bidder, error) { + bidder := &adapter{ + endpoint: config.Endpoint, + } + return bidder, nil +} + +func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapters.ExtraRequestInfo) ([]*adapters.RequestData, []error) { + var requests []*adapters.RequestData + var errors []error + + requestCopy := *request + + for _, imp := range request.Imp { + requestCopy.Imp = []openrtb2.Imp{imp} + + requestJSON, err := json.Marshal(&requestCopy) + if err != nil { + errors = append(errors, fmt.Errorf("marshal bidRequest: %w", err)) + continue + } + + cId, err := extractCid(&imp) + if err != nil { + errors = append(errors, fmt.Errorf("extract cId: %w", err)) + continue + } + + headers := http.Header{} + headers.Add("Content-Type", "application/json;charset=utf-8") + + requestData := &adapters.RequestData{ + Method: "POST", + Uri: fmt.Sprintf("%s%s", a.endpoint, url.QueryEscape(cId)), + Body: requestJSON, + Headers: headers, + ImpIDs: []string{imp.ID}, + } + + requests = append(requests, requestData) + } + + return requests, errors +} + +func getMediaTypeForBid(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 + } + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Could not define bid type for imp: %s", bid.ImpID), + } +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { + var errs []error + + if adapters.IsResponseStatusCodeNoContent(responseData) { + return nil, nil + } + + if err := adapters.CheckResponseStatusCodeForErrors(responseData); err != nil { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("Unexpected status code: %d. Run with request.debug = 1 for more info", responseData.StatusCode), + }} + } + + var response openrtb2.BidResponse + if err := jsonutil.Unmarshal(responseData.Body, &response); err != nil { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("bad server response: %d. ", err), + }} + } + + bidResponse := adapters.NewBidderResponseWithBidsCapacity(len(response.SeatBid)) + + if response.Cur != "" { + bidResponse.Currency = response.Cur + } + + for _, seatBid := range response.SeatBid { + for i, bid := range seatBid.Bid { + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errs = append(errs, err) + continue + } + bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ + Bid: &seatBid.Bid[i], + BidType: bidType, + }) + } + } + + return bidResponse, errs +} + +func extractCid(imp *openrtb2.Imp) (string, error) { + var bidderExt adapters.ExtImpBidder + if err := jsonutil.Unmarshal(imp.Ext, &bidderExt); err != nil { + return "", fmt.Errorf("unmarshal bidderExt: %w", err) + } + + var impExt openrtb_ext.ImpExtKueez + if err := jsonutil.Unmarshal(bidderExt.Bidder, &impExt); err != nil { + return "", fmt.Errorf("unmarshal ImpExtkueez: %w", err) + } + return strings.TrimSpace(impExt.ConnectionId), nil +} diff --git a/adapters/kueezrtb/kueezrtb_test.go b/adapters/kueezrtb/kueezrtb_test.go new file mode 100644 index 00000000000..b62eff292d1 --- /dev/null +++ b/adapters/kueezrtb/kueezrtb_test.go @@ -0,0 +1,24 @@ +package kueezrtb + +import ( + "testing" + + "github.com/prebid/prebid-server/v3/adapters/adapterstest" + "github.com/prebid/prebid-server/v3/config" + "github.com/prebid/prebid-server/v3/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderKueezRTB, config.Adapter{ + Endpoint: "http://prebidsrvr.kueezrtb.com/openrtb/", + }, + config.Server{ + ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2", + }) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "kueezrtbtest", bidder) +} diff --git a/adapters/kueezrtb/kueezrtbtest/exemplary/banner.json b/adapters/kueezrtb/kueezrtbtest/exemplary/banner.json new file mode 100644 index 00000000000..5df7fda99d0 --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/exemplary/banner.json @@ -0,0 +1,127 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some-request-id", + "cur": "", + "bidid": "some-bid-id", + "seatbid": [ + { + "bid": [ + { + "exp": 60, + "adm": "
Some creative
", + "burl": "", + "iurl": "http://prebidsrvr.kueezrtb.com/creative.jpg", + "lurl": "", + "nurl": "", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 400, + "w": 240, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "attr": [], + "cat": [], + "crid": "some-creative-id", + "ext": {}, + "hratio": 0, + "language": "", + "protocol": 0, + "qagmediarating": 0, + "tactic": "", + "wratio": 0, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "id": "some-bid-id", + "impid": "some-impression-id", + "price": 1, + "adm": "
Some creative
", + "adid": "some-ad-id", + "cid": "test", + "iurl": "http://prebidsrvr.kueezrtb.com/creative.jpg", + "crid": "some-creative-id", + "adomain": [ + "test.com" + ], + "dealid": "deal123", + "w": 240, + "h": 400, + "exp": 60, + "ext": {}, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/exemplary/multi-imp.json b/adapters/kueezrtb/kueezrtbtest/exemplary/multi-imp.json new file mode 100644 index 00000000000..5d71f8670fc --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/exemplary/multi-imp.json @@ -0,0 +1,265 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 1, + "maxduration": 2, + "protocols": [ + 1, + 2, + 5 + ], + "w": 300, + "h": 250, + "startdelay": 1, + "placement": 1, + "playbackmethod": [ + 2 + ], + "api": [ + 1, + 2, + 3, + 4 + ] + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + }, + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 1, + "maxduration": 2, + "protocols": [ + 1, + 2, + 5 + ], + "w": 300, + "h": 250, + "startdelay": 1, + "placement": 1, + "playbackmethod": [ + 2 + ], + "api": [ + 1, + 2, + 3, + 4 + ] + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some-request-id", + "cur": "", + "bidid": "some-bid-id", + "seatbid": [ + { + "bid": [ + { + "exp": 60, + "adm": "Some Ad SystemSome Ad Title00:00:02", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 250, + "w": 300, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "crid": "some-creative-id", + "mtype": 2 + } + ] + } + ] + } + } + }, + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some-request-id", + "cur": "", + "bidid": "some-bid-id", + "seatbid": [ + { + "bid": [ + { + "exp": 60, + "adm": "
Some creative
", + "burl": "", + "iurl": "http://prebidsrvr.kueezrtb.com/creative.jpg", + "lurl": "", + "nurl": "", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 400, + "w": 240, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "attr": [], + "cat": [], + "crid": "some-creative-id", + "ext": {}, + "hratio": 0, + "language": "", + "protocol": 0, + "qagmediarating": 0, + "tactic": "", + "wratio": 0, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "exp": 60, + "adm": "Some Ad SystemSome Ad Title00:00:02", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 250, + "w": 300, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "crid": "some-creative-id", + "mtype": 2 + }, + "type": "video" + } + ] + }, + { + "bids": [ + { + "bid": { + "id": "some-bid-id", + "impid": "some-impression-id", + "price": 1, + "adm": "
Some creative
", + "adid": "some-ad-id", + "cid": "test", + "iurl": "http://prebidsrvr.kueezrtb.com/creative.jpg", + "crid": "some-creative-id", + "adomain": [ + "test.com" + ], + "dealid": "deal123", + "w": 240, + "h": 400, + "exp": 60, + "ext": {}, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/exemplary/video.json b/adapters/kueezrtb/kueezrtbtest/exemplary/video.json new file mode 100644 index 00000000000..7dc212efdf3 --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/exemplary/video.json @@ -0,0 +1,154 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 1, + "maxduration": 2, + "protocols": [ + 1, + 2, + 5 + ], + "w": 300, + "h": 250, + "startdelay": 1, + "placement": 1, + "playbackmethod": [ + 2 + ], + "api": [ + 1, + 2, + 3, + 4 + ] + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "video": { + "mimes": [ + "video/mp4" + ], + "minduration": 1, + "maxduration": 2, + "protocols": [ + 1, + 2, + 5 + ], + "w": 300, + "h": 250, + "startdelay": 1, + "placement": 1, + "playbackmethod": [ + 2 + ], + "api": [ + 1, + 2, + 3, + 4 + ] + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some-request-id", + "cur": "", + "bidid": "some-bid-id", + "seatbid": [ + { + "bid": [ + { + "exp": 60, + "adm": "Some Ad SystemSome Ad Title00:00:02", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 250, + "w": 300, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "crid": "some-creative-id", + "mtype": 2 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [ + { + "bid": { + "exp": 60, + "adm": "Some Ad SystemSome Ad Title00:00:02", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 250, + "w": 300, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "crid": "some-creative-id", + "mtype": 2 + }, + "type": "video" + } + ] + } + ], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/supplemental/bad-request.json b/adapters/kueezrtb/kueezrtbtest/supplemental/bad-request.json new file mode 100644 index 00000000000..36656ebe471 --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/supplemental/bad-request.json @@ -0,0 +1,65 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 400. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/supplemental/internal-error.json b/adapters/kueezrtb/kueezrtbtest/supplemental/internal-error.json new file mode 100644 index 00000000000..cd69dc5b26a --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/supplemental/internal-error.json @@ -0,0 +1,65 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 500, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "Unexpected status code: 500. Run with request.debug = 1 for more info", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/supplemental/no-content.json b/adapters/kueezrtb/kueezrtbtest/supplemental/no-content.json new file mode 100644 index 00000000000..312fb3e5208 --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/supplemental/no-content.json @@ -0,0 +1,60 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cid": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [] +} \ No newline at end of file diff --git a/adapters/kueezrtb/kueezrtbtest/supplemental/unknown-bid-type.json b/adapters/kueezrtb/kueezrtbtest/supplemental/unknown-bid-type.json new file mode 100644 index 00000000000..61bd2eedf41 --- /dev/null +++ b/adapters/kueezrtb/kueezrtbtest/supplemental/unknown-bid-type.json @@ -0,0 +1,109 @@ +{ + "mockBidRequest": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "http://prebidsrvr.kueezrtb.com/openrtb/test_cid_123", + "body": { + "id": "some-request-id", + "site": { + "page": "prebid.org" + }, + "imp": [ + { + "id": "some-impression-id", + "banner": { + "w": 240, + "h": 400 + }, + "ext": { + "bidder": { + "cId": "test_cid_123" + } + } + } + ], + "tmax": 5000 + }, + "impIDs": [ + "some-impression-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "some-request-id", + "cur": "", + "bidid": "some-bid-id", + "seatbid": [ + { + "bid": [ + { + "exp": 60, + "adm": "
Some creative
", + "burl": "", + "iurl": "http://prebidsrvr.kueezrtb.com/creative.jpg", + "lurl": "", + "nurl": "", + "id": "some-bid-id", + "impid": "some-impression-id", + "h": 400, + "w": 240, + "price": 1, + "dealid": "deal123", + "adomain": [ + "test.com" + ], + "adid": "some-ad-id", + "cid": "test", + "attr": [], + "cat": [], + "crid": "some-creative-id", + "ext": {}, + "hratio": 0, + "language": "", + "protocol": 0, + "qagmediarating": 0, + "tactic": "", + "wratio": 0, + "mtype": 8 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "bids": [] + } + ], + "expectedMakeBidsErrors": [ + { + "value": "Could not define bid type for imp: some-impression-id", + "comparison": "literal" + } + ] +} \ No newline at end of file diff --git a/adapters/kueezrtb/params_test.go b/adapters/kueezrtb/params_test.go new file mode 100644 index 00000000000..3cfb9c62816 --- /dev/null +++ b/adapters/kueezrtb/params_test.go @@ -0,0 +1,42 @@ +package kueezrtb + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v3/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 _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderKueezRTB, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected valid params: %s", validParam) + } + } +} + +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.BidderKueezRTB, json.RawMessage(p)); err == nil { + t.Errorf("Schema allowed invalid params: %s", p) + } + } +} + +var validParams = []string{ + `{"cId": "provided_cid_123"}`, +} + +var invalidParams = []string{ + `{"cId": 3898334}`, +} diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 67e28286f03..e53289c1a60 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -120,6 +120,7 @@ import ( "github.com/prebid/prebid-server/v3/adapters/kidoz" "github.com/prebid/prebid-server/v3/adapters/kiviads" "github.com/prebid/prebid-server/v3/adapters/krushmedia" + "github.com/prebid/prebid-server/v3/adapters/kueezrtb" "github.com/prebid/prebid-server/v3/adapters/lemmadigital" "github.com/prebid/prebid-server/v3/adapters/limelightDigital" lmkiviads "github.com/prebid/prebid-server/v3/adapters/lm_kiviads" @@ -351,6 +352,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderKiviads: kiviads.Builder, openrtb_ext.BidderLmKiviads: lmkiviads.Builder, openrtb_ext.BidderKrushmedia: krushmedia.Builder, + openrtb_ext.BidderKueezRTB: kueezrtb.Builder, openrtb_ext.BidderLemmadigital: lemmadigital.Builder, openrtb_ext.BidderVungle: vungle.Builder, openrtb_ext.BidderLimelightDigital: limelightDigital.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index f7706ce5c25..c9875fa6534 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -138,6 +138,7 @@ var coreBidderNames []BidderName = []BidderName{ BidderKiviads, BidderLmKiviads, BidderKrushmedia, + BidderKueezRTB, BidderLemmadigital, BidderLimelightDigital, BidderLockerDome, @@ -467,6 +468,7 @@ const ( BidderKiviads BidderName = "kiviads" BidderLmKiviads BidderName = "lm_kiviads" BidderKrushmedia BidderName = "krushmedia" + BidderKueezRTB BidderName = "kueezrtb" BidderLemmadigital BidderName = "lemmadigital" BidderLimelightDigital BidderName = "limelightDigital" BidderLockerDome BidderName = "lockerdome" diff --git a/openrtb_ext/imp_kueezrtb.go b/openrtb_ext/imp_kueezrtb.go new file mode 100644 index 00000000000..79f4ae99e54 --- /dev/null +++ b/openrtb_ext/imp_kueezrtb.go @@ -0,0 +1,6 @@ +package openrtb_ext + +// ImpExtKueez defines the contract for bidrequest.imp[i].ext.prebid.bidder.kueezrtb +type ImpExtKueez struct { + ConnectionId string `json:"cId"` +} diff --git a/static/bidder-info/kueezrtb.yaml b/static/bidder-info/kueezrtb.yaml new file mode 100644 index 00000000000..4242e702d7c --- /dev/null +++ b/static/bidder-info/kueezrtb.yaml @@ -0,0 +1,20 @@ +endpoint: "https://prebidsrvr.kueezrtb.com/openrtb/" +maintainer: + email: "rtb@kueez.com" +gvlVendorID: 1165 +endpointCompression: gzip +capabilities: + app: + mediaTypes: + - banner + - video + site: + mediaTypes: + - banner + - video +userSync: + iframe: + url: https://sync.kueezrtb.com/api/user/html/62ce79e7dd15099534ae5e04?pbs=true&gdpr={{.GDPR}}&gdpr_consent={{.GDPRConsent}}&us_privacy={{.USPrivacy}}&redirect={{.RedirectURL}}&gpp={{.GPP}}&gpp_sid={{.GPPSID}} + userMacro: ${userId} +openrtb: + gpp_supported: true \ No newline at end of file diff --git a/static/bidder-params/kueezrtb.json b/static/bidder-params/kueezrtb.json new file mode 100644 index 00000000000..3b1eb3a631b --- /dev/null +++ b/static/bidder-params/kueezrtb.json @@ -0,0 +1,16 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Kueez RTB Adapter Params", + "description": "A schema which validates params accepted by the Kueez RTB adapter", + "type": "object", + "properties": { + "cId": { + "type": "string", + "description": "The connection id.", + "minLength": 1 + } + }, + "required": [ + "cId" + ] +} \ No newline at end of file From a46e40cbde7fd16cf0afed4bbc03619864e45103 Mon Sep 17 00:00:00 2001 From: saar120 Date: Tue, 26 Nov 2024 16:19:33 +0200 Subject: [PATCH 2/4] added more invalid params --- adapters/kueezrtb/params_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/adapters/kueezrtb/params_test.go b/adapters/kueezrtb/params_test.go index 3cfb9c62816..f7b263728f3 100644 --- a/adapters/kueezrtb/params_test.go +++ b/adapters/kueezrtb/params_test.go @@ -38,5 +38,13 @@ var validParams = []string{ } var invalidParams = []string{ - `{"cId": 3898334}`, + `{"cId": 123}`, + `{"cId": true}`, + `{"cId": ["array"]}`, + `{"cId": {}`, + `{"cId": ""}`, + `{"cId": null}`, + `{"cId": "provided_cid_123", "extra": "field"}`, + `{"cid": "valid_cid"}`, + `{"cId": "invalid_chars_!@#$%^&*()"}`, } From 50d129332966a2717767734a6e59c48a2cdc3c4c Mon Sep 17 00:00:00 2001 From: saar120 Date: Tue, 26 Nov 2024 16:19:49 +0200 Subject: [PATCH 3/4] move getMediaTypeForBid to the end of the adapter --- adapters/kueezrtb/kueezrtb.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/adapters/kueezrtb/kueezrtb.go b/adapters/kueezrtb/kueezrtb.go index 0257c95fae6..ee7bf42a19d 100644 --- a/adapters/kueezrtb/kueezrtb.go +++ b/adapters/kueezrtb/kueezrtb.go @@ -65,18 +65,6 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte return requests, errors } -func getMediaTypeForBid(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 - } - return "", &errortypes.BadInput{ - Message: fmt.Sprintf("Could not define bid type for imp: %s", bid.ImpID), - } -} - func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, responseData *adapters.ResponseData) (*adapters.BidderResponse, []error) { var errs []error @@ -132,3 +120,15 @@ func extractCid(imp *openrtb2.Imp) (string, error) { } return strings.TrimSpace(impExt.ConnectionId), nil } + +func getMediaTypeForBid(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 + } + return "", &errortypes.BadInput{ + Message: fmt.Sprintf("Could not define bid type for imp: %s", bid.ImpID), + } +} From b76086d67bf2759dd9fd4afefe4fcb48431033a7 Mon Sep 17 00:00:00 2001 From: saar120 Date: Tue, 26 Nov 2024 16:25:25 +0200 Subject: [PATCH 4/4] update params scheme --- static/bidder-params/kueezrtb.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/static/bidder-params/kueezrtb.json b/static/bidder-params/kueezrtb.json index 3b1eb3a631b..742412f088b 100644 --- a/static/bidder-params/kueezrtb.json +++ b/static/bidder-params/kueezrtb.json @@ -7,10 +7,12 @@ "cId": { "type": "string", "description": "The connection id.", - "minLength": 1 + "minLength": 1, + "pattern": "^[a-zA-Z0-9_]+$" } }, "required": [ "cId" - ] + ], + "additionalProperties": false } \ No newline at end of file