diff --git a/adapters/insticator/insticator.go b/adapters/insticator/insticator.go index 2e7c5d4235..fc8487971b 100644 --- a/adapters/insticator/insticator.go +++ b/adapters/insticator/insticator.go @@ -96,11 +96,8 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte } // Populate publisher.id from imp extension - if !isPublisherIdPopulated && (requestCopy.Site != nil || requestCopy.App != nil) { - if err := populatePublisherId(publisherId, &requestCopy); err != nil { - errs = append(errs, err) - continue - } + if !isPublisherIdPopulated { + populatePublisherId(publisherId, &requestCopy) isPublisherIdPopulated = true } @@ -148,11 +145,11 @@ func (a *adapter) makeRequest(request *openrtb2.BidRequest, impList []openrtb2.I } if len(request.Device.IPv6) > 0 { - headers.Add("X-Forwarded-For", request.Device.IPv6) + headers.Set("X-Forwarded-For", request.Device.IPv6) } if len(request.Device.IP) > 0 { - headers.Add("X-Forwarded-For", request.Device.IP) + headers.Set("X-Forwarded-For", request.Device.IP) headers.Add("IP", request.Device.IP) } } @@ -274,7 +271,7 @@ func resolveBidFloor(bidFloor float64, bidFloorCur string, reqInfo *adapters.Ext } func validateVideoParams(video *openrtb2.Video) error { - if (video.W == nil || *video.W == 0) || (video.H == nil || *video.H == 0) || video.MIMEs == nil { + if video.W == nil || *video.W == 0 || video.H == nil || *video.H == 0 || video.MIMEs == nil { return &errortypes.BadInput{ Message: "One or more invalid or missing video field(s) w, h, mimes", } @@ -284,7 +281,7 @@ func validateVideoParams(video *openrtb2.Video) error { } // populatePublisherId function populates site.publisher.id or app.publisher.id -func populatePublisherId(publisherId string, request *openrtb2.BidRequest) error { +func populatePublisherId(publisherId string, request *openrtb2.BidRequest) { // Populate site.publisher.id if request.Site is not nil if request.Site != nil { @@ -319,6 +316,4 @@ func populatePublisherId(publisherId string, request *openrtb2.BidRequest) error request.App.Publisher.ID = publisherId } - - return nil } diff --git a/adapters/insticator/insticatortest/exemplary/app-video.json b/adapters/insticator/insticatortest/exemplary/app-video.json index 0dcca79edb..2f0143fe96 100644 --- a/adapters/insticator/insticatortest/exemplary/app-video.json +++ b/adapters/insticator/insticatortest/exemplary/app-video.json @@ -1,95 +1,128 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 728, - "h": 90, - "protocols": [2], - "placement": 1, - "startdelay": -2, - "playbackmethod": [2], - "mimes": ["foo", "bar"] - }, - "ext": { - "bidder": { - "adUnitId": "fake-site-id", - "publisherId": "test-publisher-id" - } + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [ + 2 + ], + "placement": 1, + "startdelay": -2, + "playbackmethod": [ + 2 + ], + "mimes": [ + "foo", + "bar" + ] + }, + "ext": { + "bidder": { + "adUnitId": "fake-site-id", + "publisherId": "test-publisher-id" } } - ], - "app": { - "publisher": { - "id": "test-publisher-id" - } - }, - "device": { - "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "ip": "1.22.22.1", - "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + } + ], + "app": { + "publisher": { + "id": "test-publisher-id" } }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://insticator.example.com/v1/pbs", - "body": { - "device": { - "ip": "1.22.22.1", - "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", - "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" - }, - "ext": { - "insticator": { - "caller": [ - { - "name": "Prebid-Server", - "version": "n/a" - } + "device": { + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "ip": "1.22.22.1", + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ], + "User-Agent": [ + "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + ], + "X-Forwarded-For": [ + "1.22.22.1" + ], + "Ip": [ + "1.22.22.1" + ] + }, + "uri": "https://insticator.example.com/v1/pbs", + "body": { + "device": { + "ip": "1.22.22.1", + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + }, + "ext": { + "insticator": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [ + 2 + ], + "placement": 1, + "startdelay": -2, + "playbackmethod": [ + 2 + ], + "mimes": [ + "foo", + "bar" ] - } - }, - "id": "test-request-id", - "imp": [ - { - "id":"test-imp-id", - "video": { - "w": 728, - "h": 90, - "protocols": [2], - "placement": 1, - "startdelay": -2, - "playbackmethod": [2], - "mimes": ["foo", "bar"] - }, - "ext": { - "insticator": { - "adUnitId": "fake-site-id", - "publisherId": "test-publisher-id" - } + }, + "ext": { + "insticator": { + "adUnitId": "fake-site-id", + "publisherId": "test-publisher-id" } } - ], - "app": { - "publisher": { - "id": "test-publisher-id" - } } - }, - "impIDs":["test-imp-id"] + ], + "app": { + "publisher": { + "id": "test-publisher-id" + } + } }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "insticator", - "bid": [{ + "impIDs": [ + "test-imp-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "insticator", + "bid": [ + { "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.500000, @@ -103,39 +136,38 @@ "mediaType": "video" } } - }] - } - ], - "cur": "USD" - } + } + ] + } + ], + "cur": "USD" } } - ], - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", - "impid": "test-imp-id", - "price": 0.5, - "adm": "some-test-vast-ad", - "crid": "crid_10", - "w": 728, - "mtype": 2, - "h": 90, - "ext": { - "insticator": { - "mediaType": "video" - } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "mtype": 2, + "h": 90, + "ext": { + "insticator": { + "mediaType": "video" } - }, - "type": "video" - } - ] - } - ] - } - \ No newline at end of file + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/insticator/insticatortest/exemplary/site-banner.json b/adapters/insticator/insticatortest/exemplary/site-banner.json index 738aa297ed..4586fdc176 100644 --- a/adapters/insticator/insticatortest/exemplary/site-banner.json +++ b/adapters/insticator/insticatortest/exemplary/site-banner.json @@ -5,7 +5,12 @@ { "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 90}] + "format": [ + { + "w": 728, + "h": 90 + } + ] }, "ext": { "bidder": { @@ -19,14 +24,35 @@ "publisher": { "id": "test-publisher-id" } + }, + "device": { + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" } }, - "httpCalls": [ { "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ], + "User-Agent": [ + "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + ], + "X-Forwarded-For": [ + "2001:0db8:85a3:0000:0000:8a2e:0370:7334" + ] + }, "uri": "https://insticator.example.com/v1/pbs", "body": { + "device": { + "ipv6": "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + "ua": "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36" + }, "ext": { "insticator": { "caller": [ @@ -40,9 +66,14 @@ "id": "test-request-id", "imp": [ { - "id":"test-imp-id", + "id": "test-imp-id", "banner": { - "format": [{"w": 728, "h": 90}] + "format": [ + { + "w": 728, + "h": 90 + } + ] }, "ext": { "insticator": { @@ -58,7 +89,9 @@ } } }, - "impIDs":["test-imp-id"] + "impIDs": [ + "test-imp-id" + ] }, "mockResponse": { "status": 200, @@ -67,21 +100,23 @@ "seatbid": [ { "seat": "insticator", - "bid": [{ - "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", - "impid": "test-imp-id", - "price": 0.500000, - "adm": "some-test-ad", - "crid": "crid_10", - "h": 90, - "w": 728, - "mtype": 1, - "ext": { - "insticator": { - "mediaType": "banner" + "bid": [ + { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.500000, + "adm": "some-test-ad", + "crid": "crid_10", + "h": 90, + "w": 728, + "mtype": 1, + "ext": { + "insticator": { + "mediaType": "banner" + } } } - }] + ] } ], "cur": "USD" @@ -89,7 +124,6 @@ } } ], - "expectedBidResponses": [ { "currency": "USD", @@ -115,4 +149,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/adapters/insticator/insticatortest/supplemental/device-validation.json b/adapters/insticator/insticatortest/supplemental/device-validation.json index 0238b23eba..a493e1b28a 100644 --- a/adapters/insticator/insticatortest/supplemental/device-validation.json +++ b/adapters/insticator/insticatortest/supplemental/device-validation.json @@ -1,93 +1,123 @@ { - "mockBidRequest": { - "id": "test-request-id", - "imp": [ - { - "id": "test-imp-id", - "video": { - "w": 728, - "h": 90, - "protocols": [2], - "placement": 1, - "startdelay": -2, - "playbackmethod": [2], - "mimes": ["foo", "bar"] - }, - "ext": { - "bidder": { - "adUnitId": "fake-site-id", - "publisherId": "test-publisher-id" - } + "mockBidRequest": { + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [ + 2 + ], + "placement": 1, + "startdelay": -2, + "playbackmethod": [ + 2 + ], + "mimes": [ + "foo", + "bar" + ] + }, + "ext": { + "bidder": { + "adUnitId": "fake-site-id", + "publisherId": "test-publisher-id" } } - ], - "app": { - "publisher": { - "id": "test-publisher-id" - } - }, - "device": { - "ipv6": "", - "ip": "1.22.22.1", - "ua": "" + } + ], + "app": { + "publisher": { + "id": "test-publisher-id" } }, - - "httpCalls": [ - { - "expectedRequest": { - "uri": "https://insticator.example.com/v1/pbs", - "body": { - "device": { - "ip": "1.22.22.1" - }, - "ext": { - "insticator": { - "caller": [ - { - "name": "Prebid-Server", - "version": "n/a" - } + "device": { + "ipv6": "", + "ip": "1.22.22.1", + "ua": "" + } + }, + "httpCalls": [ + { + "expectedRequest": { + "headers": { + "Content-Type": [ + "application/json;charset=utf-8" + ], + "Accept": [ + "application/json" + ], + "X-Forwarded-For": [ + "1.22.22.1" + ], + "Ip": [ + "1.22.22.1" + ] + }, + "uri": "https://insticator.example.com/v1/pbs", + "body": { + "device": { + "ip": "1.22.22.1" + }, + "ext": { + "insticator": { + "caller": [ + { + "name": "Prebid-Server", + "version": "n/a" + } + ] + } + }, + "id": "test-request-id", + "imp": [ + { + "id": "test-imp-id", + "video": { + "w": 728, + "h": 90, + "protocols": [ + 2 + ], + "placement": 1, + "startdelay": -2, + "playbackmethod": [ + 2 + ], + "mimes": [ + "foo", + "bar" ] - } - }, - "id": "test-request-id", - "imp": [ - { - "id":"test-imp-id", - "video": { - "w": 728, - "h": 90, - "protocols": [2], - "placement": 1, - "startdelay": -2, - "playbackmethod": [2], - "mimes": ["foo", "bar"] - }, - "ext": { - "insticator": { - "adUnitId": "fake-site-id", - "publisherId": "test-publisher-id" - } + }, + "ext": { + "insticator": { + "adUnitId": "fake-site-id", + "publisherId": "test-publisher-id" } } - ], - "app": { - "publisher": { - "id": "test-publisher-id" - } } - }, - "impIDs":["test-imp-id"] + ], + "app": { + "publisher": { + "id": "test-publisher-id" + } + } }, - "mockResponse": { - "status": 200, - "body": { - "id": "test-request-id", - "seatbid": [ - { - "seat": "insticator", - "bid": [{ + "impIDs": [ + "test-imp-id" + ] + }, + "mockResponse": { + "status": 200, + "body": { + "id": "test-request-id", + "seatbid": [ + { + "seat": "insticator", + "bid": [ + { "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", "impid": "test-imp-id", "price": 0.500000, @@ -101,39 +131,38 @@ "mediaType": "video" } } - }] - } - ], - "cur": "USD" - } + } + ] + } + ], + "cur": "USD" } } - ], - - "expectedBidResponses": [ - { - "currency": "USD", - "bids": [ - { - "bid": { - "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", - "impid": "test-imp-id", - "price": 0.5, - "adm": "some-test-vast-ad", - "crid": "crid_10", - "w": 728, - "mtype": 2, - "h": 90, - "ext": { - "insticator": { - "mediaType": "video" - } + } + ], + "expectedBidResponses": [ + { + "currency": "USD", + "bids": [ + { + "bid": { + "id": "8ee514f1-b2b8-4abb-89fd-084437d1e800", + "impid": "test-imp-id", + "price": 0.5, + "adm": "some-test-vast-ad", + "crid": "crid_10", + "w": 728, + "mtype": 2, + "h": 90, + "ext": { + "insticator": { + "mediaType": "video" } - }, - "type": "video" - } - ] - } - ] - } - \ No newline at end of file + } + }, + "type": "video" + } + ] + } + ] +} \ No newline at end of file diff --git a/adapters/insticator/insticatortest/supplemental/request-ext-unmarhal-fail.json b/adapters/insticator/insticatortest/supplemental/request-ext-unmarshal-fail.json similarity index 100% rename from adapters/insticator/insticatortest/supplemental/request-ext-unmarhal-fail.json rename to adapters/insticator/insticatortest/supplemental/request-ext-unmarshal-fail.json