From c47da1364010681b56795434a0f976a73e9bd098 Mon Sep 17 00:00:00 2001 From: ix-certification Date: Mon, 22 Oct 2018 16:17:45 -0400 Subject: [PATCH] Rename indexExchange to ix (#657) (#712) --- adapters/{indexExchange/index.go => ix/ix.go} | 58 ++++--- .../index_test.go => ix/ix_test.go} | 164 +++++++++++++++--- .../ixtest}/params/race/banner.json | 0 .../ixtest}/params/race/video.json | 0 config/config.go | 3 +- config/config_test.go | 4 +- exchange/adapter_map.go | 4 +- openrtb_ext/bidders.go | 4 +- pbs/pbsrequest.go | 4 +- pbs/pbsrequest_test.go | 22 +-- pbsmetrics/prometheus/prometheus_test.go | 2 +- router/router.go | 12 +- .../{indexExchange.yaml => ix.yaml} | 1 - .../{indexExchange.json => ix.json} | 10 +- usersync/usersyncers/indexExchange_test.go | 18 -- .../usersyncers/{indexExchange.go => ix.go} | 4 +- usersync/usersyncers/ix_test.go | 18 ++ usersync/usersyncers/syncer.go | 2 +- 18 files changed, 228 insertions(+), 102 deletions(-) rename adapters/{indexExchange/index.go => ix/ix.go} (73%) rename adapters/{indexExchange/index_test.go => ix/ix_test.go} (53%) rename adapters/{indexExchange/indexExchangetest => ix/ixtest}/params/race/banner.json (100%) rename adapters/{indexExchange/indexExchangetest => ix/ixtest}/params/race/video.json (100%) rename static/bidder-info/{indexExchange.yaml => ix.yaml} (86%) rename static/bidder-params/{indexExchange.json => ix.json} (67%) delete mode 100644 usersync/usersyncers/indexExchange_test.go rename usersync/usersyncers/{indexExchange.go => ix.go} (64%) create mode 100644 usersync/usersyncers/ix_test.go diff --git a/adapters/indexExchange/index.go b/adapters/ix/ix.go similarity index 73% rename from adapters/indexExchange/index.go rename to adapters/ix/ix.go index 2b2799c1a56..45bc6300a5b 100644 --- a/adapters/indexExchange/index.go +++ b/adapters/ix/ix.go @@ -1,4 +1,4 @@ -package indexExchange +package ix import ( "bytes" @@ -17,31 +17,31 @@ import ( "github.com/prebid/prebid-server/errortypes" ) -type IndexAdapter struct { +type IxAdapter struct { http *adapters.HTTPAdapter URI string } // used for cookies and such -func (a *IndexAdapter) Name() string { - return "indexExchange" +func (a *IxAdapter) Name() string { + return "ix" } -func (a *IndexAdapter) SkipNoCookies() bool { +func (a *IxAdapter) SkipNoCookies() bool { return false } type indexParams struct { - SiteID int `json:"siteID"` + SiteID string `json:"siteId"` } -func (a *IndexAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pbs.PBSBidder) (pbs.PBSBidSlice, error) { +func (a *IxAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pbs.PBSBidder) (pbs.PBSBidSlice, error) { if req.App != nil { return nil, &errortypes.BadInput{ Message: "Index doesn't support apps", } } - mediaTypes := []pbs.MediaType{pbs.MEDIA_TYPE_BANNER, pbs.MEDIA_TYPE_VIDEO} + mediaTypes := []pbs.MediaType{pbs.MEDIA_TYPE_BANNER} indexReq, err := adapters.MakeOpenRTBGeneric(req, bidder, a.Name(), mediaTypes) if err != nil { @@ -56,9 +56,9 @@ func (a *IndexAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb Message: fmt.Sprintf("unmarshal params '%s' failed: %v", unit.Params, err), } } - if params.SiteID == 0 { + if params.SiteID == "" { return nil, &errortypes.BadInput{ - Message: "Missing siteID param", + Message: "Missing siteId param", } } @@ -72,7 +72,7 @@ func (a *IndexAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb // ext is DFP div ID and KV pairs if avail //indexReq.Imp[i].Ext = json.RawMessage("{}") siteCopy := *indexReq.Site - siteCopy.Publisher = &openrtb.Publisher{ID: fmt.Sprintf("%d", params.SiteID)} + siteCopy.Publisher = &openrtb.Publisher{ID: fmt.Sprintf("%s", params.SiteID)} indexReq.Site = &siteCopy } // spec also asks for publisher id if set @@ -136,11 +136,8 @@ func (a *IndexAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb bids := make(pbs.PBSBidSlice, 0) - numBids := 0 for _, sb := range bidResp.SeatBid { - for i, bid := range sb.Bid { - numBids++ - + for _, bid := range sb.Bid { bidID := bidder.LookupBidID(bid.ImpID) if bidID == "" { return nil, &errortypes.BadServerResponse{ @@ -148,26 +145,31 @@ func (a *IndexAdapter) Call(ctx context.Context, req *pbs.PBSRequest, bidder *pb } } - pbid := pbs.PBSBid{ - BidID: bidID, - AdUnitCode: bidder.AdUnits[i].Code, // todo: check this - BidderCode: bidder.BidderCode, - Price: bid.Price, - Adm: bid.AdM, - Creative_id: bid.CrID, - Width: bid.W, - Height: bid.H, - DealId: bid.DealID, + for _, adunit := range bidder.AdUnits { + if adunit.BidID == bidID { + pbid := pbs.PBSBid{ + BidID: bidID, + AdUnitCode: adunit.Code, + BidderCode: bidder.BidderCode, + Price: bid.Price, + Adm: bid.AdM, + Creative_id: bid.CrID, + Width: bid.W, + Height: bid.H, + DealId: bid.DealID, + CreativeMediaType: "banner", + } + bids = append(bids, &pbid) + } } - bids = append(bids, &pbid) } } return bids, nil } -func NewIndexAdapter(config *adapters.HTTPAdapterConfig, uri string) *IndexAdapter { +func NewIxAdapter(config *adapters.HTTPAdapterConfig, uri string) *IxAdapter { a := adapters.NewHTTPAdapter(config) - return &IndexAdapter{ + return &IxAdapter{ http: a, URI: uri, } diff --git a/adapters/indexExchange/index_test.go b/adapters/ix/ix_test.go similarity index 53% rename from adapters/indexExchange/index_test.go rename to adapters/ix/ix_test.go index a0bfcc3e205..08c86625cc0 100644 --- a/adapters/indexExchange/index_test.go +++ b/adapters/ix/ix_test.go @@ -1,4 +1,4 @@ -package indexExchange +package ix import ( "context" @@ -16,9 +16,11 @@ import ( "github.com/prebid/prebid-server/adapters" ) -func TestIndexInvalidCall(t *testing.T) { +const url string = "http://appnexus-us-east.lb.indexww.com/bidder?p=184932" - an := NewIndexAdapter(adapters.DefaultHTTPAdapterConfig, "http://appnexus-eu.lb.indexww.com/bidder?p=184932") +func TestIxInvalidCall(t *testing.T) { + + an := NewIxAdapter(adapters.DefaultHTTPAdapterConfig, url) an.URI = "blah" ctx := context.TODO() @@ -30,7 +32,55 @@ func TestIndexInvalidCall(t *testing.T) { } } -func TestIndexTimeout(t *testing.T) { +func TestIxInvalidCallReqAppNil(t *testing.T) { + + an := NewIxAdapter(adapters.DefaultHTTPAdapterConfig, url) + an.URI = "blah" + + ctx := context.TODO() + pbReq := pbs.PBSRequest{ + App: &openrtb.App{}, + } + + pbBidder := pbs.PBSBidder{} + _, err := an.Call(ctx, &pbReq, &pbBidder) + + if err == nil { + t.Fatalf("No error recived for invalid request") + } +} + +func TestIxInvalidCallMissingSiteID(t *testing.T) { + + an := NewIxAdapter(adapters.DefaultHTTPAdapterConfig, url) + an.URI = "blah" + + ctx := context.TODO() + pbReq := pbs.PBSRequest{} + + pbBidder := pbs.PBSBidder{ + BidderCode: "bannerCode", + AdUnits: []pbs.PBSAdUnit{ + { + Code: "unitCode", + MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, + Sizes: []openrtb.Format{ + { + W: 10, + H: 12, + }, + }, + Params: json.RawMessage("{}"), + }, + }, + } + _, err := an.Call(ctx, &pbReq, &pbBidder) + if err == nil { + t.Fatalf("No error received for request with missing siteId") + } +} + +func TestIxTimeout(t *testing.T) { server := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +90,7 @@ func TestIndexTimeout(t *testing.T) { defer server.Close() conf := *adapters.DefaultHTTPAdapterConfig - an := NewIndexAdapter(&conf, server.URL) + an := NewIxAdapter(&conf, server.URL) ctx, cancel := context.WithTimeout(context.Background(), 0) defer cancel() @@ -57,7 +107,7 @@ func TestIndexTimeout(t *testing.T) { H: 12, }, }, - Params: json.RawMessage("{\"siteID\": 12}"), + Params: json.RawMessage("{\"siteId\": \"12\"}"), }, }, } @@ -67,7 +117,7 @@ func TestIndexTimeout(t *testing.T) { } } -func TestIndexInvalidJson(t *testing.T) { +func TestIxInvalidJsonResponse(t *testing.T) { server := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +127,7 @@ func TestIndexInvalidJson(t *testing.T) { defer server.Close() conf := *adapters.DefaultHTTPAdapterConfig - an := NewIndexAdapter(&conf, server.URL) + an := NewIxAdapter(&conf, server.URL) ctx := context.TODO() pbReq := pbs.PBSRequest{} pbBidder := pbs.PBSBidder{ @@ -92,7 +142,7 @@ func TestIndexInvalidJson(t *testing.T) { H: 12, }, }, - Params: json.RawMessage("{\"siteID\": 12}"), + Params: json.RawMessage("{\"siteId\": \"12\"}"), }, }, } @@ -102,7 +152,7 @@ func TestIndexInvalidJson(t *testing.T) { } } -func TestIndexInvalidStatusCode(t *testing.T) { +func TestIxInvalidStatusCode(t *testing.T) { server := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -113,7 +163,7 @@ func TestIndexInvalidStatusCode(t *testing.T) { defer server.Close() conf := *adapters.DefaultHTTPAdapterConfig - an := NewIndexAdapter(&conf, server.URL) + an := NewIxAdapter(&conf, server.URL) ctx := context.TODO() pbReq := pbs.PBSRequest{} pbBidder := pbs.PBSBidder{ @@ -128,7 +178,7 @@ func TestIndexInvalidStatusCode(t *testing.T) { H: 12, }, }, - Params: json.RawMessage("{\"siteID\": 12}"), + Params: json.RawMessage("{\"siteId\": \"12\"}"), }, }, } @@ -138,18 +188,18 @@ func TestIndexInvalidStatusCode(t *testing.T) { } } -func TestIndexMissingSiteId(t *testing.T) { +func TestIxBadRequest(t *testing.T) { server := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // Send 404 - http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) + // Send 400 + http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) }), ) defer server.Close() conf := *adapters.DefaultHTTPAdapterConfig - an := NewIndexAdapter(&conf, server.URL) + an := NewIxAdapter(&conf, server.URL) ctx := context.TODO() pbReq := pbs.PBSRequest{} pbBidder := pbs.PBSBidder{ @@ -164,16 +214,90 @@ func TestIndexMissingSiteId(t *testing.T) { H: 12, }, }, + Params: json.RawMessage("{\"siteId\": \"12\"}"), + }, + }, + } + _, err := an.Call(ctx, &pbReq, &pbBidder) + if err == nil { + t.Fatalf("No error received for bad request") + } +} + +func TestIxNoContent(t *testing.T) { + + server := httptest.NewServer( + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // Send 204 + http.Error(w, http.StatusText(http.StatusNoContent), http.StatusNoContent) + }), + ) + defer server.Close() + + conf := *adapters.DefaultHTTPAdapterConfig + an := NewIxAdapter(&conf, server.URL) + ctx := context.TODO() + pbReq := pbs.PBSRequest{} + pbBidder := pbs.PBSBidder{ + BidderCode: "bannerCode", + AdUnits: []pbs.PBSAdUnit{ + { + MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, + Sizes: []openrtb.Format{ + { + W: 10, + H: 12, + }, + }, + Params: json.RawMessage("{\"siteId\": \"12\"}"), + }, + }, + } + + bids, err := an.Call(ctx, &pbReq, &pbBidder) + if err != nil || bids != nil { + t.Fatalf("Must return nil for no content") + } +} + +func TestIxInvalidCallMissingSize(t *testing.T) { + + server := httptest.NewServer( + http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + resp := openrtb.BidResponse{} + js, err := json.Marshal(resp) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Header().Set("Content-Type", "application/json") + w.Write(js) + }), + ) + defer server.Close() + + conf := *adapters.DefaultHTTPAdapterConfig + an := NewIxAdapter(&conf, server.URL) + ctx := context.TODO() + pbReq := pbs.PBSRequest{} + pbBidder := pbs.PBSBidder{ + BidderCode: "bannerCode", + AdUnits: []pbs.PBSAdUnit{ + { + Code: "unitCode", + MediaTypes: []pbs.MediaType{pbs.MEDIA_TYPE_BANNER}, + BidID: "bidid", + Params: json.RawMessage("{\"siteId\": \"12\"}"), }, }, } _, err := an.Call(ctx, &pbReq, &pbBidder) if err == nil { - t.Fatalf("No error received for missing siteID") + t.Fatalf("Should not have gotten an error for missing/invalid size: %v", err) } } -func TestIndexBasicResponse(t *testing.T) { +func TestIxBasicResponse(t *testing.T) { server := httptest.NewServer( http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { @@ -208,7 +332,7 @@ func TestIndexBasicResponse(t *testing.T) { defer server.Close() conf := *adapters.DefaultHTTPAdapterConfig - an := NewIndexAdapter(&conf, server.URL) + an := NewIxAdapter(&conf, server.URL) ctx := context.TODO() pbReq := pbs.PBSRequest{} pbBidder := pbs.PBSBidder{ @@ -224,7 +348,7 @@ func TestIndexBasicResponse(t *testing.T) { H: 12, }, }, - Params: json.RawMessage("{\"siteID\": 12}"), + Params: json.RawMessage("{\"siteId\": \"12\"}"), }, }, } diff --git a/adapters/indexExchange/indexExchangetest/params/race/banner.json b/adapters/ix/ixtest/params/race/banner.json similarity index 100% rename from adapters/indexExchange/indexExchangetest/params/race/banner.json rename to adapters/ix/ixtest/params/race/banner.json diff --git a/adapters/indexExchange/indexExchangetest/params/race/video.json b/adapters/ix/ixtest/params/race/video.json similarity index 100% rename from adapters/indexExchange/indexExchangetest/params/race/video.json rename to adapters/ix/ixtest/params/race/video.json diff --git a/config/config.go b/config/config.go index 7116e281331..8c6fa2fc62f 100644 --- a/config/config.go +++ b/config/config.go @@ -349,7 +349,8 @@ func SetupViper(v *viper.Viper, filename string) { v.SetDefault("adapters.conversant.usersync_url", "//prebid-match.dotomi.com/prebid/match?rurl=") v.SetDefault("adapters.eplanning.endpoint", "http://ads.us.e-planning.net/dsp/obr/1") v.SetDefault("adapters.eplanning.usersync_url", "http://sync.e-planning.net/um?uid") - v.SetDefault("adapters.indexexchange.usersync_url", "//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3DindexExchange%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D") + v.SetDefault("adapters.ix.usersync_url", "http://ssum.casalemedia.com/usermatchredir?s=184932&cb=https%3A%2F%2Fprebid.adnxs.com%2Fpbs%2Fv1%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D") + v.SetDefault("adapters.ix.endpoint", "http://appnexus-us-east.lb.indexww.com/transbidder?p=184932") v.SetDefault("adapters.lifestreet.endpoint", "https://prebid.s2s.lfstmedia.com/adrequest") v.SetDefault("adapters.openx.endpoint", "http://rtb.openx.net/prebid") v.SetDefault("adapters.pubmatic.endpoint", "http://hbopenbid.pubmatic.com/translator?source=prebid-server") diff --git a/config/config_test.go b/config/config_test.go index 1d7500895bf..0622b4d3948 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -72,7 +72,7 @@ adapters: endpoint: http://facebook.com/pbs usersync_url: http://facebook.com/ortb/prebid-s2s platform_id: abcdefgh1234 - indexExchange: + ix: endpoint: http://ixtest.com/api rubicon: endpoint: http://rubitest.com/api @@ -151,7 +151,7 @@ func TestFullConfig(t *testing.T) { cmpStrings(t, "adapters.audiencenetwork.endpoint", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].Endpoint, "http://facebook.com/pbs") 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.indexexchange.endpoint", cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIndex))].Endpoint, "http://ixtest.com/api") + 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") cmpStrings(t, "adapters.rubicon.xapi.username", cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Username, "rubiuser") diff --git a/exchange/adapter_map.go b/exchange/adapter_map.go index 5c8351c8ab3..218cb7b252c 100644 --- a/exchange/adapter_map.go +++ b/exchange/adapter_map.go @@ -14,7 +14,7 @@ import ( "github.com/prebid/prebid-server/adapters/brightroll" "github.com/prebid/prebid-server/adapters/conversant" "github.com/prebid/prebid-server/adapters/eplanning" - "github.com/prebid/prebid-server/adapters/indexExchange" + "github.com/prebid/prebid-server/adapters/ix" "github.com/prebid/prebid-server/adapters/lifestreet" "github.com/prebid/prebid-server/adapters/openx" "github.com/prebid/prebid-server/adapters/pubmatic" @@ -59,7 +59,7 @@ func newAdapterMap(client *http.Client, cfg *config.Configuration, infos adapter // TODO #211: Upgrade the Facebook adapter openrtb_ext.BidderFacebook: audienceNetwork.NewAdapterFromFacebook(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID), // TODO #212: Upgrade the Index adapter - openrtb_ext.BidderIndex: indexExchange.NewIndexAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIndex))].Endpoint), + openrtb_ext.BidderIx: ix.NewIxAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIx))].Endpoint), // TODO #213: Upgrade the Lifestreet adapter openrtb_ext.BidderLifestreet: lifestreet.NewLifestreetAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderLifestreet)].Endpoint), // TODO #215: Upgrade the Pulsepoint adapter diff --git a/openrtb_ext/bidders.go b/openrtb_ext/bidders.go index d8e0af5a70e..1445e0a4999 100644 --- a/openrtb_ext/bidders.go +++ b/openrtb_ext/bidders.go @@ -29,7 +29,7 @@ const ( BidderConversant BidderName = "conversant" BidderEPlanning BidderName = "eplanning" BidderFacebook BidderName = "audienceNetwork" - BidderIndex BidderName = "indexExchange" + BidderIx BidderName = "ix" BidderLifestreet BidderName = "lifestreet" BidderOpenx BidderName = "openx" BidderPubmatic BidderName = "pubmatic" @@ -51,7 +51,7 @@ var BidderMap = map[string]BidderName{ "brightroll": BidderBrightroll, "conversant": BidderConversant, "eplanning": BidderEPlanning, - "indexExchange": BidderIndex, + "ix": BidderIx, "lifestreet": BidderLifestreet, "openx": BidderOpenx, "pubmatic": BidderPubmatic, diff --git a/pbs/pbsrequest.go b/pbs/pbsrequest.go index e435cf02bc0..3efe742f5c4 100644 --- a/pbs/pbsrequest.go +++ b/pbs/pbsrequest.go @@ -320,7 +320,7 @@ func ParsePBSRequest(r *http.Request, cfg *config.AuctionTimeouts, cache cache.C for _, b := range bidders { var bidder *PBSBidder // index requires a different request for each ad unit - if b.BidderCode != "indexExchange" { + if b.BidderCode != "ix" { for _, pb := range pbsReq.Bidders { if pb.BidderCode == b.BidderCode { bidder = pb @@ -329,7 +329,7 @@ func ParsePBSRequest(r *http.Request, cfg *config.AuctionTimeouts, cache cache.C } if bidder == nil { bidder = &PBSBidder{BidderCode: b.BidderCode} - if b.BidderCode == "indexExchange" { + if b.BidderCode == "ix" { bidder.AdUnitCode = unit.Code } pbsReq.Bidders = append(pbsReq.Bidders, bidder) diff --git a/pbs/pbsrequest_test.go b/pbs/pbsrequest_test.go index 92122cc7d2f..800845eb793 100644 --- a/pbs/pbsrequest_test.go +++ b/pbs/pbsrequest_test.go @@ -43,7 +43,7 @@ func TestParseSimpleRequest(t *testing.T) { "sizes": [{"w": 300, "h": 250}], "bids": [ { - "bidder": "indexExchange" + "bidder": "ix" }, { "bidder": "appnexus" @@ -59,7 +59,7 @@ func TestParseSimpleRequest(t *testing.T) { }, "bids": [ { - "bidder": "indexExchange" + "bidder": "ix" }, { "bidder": "appnexus" @@ -93,7 +93,7 @@ func TestParseSimpleRequest(t *testing.T) { if len(pbs_req.Bidders) != 3 { t.Fatalf("Should have three bidders (2 for index) not %d", len(pbs_req.Bidders)) } - if pbs_req.Bidders[0].BidderCode != "indexExchange" { + if pbs_req.Bidders[0].BidderCode != "ix" { t.Errorf("First bidder not index") } if len(pbs_req.Bidders[0].AdUnits) != 1 { @@ -105,7 +105,7 @@ func TestParseSimpleRequest(t *testing.T) { if len(pbs_req.Bidders[1].AdUnits) != 2 { t.Errorf("AppNexus bidder should have 2 ad unit") } - if pbs_req.Bidders[2].BidderCode != "indexExchange" { + if pbs_req.Bidders[2].BidderCode != "ix" { t.Errorf("Third bidder not index") } if len(pbs_req.Bidders[2].AdUnits) != 1 { @@ -141,7 +141,7 @@ func TestHeaderParsing(t *testing.T) { "sizes": [{"w": 300, "h": 250}], "bidders": [ { - "bidder": "indexExchange", + "bidder": "ix", "params": { "id": "417", "siteID": "test-site" @@ -181,7 +181,7 @@ func TestHeaderParsing(t *testing.T) { var dummyConfig = ` [ { - "bidder": "indexExchange", + "bidder": "ix", "bid_id": "22222222", "params": { "id": "4", @@ -223,7 +223,7 @@ func TestParseConfig(t *testing.T) { "sizes": [{"w": 300, "h": 250}], "bids": [ { - "bidder": "indexExchange" + "bidder": "ix" }, { "bidder": "appnexus" @@ -263,7 +263,7 @@ func TestParseConfig(t *testing.T) { if len(pbs_req.Bidders) != 5 { t.Fatalf("Should have 5 bidders (2 for index) not %d", len(pbs_req.Bidders)) } - if pbs_req.Bidders[0].BidderCode != "indexExchange" { + if pbs_req.Bidders[0].BidderCode != "ix" { t.Errorf("First bidder not index") } if len(pbs_req.Bidders[0].AdUnits) != 1 { @@ -275,7 +275,7 @@ func TestParseConfig(t *testing.T) { if len(pbs_req.Bidders[1].AdUnits) != 2 { t.Errorf("AppNexus bidder should have 2 ad unit") } - if pbs_req.Bidders[2].BidderCode != "indexExchange" { + if pbs_req.Bidders[2].BidderCode != "ix" { t.Errorf("Third bidder not index") } if len(pbs_req.Bidders[2].AdUnits) != 1 { @@ -603,7 +603,7 @@ func TestParseRequestWithInstl(t *testing.T) { ], "bids": [ { - "bidder": "indexExchange" + "bidder": "ix" }, { "bidder": "appnexus" @@ -684,7 +684,7 @@ func doTimeoutTest(t *testing.T, expected int, requested int, max uint64, def ui "sizes": [{"w": 300, "h": 250}], "bids": [ { - "bidder": "indexExchange" + "bidder": "ix" } ] } diff --git a/pbsmetrics/prometheus/prometheus_test.go b/pbsmetrics/prometheus/prometheus_test.go index c4e932eb44e..6c7b7731f56 100644 --- a/pbsmetrics/prometheus/prometheus_test.go +++ b/pbsmetrics/prometheus/prometheus_test.go @@ -381,7 +381,7 @@ var adaptLabels = []pbsmetrics.AdapterLabels{ { Source: pbsmetrics.DemandApp, RType: pbsmetrics.ReqTypeORTB2Web, - Adapter: openrtb_ext.BidderIndex, + Adapter: openrtb_ext.BidderIx, PubID: "Pub2", Browser: pbsmetrics.BrowserOther, CookieFlag: pbsmetrics.CookieFlagNo, diff --git a/router/router.go b/router/router.go index d904be623b4..91f141b6931 100644 --- a/router/router.go +++ b/router/router.go @@ -17,7 +17,7 @@ import ( "github.com/prebid/prebid-server/adapters/appnexus" "github.com/prebid/prebid-server/adapters/audienceNetwork" "github.com/prebid/prebid-server/adapters/conversant" - "github.com/prebid/prebid-server/adapters/indexExchange" + "github.com/prebid/prebid-server/adapters/ix" "github.com/prebid/prebid-server/adapters/lifestreet" "github.com/prebid/prebid-server/adapters/pubmatic" "github.com/prebid/prebid-server/adapters/pulsepoint" @@ -135,11 +135,11 @@ func loadDataCache(cfg *config.Configuration, db *sql.DB) (err error) { func newExchangeMap(cfg *config.Configuration) map[string]adapters.Adapter { // These keys _must_ coincide with the bidder code in Prebid.js, if the adapter exists in both projects return map[string]adapters.Adapter{ - "appnexus": appnexus.NewAppNexusAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint), - "districtm": appnexus.NewAppNexusAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint), - "indexExchange": indexExchange.NewIndexAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIndex))].Endpoint), - "pubmatic": pubmatic.NewPubmaticAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderPubmatic)].Endpoint), - "pulsepoint": pulsepoint.NewPulsePointAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderPulsepoint)].Endpoint), + "appnexus": appnexus.NewAppNexusAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint), + "districtm": appnexus.NewAppNexusAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderAppnexus)].Endpoint), + "ix": ix.NewIxAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIx))].Endpoint), + "pubmatic": pubmatic.NewPubmaticAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderPubmatic)].Endpoint), + "pulsepoint": pulsepoint.NewPulsePointAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderPulsepoint)].Endpoint), "rubicon": rubicon.NewRubiconAdapter(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[string(openrtb_ext.BidderRubicon)].Endpoint, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Username, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Password, cfg.Adapters[string(openrtb_ext.BidderRubicon)].XAPI.Tracker), "audienceNetwork": audienceNetwork.NewAdapterFromFacebook(adapters.DefaultHTTPAdapterConfig, cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderFacebook))].PlatformID), diff --git a/static/bidder-info/indexExchange.yaml b/static/bidder-info/ix.yaml similarity index 86% rename from static/bidder-info/indexExchange.yaml rename to static/bidder-info/ix.yaml index fb03c684fbc..ff29ec03f77 100644 --- a/static/bidder-info/indexExchange.yaml +++ b/static/bidder-info/ix.yaml @@ -4,4 +4,3 @@ capabilities: site: mediaTypes: - banner - - video diff --git a/static/bidder-params/indexExchange.json b/static/bidder-params/ix.json similarity index 67% rename from static/bidder-params/indexExchange.json rename to static/bidder-params/ix.json index 90209d10fc6..5aaed59972e 100644 --- a/static/bidder-params/indexExchange.json +++ b/static/bidder-params/ix.json @@ -1,13 +1,13 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Index Adapter Params", - "description": "A schema which validates params accepted by the Index adapter", + "title": "Ix Adapter Params", + "description": "A schema which validates params accepted by the Ix adapter", "type": "object", "properties": { - "siteID": { - "type": "integer", + "siteId": { + "type": "string", "description": "An ID which identifies the site selling the impression" } }, - "required": ["siteID"] + "required": ["siteId"] } diff --git a/usersync/usersyncers/indexExchange_test.go b/usersync/usersyncers/indexExchange_test.go deleted file mode 100644 index faefd7183fc..00000000000 --- a/usersync/usersyncers/indexExchange_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package usersyncers - -import ( - "testing" -) - -func TestIndexSyncer(t *testing.T) { - syncer := NewIndexSyncer("//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3DindexExchange%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D") - info := syncer.GetUsersyncInfo("", "") - assertStringsMatch(t, "//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3DindexExchange%26gdpr%3D%26gdpr_consent%3D%26uid%3D", info.URL) - assertStringsMatch(t, "redirect", info.Type) - if info.SupportCORS != false { - t.Fatalf("should have been false") - } - if syncer.GDPRVendorID() != 10 { - t.Errorf("Wrong Index GDPR VendorID. Got %d", syncer.GDPRVendorID()) - } -} diff --git a/usersync/usersyncers/indexExchange.go b/usersync/usersyncers/ix.go similarity index 64% rename from usersync/usersyncers/indexExchange.go rename to usersync/usersyncers/ix.go index 4dcb34b00e0..0a3328f53c1 100644 --- a/usersync/usersyncers/indexExchange.go +++ b/usersync/usersyncers/ix.go @@ -1,8 +1,8 @@ package usersyncers -func NewIndexSyncer(userSyncURL string) *syncer { +func NewIxSyncer(userSyncURL string) *syncer { return &syncer{ - familyName: "indexExchange", + familyName: "ix", gdprVendorID: 10, syncEndpointBuilder: resolveMacros(userSyncURL), syncType: SyncTypeRedirect, diff --git a/usersync/usersyncers/ix_test.go b/usersync/usersyncers/ix_test.go new file mode 100644 index 00000000000..8ba0f52b26c --- /dev/null +++ b/usersync/usersyncers/ix_test.go @@ -0,0 +1,18 @@ +package usersyncers + +import ( + "testing" +) + +func TestIxSyncer(t *testing.T) { + syncer := NewIxSyncer("//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3Dix%26gdpr%3D{{gdpr}}%26gdpr_consent%3D{{gdpr_consent}}%26uid%3D") + info := syncer.GetUsersyncInfo("", "") + assertStringsMatch(t, "//ssum-sec.casalemedia.com/usermatchredir?s=184932&cb=localhost%2Fsetuid%3Fbidder%3Dix%26gdpr%3D%26gdpr_consent%3D%26uid%3D", info.URL) + assertStringsMatch(t, "redirect", info.Type) + if info.SupportCORS != false { + t.Fatalf("should have been false") + } + if syncer.GDPRVendorID() != 10 { + t.Errorf("Wrong IX GDPR VendorID. Got %d", syncer.GDPRVendorID()) + } +} diff --git a/usersync/usersyncers/syncer.go b/usersync/usersyncers/syncer.go index 30f80e599f9..5d924f64f16 100644 --- a/usersync/usersyncers/syncer.go +++ b/usersync/usersyncers/syncer.go @@ -21,7 +21,7 @@ func NewSyncerMap(cfg *config.Configuration) map[openrtb_ext.BidderName]usersync openrtb_ext.BidderBrightroll: NewBrightrollSyncer(cfg.Adapters[string(openrtb_ext.BidderBrightroll)].UserSyncURL, cfg.ExternalURL), openrtb_ext.BidderConversant: NewConversantSyncer(cfg.Adapters[string(openrtb_ext.BidderConversant)].UserSyncURL, cfg.ExternalURL), openrtb_ext.BidderEPlanning: NewEPlanningSyncer(cfg.Adapters[string(openrtb_ext.BidderEPlanning)].UserSyncURL, cfg.ExternalURL), - openrtb_ext.BidderIndex: NewIndexSyncer(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIndex))].UserSyncURL), + openrtb_ext.BidderIx: NewIxSyncer(cfg.Adapters[strings.ToLower(string(openrtb_ext.BidderIx))].UserSyncURL), openrtb_ext.BidderLifestreet: NewLifestreetSyncer(cfg.ExternalURL), openrtb_ext.BidderOpenx: NewOpenxSyncer(cfg.ExternalURL), openrtb_ext.BidderPubmatic: NewPubmaticSyncer(cfg.ExternalURL),