diff --git a/adapters/beachfront/beachfront.go b/adapters/beachfront/beachfront.go index e2eb31b3577..34a198e93a2 100644 --- a/adapters/beachfront/beachfront.go +++ b/adapters/beachfront/beachfront.go @@ -4,26 +4,27 @@ import ( "encoding/json" "errors" "fmt" - "github.com/mxmCherry/openrtb" - "github.com/prebid/prebid-server/adapters" - "github.com/prebid/prebid-server/errortypes" - "github.com/prebid/prebid-server/openrtb_ext" "net/http" "reflect" "strconv" "strings" + + "github.com/golang/glog" + "github.com/mxmCherry/openrtb" + "github.com/prebid/prebid-server/adapters" + "github.com/prebid/prebid-server/errortypes" + "github.com/prebid/prebid-server/openrtb_ext" ) const Seat = "beachfront" const BidCapacity = 5 -const bannerEndpoint = "https://display.bfmio.com/prebid_display" -const videoEndpoint = "https://reachms.bfmio.com/bid.json?exchange_id" +const defaultVideoEndpoint = "https://reachms.bfmio.com/bid.json?exchange_id" const nurlVideoEndpointSuffix = "&prebidserver" const beachfrontAdapterName = "BF_PREBID_S2S" -const beachfrontAdapterVersion = "0.8.0" +const beachfrontAdapterVersion = "0.9.0" const minBidFloor = 0.01 @@ -31,6 +32,12 @@ const DefaultVideoWidth = 300 const DefaultVideoHeight = 250 type BeachfrontAdapter struct { + bannerEndpoint string + extraInfo ExtraInfo +} + +type ExtraInfo struct { + VideoEndpoint string `json:"video_endpoint,omitempty"` } type beachfrontRequests struct { @@ -138,7 +145,7 @@ func (a *BeachfrontAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a if err == nil { reqs[0] = &adapters.RequestData{ Method: "POST", - Uri: bannerEndpoint, + Uri: a.bannerEndpoint, Body: bytes, Headers: headers, } @@ -159,7 +166,7 @@ func (a *BeachfrontAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a if err == nil { reqs[j+nurlBump] = &adapters.RequestData{ Method: "POST", - Uri: videoEndpoint + "=" + beachfrontRequests.ADMVideo[j].AppId, + Uri: a.extraInfo.VideoEndpoint + "=" + beachfrontRequests.ADMVideo[j].AppId, Body: bytes, Headers: headers, } @@ -178,7 +185,7 @@ func (a *BeachfrontAdapter) MakeRequests(request *openrtb.BidRequest, reqInfo *a bytes = append([]byte(`{"isPrebid":true,`), bytes[1:]...) reqs[j+admBump] = &adapters.RequestData{ Method: "POST", - Uri: videoEndpoint + "=" + beachfrontRequests.NurlVideo[j].AppId + nurlVideoEndpointSuffix, + Uri: a.extraInfo.VideoEndpoint + "=" + beachfrontRequests.NurlVideo[j].AppId + nurlVideoEndpointSuffix, Body: bytes, Headers: headers, } @@ -518,13 +525,13 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bids[i], - BidType: getBidType(externalRequest), + BidType: a.getBidType(externalRequest), BidVideo: &impVideo, }) } else { bidResponse.Bids = append(bidResponse.Bids, &adapters.TypedBid{ Bid: &bids[i], - BidType: getBidType(externalRequest), + BidType: a.getBidType(externalRequest), }) } } @@ -532,6 +539,15 @@ func (a *BeachfrontAdapter) MakeBids(internalRequest *openrtb.BidRequest, extern return bidResponse, errs } +func (a *BeachfrontAdapter) getBidType(externalRequest *adapters.RequestData) openrtb_ext.BidType { + t := strings.Split(externalRequest.Uri, "=")[0] + if t == a.extraInfo.VideoEndpoint { + return openrtb_ext.BidTypeVideo + } + + return openrtb_ext.BidTypeBanner +} + func postprocess(response *adapters.ResponseData, xtrnal openrtb.BidRequest, uri string, id string) ([]openrtb.Bid, []error) { var beachfrontResp []beachfrontResponseSlot var errs = make([]error, 0) @@ -629,13 +645,13 @@ func getBeachfrontExtension(imp openrtb.Imp) (openrtb_ext.ExtImpBeachfront, erro } func getDomain(page string) string { - protoUrl := strings.Split(page, "//") + protoURL := strings.Split(page, "//") var domainPage string - if len(protoUrl) > 1 { - domainPage = protoUrl[1] + if len(protoURL) > 1 { + domainPage = protoURL[1] } else { - domainPage = protoUrl[0] + domainPage = protoURL[0] } return strings.Split(domainPage, "/")[0] @@ -643,9 +659,9 @@ func getDomain(page string) string { } func isSecure(page string) int8 { - protoUrl := strings.Split(page, "://") + protoURL := strings.Split(page, "://") - if len(protoUrl) > 1 && protoUrl[0] == "https" { + if len(protoURL) > 1 && protoURL[0] == "https" { return 1 } @@ -663,19 +679,25 @@ func getIP(ip string) string { return ip } -func getBidType(externalRequest *adapters.RequestData) openrtb_ext.BidType { - t := strings.Split(externalRequest.Uri, "=")[0] - if t == videoEndpoint { - return openrtb_ext.BidTypeVideo - } - - return openrtb_ext.BidTypeBanner -} - func removeVideoElement(slice []beachfrontVideoRequest, s int) []beachfrontVideoRequest { return append(slice[:s], slice[s+1:]...) } -func NewBeachfrontBidder() *BeachfrontAdapter { - return &BeachfrontAdapter{} +func NewBeachfrontBidder(bannerEndpoint string, extraAdapterInfo string) adapters.Bidder { + var extraInfo ExtraInfo + + if len(extraAdapterInfo) == 0 { + extraAdapterInfo = "{\"video_endpoint\":\"" + defaultVideoEndpoint + "\"}" + } + + if err := json.Unmarshal([]byte(extraAdapterInfo), &extraInfo); err != nil { + glog.Fatal("Invalid Beachfront extra adapter info: " + err.Error()) + return nil + } + + if extraInfo.VideoEndpoint == "" { + extraInfo.VideoEndpoint = defaultVideoEndpoint + } + + return &BeachfrontAdapter{bannerEndpoint: bannerEndpoint, extraInfo: extraInfo} } diff --git a/adapters/beachfront/beachfront_test.go b/adapters/beachfront/beachfront_test.go index 4e82deaf3d8..c220cebf9b0 100644 --- a/adapters/beachfront/beachfront_test.go +++ b/adapters/beachfront/beachfront_test.go @@ -7,5 +7,5 @@ import ( ) func TestJsonSamples(t *testing.T) { - adapterstest.RunJSONBidderTest(t, "beachfronttest", new(BeachfrontAdapter)) + adapterstest.RunJSONBidderTest(t, "beachfronttest", NewBeachfrontBidder("https://display.bfmio.com/prebid_display", "{\"video_endpoint\":\"https://reachms.bfmio.com/bid.json?exchange_id\"}")) } diff --git a/adapters/beachfront/beachfronttest/exemplary/minimal-banner.json b/adapters/beachfront/beachfronttest/exemplary/minimal-banner.json index ffcea194cdd..51ce4e9295e 100644 --- a/adapters/beachfront/beachfronttest/exemplary/minimal-banner.json +++ b/adapters/beachfront/beachfronttest/exemplary/minimal-banner.json @@ -56,7 +56,7 @@ "dnt": 0, "ua": "", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.8.0", + "adapterVersion": "0.9.0", "user": { } } diff --git a/adapters/beachfront/beachfronttest/exemplary/simple-mix.json b/adapters/beachfront/beachfronttest/exemplary/simple-mix.json index 6d8e483ee6d..eb5d9b07abc 100644 --- a/adapters/beachfront/beachfronttest/exemplary/simple-mix.json +++ b/adapters/beachfront/beachfronttest/exemplary/simple-mix.json @@ -85,7 +85,7 @@ "buyeruid": "some-buyer" }, "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.8.0", + "adapterVersion": "0.9.0", "ip": "192.168.255.255", "requestId": "61b87329-8790-47b7-90dd-c53ae7ce1723" } diff --git a/adapters/beachfront/beachfronttest/supplemental/minimal-banner-empty_array-200.json b/adapters/beachfront/beachfronttest/supplemental/minimal-banner-empty_array-200.json index f189b2c8c79..7bdbc73cd5e 100644 --- a/adapters/beachfront/beachfronttest/supplemental/minimal-banner-empty_array-200.json +++ b/adapters/beachfront/beachfronttest/supplemental/minimal-banner-empty_array-200.json @@ -56,7 +56,7 @@ "dnt": 0, "ua": "", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.8.0", + "adapterVersion": "0.9.0", "user": { } } diff --git a/adapters/beachfront/beachfronttest/supplemental/minimal-site-banner.json b/adapters/beachfront/beachfronttest/supplemental/minimal-site-banner.json index b610c96f58a..27b24357247 100644 --- a/adapters/beachfront/beachfronttest/supplemental/minimal-site-banner.json +++ b/adapters/beachfront/beachfronttest/supplemental/minimal-site-banner.json @@ -56,7 +56,7 @@ "dnt": 0, "ua": "", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.8.0", + "adapterVersion": "0.9.0", "user": { } } diff --git a/adapters/beachfront/beachfronttest/supplemental/mobile-banner.json b/adapters/beachfront/beachfronttest/supplemental/mobile-banner.json index d47393b7caf..ea38d7adae7 100644 --- a/adapters/beachfront/beachfronttest/supplemental/mobile-banner.json +++ b/adapters/beachfront/beachfronttest/supplemental/mobile-banner.json @@ -87,7 +87,7 @@ }, "adapterName":"BF_PREBID_S2S", - "adapterVersion":"0.8.0", + "adapterVersion":"0.9.0", "ip":"192.168.255.255", "requestId":"763e3312-19d5-4b07-a61d-890147e863a1" } diff --git a/adapters/beachfront/beachfronttest/supplemental/multi-banner.json b/adapters/beachfront/beachfronttest/supplemental/multi-banner.json index c4120787852..46699511a9c 100644 --- a/adapters/beachfront/beachfronttest/supplemental/multi-banner.json +++ b/adapters/beachfront/beachfronttest/supplemental/multi-banner.json @@ -96,7 +96,7 @@ "dnt": 1, "ua": "Opera/9.80 (X11; Linux i686; Ubuntu/14.10) Presto/2.12.388 Version/12.16", "adapterName": "BF_PREBID_S2S", - "adapterVersion": "0.8.0", + "adapterVersion": "0.9.0", "user": { "buyeruid": "some-buyer", "id": "some-user" diff --git a/config/config.go b/config/config.go index 652ad28cd87..1c686591ef2 100644 --- a/config/config.go +++ b/config/config.go @@ -695,6 +695,7 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.appnexus.endpoint", "http://ib.adnxs.com/openrtb2") // Docs: https://wiki.appnexus.com/display/supply/Incoming+Bid+Request+from+SSPs v.SetDefault("adapters.appnexus.platform_id", "5") v.SetDefault("adapters.beachfront.endpoint", "https://display.bfmio.com/prebid_display") + v.SetDefault("adapters.beachfront.extra_info", "{\"video_endpoint\":\"https://reachms.bfmio.com/bid.json?exchange_id\"}") v.SetDefault("adapters.brightroll.endpoint", "http://east-bid.ybp.yahoo.com/bid/appnexuspbs") v.SetDefault("adapters.consumable.endpoint", "https://e.serverbid.com/api/v2") v.SetDefault("adapters.conversant.endpoint", "http://api.hb.ad.cpe.dotomi.com/s2s/header/24") diff --git a/config/config_test.go b/config/config_test.go index 9677ce2aaba..92794d7941e 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -270,6 +270,8 @@ func TestFullConfig(t *testing.T) { cmpStrings(t, "adapters.audiencenetwork.usersync_url", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].UserSyncURL, "http://facebook.com/ortb/prebid-s2s") cmpStrings(t, "adapters.audiencenetwork.platform_id", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID, "abcdefgh1234") cmpStrings(t, "adapters.audiencenetwork.app_secret", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].AppSecret, "987abc") + cmpStrings(t, "adapters.beachfront.endpoint", cfg.Adapters[string(openrtb_ext.BidderBeachfront)].Endpoint, "https://display.bfmio.com/prebid_display") + cmpStrings(t, "adapters.beachfront.extra_info", cfg.Adapters[string(openrtb_ext.BidderBeachfront)].ExtraAdapterInfo, "{\"video_endpoint\":\"https://reachms.bfmio.com/bid.json?exchange_id\"}") cmpStrings(t, "adapters.ix.endpoint", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIx))].Endpoint, "http://ixtest.com/api") cmpStrings(t, "adapters.rubicon.endpoint", cfg.Adapters[string(openrtb_ext.BidderRubicon)].Endpoint, "http://rubitest.com/api") cmpStrings(t, "adapters.rubicon.usersync_url", cfg.Adapters[string(openrtb_ext.BidderRubicon)].UserSyncURL, "http://pixel.rubiconproject.com/sync.php?p=prebid") diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 8e779822cae..20805fb7898 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -85,15 +85,14 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter openrtb_ext.BidderAdvangelists: advangelists.NewAdvangelistsBidder(cfg.Adapters[string(openrtb_ext.BidderAdvangelists)].Endpoint), openrtb_ext.BidderApplogy: applogy.NewApplogyBidder(cfg.Adapters[string(openrtb_ext.BidderApplogy)].Endpoint), openrtb_ext.BidderAppnexus: appnexus.NewAppNexusBidder(client, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].PlatformID), - // TODO #615: Update the config setup so that the Beachfront URLs can be configured, and use those in TestRaceIntegration in exchange_test.go - openrtb_ext.BidderBeachfront: beachfront.NewBeachfrontBidder(), - openrtb_ext.BidderBrightroll: brightroll.NewBrightrollBidder(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].Endpoint), - openrtb_ext.BidderConsumable: consumable.NewConsumableBidder(cfg.Adapters[string(openrtb_ext.BidderConsumable)].Endpoint), - openrtb_ext.BidderCpmstar: cpmstar.NewCpmstarBidder(cfg.Adapters[string(openrtb_ext.BidderCpmstar)].Endpoint), - openrtb_ext.BidderDatablocks: datablocks.NewDatablocksBidder(cfg.Adapters[string(openrtb_ext.BidderDatablocks)].Endpoint), - openrtb_ext.BidderEmxDigital: emx_digital.NewEmxDigitalBidder(cfg.Adapters[string(openrtb_ext.BidderEmxDigital)].Endpoint), - openrtb_ext.BidderEngageBDR: engagebdr.NewEngageBDRBidder(client, cfg.Adapters[string(openrtb_ext.BidderEngageBDR)].Endpoint), - openrtb_ext.BidderEPlanning: eplanning.NewEPlanningBidder(client, cfg.Adapters[string(openrtb_ext.BidderEPlanning)].Endpoint), + openrtb_ext.BidderBeachfront: beachfront.NewBeachfrontBidder(cfg.Adapters[string(openrtb_ext.BidderBeachfront)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderBeachfront)].ExtraAdapterInfo), + openrtb_ext.BidderBrightroll: brightroll.NewBrightrollBidder(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].Endpoint), + openrtb_ext.BidderConsumable: consumable.NewConsumableBidder(cfg.Adapters[string(openrtb_ext.BidderConsumable)].Endpoint), + openrtb_ext.BidderCpmstar: cpmstar.NewCpmstarBidder(cfg.Adapters[string(openrtb_ext.BidderCpmstar)].Endpoint), + openrtb_ext.BidderDatablocks: datablocks.NewDatablocksBidder(cfg.Adapters[string(openrtb_ext.BidderDatablocks)].Endpoint), + openrtb_ext.BidderEmxDigital: emx_digital.NewEmxDigitalBidder(cfg.Adapters[string(openrtb_ext.BidderEmxDigital)].Endpoint), + openrtb_ext.BidderEngageBDR: engagebdr.NewEngageBDRBidder(client, cfg.Adapters[string(openrtb_ext.BidderEngageBDR)].Endpoint), + openrtb_ext.BidderEPlanning: eplanning.NewEPlanningBidder(client, cfg.Adapters[string(openrtb_ext.BidderEPlanning)].Endpoint), openrtb_ext.BidderFacebook: audienceNetwork.NewFacebookBidder( client, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID, diff --git a/exchange/exchange_test.go b/exchange/exchange_test.go index f263eea8569..e7df5e85733 100644 --- a/exchange/exchange_test.go +++ b/exchange/exchange_test.go @@ -483,6 +483,11 @@ func TestRaceIntegration(t *testing.T) { Endpoint: server.URL, PlatformID: "abc", } + cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderBeachfront))] = config.Adapter{ + Endpoint: server.URL, + ExtraAdapterInfo: "{\"video_endpoint\":\"" + server.URL + "\"}", + } + categoriesFetcher, error := newCategoryFetcher("./test/category-mapping") if error != nil { t.Errorf("Failed to create a category Fetcher: %v", error)