diff --git a/adapters/viant/params_test.go b/adapters/viant/params_test.go new file mode 100644 index 00000000000..7c29222d41e --- /dev/null +++ b/adapters/viant/params_test.go @@ -0,0 +1,46 @@ +package viant + +import ( + "encoding/json" + "testing" + + "github.com/prebid/prebid-server/v4/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-schemas. %v", err) + } + + for _, validParam := range validParams { + if err := validator.Validate(openrtb_ext.BidderViant, json.RawMessage(validParam)); err != nil { + t.Errorf("Schema rejected viant 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-schemas. %v", err) + } + + for _, invalidParam := range invalidParams { + if err := validator.Validate(openrtb_ext.BidderViant, json.RawMessage(invalidParam)); err == nil { + t.Errorf("Schema allowed unexpected params: %s", invalidParam) + } + } +} + +var validParams = []string{ + `{"publisherId": "prebid-test-pub-001"}`, + `{"publisherId": "viant-pub-12345"}`, + `{"publisherId": "any-string"}`, +} + +var invalidParams = []string{ + `{}`, + `{"publisherId": ""}`, + `{"publisherId": 123}`, +} diff --git a/adapters/viant/viant.go b/adapters/viant/viant.go new file mode 100644 index 00000000000..40666d10520 --- /dev/null +++ b/adapters/viant/viant.go @@ -0,0 +1,251 @@ +package viant + +import ( + "encoding/json" + "fmt" + "net/http" + "strings" + + "github.com/prebid/openrtb/v20/openrtb2" + "github.com/prebid/prebid-server/v4/adapters" + "github.com/prebid/prebid-server/v4/config" + "github.com/prebid/prebid-server/v4/errortypes" + "github.com/prebid/prebid-server/v4/openrtb_ext" + "github.com/prebid/prebid-server/v4/util/jsonutil" +) + +// defaultCurrency is the fallback Viant bids in and the target we convert +// unsupported bid floor currencies into. +const defaultCurrency = "USD" + +// supportedCurrencies are the bid floor currencies Viant can interpret directly. +// Floors already in one of these are passed through untouched so Viant applies +// its own conversion rates; anything else is converted to defaultCurrency first. +// Adding a newly supported currency here is the only change needed to stop +// converting it. +var supportedCurrencies = map[string]struct{}{ + "USD": {}, + "GBP": {}, + "CAD": {}, + "EUR": {}, + "AUD": {}, + "SAR": {}, + "AED": {}, +} + +type adapter struct { + endpoint string +} + +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 errs []error + + reqCopy := *request + cleanImps := make([]openrtb2.Imp, 0, len(request.Imp)) + + for i := range request.Imp { + var impExt adapters.ExtImpBidder + if err := jsonutil.Unmarshal(request.Imp[i].Ext, &impExt); err != nil { + errs = append(errs, &errortypes.BadInput{ + Message: fmt.Sprintf("invalid imp.ext for impression index %d. %s", i, err.Error()), + }) + continue + } + + var bidderExt openrtb_ext.ImpExtViant + if err := jsonutil.Unmarshal(impExt.Bidder, &bidderExt); err != nil { + errs = append(errs, &errortypes.BadInput{ + Message: fmt.Sprintf("invalid imp.ext.bidder for impression index %d. %s", i, err.Error()), + }) + continue + } + + if bidderExt.PublisherID == "" { + errs = append(errs, &errortypes.BadInput{ + Message: fmt.Sprintf("imp.ext.bidder.publisherId is required for impression index %d", i), + }) + continue + } + + imp := request.Imp[i] + imp.Ext = stripBidderExt(imp.Ext) + + if imp.BidFloor > 0 && imp.BidFloorCur != "" { + if _, ok := supportedCurrencies[strings.ToUpper(imp.BidFloorCur)]; !ok { + convertedValue, err := requestInfo.ConvertCurrency(imp.BidFloor, imp.BidFloorCur, defaultCurrency) + if err != nil { + // Viant accepts requests in currencies it doesn't support without + // erroring and simply bids in USD. Mirror that leniency: if we can't + // express the floor in USD, drop the floor rather than the impression + // so Viant can still return a (USD) bid. + errs = append(errs, &errortypes.Warning{ + Message: fmt.Sprintf("dropping unconvertible bid floor for impression index %d: %s", i, err.Error()), + }) + imp.BidFloor = 0 + imp.BidFloorCur = "" + } else { + imp.BidFloorCur = defaultCurrency + imp.BidFloor = convertedValue + } + } + } + + cleanImps = append(cleanImps, imp) + } + + if len(cleanImps) == 0 { + return nil, append(errs, &errortypes.BadInput{ + Message: "no valid impressions in the bid request", + }) + } + + reqCopy.Imp = cleanImps + // Viant prices its bids in any currency it supports, so pass a supported + // requested currency straight through and let it respond in that currency. + // For unsupported currencies (or none) ask for USD and let Prebid core + // convert the USD bid into the publisher's requested currency downstream. + reqCopy.Cur = []string{resolveRequestCurrency(request.Cur)} + + requestJSON, err := json.Marshal(reqCopy) + if err != nil { + return nil, append(errs, 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: requestJSON, + Headers: headers, + ImpIDs: openrtb_ext.GetImpIDs(reqCopy.Imp), + }}, errs +} + +// resolveRequestCurrency returns the first requested currency Viant supports so +// it can bid in it directly. If none of the requested currencies are supported +// (or none were requested), it returns defaultCurrency. +func resolveRequestCurrency(requestCurrencies []string) string { + for _, cur := range requestCurrencies { + if _, ok := supportedCurrencies[strings.ToUpper(cur)]; ok { + return cur + } + } + return defaultCurrency +} + +// stripBidderExt removes the "bidder" and "prebid" keys from imp.ext, +// returning nil if nothing else remains. +func stripBidderExt(ext json.RawMessage) json.RawMessage { + if ext == nil { + return nil + } + + var extMap map[string]json.RawMessage + if err := jsonutil.Unmarshal(ext, &extMap); err != nil { + return nil + } + + delete(extMap, openrtb_ext.PrebidExtBidderKey) + delete(extMap, openrtb_ext.PrebidExtKey) + + if len(extMap) == 0 { + return nil + } + + cleaned, err := json.Marshal(extMap) + if err != nil { + return nil + } + return cleaned +} + +func (a *adapter) MakeBids(request *openrtb2.BidRequest, requestData *adapters.RequestData, response *adapters.ResponseData) (*adapters.BidderResponse, []error) { + + if response.StatusCode == http.StatusNoContent { + return nil, nil + } + + if response.StatusCode == http.StatusBadRequest { + return nil, []error{&errortypes.BadInput{ + Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info.", response.StatusCode), + }} + } + + if response.StatusCode == http.StatusServiceUnavailable { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("service unavailable: HTTP status %d", response.StatusCode), + }} + } + + if response.StatusCode != http.StatusOK { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("unexpected status code: %d. Run with request.debug = 1 for more info.", response.StatusCode), + }} + } + + if len(response.Body) == 0 { + return nil, nil + } + + var bidResponse openrtb2.BidResponse + if err := jsonutil.Unmarshal(response.Body, &bidResponse); err != nil { + return nil, []error{&errortypes.BadServerResponse{ + Message: fmt.Sprintf("JSON parsing error: %s", err.Error()), + }} + } + + bidderResponse := adapters.NewBidderResponseWithBidsCapacity(len(request.Imp)) + // Viant bids in the requested currency when it supports it, so trust the + // currency it reports. Fall back to USD if the response omits it. + if bidResponse.Cur != "" { + bidderResponse.Currency = bidResponse.Cur + } else { + bidderResponse.Currency = defaultCurrency + } + + var errs []error + for _, seatBid := range bidResponse.SeatBid { + for i := range seatBid.Bid { + bid := &seatBid.Bid[i] + bidType, err := getMediaTypeForBid(bid) + if err != nil { + errs = append(errs, err) + continue + } + + bidderResponse.Bids = append(bidderResponse.Bids, &adapters.TypedBid{ + Bid: bid, + BidType: bidType, + }) + } + } + + return bidderResponse, errs +} + +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 + case openrtb2.MarkupNative: + return openrtb_ext.BidTypeNative, nil + case openrtb2.MarkupAudio: + return openrtb_ext.BidTypeAudio, nil + default: + return "", &errortypes.BadServerResponse{ + Message: fmt.Sprintf("unsupported MType %d for bid %s", bid.MType, bid.ImpID), + } + } +} diff --git a/adapters/viant/viant_test.go b/adapters/viant/viant_test.go new file mode 100644 index 00000000000..8e5dbd716e8 --- /dev/null +++ b/adapters/viant/viant_test.go @@ -0,0 +1,21 @@ +package viant + +import ( + "testing" + + "github.com/prebid/prebid-server/v4/adapters/adapterstest" + "github.com/prebid/prebid-server/v4/config" + "github.com/prebid/prebid-server/v4/openrtb_ext" +) + +func TestJsonSamples(t *testing.T) { + bidder, buildErr := Builder(openrtb_ext.BidderViant, config.Adapter{ + Endpoint: "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + }, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"}) + + if buildErr != nil { + t.Fatalf("Builder returned unexpected error %v", buildErr) + } + + adapterstest.RunJSONBidderTest(t, "vianttest", bidder) +} diff --git a/adapters/viant/vianttest/exemplary/audio.json b/adapters/viant/vianttest/exemplary/audio.json new file mode 100644 index 00000000000..e8db6b45d46 --- /dev/null +++ b/adapters/viant/vianttest/exemplary/audio.json @@ -0,0 +1,218 @@ +{ + "mockBidRequest": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "audio": { + "mimes": ["audio/aac", "audio/mpeg", "audio/mp3", "audio/ogg"], + "protocols": [2, 5, 3, 6, 7, 8, 11, 12, 13, 14], + "minduration": 1, + "maxduration": 92, + "startdelay": -2, + "feed": 3, + "maxseq": 3, + "battr": [1, 2, 3, 8] + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "tagid": "medianet_480898083", + "pmp": { + "private_auction": 0, + "deals": [ + { + "id": "mn_mrpartners_ron_viant_a", + "bidfloor": 5.718, + "bidfloorcur": "USD", + "wseat": ["306"], + "at": 1 + } + ] + }, + "exp": 3000, + "secure": 1, + "instl": 0, + "ext": { + "bidder": { + "publisherId": "prebid-test-pub-001" + } + } + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "audio": { + "mimes": ["audio/aac", "audio/mpeg", "audio/mp3", "audio/ogg"], + "protocols": [2, 5, 3, 6, 7, 8, 11, 12, 13, 14], + "minduration": 1, + "maxduration": 92, + "startdelay": -2, + "feed": 3, + "maxseq": 3, + "battr": [1, 2, 3, 8] + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "tagid": "medianet_480898083", + "pmp": { + "deals": [ + { + "id": "mn_mrpartners_ron_viant_a", + "bidfloor": 5.718, + "bidfloorcur": "USD", + "wseat": ["306"], + "at": 1 + } + ] + }, + "exp": 3000, + "secure": 1 + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + "impIDs": ["1"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "seatbid": [ + { + "bid": [ + { + "id": "bid-audio-1", + "impid": "1", + "price": 4.20, + "adid": "69757-audio-001", + "adm": "Viant Audio Ad", + "adomain": ["viantinc.com"], + "crid": "audio-crid-001", + "mtype": 3 + } + ], + "seat": "2722" + } + ], + "bidid": "bid-audio-1", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-audio-1", + "impid": "1", + "price": 4.20, + "adid": "69757-audio-001", + "adm": "Viant Audio Ad", + "adomain": ["viantinc.com"], + "crid": "audio-crid-001", + "mtype": 3 + }, + "type": "audio" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/exemplary/banner.json b/adapters/viant/vianttest/exemplary/banner.json new file mode 100644 index 00000000000..d0be4847921 --- /dev/null +++ b/adapters/viant/vianttest/exemplary/banner.json @@ -0,0 +1,200 @@ +{ + "mockBidRequest": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "banner": { + "h": 250, + "w": 300, + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "exp": 120, + "secure": 1, + "ext": { + "bidder": { + "publisherId": "prebid-test-pub-001" + } + } + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "banner": { + "h": 250, + "w": 300, + "format": [ + { + "h": 250, + "w": 300 + } + ] + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "exp": 120, + "secure": 1 + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + "impIDs": ["1"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "seatbid": [ + { + "bid": [ + { + "id": "bid-1", + "impid": "1", + "price": 2.89, + "adid": "69757-553138-2667435", + "adm": "
ad markup
", + "adomain": ["viantinc.com"], + "iurl": "https://media-cdn.ipredictive.com/image/69757/creative_300x250.gif", + "crid": "24877748", + "cat": ["IAB10-2"], + "w": 300, + "h": 250, + "mtype": 1 + } + ], + "seat": "2722" + } + ], + "bidid": "bid-1", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "1", + "price": 2.89, + "adid": "69757-553138-2667435", + "adm": "
ad markup
", + "adomain": ["viantinc.com"], + "iurl": "https://media-cdn.ipredictive.com/image/69757/creative_300x250.gif", + "crid": "24877748", + "cat": ["IAB10-2"], + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/exemplary/native.json b/adapters/viant/vianttest/exemplary/native.json new file mode 100644 index 00000000000..3c0e9fd9076 --- /dev/null +++ b/adapters/viant/vianttest/exemplary/native.json @@ -0,0 +1,183 @@ +{ + "mockBidRequest": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "4", + "native": { + "request": "{\"privacy\":1,\"plcmtcnt\":1,\"assets\":[{\"title\":{\"len\":100},\"id\":0,\"required\":1},{\"id\":3,\"img\":{\"hmin\":168,\"wmin\":319,\"type\":3},\"required\":1},{\"id\":4,\"data\":{\"len\":90,\"type\":1},\"required\":1}],\"context\":1,\"ver\":\"1.2\",\"plcmttype\":1}", + "api": [7] + }, + "bidfloor": 0.1, + "bidfloorcur": "USD", + "tagid": "nativo_1166345-RcB2FnjvX-Sp9-Kzy48V1Q-OPEN", + "exp": 120, + "secure": 1, + "instl": 0, + "ext": { + "bidder": { + "publisherId": "prebid-test-pub-001" + } + } + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "4", + "native": { + "request": "{\"privacy\":1,\"plcmtcnt\":1,\"assets\":[{\"title\":{\"len\":100},\"id\":0,\"required\":1},{\"id\":3,\"img\":{\"hmin\":168,\"wmin\":319,\"type\":3},\"required\":1},{\"id\":4,\"data\":{\"len\":90,\"type\":1},\"required\":1}],\"context\":1,\"ver\":\"1.2\",\"plcmttype\":1}", + "api": [7] + }, + "bidfloor": 0.1, + "bidfloorcur": "USD", + "tagid": "nativo_1166345-RcB2FnjvX-Sp9-Kzy48V1Q-OPEN", + "exp": 120, + "secure": 1 + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + "impIDs": ["4"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "seatbid": [ + { + "bid": [ + { + "id": "bid-native-1", + "impid": "4", + "price": 1.25, + "adid": "69757-native-001", + "adm": "{\"native\":{\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"title\":{\"text\":\"Viant Native Ad\"}},{\"id\":3,\"img\":{\"url\":\"https://media-cdn.ipredictive.com/image/native.jpg\",\"w\":319,\"h\":168}}]}}", + "adomain": ["viantinc.com"], + "crid": "native-crid-001", + "mtype": 4 + } + ], + "seat": "2722" + } + ], + "bidid": "bid-native-1", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-native-1", + "impid": "4", + "price": 1.25, + "adid": "69757-native-001", + "adm": "{\"native\":{\"ver\":\"1.2\",\"assets\":[{\"id\":0,\"title\":{\"text\":\"Viant Native Ad\"}},{\"id\":3,\"img\":{\"url\":\"https://media-cdn.ipredictive.com/image/native.jpg\",\"w\":319,\"h\":168}}]}}", + "adomain": ["viantinc.com"], + "crid": "native-crid-001", + "mtype": 4 + }, + "type": "native" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/exemplary/video.json b/adapters/viant/vianttest/exemplary/video.json new file mode 100644 index 00000000000..e1825c401ee --- /dev/null +++ b/adapters/viant/vianttest/exemplary/video.json @@ -0,0 +1,212 @@ +{ + "mockBidRequest": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "video": { + "mimes": ["video/mp4", "video/H264"], + "linearity": 1, + "minduration": 1, + "maxduration": 30, + "protocols": [2, 3, 5, 6, 7, 8], + "w": 1920, + "h": 1080, + "startdelay": -1, + "skip": 0, + "sequence": 1, + "minbitrate": 240, + "maxbitrate": 30000, + "playbackmethod": [1], + "delivery": [1, 2], + "placement": 1, + "plcmt": 1 + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "exp": 120, + "secure": 1, + "ext": { + "bidder": { + "publisherId": "prebid-test-pub-001" + } + } + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "at": 2, + "cur": ["USD"], + "tmax": 500, + "imp": [ + { + "id": "1", + "video": { + "mimes": ["video/mp4", "video/H264"], + "linearity": 1, + "minduration": 1, + "maxduration": 30, + "protocols": [2, 3, 5, 6, 7, 8], + "w": 1920, + "h": 1080, + "startdelay": -1, + "skip": 0, + "sequence": 1, + "minbitrate": 240, + "maxbitrate": 30000, + "playbackmethod": [1], + "delivery": [1, 2], + "placement": 1, + "plcmt": 1 + }, + "bidfloor": 0.5, + "bidfloorcur": "USD", + "exp": 120, + "secure": 1 + } + ], + "site": { + "cat": ["190_viant_prebid_server"], + "domain": "prebid.org", + "page": "https://prebid.org/", + "publisher": { + "id": "prebid-test-pub-001", + "name": "Prebid Test Publisher" + } + }, + "device": { + "devicetype": 2, + "ua": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.59 Safari/537.36", + "ip": "203.0.113.1", + "language": "en", + "geo": { + "country": "USA", + "lat": 40.7128, + "lon": -74.006, + "type": 2, + "zip": "10001" + } + }, + "user": { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "eids": [ + { + "source": "adserver.org", + "uids": [ + { + "id": "7b3e4f5a-8c9d-0e1f-a2b3-c4d5e6f70001", + "ext": { + "rtiPartner": "TDID" + } + } + ] + } + ] + } + } + }, + "impIDs": ["1"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "f8c3de3d-1fea-4d7c-a8b0-29f63c4c3454", + "seatbid": [ + { + "bid": [ + { + "id": "bid-video-1", + "impid": "1", + "price": 5.50, + "adid": "69757-video-001", + "adm": "Viant Video Ad", + "adomain": ["viantinc.com"], + "crid": "video-crid-001", + "w": 1920, + "h": 1080, + "mtype": 2 + } + ], + "seat": "2722" + } + ], + "bidid": "bid-video-1", + "cur": "USD" + } + } + } + ], + + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-video-1", + "impid": "1", + "price": 5.50, + "adid": "69757-video-001", + "adm": "Viant Video Ad", + "adomain": ["viantinc.com"], + "crid": "video-crid-001", + "w": 1920, + "h": 1080, + "mtype": 2 + }, + "type": "video" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/currency-conversion-failure.json b/adapters/viant/vianttest/supplemental/currency-conversion-failure.json new file mode 100644 index 00000000000..a1cbdcaa370 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/currency-conversion-failure.json @@ -0,0 +1,112 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "bidfloor": 2.0, + "bidfloorcur": "INR", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "EUR": { "USD": 1.1 } + }, + "usepbsrates": false + } + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "EUR": { "USD": 1.1 } + }, + "usepbsrates": false + } + } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "test-imp-id", + "price": 1.5, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedMakeRequestsErrors": [ + { + "value": "dropping unconvertible bid floor for impression index 0: Currency conversion rate not found: 'INR' => 'USD'", + "comparison": "literal" + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "test-imp-id", + "price": 1.5, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/currency-conversion.json b/adapters/viant/vianttest/supplemental/currency-conversion.json new file mode 100644 index 00000000000..023701e76fd --- /dev/null +++ b/adapters/viant/vianttest/supplemental/currency-conversion.json @@ -0,0 +1,109 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "cur": ["INR"], + "imp": [ + { + "id": "test-imp-id", + "bidfloor": 200.0, + "bidfloorcur": "INR", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "INR": { "USD": 0.012 } + }, + "usepbsrates": false + } + } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "bidfloor": 2.4, + "bidfloorcur": "USD", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + }, + "ext": { + "prebid": { + "currency": { + "rates": { + "INR": { "USD": 0.012 } + }, + "usepbsrates": false + } + } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "test-imp-id", + "price": 2.89, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "test-imp-id", + "price": 2.89, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/empty-response-body.json b/adapters/viant/vianttest/supplemental/empty-response-body.json new file mode 100644 index 00000000000..14988643d53 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/empty-response-body.json @@ -0,0 +1,44 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200 + } + } + ], + "expectedBidResponses": [] +} diff --git a/adapters/viant/vianttest/supplemental/imp-ext-extra-keys-passthrough.json b/adapters/viant/vianttest/supplemental/imp-ext-extra-keys-passthrough.json new file mode 100644 index 00000000000..4c9b38f2609 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/imp-ext-extra-keys-passthrough.json @@ -0,0 +1,90 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" }, + "data": { "pbadslot": "/1111/homepage" }, + "gpid": "/1111/homepage" + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 }, + "ext": { + "data": { "pbadslot": "/1111/homepage" }, + "gpid": "/1111/homepage" + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-banner"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "imp-banner", + "price": 2.50, + "adm": "
ad markup
", + "crid": "crid-001", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "imp-banner", + "price": 2.50, + "adm": "
ad markup
", + "crid": "crid-001", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/invalid-imp-ext-bidder.json b/adapters/viant/vianttest/supplemental/invalid-imp-ext-bidder.json new file mode 100644 index 00000000000..521d5bfd6ce --- /dev/null +++ b/adapters/viant/vianttest/supplemental/invalid-imp-ext-bidder.json @@ -0,0 +1,28 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": 12345 } + } + } + ], + "site": { + "page": "https://prebid.org/" + } + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "invalid imp.ext.bidder for impression index 0.", + "comparison": "startswith" + }, + { + "value": "no valid impressions in the bid request", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/missing-mtype.json b/adapters/viant/vianttest/supplemental/missing-mtype.json new file mode 100644 index 00000000000..b237607b807 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/missing-mtype.json @@ -0,0 +1,83 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-video", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-video", + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480 + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-video"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-no-mtype", + "impid": "imp-video", + "price": 4.10, + "adm": "", + "crid": "video-crid-001", + "w": 640, + "h": 480 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [] + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unsupported MType 0 for bid imp-video", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/missing-publisher-id.json b/adapters/viant/vianttest/supplemental/missing-publisher-id.json new file mode 100644 index 00000000000..5ad770b6854 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/missing-publisher-id.json @@ -0,0 +1,28 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "" } + } + } + ], + "site": { + "page": "https://prebid.org/" + } + }, + "httpCalls": [], + "expectedMakeRequestsErrors": [ + { + "value": "imp.ext.bidder.publisherId is required for impression index 0", + "comparison": "literal" + }, + { + "value": "no valid impressions in the bid request", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/multi-format-missing-mtype.json b/adapters/viant/vianttest/supplemental/multi-format-missing-mtype.json new file mode 100644 index 00000000000..9ae4dcbabb8 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/multi-format-missing-mtype.json @@ -0,0 +1,85 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-multi", + "banner": { "w": 300, "h": 250 }, + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480 + }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-multi", + "banner": { "w": 300, "h": 250 }, + "video": { + "mimes": ["video/mp4"], + "w": 640, + "h": 480 + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-multi"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-no-mtype", + "impid": "imp-multi", + "price": 4.10, + "adm": "", + "crid": "video-crid-001", + "w": 640, + "h": 480 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [] + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unsupported MType 0 for bid imp-multi", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/multi-imp-partial-valid.json b/adapters/viant/vianttest/supplemental/multi-imp-partial-valid.json new file mode 100644 index 00000000000..fd28fa7699c --- /dev/null +++ b/adapters/viant/vianttest/supplemental/multi-imp-partial-valid.json @@ -0,0 +1,97 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-valid", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + }, + { + "id": "imp-invalid", + "banner": { "w": 728, "h": 90 }, + "ext": { + "bidder": { "publisherId": "" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-valid", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-valid"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "imp-valid", + "price": 2.89, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedMakeRequestsErrors": [ + { + "value": "imp.ext.bidder.publisherId is required for impression index 1", + "comparison": "literal" + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "imp-valid", + "price": 2.89, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/response-missing-currency.json b/adapters/viant/vianttest/supplemental/response-missing-currency.json new file mode 100644 index 00000000000..591ac600594 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/response-missing-currency.json @@ -0,0 +1,83 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-banner"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "imp-banner", + "price": 2.50, + "adm": "
ad markup
", + "crid": "crid-001", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "imp-banner", + "price": 2.50, + "adm": "
ad markup
", + "crid": "crid-001", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/status-204.json b/adapters/viant/vianttest/supplemental/status-204.json new file mode 100644 index 00000000000..492b4e7fc3e --- /dev/null +++ b/adapters/viant/vianttest/supplemental/status-204.json @@ -0,0 +1,45 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 204, + "body": {} + } + } + ], + "expectedBidResponses": [] +} diff --git a/adapters/viant/vianttest/supplemental/status-400.json b/adapters/viant/vianttest/supplemental/status-400.json new file mode 100644 index 00000000000..52dd97e60f3 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/status-400.json @@ -0,0 +1,50 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 400, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 400. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/status-500.json b/adapters/viant/vianttest/supplemental/status-500.json new file mode 100644 index 00000000000..2085ebd44ff --- /dev/null +++ b/adapters/viant/vianttest/supplemental/status-500.json @@ -0,0 +1,50 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 500, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unexpected status code: 500. Run with request.debug = 1 for more info.", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/status-503.json b/adapters/viant/vianttest/supplemental/status-503.json new file mode 100644 index 00000000000..d3f068eaf32 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/status-503.json @@ -0,0 +1,50 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 503, + "body": {} + } + } + ], + "expectedMakeBidsErrors": [ + { + "value": "service unavailable: HTTP status 503", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/supported-currency-passthrough.json b/adapters/viant/vianttest/supplemental/supported-currency-passthrough.json new file mode 100644 index 00000000000..7a9fef48f12 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/supported-currency-passthrough.json @@ -0,0 +1,89 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "cur": ["AUD"], + "imp": [ + { + "id": "test-imp-id", + "bidfloor": 2.0, + "bidfloorcur": "AUD", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["AUD"], + "imp": [ + { + "id": "test-imp-id", + "bidfloor": 2.0, + "bidfloorcur": "AUD", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "AUD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-1", + "impid": "test-imp-id", + "price": 3.5, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "AUD", + "bids": [ + { + "bid": { + "id": "bid-1", + "impid": "test-imp-id", + "price": 3.5, + "adm": "
ad markup
", + "crid": "24877748", + "w": 300, + "h": 250, + "mtype": 1 + }, + "type": "banner" + } + ] + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/unknown-mtype-dropped.json b/adapters/viant/vianttest/supplemental/unknown-mtype-dropped.json new file mode 100644 index 00000000000..f09dd4f9f01 --- /dev/null +++ b/adapters/viant/vianttest/supplemental/unknown-mtype-dropped.json @@ -0,0 +1,75 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "imp-banner", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["imp-banner"] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "cur": "USD", + "seatbid": [ + { + "seat": "2722", + "bid": [ + { + "id": "bid-unknown", + "impid": "imp-does-not-exist", + "price": 1.50, + "adm": "
ad markup
", + "crid": "crid-unknown", + "w": 300, + "h": 250 + } + ] + } + ] + } + } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [] + } + ], + "expectedMakeBidsErrors": [ + { + "value": "unsupported MType 0 for bid imp-does-not-exist", + "comparison": "literal" + } + ] +} diff --git a/adapters/viant/vianttest/supplemental/unparsable-response.json b/adapters/viant/vianttest/supplemental/unparsable-response.json new file mode 100644 index 00000000000..7085a7c4a1b --- /dev/null +++ b/adapters/viant/vianttest/supplemental/unparsable-response.json @@ -0,0 +1,51 @@ +{ + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 }, + "ext": { + "bidder": { "publisherId": "prebid-test-pub-001" } + } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "httpCalls": [ + { + "expectedRequest": { + "uri": "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder", + "body": { + "id": "test-request-id", + "cur": ["USD"], + "imp": [ + { + "id": "test-imp-id", + "banner": { "w": 300, "h": 250 } + } + ], + "site": { + "page": "https://prebid.org/", + "publisher": { "id": "prebid-test-pub-001" } + } + }, + "impIDs": ["test-imp-id"] + }, + "mockResponse": { + "status": 200, + "body": "this-is-not-valid-json" + } + } + ], + "expectedBidResponses": [], + "expectedMakeBidsErrors": [ + { + "value": "JSON parsing error:", + "comparison": "startswith" + } + ] +} diff --git a/exchange/adapter_builders.go b/exchange/adapter_builders.go index 75a848b7596..57ef5dc61ce 100755 --- a/exchange/adapter_builders.go +++ b/exchange/adapter_builders.go @@ -246,6 +246,7 @@ import ( "github.com/prebid/prebid-server/v4/adapters/undertone" "github.com/prebid/prebid-server/v4/adapters/unicorn" "github.com/prebid/prebid-server/v4/adapters/unruly" + "github.com/prebid/prebid-server/v4/adapters/viant" "github.com/prebid/prebid-server/v4/adapters/vidazoo" "github.com/prebid/prebid-server/v4/adapters/videobyte" "github.com/prebid/prebid-server/v4/adapters/videoheroes" @@ -521,6 +522,7 @@ func newAdapterBuilders() map[openrtb_ext.BidderName]adapters.Builder { openrtb_ext.BidderUndertone: undertone.Builder, openrtb_ext.BidderUnicorn: unicorn.Builder, openrtb_ext.BidderUnruly: unruly.Builder, + openrtb_ext.BidderViant: viant.Builder, openrtb_ext.BidderVidazoo: vidazoo.Builder, openrtb_ext.BidderVideoByte: videobyte.Builder, openrtb_ext.BidderVideoHeroes: videoheroes.Builder, diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index aa725e7d1bd..1935a1c1d58 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -264,6 +264,7 @@ var coreBidderNames []BidderName = []BidderName{ BidderUndertone, BidderUnicorn, BidderUnruly, + BidderViant, BidderVidazoo, BidderVideoByte, BidderVideoHeroes, @@ -643,6 +644,7 @@ const ( BidderUndertone BidderName = "undertone" BidderUnicorn BidderName = "unicorn" BidderUnruly BidderName = "unruly" + BidderViant BidderName = "viant" BidderVidazoo BidderName = "vidazoo" BidderVideoByte BidderName = "videobyte" BidderVideoHeroes BidderName = "videoheroes" diff --git a/openrtb_ext/imp_viant.go b/openrtb_ext/imp_viant.go new file mode 100644 index 00000000000..086b51bcf3b --- /dev/null +++ b/openrtb_ext/imp_viant.go @@ -0,0 +1,5 @@ +package openrtb_ext + +type ImpExtViant struct { + PublisherID string `json:"publisherId"` +} diff --git a/static/bidder-info/viant.yaml b/static/bidder-info/viant.yaml new file mode 100644 index 00000000000..90951236061 --- /dev/null +++ b/static/bidder-info/viant.yaml @@ -0,0 +1,25 @@ +endpoint: "https://bidders-us.adelphic.net/rtb/v25/viant-prebid-server/bidder" +endpointCompression: gzip +maintainer: + email: "dist-vps@viantinc.com" +gvlVendorID: 1542 +modifyingVastXmlAllowed: true +capabilities: + app: + mediaTypes: + - banner + - video + - native + - audio + site: + mediaTypes: + - banner + - video + - native + - audio + dooh: + mediaTypes: + - banner + - video + - native + - audio diff --git a/static/bidder-params/viant.json b/static/bidder-params/viant.json new file mode 100644 index 00000000000..21a3f5acffd --- /dev/null +++ b/static/bidder-params/viant.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Viant Adapter Params", + "description": "A schema which validates params accepted by the Viant adapter.", + "type": "object", + "properties": { + "publisherId": { + "type": "string", + "minLength": 1, + "description": "Viant-assigned publisher ID." + } + }, + "required": ["publisherId"] +}