github.com/prebid/prebid-server/v2@v2.18.0/adapters/dmx/dmx_test.go (about)

     1  package dmx
     2  
     3  import (
     4  	"encoding/json"
     5  	"strings"
     6  	"testing"
     7  
     8  	"github.com/prebid/openrtb/v20/openrtb2"
     9  	"github.com/prebid/prebid-server/v2/adapters"
    10  	"github.com/prebid/prebid-server/v2/config"
    11  	"github.com/prebid/prebid-server/v2/openrtb_ext"
    12  
    13  	"github.com/prebid/prebid-server/v2/adapters/adapterstest"
    14  )
    15  
    16  func TestFetchParams(t *testing.T) {
    17  	var w, h int = 300, 250
    18  
    19  	var width, height int64 = int64(w), int64(h)
    20  	var arrImp []openrtb2.Imp
    21  	var imps = fetchParams(
    22  		dmxExt{Bidder: dmxParams{
    23  			TagId:       "222",
    24  			PublisherId: "5555",
    25  		}},
    26  		openrtb2.Imp{ID: "32"},
    27  		openrtb2.Imp{ID: "32"},
    28  		arrImp,
    29  		&openrtb2.Banner{W: &width, H: &height, Format: []openrtb2.Format{
    30  			{W: 300, H: 250},
    31  		}},
    32  		nil,
    33  		1)
    34  	var imps2 = fetchParams(
    35  		dmxExt{Bidder: dmxParams{
    36  			DmxId:    "222",
    37  			MemberId: "5555",
    38  		}},
    39  		openrtb2.Imp{ID: "32"},
    40  		openrtb2.Imp{ID: "32"},
    41  		arrImp,
    42  		&openrtb2.Banner{W: &width, H: &height, Format: []openrtb2.Format{
    43  			{W: 300, H: 250},
    44  		}},
    45  		nil,
    46  		1)
    47  	if len(imps) == 0 {
    48  		t.Errorf("should increment the length by one")
    49  	}
    50  
    51  	if len(imps2) == 0 {
    52  		t.Errorf("should increment the length by one")
    53  	}
    54  
    55  }
    56  func TestJsonSamples(t *testing.T) {
    57  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    58  
    59  	if buildErr != nil {
    60  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    61  	}
    62  
    63  	adapterstest.RunJSONBidderTest(t, "dmxtest", bidder)
    64  }
    65  
    66  func TestMakeRequestsOtherPlacement(t *testing.T) {
    67  	var w, h int = 300, 250
    68  
    69  	var width, height int64 = int64(w), int64(h)
    70  
    71  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
    72  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
    73  
    74  	if buildErr != nil {
    75  		t.Fatalf("Builder returned unexpected error %v", buildErr)
    76  	}
    77  
    78  	imp1 := openrtb2.Imp{
    79  		ID:  "imp1",
    80  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
    81  		Banner: &openrtb2.Banner{
    82  			W: &width,
    83  			H: &height,
    84  			Format: []openrtb2.Format{
    85  				{W: 300, H: 250},
    86  			},
    87  		}}
    88  
    89  	inputRequest := openrtb2.BidRequest{
    90  		User: &openrtb2.User{ID: "bscakucbkasucbkasunscancasuin"},
    91  		Imp:  []openrtb2.Imp{imp1},
    92  		Site: &openrtb2.Site{
    93  			Publisher: &openrtb2.Publisher{
    94  				ID: "10007",
    95  			},
    96  		},
    97  		ID: "1234",
    98  	}
    99  
   100  	actualAdapterRequests, err := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   101  
   102  	if actualAdapterRequests == nil {
   103  		t.Errorf("request should be nil")
   104  	}
   105  	if len(err) != 0 {
   106  		t.Errorf("We should have no error")
   107  	}
   108  
   109  }
   110  
   111  func TestMakeRequestsInvalid(t *testing.T) {
   112  	var w, h int = 300, 250
   113  
   114  	var width, height int64 = int64(w), int64(h)
   115  
   116  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   117  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   118  
   119  	if buildErr != nil {
   120  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   121  	}
   122  
   123  	imp1 := openrtb2.Imp{
   124  		ID:  "imp1",
   125  		Ext: json.RawMessage("{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}"),
   126  		Banner: &openrtb2.Banner{
   127  			W: &width,
   128  			H: &height,
   129  			Format: []openrtb2.Format{
   130  				{W: 300, H: 250},
   131  			},
   132  		}}
   133  
   134  	inputRequest := openrtb2.BidRequest{
   135  		Imp: []openrtb2.Imp{imp1},
   136  		Site: &openrtb2.Site{
   137  			Publisher: &openrtb2.Publisher{
   138  				ID: "10007",
   139  			},
   140  		},
   141  		ID: "1234",
   142  	}
   143  
   144  	actualAdapterRequests, err := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   145  
   146  	if len(actualAdapterRequests) != 0 {
   147  		t.Errorf("request should be nil")
   148  	}
   149  	if len(err) == 0 {
   150  		t.Errorf("We should have no error")
   151  	}
   152  
   153  }
   154  
   155  func TestMakeRequestNoSite(t *testing.T) {
   156  	var w, h int = 300, 250
   157  
   158  	var width, height int64 = int64(w), int64(h)
   159  
   160  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   161  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   162  
   163  	if buildErr != nil {
   164  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   165  	}
   166  
   167  	imp1 := openrtb2.Imp{
   168  		ID:  "imp1",
   169  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   170  		Banner: &openrtb2.Banner{
   171  			W: &width,
   172  			H: &height,
   173  			Format: []openrtb2.Format{
   174  				{W: 300, H: 250},
   175  			},
   176  		}}
   177  
   178  	inputRequest := openrtb2.BidRequest{
   179  		Imp: []openrtb2.Imp{imp1},
   180  		App: &openrtb2.App{ID: "cansanuabnua", Publisher: &openrtb2.Publisher{ID: "whatever"}},
   181  		ID:  "1234",
   182  	}
   183  
   184  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   185  
   186  	if len(actualAdapterRequests) != 1 {
   187  		t.Errorf("openrtb type should be an Array when it's an App")
   188  	}
   189  	var the_body openrtb2.BidRequest
   190  	if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil {
   191  		t.Errorf("failed to read bid request")
   192  	}
   193  
   194  	if the_body.App == nil {
   195  		t.Errorf("app property should be populated")
   196  	}
   197  
   198  	if the_body.App.Publisher.ID == "" {
   199  		t.Errorf("Missing publisher ID must be in")
   200  	}
   201  }
   202  
   203  func TestMakeRequestsApp(t *testing.T) {
   204  	var w, h int = 300, 250
   205  
   206  	var width, height int64 = int64(w), int64(h)
   207  
   208  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   209  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   210  
   211  	if buildErr != nil {
   212  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   213  	}
   214  
   215  	imp1 := openrtb2.Imp{
   216  		ID:  "imp1",
   217  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   218  		Banner: &openrtb2.Banner{
   219  			W: &width,
   220  			H: &height,
   221  			Format: []openrtb2.Format{
   222  				{W: 300, H: 250},
   223  			},
   224  		}}
   225  
   226  	inputRequest := openrtb2.BidRequest{
   227  		Imp: []openrtb2.Imp{imp1},
   228  		Site: &openrtb2.Site{
   229  			Publisher: &openrtb2.Publisher{
   230  				ID: "10007",
   231  			},
   232  		},
   233  		App: &openrtb2.App{ID: "cansanuabnua", Publisher: &openrtb2.Publisher{ID: "whatever"}},
   234  		ID:  "1234",
   235  	}
   236  
   237  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   238  
   239  	if len(actualAdapterRequests) != 1 {
   240  		t.Errorf("openrtb type should be an Array when it's an App")
   241  	}
   242  	var the_body openrtb2.BidRequest
   243  	if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil {
   244  		t.Errorf("failed to read bid request")
   245  	}
   246  
   247  	if the_body.App == nil {
   248  		t.Errorf("app property should be populated")
   249  	}
   250  
   251  }
   252  
   253  func TestMakeRequestsNoUser(t *testing.T) {
   254  	var w, h int = 300, 250
   255  
   256  	var width, height int64 = int64(w), int64(h)
   257  
   258  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   259  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   260  
   261  	if buildErr != nil {
   262  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   263  	}
   264  
   265  	imp1 := openrtb2.Imp{
   266  		ID:  "imp1",
   267  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   268  		Banner: &openrtb2.Banner{
   269  			W: &width,
   270  			H: &height,
   271  			Format: []openrtb2.Format{
   272  				{W: 300, H: 250},
   273  			},
   274  		}}
   275  
   276  	inputRequest := openrtb2.BidRequest{
   277  		Imp: []openrtb2.Imp{imp1},
   278  		Site: &openrtb2.Site{
   279  			Publisher: &openrtb2.Publisher{
   280  				ID: "10007",
   281  			},
   282  		},
   283  		ID: "1234",
   284  	}
   285  
   286  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   287  
   288  	if actualAdapterRequests != nil {
   289  		t.Errorf("openrtb type should be empty")
   290  	}
   291  
   292  }
   293  
   294  func TestMakeRequests(t *testing.T) {
   295  	var w, h int = 300, 250
   296  
   297  	var width, height int64 = int64(w), int64(h)
   298  
   299  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   300  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   301  
   302  	if buildErr != nil {
   303  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   304  	}
   305  
   306  	imp1 := openrtb2.Imp{
   307  		ID:  "imp1",
   308  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   309  		Banner: &openrtb2.Banner{
   310  			W: &width,
   311  			H: &height,
   312  			Format: []openrtb2.Format{
   313  				{W: 300, H: 250},
   314  			},
   315  		}}
   316  	imp2 := openrtb2.Imp{
   317  		ID:  "imp2",
   318  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   319  		Banner: &openrtb2.Banner{
   320  			W: &width,
   321  			H: &height,
   322  			Format: []openrtb2.Format{
   323  				{W: 300, H: 250},
   324  			},
   325  		}}
   326  	imp3 := openrtb2.Imp{
   327  		ID:  "imp3",
   328  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   329  		Banner: &openrtb2.Banner{
   330  			W: &width,
   331  			H: &height,
   332  			Format: []openrtb2.Format{
   333  				{W: 300, H: 250},
   334  			},
   335  		}}
   336  
   337  	inputRequest := openrtb2.BidRequest{
   338  		Imp: []openrtb2.Imp{imp1, imp2, imp3},
   339  		Site: &openrtb2.Site{
   340  			Publisher: &openrtb2.Publisher{
   341  				ID: "10007",
   342  			},
   343  		},
   344  		User: &openrtb2.User{ID: "districtmID"},
   345  		ID:   "1234",
   346  	}
   347  
   348  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   349  
   350  	if len(actualAdapterRequests) != 1 {
   351  		t.Errorf("should have 1 request")
   352  	}
   353  	var the_body openrtb2.BidRequest
   354  	if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil {
   355  		t.Errorf("failed to read bid request")
   356  	}
   357  
   358  	if len(the_body.Imp) != 3 {
   359  		t.Errorf("must have 3 bids")
   360  	}
   361  
   362  }
   363  
   364  func TestMakeBidVideo(t *testing.T) {
   365  	var w, h int = 640, 480
   366  
   367  	var width, height int64 = int64(w), int64(h)
   368  
   369  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   370  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   371  
   372  	if buildErr != nil {
   373  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   374  	}
   375  
   376  	imp1 := openrtb2.Imp{
   377  		ID:  "imp1",
   378  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   379  		Video: &openrtb2.Video{
   380  			W:     &width,
   381  			H:     &height,
   382  			MIMEs: []string{"video/mp4"},
   383  		}}
   384  
   385  	inputRequest := openrtb2.BidRequest{
   386  		Imp: []openrtb2.Imp{imp1},
   387  		Site: &openrtb2.Site{
   388  			Publisher: &openrtb2.Publisher{
   389  				ID: "10007",
   390  			},
   391  		},
   392  		User: &openrtb2.User{ID: "districtmID"},
   393  		ID:   "1234",
   394  	}
   395  
   396  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   397  
   398  	if len(actualAdapterRequests) != 1 {
   399  		t.Errorf("should have 1 request")
   400  	}
   401  	var the_body openrtb2.BidRequest
   402  	if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil {
   403  		t.Errorf("failed to read bid request")
   404  	}
   405  
   406  	if len(the_body.Imp) != 1 {
   407  		t.Errorf("must have 1 bids")
   408  	}
   409  }
   410  
   411  func TestMakeBidsNoContent(t *testing.T) {
   412  	var w, h int = 300, 250
   413  
   414  	var width, height int64 = int64(w), int64(h)
   415  
   416  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   417  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   418  
   419  	if buildErr != nil {
   420  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   421  	}
   422  
   423  	imp1 := openrtb2.Imp{
   424  		ID:  "imp1",
   425  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   426  		Banner: &openrtb2.Banner{
   427  			W: &width,
   428  			H: &height,
   429  			Format: []openrtb2.Format{
   430  				{W: 300, H: 250},
   431  			},
   432  		}}
   433  
   434  	inputRequest := openrtb2.BidRequest{
   435  		Imp: []openrtb2.Imp{imp1},
   436  		Site: &openrtb2.Site{
   437  			Publisher: &openrtb2.Publisher{
   438  				ID: "10007",
   439  			},
   440  		},
   441  		User: &openrtb2.User{ID: "districtmID"},
   442  		ID:   "1234",
   443  	}
   444  
   445  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   446  
   447  	_, err204 := bidder.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 204})
   448  
   449  	if err204 != nil {
   450  		t.Errorf("Was expecting nil")
   451  	}
   452  
   453  	_, err400 := bidder.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 400})
   454  
   455  	if err400 == nil {
   456  		t.Errorf("Was expecting error")
   457  	}
   458  
   459  	_, err500 := bidder.MakeBids(&inputRequest, actualAdapterRequests[0], &adapters.ResponseData{StatusCode: 500})
   460  
   461  	if err500 == nil {
   462  		t.Errorf("Was expecting error")
   463  	}
   464  
   465  	bidResponse := &adapters.ResponseData{
   466  		StatusCode: 200,
   467  		Body: []byte(`{
   468    "id": "JdSgvXjee0UZ",
   469    "seatbid": [
   470      {
   471        "bid": [
   472          {
   473            "id": "16-40dbf1ef_0gKywr9JnzPAW4bE-1",
   474            "impid": "imp1",
   475            "price": 2.3456,
   476            "adm": "<some html here \/>",
   477            "nurl": "dmxnotificationurlhere",
   478            "adomain": [
   479              "brand.com",
   480              "advertiser.net"
   481            ],
   482            "cid": "12345",
   483            "crid": "232303",
   484            "cat": [
   485              "IAB20-3"
   486            ],
   487            "attr": [
   488              2
   489            ],
   490            "w": 300,
   491            "h": 600,
   492            "language": "en"
   493          }
   494        ],
   495      "seat": "10001"
   496      }
   497    ],
   498    "cur": "USD"
   499  }`),
   500  	}
   501  
   502  	bidResponseNoMatch := &adapters.ResponseData{
   503  		StatusCode: 200,
   504  		Body: []byte(`{
   505    "id": "JdSgvXjee0UZ",
   506    "seatbid": [
   507      {
   508        "bid": [
   509          {
   510            "id": "16-40dbf1ef_0gKywr9JnzPAW4bE-1",
   511            "impid": "djvnsvns",
   512            "price": 2.3456,
   513            "adm": "<some html here \/>",
   514            "nurl": "dmxnotificationurlhere",
   515            "adomain": [
   516              "brand.com",
   517              "advertiser.net"
   518            ],
   519            "cid": "12345",
   520            "crid": "232303",
   521            "cat": [
   522              "IAB20-3"
   523            ],
   524            "attr": [
   525              2
   526            ],
   527            "w": 300,
   528            "h": 600,
   529            "language": "en"
   530          }
   531        ],
   532      "seat": "10001"
   533      }
   534    ],
   535    "cur": "USD"
   536  }`),
   537  	}
   538  
   539  	bids, _ := bidder.MakeBids(&inputRequest, actualAdapterRequests[0], bidResponse)
   540  	if bids == nil {
   541  		t.Errorf("ads not parse")
   542  	}
   543  	bidsNoMatching, _ := bidder.MakeBids(&inputRequest, actualAdapterRequests[0], bidResponseNoMatch)
   544  	if bidsNoMatching == nil {
   545  		t.Errorf("ads not parse")
   546  	}
   547  
   548  }
   549  func TestUserExtEmptyObject(t *testing.T) {
   550  	var w, h int = 300, 250
   551  
   552  	var width, height int64 = int64(w), int64(h)
   553  
   554  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   555  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   556  
   557  	if buildErr != nil {
   558  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   559  	}
   560  
   561  	imp1 := openrtb2.Imp{
   562  		ID:  "imp1",
   563  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   564  		Banner: &openrtb2.Banner{
   565  			W: &width,
   566  			H: &height,
   567  			Format: []openrtb2.Format{
   568  				{W: 300, H: 250},
   569  			},
   570  		}}
   571  
   572  	inputRequest := openrtb2.BidRequest{
   573  		Imp: []openrtb2.Imp{imp1, imp1, imp1},
   574  		Site: &openrtb2.Site{
   575  			Publisher: &openrtb2.Publisher{
   576  				ID: "10007",
   577  			},
   578  		},
   579  		User: &openrtb2.User{Ext: json.RawMessage(`{}`)},
   580  		ID:   "1234",
   581  	}
   582  
   583  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   584  	if len(actualAdapterRequests) != 0 {
   585  		t.Errorf("should have 0 request")
   586  	}
   587  }
   588  func TestUserEidsOnly(t *testing.T) {
   589  	var w, h int = 300, 250
   590  
   591  	var width, height int64 = int64(w), int64(h)
   592  
   593  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   594  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   595  
   596  	if buildErr != nil {
   597  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   598  	}
   599  
   600  	imp1 := openrtb2.Imp{
   601  		ID:  "imp1",
   602  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   603  		Banner: &openrtb2.Banner{
   604  			W: &width,
   605  			H: &height,
   606  			Format: []openrtb2.Format{
   607  				{W: 300, H: 250},
   608  			},
   609  		}}
   610  
   611  	inputRequest := openrtb2.BidRequest{
   612  		Imp: []openrtb2.Imp{imp1, imp1, imp1},
   613  		Site: &openrtb2.Site{
   614  			Publisher: &openrtb2.Publisher{
   615  				ID: "10007",
   616  			},
   617  		},
   618  		User: &openrtb2.User{Ext: json.RawMessage(`{"eids": [{
   619                  "source": "adserver.org",
   620                  "uids": [{
   621                      "id": "111111111111",
   622                      "ext": {
   623                          "rtiPartner": "TDID"
   624                      }
   625                  }]
   626              },{
   627                  "source": "netid.de",
   628                  "uids": [{
   629                      "id": "11111111"
   630                  }]
   631              }]
   632              }`)},
   633  		ID: "1234",
   634  	}
   635  
   636  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   637  	if len(actualAdapterRequests) != 1 {
   638  		t.Errorf("should have 1 request")
   639  	}
   640  }
   641  
   642  func TestUsersEids(t *testing.T) {
   643  	var w, h int = 300, 250
   644  
   645  	var width, height int64 = int64(w), int64(h)
   646  
   647  	bidder, buildErr := Builder(openrtb_ext.BidderDmx, config.Adapter{
   648  		Endpoint: "https://dmx.districtm.io/b/v2"}, config.Server{ExternalUrl: "http://hosturl.com", GvlID: 1, DataCenter: "2"})
   649  
   650  	if buildErr != nil {
   651  		t.Fatalf("Builder returned unexpected error %v", buildErr)
   652  	}
   653  
   654  	imp1 := openrtb2.Imp{
   655  		ID:  "imp1",
   656  		Ext: json.RawMessage("{\"bidder\":{\"dmxid\": \"1007\", \"memberid\": \"123456\", \"seller_id\":\"1008\"}}"),
   657  		Banner: &openrtb2.Banner{
   658  			W: &width,
   659  			H: &height,
   660  			Format: []openrtb2.Format{
   661  				{W: 300, H: 250},
   662  			},
   663  		}}
   664  
   665  	inputRequest := openrtb2.BidRequest{
   666  		Imp: []openrtb2.Imp{imp1, imp1, imp1},
   667  		Site: &openrtb2.Site{
   668  			Publisher: &openrtb2.Publisher{
   669  				ID: "10007",
   670  			},
   671  		},
   672  		User: &openrtb2.User{ID: "districtmID", Ext: json.RawMessage(`{"eids": [{
   673                  "source": "adserver.org",
   674                  "uids": [{
   675                      "id": "111111111111",
   676                      "ext": {
   677                          "rtiPartner": "TDID"
   678                      }
   679                  }]
   680              },
   681  			{
   682                  "source": "pubcid.org",
   683                  "uids": [{
   684                      "id": "11111111"
   685                  }]
   686              },
   687  			{
   688                  "source": "id5-sync.com",
   689                  "uids": [{
   690                      "id": "ID5-12345"
   691                  }]
   692              },            
   693  			{
   694                  "source": "parrable.com",
   695                  "uids": [{
   696                      "id": "01.1563917337.test-eid"
   697                  }]
   698              },
   699  			{
   700                  "source": "identityLink",
   701                  "uids": [{
   702                      "id": "11111111"
   703                  }]
   704              },
   705  			{
   706                  "source": "criteo",
   707                  "uids": [{
   708                      "id": "11111111"
   709                  }]
   710              },
   711  			{
   712                  "source": "britepool.com",
   713                  "uids": [{
   714                      "id": "11111111"
   715                  }]
   716              },
   717  			{
   718                  "source": "liveintent.com",
   719                  "uids": [{
   720                      "id": "11111111"
   721                  }]
   722              },
   723  			{
   724                  "source": "netid.de",
   725                  "uids": [{
   726                      "id": "11111111"
   727                  }]
   728              }]
   729              }`)},
   730  		ID: "1234",
   731  	}
   732  
   733  	actualAdapterRequests, _ := bidder.MakeRequests(&inputRequest, &adapters.ExtraRequestInfo{})
   734  	if len(actualAdapterRequests) != 1 {
   735  		t.Errorf("should have 1 request")
   736  	}
   737  	var the_body openrtb2.BidRequest
   738  	if err := json.Unmarshal(actualAdapterRequests[0].Body, &the_body); err != nil {
   739  		t.Errorf("failed to read bid request")
   740  	}
   741  
   742  	if len(the_body.Imp) != 3 {
   743  		t.Errorf("must have 3 bids")
   744  	}
   745  }
   746  func TestVideoImpInsertion(t *testing.T) {
   747  	var bidResp openrtb2.BidResponse
   748  	var bid openrtb2.Bid
   749  	payload := []byte(`{
   750      "id": "some-request-id",
   751      "seatbid": [
   752          {
   753              "bid": [
   754                  {
   755                      "id": "video1",
   756                      "impid": "video1",
   757                      "price": 5.01,
   758                      "nurl": "https://demo.arripiblik.com/359585167267151",
   759                      "adm": "<?xml version=\"1.0\" enc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ygzMRMn5KvUjGuxMtD53xTcAXgmbd_5Q0eryr4lMKlDFop2Djei9pyxJR1rTQ4xTfHG3kB-MgdyGZLuFuHtILkPjuVQXhNCuBFMe6dRAtuDvptk1y8VAULdda0YNDLo960PxeTFjbqrRz5wfeUqnu1FV6h9cERcJBGSZlAPH254XNcCwwYyyYr0oD2yQZxmSlr2slQpaW-XdwdGie3vlrmYhfe4-5VrDMHymfKIM-ZUuD3sq6V03Efg14JDMghu9IHO0xbefQuTFBCen1AHBVy4mwJm0Kxp6jEgdNXb7Taa0AF2zwzORu0W0P8lTtWFv3Pg5JWplYorfdJSQGr7hDuxLpyeRiJjzft9liSp22APvHumvJCNgNe0DrWddzW0sRMZOLAFQn1F8cQwLX7mIFEplD3MEQht2HYe4gR8sN44lHQw6CmYV0Ai_tjL1oS17BShey-JkVSPdWVp9r3VfNV1releGX3u-12HtheEvOSsv7qQxIU30Ui10QjnSony-ORz48c4_wbhGmucwUx37Ggf5XhmvVjJUEMDlhYtCj2-rtik2-nskOeSNYKo9hb0DPcahsBEiL4vz7fhgEiivFV0FxiHq0pEukcmOFgE6V7X_upwKli65YEOxrH_GZn2DmjjcUJHD0UNLHOe4D7DV16K7YC9HfodCtzeX0LWZnMCKXv76UiXy_sVITPm4G6Td4AXliC2zwiI_URnQqdCyhRIA40E2qjU31ED56DpkOSo1WiU4fv2mv-n5lyb99lzL2srVV0KFYcvwDOyOnNByXmFw18w6-9snWvYtCDY_AbWtvlSI_60OxCOxipqxGVvA4HXWlFUvOl3OtqRf6apMZIaEpFDcL4N0NGuItEKRb04ZE6lv1zNOxC9WBQHZV_pqK9RQ7YbKrWfcL_c79XQji0Bd3mE6k08AfsjYugcWy-wsjmq467VhLWe4OcSAB8B2Qq_eZl5RPrM6LayPWpuz637TeHNfMwuta9R394K36rAtWRf3Ns_oDJz6g&cid=CAASEuRoF_6hDi9IvsHr8we-jyLVhw]]></VASTAdTagURI><Error><![CDATA[https://gce-sc.bidswitch.net/vast_error/O2lw3vm7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kc2fwHXAzG2Tbu4wyRxenfkeMPAaq5aGvIFL2fWlgz9_Y7tUaUq-k6YZxzlTJ3QbwnmbvL3LejwjkG6BnhR5DuJ-X_EWhKWmna0YsxXA-vnFBmqcH6pyuKQ5C93ZApV8xq_N86vccZ2nVTOI6DLL-8N8cVBKvmp2lL0vAPLU2A5uEaaoX8xuw322lv8ksG1McwGwlFoaWkzjBsJivY2eNeFxXCsFBF6BYiBKLCWy62iecTnQfJykTx3orDsnQez89JPW52DQSsxSb0_YPpUpfclYrBe_FAMle4AOBpZs8ib7hsGXxNOkgJdtwz8_bIIlv-U4Hmoym9ulx0svFV78boErVYrNBf6D43tHl027bfkZgXC0CsVpdmZKUHSpcI3mBQKPC5Qb-tCgVpsLK4xUMvFvJFLXIX1yjj062J4ZH9fqm3kNZdfESq4XIVOlx7aMYoDxxnBrSjthW0KKvruGzicYm7c8Nwp19xjTQwR83Cks2FPzxbAm3jAmP0vaNhS7_xkBpN_nVvxis18qaY1YYt4KQAqtxr90Y9rG0wOcmQQf52sbXzd4DqVs3H4PM4v_ZmqJOSFpvDczzKPasn0mV43TyaG-UOnkX1nFqXjMnty8-gpGPqkO5RyhKfP1vTQxpVDI_VaEiOPdNCUwXmhoxJJophsVX4FNBg_kwF-FL2d59j2Oi6gBPASSZ94dr8CMgRC1YZ_SRLwr90h/]]></Impression><Impression><![CDATA[https://us-east-sync.bidswitch.net/sync_cors?ssp=districtm&dsp_id=16&imp=1]]></Impression><Creatives></Creatives></Wrapper></Ad></VAST><!-- DMX - seat 10009 - crid 16_215446116 -->",
   760                      "crid": "76575664756",
   761                      "dealid": "dmx-deal-hp-24",
   762                      "w": 640,
   763                      "h": 480,
   764                      "ext": {
   765                          "prebid": {
   766                              "type": "video"
   767                          }
   768                      }
   769                  },
   770                  {
   771                      "id": "some-impression-id",
   772                      "impid": "some-impression-id",
   773                      "price": 5.01,
   774                      "adm": "<img src='https://via.placeholder.com/300x250.png?text=dmx+2.0+300x250' height='250' width='300'/>",
   775                      "crid": "1346943998",
   776                      "dealid": "dmx-deal-hp-24",
   777                      "w": 300,
   778                      "h": 250,
   779                      "ext": {
   780                          "prebid": {
   781                              "type": "banner"
   782                          }
   783                      }
   784                  },
   785                  {
   786                      "id": "some-impression-id2",
   787                      "impid": "some-impression-id2",
   788                      "price": 5.01,
   789                      "adm": "<img src='https://via.placeholder.com/728x90.png?text=dmx+2.0+728x90' height='90' width='728'/>",
   790                      "crid": "1424798162",
   791                      "dealid": "dmx-deal-hp-24",
   792                      "w": 728,
   793                      "h": 90,
   794                      "ext": {
   795                          "prebid": {
   796                              "type": "banner"
   797                          }
   798                      }
   799                  }
   800              ],
   801              "seat": "dmx"
   802          }
   803      ]
   804  }`)
   805  
   806  	err := json.Unmarshal(payload, &bidResp)
   807  	if err != nil {
   808  		t.Errorf("Payload is invalid")
   809  	}
   810  	bid = openrtb2.Bid(bidResp.SeatBid[0].Bid[0])
   811  	data := videoImpInsertion(&bid)
   812  	find := strings.Index(data, "demo.arripiblik.com")
   813  	if find == -1 {
   814  		t.Errorf("String was not found")
   815  	}
   816  
   817  }