Skip to content

Commit

Permalink
update and add test cases for insticator
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamc-ins committed Dec 6, 2024
1 parent ff2df10 commit fdcdc59
Show file tree
Hide file tree
Showing 20 changed files with 944 additions and 21 deletions.
14 changes: 5 additions & 9 deletions adapters/insticator/insticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ func (a *adapter) MakeRequests(request *openrtb2.BidRequest, requestInfo *adapte
impCopy.BidFloorCur),
})
continue
} else {
if resolvedBidFloor > 0 {
impCopy.BidFloor = resolvedBidFloor
impCopy.BidFloorCur = "USD"
}
}
if resolvedBidFloor > 0 {
impCopy.BidFloor = resolvedBidFloor
impCopy.BidFloorCur = "USD"
}

groupedImps[impKey] = append(groupedImps[impKey], impCopy)
Expand Down Expand Up @@ -273,10 +272,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",
}
Expand Down
4 changes: 2 additions & 2 deletions adapters/insticator/insticator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

func TestJsonSamples(t *testing.T) {
bidder, buildErr := Builder(openrtb_ext.BidderInsticator, config.Adapter{
Endpoint: "https://ex.ingage.tech/v1/prebidserver"},
config.Server{ExternalUrl: "https://ex.ingage.tech/v1/prebidserver", GvlID: 1, DataCenter: "2"})
Endpoint: "https://insticator.example.com/v1/pbs"},
config.Server{ExternalUrl: "https://insticator.example.com/v1/pbs", GvlID: 1, DataCenter: "2"})

if buildErr != nil {
t.Fatalf("Builder returned unexpected error %v", buildErr)
Expand Down
10 changes: 9 additions & 1 deletion adapters/insticator/insticatortest/exemplary/app-banner.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@
"publisher": {
"id": "test-publisher-id"
}
},
"device": {
"ua": "",
"ip": "1.1.1.2",
"ipv6": ""
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"device":{
"ip": "1.1.1.2"
},
"ext": {
"insticator": {
"caller": [
Expand Down
12 changes: 11 additions & 1 deletion adapters/insticator/insticatortest/exemplary/app-video.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@
"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"
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
Expand Down
4 changes: 2 additions & 2 deletions adapters/insticator/insticatortest/exemplary/multi-imps.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
Expand Down Expand Up @@ -179,7 +179,7 @@
},
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"httpCalls": [
{
"expectedRequest": {
"uri": "https://ex.ingage.tech/v1/prebidserver",
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
Expand Down
71 changes: 71 additions & 0 deletions adapters/insticator/insticatortest/supplemental/204.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 728, "h": 90}]
},
"ext": {
"bidder": {
"adUnitId": "fake-site-id",
"publisherId": "test-publisher-id"
}
}
}
],
"site": {
"publisher": {
"id": "test-publisher-id"
}
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
"caller": [
{
"name": "Prebid-Server",
"version": "n/a"
}
]
}
},
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"banner": {
"format": [{"w": 728, "h": 90}]
},
"ext": {
"insticator": {
"adUnitId": "fake-site-id",
"publisherId": "test-publisher-id"
}
}
}
],
"site": {
"publisher": {
"id": "test-publisher-id"
}
}
},
"impIDs":["test-imp-id"]
},
"mockResponse": {
"status": 204,
"body": {}
}
}
],
"expectedBidResponses": []
}

120 changes: 120 additions & 0 deletions adapters/insticator/insticatortest/supplemental/app-pubid-absent.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 728, "h": 90}]
},
"ext": {
"bidder": {
"adUnitId": "fake-app-id",
"publisherId": "test-publisher-id"
}
}
}
],
"app": {
"id": "test-app-id",
"bundle": "test-app.com"
}
},

"httpCalls": [
{
"expectedRequest": {
"uri": "https://insticator.example.com/v1/pbs",
"body": {
"ext": {
"insticator": {
"caller": [
{
"name": "Prebid-Server",
"version": "n/a"
}
]
}
},
"id": "test-request-id",
"imp": [
{
"id":"test-imp-id",
"banner": {
"format": [{"w": 728, "h": 90}]
},
"ext": {
"insticator": {
"adUnitId": "fake-app-id",
"publisherId": "test-publisher-id"
}
}
}
],
"app": {
"id": "test-app-id",
"bundle": "test-app.com",
"publisher": {
"id": "test-publisher-id"
}
}
},
"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,
"adm": "some-test-ad",
"crid": "crid_10",
"h": 90,
"w": 728,
"mtype": 1,
"ext": {
"insticator": {
"mediaType": "banner"
}
}
}]
}
],
"cur": "USD"
}
}
}
],

"expectedBidResponses": [
{
"currency": "USD",
"bids": [
{
"bid": {
"id": "8ee514f1-b2b8-4abb-89fd-084437d1e800",
"impid": "test-imp-id",
"price": 0.5,
"adm": "some-test-ad",
"crid": "crid_10",
"w": 728,
"h": 90,
"mtype": 1,
"ext": {
"insticator": {
"mediaType": "banner"
}
}
},
"type": "banner"
}
]
}
]
}

29 changes: 29 additions & 0 deletions adapters/insticator/insticatortest/supplemental/bad-imp-ext.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"mockBidRequest": {
"id": "test-request-id",
"imp": [
{
"id": "test-imp-id",
"banner": {
"format": [{"w": 728, "h": 90}]
},
"ext": {
"bidder": "invalid ext"
}
}
],
"site": {
"publisher": {
"id": "test-publisher-id"
}
}
},

"expectedMakeRequestsErrors": [
{
"value": "expect { or n, but found \"",
"comparison": "literal"
}
]
}

Loading

0 comments on commit fdcdc59

Please sign in to comment.